@use "sass:color";

$background-color: #1c1f23;
$primary-color: #00a346;
$text-white: #ffffff;
$text-gray: #667788;

.app-header {
  background-color: $background-color !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) !important;

  .header-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
  }

  .header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex-shrink: 0;

    &:hover .header-title {
      color: $primary-color;
    }
  }

  .header-logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
  }

  .header-title {
    color: $text-white;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: color 0.15s ease;
  }

  .header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    max-width: 40%;
  }

  .header-movie-name {
    color: $text-white;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-username {
    color: $text-gray;
    font-size: 0.85rem !important;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    &::before {
      content: '@';
      opacity: 0.6;
    }
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .header-menu-btn {
    display: none !important;
    color: $text-gray !important;
    &:hover { color: $text-white !important; }
  }

  @media (max-width: 640px) {
    .header-actions { display: none !important; }
    .header-menu-btn { display: flex !important; }
    .header-title { font-size: 1rem !important; }
    .header-center { display: none; }
  }

  .header-reset-btn {
    color: $text-gray !important;

    &:hover {
      color: $text-white !important;
    }
  }

  .header-recap-btn {
    color: $text-gray !important;

    &:hover {
      color: $text-white !important;
    }
  }

  .header-sync-btn {
    color: $text-gray !important;

    &:hover { color: $text-white !important; }

    &--active { color: $primary-color !important; }
  }

  .spin {
    animation: spin 1s linear infinite;
  }

  @keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }

  .header-download-btn {
    background-color: $primary-color !important;
    color: $text-white !important;
    font-weight: 600;
    padding: 0.4rem 1rem;
    border-radius: 4px;
    text-transform: none;
    font-size: 0.875rem;

    &:hover {
      background-color: color.adjust($primary-color, $lightness: -8%) !important;
    }

    &--loading {
      background-color: color.adjust($primary-color, $lightness: -12%) !important;
      cursor: default !important;
      min-width: 140px;
    }
  }

  .header-download-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 120px;

    span {
      font-size: 0.8rem;
      font-weight: 600;
      color: $text-white;
      line-height: 1;
    }
  }

  .header-progress-bar {
    width: 100%;
    border-radius: 2px;
    height: 4px !important;

    .MuiLinearProgress-bar {
      background-color: $text-white !important;
    }

    &.MuiLinearProgress-root {
      background-color: rgba(255, 255, 255, 0.3) !important;
    }
  }
}

// Menu mobile (portail MUI, hors de .app-header)
.header-menu-paper {
  background-color: #1c1f23 !important;
  border: 1px solid #2c3038 !important;
  border-radius: 6px !important;
  min-width: 200px;

  .MuiList-root { padding: 4px 0; }
}

.header-menu-item {
  color: #ffffff !important;
  font-size: 0.875rem !important;
  gap: 10px;
  padding: 10px 16px !important;

  &:hover { background-color: rgba(102, 119, 136, 0.2) !important; }
  &.Mui-disabled { opacity: 0.4 !important; color: #ffffff !important; }

  &--danger {
    color: #ef9a9a !important;
    margin-top: 4px;
    border-top: 1px solid #2c3038;
  }
}

.header-menu-icon {
  opacity: 0.6;
  flex-shrink: 0;
}
