// =============================================================================
// Header & Navigation
// =============================================================================

.header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--transition-base);

  // Admin bar
  .admin-bar {
    background: var(--text);
    font-size: 0.8125rem;

    a {
      color: rgba(255, 255, 255, 0.8);
      text-decoration: none;
      font-weight: 500;

      &:hover {
        color: var(--white);
      }
    }

    &__user {
      color: rgba(255, 255, 255, 0.7);
      font-size: 0.8125rem;
      display: flex;
      align-items: center;
      gap: 0.375rem;

      svg {
        opacity: 0.7;
      }
    }

    &__logout {
      color: rgba(255, 255, 255, 0.6);
      font-size: 0.75rem;
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
      padding: 0.2rem 0.5rem;
      border-radius: var(--radius-sm, 4px);
      border: 1px solid rgba(255, 255, 255, 0.15);
      transition: all 0.2s ease;

      &:hover {
        color: #fff;
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.3);
      }
    }

    @media (max-width: 575.98px) {
      .admin-bar__user span,
      .admin-bar__logout span {
        display: none;
      }
    }
  }

  // Desktop
  .desk {
    display: block;
    @media (max-width: 991.98px) {
      display: none;
    }
  }

  .header-main {
    padding: 0.75rem 0;
  }

  .header-logo img {
    height: 42px;
    width: auto;
    transition: opacity var(--transition-fast);

    &:hover {
      opacity: 0.8;
    }
  }

  .header-nav {
    .nav-link {
      @include link-menu;
      font-weight: 600;
      padding: 0.5rem 1rem;
      border-radius: var(--radius-sm);

      &:hover {
        color: var(--primary);
        background: var(--primary-light);
      }
    }

    .dropdown-toggle::after {
      margin-left: 0.375rem;
    }
  }

  .header-actions {
    .search-input {
      width: 160px;
      transition: width var(--transition-base);

      &:focus {
        width: 220px;
      }
    }
  }

  // Mobile
  .smart {
    display: none;
    @media (max-width: 991.98px) {
      display: block;
    }
  }

  .header-mobile {
    .header-logo img {
      height: 36px;
    }

    .navbar-toggler {
      color: var(--text);
      padding: 0.5rem;
      min-width: 44px;
      min-height: 44px;

      &:focus {
        box-shadow: none;
      }
    }
  }
}

// ─── Nested dropdowns (level 2 sub-menus) ──────────────────────────────────
.header-nav .dropdown-menu .dropend {
  position: relative;

  > .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -0.5rem;
    margin-left: 0;
  }

  > .dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;

    &::after {
      border-top: 0.3em solid transparent;
      border-right: 0;
      border-bottom: 0.3em solid transparent;
      border-left: 0.3em solid;
      margin-left: 0.75rem;
    }
  }

  &:hover > .dropdown-menu,
  &:focus-within > .dropdown-menu {
    display: block;
  }
}

// ─── Fix alignement des liens avec sous-menu (cross-themes) ────────────────
// Le pattern commun <div class="dropdown"><a class="<nav-link> dropdown-toggle">
// fait que le <div> wrapper devient l'enfant direct du conteneur nav au lieu
// du <a>. Les paddings et l'alignement vertical du <a> restent internes et
// creent un decalage visible (surtout sur les navs flex/gap comme artisan).
// Le :has() cible uniquement les .dropdown qui wrappent un lien de nav,
// sans toucher .header-search.dropdown qui a une structure differente.
header nav .dropdown:has(> .dropdown-toggle) {
  display: inline-flex;
  align-items: stretch;

  > .dropdown-toggle {
    display: inline-flex;
    align-items: center;
  }
}
