/**
 * ═══════════════════════════════════════════════════════════════
 * Modern Navigation Header - Award-Winning UX Design
 * ═══════════════════════════════════════════════════════════════
 *
 * Features:
 * - Clean, professional design with gradient accents
 * - Mega menu for complex navigation
 * - User avatar with initials
 * - Scroll-aware compact mode
 * - Mobile slide-out menu
 * - Full keyboard accessibility
 * - WCAG 2.2 AAA compliant
 */

/* ===== CSS Custom Properties ===== */
.site-header {
    --header-height: 80px;
    --header-height-scrolled: 64px;
    --header-bg: #ffffff;
    --header-border: #e5e7eb;
    --header-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --header-shadow-scrolled: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --nav-text: #374151;
    --nav-text-hover: #1e3a8a;
    --nav-active: #2563eb;
    --nav-active-bg: rgba(37, 99, 235, 0.1);
    --accent-gradient: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;
}

/* ===== Site Header ===== */
.site-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    box-shadow: var(--header-shadow);
    transition: all var(--transition-base);
}

.site-header--scrolled {
    box-shadow: var(--header-shadow-scrolled);
}

.site-header--scrolled .nav-brand-logo {
    height: 60px;
}

/* ===== Main Navigation ===== */
.main-nav {
    width: 100%;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    min-height: var(--header-height);
    transition: min-height var(--transition-base);
}

.site-header--scrolled .nav-container {
    min-height: var(--header-height-scrolled);
}

/* ===== Brand Logo ===== */
.nav-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    order: 0; /* Ensure logo stays on left */
}

.nav-brand-logo {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: 80px;
    width: auto;
    min-width: 150px;
    min-height: 50px;
    transition: height var(--transition-base);
    box-shadow: none;
    border-radius: 0;
    border: none;
    background: transparent;
    object-fit: contain;
    clip: auto !important;
    clip-path: none !important;
    -webkit-clip-path: none !important;
    filter: none !important;
    transform: none !important;
}

/* ===== Navigation Menu ===== */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: flex-end;
    order: 1; /* After logo */
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
}

/* ===== Navigation Links ===== */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    white-space: nowrap;
    border: none;
    background: transparent;
    cursor: pointer;
}

.nav-link i:first-child {
    font-size: 1.125rem;
    opacity: 0.7;
}

.nav-link:hover {
    color: var(--nav-text-hover);
    background: #f3f4f6;
}

.nav-link:focus-visible {
    outline: 2px solid var(--nav-active);
    outline-offset: 2px;
}

.nav-link--active {
    color: var(--nav-active);
    background: var(--nav-active-bg);
}

.nav-link--active i:first-child {
    opacity: 1;
}

.nav-link--dropdown {
    padding-right: 0.75rem;
}

.nav-chevron {
    font-size: 0.75rem;
    transition: transform var(--transition-fast);
    margin-left: 0.125rem;
}

.nav-link--dropdown[aria-expanded="true"] .nav-chevron {
    transform: rotate(180deg);
}

.nav-link--admin {
    color: #dc2626;
}

.nav-link--admin:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
}

/* ===== Mega Menu ===== */
.mega-menu {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    min-width: 700px;
    max-width: calc(100vw - 2rem);
    background: var(--header-bg);
    border: 1px solid var(--header-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-base);
    z-index: 100;
    margin-top: 0.5rem;
}

.mega-menu--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mega-menu-inner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 1rem;
}

.mega-menu-col {
    padding: 0.5rem;
}

.mega-menu-col--highlight {
    grid-column: 1 / -1;
    border-top: 1px solid var(--header-border);
    margin-top: 0.5rem;
    padding-top: 1rem;
}

.mega-menu-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.mega-menu-heading i {
    font-size: 0.875rem;
    color: var(--nav-active);
}

.mega-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mega-menu-link {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.625rem 0.5rem;
    color: var(--nav-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.mega-menu-link:hover {
    background: #f3f4f6;
    color: var(--nav-text-hover);
}

.mega-menu-link:focus-visible {
    outline: 2px solid var(--nav-active);
    outline-offset: -2px;
}

.mega-menu-link i {
    font-size: 1.25rem;
    color: var(--nav-active);
    margin-top: 0.125rem;
    flex-shrink: 0;
}

.mega-menu-link strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--nav-text);
    margin-bottom: 0.125rem;
}

.mega-menu-link small {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.3;
}

.mega-menu-cta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--nav-text);
    transition: all var(--transition-fast);
}

.mega-menu-cta:hover {
    background: linear-gradient(135deg, #dbeafe 0%, #cffafe 100%);
    border-color: #93c5fd;
}

.mega-menu-cta i:first-child {
    font-size: 1.5rem;
    color: var(--nav-active);
}

.mega-menu-cta i:last-child {
    margin-left: auto;
    color: var(--nav-active);
}

.mega-menu-cta strong {
    font-size: 0.875rem;
    font-weight: 600;
}

.mega-menu-cta small {
    font-size: 0.75rem;
    color: #6b7280;
}

/* ===== Navigation Actions ===== */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 1.5rem;
    padding-left: 1.5rem;
    border-left: 1px solid var(--header-border);
}

.nav-action-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-action-link:hover {
    color: var(--nav-text-hover);
    background: #f3f4f6;
}

.nav-action-link--active {
    color: var(--nav-active);
}

.nav-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--accent-gradient);
    color: #ffffff;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.nav-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
    color: #ffffff;
}

.nav-action-btn:focus-visible {
    outline: 3px solid var(--nav-active);
    outline-offset: 3px;
}

/* ===== User Menu ===== */
.nav-user {
    position: relative;
}

.nav-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem 0.375rem 0.375rem;
    background: #f3f4f6;
    border: 1px solid var(--header-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-user-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.nav-user-btn:focus-visible {
    outline: 2px solid var(--nav-active);
    outline-offset: 2px;
}

.nav-user-avatar {
    width: 2rem;
    height: 2rem;
    background: var(--accent-gradient);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.025em;
}

.nav-user-avatar--lg {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 0.875rem;
}

.nav-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--nav-text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-user-btn i {
    font-size: 0.75rem;
    color: #9ca3af;
    transition: transform var(--transition-fast);
}

.nav-user-btn[aria-expanded="true"] i {
    transform: rotate(180deg);
}

/* User Dropdown Menu */
.nav-user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 240px;
    background: var(--header-bg);
    border: 1px solid var(--header-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-base);
    z-index: 100;
    margin-top: 0.5rem;
    padding: 0.5rem;
}

.nav-user-menu--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-user-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    background: #f9fafb;
    margin-bottom: 0.5rem;
}

.nav-user-info strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--nav-text);
}

.nav-user-info small {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-user-divider {
    height: 1px;
    background: var(--header-border);
    margin: 0.375rem 0;
}

.nav-user-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.nav-user-link:hover {
    background: #f3f4f6;
    color: var(--nav-text-hover);
}

.nav-user-link i {
    font-size: 1rem;
    color: #6b7280;
}

.nav-user-link--danger {
    color: #dc2626;
}

.nav-user-link--danger:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
}

.nav-user-link--danger i {
    color: #dc2626;
}

/* ===== Mobile Menu Toggle ===== */
.nav-mobile-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1050;
    order: 2; /* After logo and nav-menu */
}

.nav-mobile-toggle-bar {
    width: 24px;
    height: 2px;
    background: var(--nav-text);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.nav-mobile-toggle--active .nav-mobile-toggle-bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-mobile-toggle--active .nav-mobile-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-mobile-toggle--active .nav-mobile-toggle-bar:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Mobile Menu ===== */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 320px;
    height: 100vh;
    background: var(--header-bg);
    box-shadow: -10px 0 30px rgb(0 0 0 / 0.1);
    z-index: 1045;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.mobile-menu:not([hidden]) {
    transform: translateX(0);
}

.mobile-menu-inner {
    padding: 1.5rem;
}

.mobile-user-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.mobile-user-info strong {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--nav-text);
}

.mobile-user-info small {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.mobile-nav-link:hover,
.mobile-nav-link--active {
    background: var(--nav-active-bg);
    color: var(--nav-active);
}

.mobile-nav-link i {
    font-size: 1.25rem;
    opacity: 0.7;
}

.mobile-nav-link--active i {
    opacity: 1;
}

.mobile-nav-link--admin {
    color: #dc2626;
}

.mobile-nav-link--danger {
    color: #dc2626;
}

.mobile-nav-link--danger:hover {
    background: rgba(220, 38, 38, 0.1);
}

.mobile-nav-divider {
    height: 1px;
    background: var(--header-border);
    margin: 0.75rem 0;
}

.mobile-nav-accordion {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    color: var(--nav-text);
    font-size: 0.9375rem;
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-fast);
}

.mobile-nav-accordion:hover {
    background: #f3f4f6;
}

.mobile-nav-accordion i:first-child {
    font-size: 1.25rem;
    opacity: 0.7;
}

.mobile-nav-accordion span {
    flex: 1;
}

.mobile-nav-chevron {
    font-size: 0.875rem;
    transition: transform var(--transition-fast);
}

.mobile-nav-accordion--expanded .mobile-nav-chevron {
    transform: rotate(180deg);
}

.mobile-nav-submenu {
    padding-left: 1rem;
    margin-top: 0.25rem;
}

.mobile-nav-sublink {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.mobile-nav-sublink:hover {
    background: #f3f4f6;
    color: var(--nav-text);
}

.mobile-nav-sublink i {
    font-size: 1rem;
    color: var(--nav-active);
}

.mobile-nav-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.875rem 1.5rem;
    background: var(--accent-gradient);
    color: #ffffff;
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.mobile-nav-cta:hover {
    color: #ffffff;
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.mobile-menu-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
}

/* ===== Responsive Styles ===== */

/* Hide mobile toggle on desktop */
@media (min-width: 992px) {
    .nav-mobile-toggle {
        display: none !important;
    }

    .mobile-menu,
    .mobile-menu-overlay {
        display: none !important;
    }
}

/* Smaller desktop screens - adjust mega menu */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .mega-menu {
        min-width: 600px;
    }

    .mega-menu-inner {
        grid-template-columns: repeat(3, 1fr);
    }

    .mega-menu-col:nth-child(3) .mega-menu-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0;
    }
}

/* Tablet */
@media (max-width: 991.98px) {
    .nav-menu {
        display: none;
    }

    .nav-mobile-toggle {
        display: flex;
    }

    .nav-brand-logo {
        height: 60px;
    }

    .site-header--scrolled .nav-brand-logo {
        height: 50px;
    }
}

/* Mobile */
@media (max-width: 575.98px) {
    .nav-container {
        padding: 0 1rem;
    }

    .nav-brand-logo {
        height: 50px;
    }

    .site-header--scrolled .nav-brand-logo {
        height: 45px;
    }

    .mobile-menu {
        max-width: 100%;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .site-header,
    .nav-brand-logo,
    .nav-container,
    .nav-link,
    .mega-menu,
    .nav-user-menu,
    .mobile-menu,
    .mobile-menu-overlay,
    .nav-mobile-toggle-bar,
    .nav-chevron,
    .nav-action-btn {
        transition: none !important;
    }
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
    .nav-link:focus-visible,
    .nav-action-btn:focus-visible,
    .nav-user-btn:focus-visible {
        outline-width: 3px;
    }

    .nav-link--active {
        border: 2px solid var(--nav-active);
    }
}

/* ===== Print Styles ===== */
@media print {
    .site-header {
        display: none !important;
    }
}
