// ==========================================================================
// Dashboard - Page d'administration
// ==========================================================================

@use '../base/variables' as *;
@use '../base/colors' as *;

.admin-dashboard {
  background: $color-neutral;
  min-height: 100vh;

  .header {
    background: $color-light;
    padding: 20px 40px;
    box-shadow: $shadow;
    display: flex;
    justify-content: space-between;
    align-items: center;

    h1 {
      color: $color-dark;
      font-size: $font-size-h4;
      margin: 0;
    }

    .header-user-menu {
      display: flex;
      align-items: center;
      gap: 20px;
    }

    .user-profile-link {
      display: flex;
      align-items: center;
      gap: 8px;
      color: $color-primary-dark;
      text-decoration: none;
      transition: color 0.2s;

      &:hover {
        color: $color-primary;
        text-decoration: none;

        .user-icon {
          color: $color-primary;
        }
      }

      .user-icon {
        flex-shrink: 0;
        color: $color-primary-dark;
        transition: color 0.2s;
      }

      .user-name {
        font-weight: 500;
      }
    }

    a {
      color: $color-primary;
      text-decoration: none;

      &:hover {
        text-decoration: underline;
      }
    }
  }

  .container {
    max-width: 1200px;
    margin: $spacing-lg auto;
    padding: 0 20px;
  }

  .section {
    margin-bottom: $spacing-lg;

    &-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;

      h2 {
        color: $color-dark;
        font-size: 20px;
        margin: 0;
      }

      a {
        padding: 8px 16px;
        background: $color-secondary;
        color: $color-light;
        text-decoration: none;
        border-radius: $radius-sm;
        font-size: 14px;
        transition: background 0.2s;

        &:hover {
          background: $color-secondary-dark;
        }
      }
    }
  }

  .cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;

    .card {
      position: relative;
      background: $color-light;
      padding: 20px;
      border-radius: $radius-md;
      box-shadow: $shadow;

      &__badge {
        width: 22px;
        height: 22px;
        padding: 0 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        background: $color-warning;
        color: $color-light;
        font-size: 12px;
        font-weight: 700;
        line-height: 1;
        box-shadow: $shadow;
      }

      h3 {
        display: flex;
        color: $color-dark;
        margin-bottom: 10px;
        font-size: 18px;
        gap: 9px;
        align-items: center;
      }

      p {
        color: $color-primary-dark;
        margin-bottom: 15px;
        font-size: 14px;
      }

      a {
        display: inline-block;
        padding: 8px 16px;
        background: $color-primary;
        color: $color-light;
        text-decoration: none;
        border-radius: $radius-sm;
        font-size: 14px;
        transition: background 0.2s;

        &:hover {
          background: $color-primary-dark;
        }
      }
    }

    // Card whose action is a switch rather than a link (mode maintenance,
    // blocage de la préhome).
    .card--toggle {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
    }
  }

  .switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;

    input {
      opacity: 0;
      width: 0;
      height: 0;

      &:checked + .switch__slider {
        background: $color-primary;

        &::before {
          transform: translateX(22px);
        }
      }

      &:disabled + .switch__slider {
        opacity: 0.6;
        cursor: not-allowed;
      }
    }

    &__slider {
      position: absolute;
      inset: 0;
      background: $color-primary-lighter;
      border-radius: 999px;
      cursor: pointer;
      transition: background 0.2s;

      &::before {
        content: '';
        position: absolute;
        left: 3px;
        top: 3px;
        width: 20px;
        height: 20px;
        background: $color-light;
        border-radius: 50%;
        transition: transform 0.2s;
        box-shadow: $shadow;
      }
    }
  }

  .list {
    list-style: none;
    margin: 0;
    padding: 0;

    li {
      background: $color-light;
      padding: 15px 20px;
      margin-bottom: 10px;
      border-radius: $radius-sm;
      display: grid;
      grid-template-columns: 1fr 1fr auto;
      gap: 20px;
      align-items: center;

      strong {
        color: $color-dark;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}
