/* ============================================
   TUMQUAN PREMIUM HEADER - NEXT-GEN DESIGN
   Rich Technology Aesthetic
   ============================================ */

.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: linear-gradient(
        135deg,
        rgba(5, 5, 15, 0.92) 0%,
        rgba(10, 10, 25, 0.95) 50%,
        rgba(5, 5, 15, 0.92) 100%
    );
    backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid transparent;
    border-image: linear-gradient(
            90deg,
            transparent,
            rgba(99, 102, 241, 0.3) 20%,
            rgba(139, 92, 246, 0.3) 50%,
            rgba(99, 102, 241, 0.3) 80%,
            transparent
        )
        1;
    z-index: var(--z-fixed);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.4),
        0 0 80px rgba(99, 102, 241, 0.08);
}

.main-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(99, 102, 241, 0.5) 20%,
        rgba(139, 92, 246, 0.6) 50%,
        rgba(99, 102, 241, 0.5) 80%,
        transparent
    );
    opacity: 0.6;
}

.main-header.scrolled {
    height: 64px;
    background: linear-gradient(
        135deg,
        rgba(5, 5, 15, 0.98) 0%,
        rgba(10, 10, 25, 0.98) 50%,
        rgba(5, 5, 15, 0.98) 100%
    );
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 100px rgba(99, 102, 241, 0.12);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2.5rem;
}

/* ============================================
   BRAND LOGO
   ============================================ */

.logo-container {
    display: flex;
    align-items: center;
    text-decoration: none;
    position: relative;
    padding: 0.5rem 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logo-container::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(
        180deg,
        var(--color-quantum-blue),
        var(--color-quantum-purple)
    );
    border-radius: 2px;
    transition: height 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logo-container:hover::before {
    height: 32px;
}

.logo-container:hover {
    transform: translateX(4px);
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 50%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    position: relative;
    text-shadow: 0 0 40px rgba(129, 140, 248, 0.4);
    filter: drop-shadow(0 2px 12px rgba(129, 140, 248, 0.3));
}

/* ============================================
   NAVIGATION
   ============================================ */

.main-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    border-radius: 0.5rem;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.01em;
}

.nav-link::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(99, 102, 241, 0.1) 0%,
        rgba(139, 92, 246, 0.08) 100%
    );
    border-radius: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-link:hover {
    color: #ffffff;
    transform: translateY(-1px);
}

.nav-link:hover::before {
    opacity: 1;
}

.dropdown-arrow {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
}

.nav-item:hover .dropdown-arrow {
    transform: translateY(2px);
    opacity: 1;
}

/* ============================================
   MEGA MENU - PREMIUM DESIGN
   ============================================ */

.mega-menu {
    position: fixed;
    top: 72px;
    left: 0;
    right: 0;
    width: 100vw;
    background: linear-gradient(
        135deg,
        rgba(8, 8, 20, 0.98) 0%,
        rgba(12, 12, 28, 0.98) 50%,
        rgba(8, 8, 20, 0.98) 100%
    );
    backdrop-filter: blur(24px);
    border-top: 1px solid rgba(99, 102, 241, 0.15);
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    z-index: 999;
}

.mega-menu::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(99, 102, 241, 0.4) 20%,
        rgba(139, 92, 246, 0.5) 50%,
        rgba(99, 102, 241, 0.4) 80%,
        transparent
    );
}

.nav-item:hover .mega-menu,
.nav-item.active .mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 2.5rem;
}

.mega-menu-item {
    display: block;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(
        135deg,
        rgba(15, 15, 30, 0.6) 0%,
        rgba(20, 20, 35, 0.4) 100%
    );
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.mega-menu-item::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(99, 102, 241, 0.15) 0%,
        rgba(139, 92, 246, 0.1) 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mega-menu-item::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(
        180deg,
        var(--color-quantum-blue),
        var(--color-quantum-purple)
    );
    transform: scaleY(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mega-menu-item:hover {
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateX(8px);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(99, 102, 241, 0.15);
}

.mega-menu-item:hover::before {
    opacity: 1;
}

.mega-menu-item:hover::after {
    transform: scaleY(1);
}

.mega-menu-item-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0.5rem;
    position: relative;
    letter-spacing: 0.01em;
    transition: color 0.3s ease;
}

.mega-menu-item:hover .mega-menu-item-title {
    color: #a5b4fc;
}

.mega-menu-item-description {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.6;
    position: relative;
    transition: color 0.3s ease;
}

.mega-menu-item:hover .mega-menu-item-description {
    color: rgba(255, 255, 255, 0.75);
}

/* ============================================
   HEADER CTA BUTTON
   ============================================ */

.header-cta {
    margin-left: 1.5rem;
}

.header-cta .btn {
    padding: 0.625rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    background: linear-gradient(
        135deg,
        rgba(99, 102, 241, 1) 0%,
        rgba(139, 92, 246, 1) 100%
    );
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 4px 12px rgba(99, 102, 241, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.header-cta .btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(139, 92, 246, 1) 0%,
        rgba(99, 102, 241, 1) 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.header-cta .btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 24px rgba(99, 102, 241, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.header-cta .btn:hover::before {
    opacity: 1;
}

.header-cta .btn span {
    position: relative;
    z-index: 1;
}

/* ============================================
   THEME TOGGLE & SEARCH
   ============================================ */

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

.theme-toggle,
.search-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover,
.search-toggle:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.theme-icon {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
}

.theme-icon-light {
    display: block;
}

.theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-dark {
    display: block;
}

/* ============================================
   MOBILE MENU
   ============================================ */

/* ============================================
   DESKTOP: Hide mobile-only elements
   ============================================ */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-left: 0.5rem;
}

.mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover span {
    background: #ffffff;
}

/* Mobile Menu Header - hidden on desktop */
.mobile-menu-header {
    display: none;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Mobile theme toggle item - MUST be hidden on desktop */
.mobile-theme-toggle-item {
    display: none !important;
}

.mobile-menu-close {
    display: flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

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

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .header-container {
        padding: 0 1.5rem;
    }

    .nav-link {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .mega-menu-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    html,
    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* CRITICAL: Ensure header is always visible on mobile */
    .main-header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 64px !important;
        z-index: 9999 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        background: rgba(10, 10, 25, 0.95) !important;
    }

    /* Header container adjustments */
    .header-container {
        padding: 0 1rem;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        height: 100% !important;
    }

    /* Logo adjustments - ensure it's visible */
    .logo-container {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 10000 !important;
        color: white !important;
    }

    .logo-text {
        font-size: 1.25rem !important;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        color: white !important;
        background: none !important;
        -webkit-text-fill-color: white !important;
        text-fill-color: white !important;
    }

    /* Hide desktop header actions (search and theme toggle) */
    .header-actions {
        display: none !important;
    }

    /* Show mobile menu toggle - CRITICAL */
    .mobile-menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 10000 !important;
        position: relative !important;
        background: transparent !important;
        border: none !important;
        padding: 8px !important;
        cursor: pointer !important;
    }

    .mobile-menu-toggle span {
        display: block !important;
        background: white !important;
    }

    /* Hide desktop CTA button */
    .header-cta {
        display: none !important;
    }

    /* Show mobile menu header with close and theme toggle */
    .mobile-menu-header {
        display: flex !important;
    }

    /* Ensure main content doesn't overlap header */
    .main-content {
        margin-top: 64px !important;
    }

    /* Mobile slide-out navigation */
    .main-nav {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        bottom: 0 !important;
        width: 85vw !important;
        max-width: 400px !important;
        height: 100vh !important;
        background: linear-gradient(
            135deg,
            rgba(8, 8, 20, 0.98) 0%,
            rgba(12, 12, 28, 0.98) 100%
        ) !important;
        backdrop-filter: blur(24px) !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 1.5rem !important;
        transition: left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
        z-index: 10001 !important;
        overflow-y: auto !important;
        border-right: 1px solid rgba(99, 102, 241, 0.2) !important;
        display: flex !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    .main-nav.active {
        left: 0 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    .nav-list {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        width: 100%;
        justify-content: space-between;
    }

    .mega-menu {
        position: static;
        width: 100%;
        background: rgba(15, 15, 30, 0.6);
        backdrop-filter: none;
        border: none;
        box-shadow: none;
        margin-top: 0.5rem;
        border-radius: 0.5rem;
        max-height: 0;
        overflow: hidden;
        transform: none;
    }

    .nav-item:hover .mega-menu {
        max-height: 1000px;
        opacity: 1;
        visibility: visible;
    }

    .mega-menu-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 0.75rem;
    }

    .mega-menu-item {
        padding: 1rem;
    }

    body.menu-open::after {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.85);
        z-index: 1050;
        animation: fadeIn 0.3s ease;
        backdrop-filter: blur(4px);
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
}

/* ============================================
   LIGHT THEME OVERRIDES
   ============================================ */

[data-theme="light"] .main-header {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.92) 0%,
        rgba(250, 250, 255, 0.95) 50%,
        rgba(255, 255, 255, 0.92) 100%
    );
    border-image: linear-gradient(
            90deg,
            transparent,
            rgba(99, 102, 241, 0.2) 20%,
            rgba(139, 92, 246, 0.2) 50%,
            rgba(99, 102, 241, 0.2) 80%,
            transparent
        )
        1;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.08),
        0 0 80px rgba(99, 102, 241, 0.05);
}

[data-theme="light"] .main-header.scrolled {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.98) 0%,
        rgba(250, 250, 255, 0.98) 50%,
        rgba(255, 255, 255, 0.98) 100%
    );
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.1),
        0 0 100px rgba(99, 102, 241, 0.08);
}

[data-theme="light"] .nav-link {
    color: rgba(0, 0, 0, 0.75);
}

[data-theme="light"] .nav-link:hover {
    color: rgba(0, 0, 0, 0.95);
}

[data-theme="light"] .mega-menu {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.98) 0%,
        rgba(250, 250, 255, 0.98) 50%,
        rgba(255, 255, 255, 0.98) 100%
    );
    border-top-color: rgba(99, 102, 241, 0.15);
    border-bottom-color: rgba(99, 102, 241, 0.15);
}

[data-theme="light"] .mega-menu-item {
    background: linear-gradient(
        135deg,
        rgba(248, 248, 255, 0.6) 0%,
        rgba(250, 250, 255, 0.4) 100%
    );
    border-color: rgba(99, 102, 241, 0.15);
}

[data-theme="light"] .mega-menu-item-title {
    color: rgba(0, 0, 0, 0.9);
}

[data-theme="light"] .mega-menu-item-description {
    color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .mega-menu-item:hover {
    background: linear-gradient(
        135deg,
        rgba(240, 242, 255, 0.9) 0%,
        rgba(245, 247, 255, 0.8) 100%
    );
    border-color: rgba(99, 102, 241, 0.3);
}

[data-theme="light"] .mega-menu-item:hover .mega-menu-item-title {
    color: #3b82f6;
}

[data-theme="light"] .mega-menu-item:hover .mega-menu-item-description {
    color: rgba(0, 0, 0, 0.75);
}

[data-theme="light"] .theme-toggle,
[data-theme="light"] .search-toggle {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.7);
}

[data-theme="light"] .theme-toggle:hover,
[data-theme="light"] .search-toggle:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: rgba(0, 0, 0, 0.9);
}
