@use '../../../../shared/styles/variables' as *;

.device-page-skeleton {
  position: relative;
  display: block;
  overflow: hidden;
  flex: 0 0 auto;
  border-radius: 12px;
  background: $color-skeleton;

  &::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg,
        $transparent,
        $color-skeleton-highlight,
        $transparent);
    animation: device-page-skeleton-shimmer 1.35s ease-in-out infinite;
  }
}

.device-page-skeleton--text {
  height: 1em;
  min-width: 32px;
  border-radius: 999px;
}

.device-page-skeleton--icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.device-page-skeleton--button {
  width: 100%;
  height: 44px;
  border-radius: 12px;
}

.device-page-skeleton--square-button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.device-page-skeleton--mini-button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.device-page-skeleton--switch {
  width: 48px;
  height: 26px;
  border-radius: 999px;
}

.device-page-skeleton--battery-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
}

.device-page-loading__grid {
  align-items: stretch;
}

.device-page-loading__main-card,
.device-page-loading__map-card,
.device-page-loading__actions-card,
.device-page-loading__permissions-card,
.device-page-loading__battery-card,
.device-page-loading__impacts-card {
  pointer-events: none;
}

.device-page-loading__device-image {
  min-height: 220px;
}

.device-page-loading__phone {
  width: 42%;
  min-width: 92px;
  max-width: 138px;
  height: 100%;
  min-height: 180px;
  border-radius: 28px;
}

.device-page-loading__main-info {
  padding-top: 2px;

  .device-page-skeleton--text {
    height: 17px;
  }
}

.device-page-loading__title {
  height: 30px !important;
  margin-bottom: 2px;
}

.device-page-loading__status-row {
  .device-page-skeleton--text {
    height: 18px;
  }
}

.device-page-loading__registered {
  .device-registered-info {
    min-height: 44px;
  }
}

.device-page-loading__history-button {
  max-width: 286px;
}

.device-page-loading__map-card {
  min-height: 420px;
}

.device-page-loading__map-header {
  align-items: flex-start;

  .device-card__title {
    flex: 0 0 auto;
  }

  >.device-page-skeleton--text {
    height: 15px;
    margin-top: 7px;
  }
}

.device-page-loading__map-container {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 332px;
  border-radius: 16px;
}

.device-page-loading__period-control {
  position: absolute;
  z-index: 1;
  top: 12px;
  left: 12px;
  right: 12px;

  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;

  .device-page-skeleton--button {
    height: 34px;
    border-radius: 10px;
    background: rgba($white, 0.86);
  }
}

.device-page-loading__map {
  width: 100%;
  min-height: 332px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba($color-primary-rgb, 0.05), $transparent 48%),
    $color-skeleton;
}

.device-page-loading__actions-card {
  min-height: 174px;

  .device-page-loading__card-title {
    height: 18px;
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .actions-button-container {
    gap: 8px;
  }
}

.device-page-loading__permissions-card {
  min-height: 236px;
}

.device-page-loading__permissions-header {
  margin-bottom: 12px;

  .device-permissions__header-actions {
    display: flex;
    gap: 8px;
  }
}

.device-page-loading__card-title {
  height: 18px;
}

.device-page-loading__permission {
  .device-permission__label {
    min-height: 43px;
  }
}

.device-page-loading__stats-column {
  align-self: stretch;
}

.device-page-loading__battery-card {
  min-height: 194px;

  >.device-page-loading__card-title {
    margin-bottom: 12px;
    padding-bottom: 12px;
  }
}

.device-page-loading__stat {
  .device-stats-text {
    min-height: 30px;
  }
}

.device-page-loading__impacts-card {
  min-height: 34px;
}

@keyframes device-page-skeleton-shimmer {
  to {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .device-page-skeleton::after {
    animation: none;
  }
}
