/* ===== ULTIMATE HEADER SYSTEM - PROFESSIONAL ENHANCEMENT ===== */

:root {
    /* CSS Custom Properties for Dynamic Theming */
    --header-height: 80px;
    --header-bg: rgba(26, 26, 26, 0.97);
    --header-blur: 20px;
    --accent-primary: #ff4757;
    --accent-secondary: #ff6b81;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-elegant: 0 10px 40px rgba(0, 0, 0, 0.3);
    --shadow-intense: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ===== PERFORMANCE-OPTIMIZED HEADER ===== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--header-bg);
    /* Optimized backdrop with fallback */
    backdrop-filter: blur(var(--header-blur));
    -webkit-backdrop-filter: blur(var(--header-blur));
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(20px, 5vw, 40px);
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    /* Hardware acceleration */
    transform: translateZ(0);
    will-change: transform, backdrop-filter;
    /* Dynamic scroll effect */
    transition: transform 0.4s var(--transition-smooth), 
                backdrop-filter 0.4s var(--transition-smooth),
                box-shadow 0.4s var(--transition-smooth);
}

/* Dynamic scroll effect */
.main-header.scrolled {
    --header-bg: rgba(10, 10, 10, 0.98);
    --header-blur: 25px;
    box-shadow: var(--shadow-elegant);
    transform: translateY(0);
}

.main-header.hidden {
    transform: translateY(-100%);
}

/* ===== ENHANCED LOGO WITH MICRO-ANIMATIONS ===== */
.logo {
    font-family: 'Croissant One', serif;
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-weight: 900;
    color: var(--text-primary);
    text-decoration: none;
    position: relative;
    display: inline-block;
    padding: 5px 0;
}

.logo::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.6s var(--transition-smooth);
}

.logo:hover::after {
    width: 100%;
}

.logo span {
    color: var(--accent-primary);
    position: relative;
    display: inline-block;
    animation: logoPulse 3s infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ===== INNOVATIVE NAVIGATION SYSTEM ===== */
.main-nav ul {
    display: flex;
    list-style: none;
    gap: clamp(15px, 3vw, 30px);
    align-items: center;
    margin: 0;
    padding: 0;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-family: 'Madimi One', sans-serif;
    font-size: clamp(0.95rem, 2vw, 1.15rem);
    padding: 4px clamp(12px, 2vw, 20px);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    transition: all 0.4s var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 8px;
    /* Accessibility */
    outline: 1px solid transparent;
    outline-offset: 1px;
}

.main-nav a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 71, 87, 0.2), 
        transparent);
    transition: left 0.6s var(--transition-smooth);
}

.main-nav a:hover::before {
    left: 100%;
}

.main-nav a:hover,
.main-nav a:focus-visible {
    color: var(--accent-primary);
    background: rgba(255, 71, 87, 0.1);
    transform: translateY(-2px);
    outline-color: var(--accent-primary);
    
    box-shadow: 0 6px 18px rgba(255, 71, 87, 0.25);
}

.main-nav a.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--text-primary);
    box-shadow: 0 5px 20px rgba(255, 71, 87, 0.3);
}

.main-nav a.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: activeDot 2s infinite;
}

@keyframes activeDot {
    0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.5; transform: translateX(-50%) scale(1.2); }
}

/* ===== ADVANCED DROPDOWN SYSTEM ===== */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    background: rgba(45, 45, 45, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    min-width: 240px;
    border-radius: 16px;
    padding: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.4s var(--transition-smooth);
    box-shadow: var(--shadow-elegant);
    border: 1px solid var(--border-color);
    z-index: 1001;
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    padding: 14px 20px;
    margin: 4px 0;
    border-radius: 10px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropdown-menu a:hover {
    background: linear-gradient(135deg, 
        rgba(255, 71, 87, 0.2), 
        rgba(255, 107, 129, 0.2));
    transform: translateX(5px);
}

.dropdown-menu a::after {
    content: '→';
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s var(--transition-smooth);
}

.dropdown-menu a:hover::after {
    opacity: 1;
    transform: translateX(0);
}

/* ===== ACTION BUTTONS WITH ENHANCED FEEDBACK ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 20px);
}

.cart-btn, .theme-btn {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: all 0.4s var(--transition-smooth);
    /* Accessibility */
    outline: none;
}

.cart-btn::before,
.theme-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s var(--transition-smooth);
}

.cart-btn:hover,
.theme-btn:hover,
.cart-btn:focus-visible,
.theme-btn:focus-visible {
    transform: scale(1.15) rotate(5deg);
    border-color: var(--accent-primary);
    background: transparent;
}

.cart-btn:hover::before,
.theme-btn:hover::before {
    opacity: 1;
}

.cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    font-size: 0.75rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 3px 10px rgba(255, 71, 87, 0.4);
    animation: countPop 0.3s var(--transition-smooth);
}

@keyframes countPop {
    0% { transform: scale(0); }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ===== INTELLIGENT MOBILE MENU SYSTEM ===== */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.8rem;
    cursor: pointer;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    position: relative;
    z-index: 1002;
    transition: all 0.4s var(--transition-smooth);
}

.mobile-menu-toggle:hover {
    background: rgba(255, 71, 87, 0.1);
    transform: rotate(90deg);
}

.mobile-menu-toggle.active {
    transform: rotate(180deg);
}

/* ===== RESPONSIVE BREAKPOINT SYSTEM ===== */

/* Tablet Landscape */
@media (max-width: 1024px) {
    :root {
        --header-height: 70px;
    }
    
    .main-nav ul {
        gap: 20px;
    }
}

/* Tablet Portrait */
@media (max-width: 900px) {
    .main-nav ul {
        gap: 15px;
    }
    
    .dropdown-menu {
        min-width: 200px;
    }
}

/* Mobile & Tablet */
@media (max-width: 768px) {
    .main-header {
        padding: 0 15px;
    }
    
    .main-nav ul {
        position: fixed;
        top: var(--header-height);
        left: 0;
        width: 100%;
        height: calc(100vh - var(--header-height));
        background: rgba(10, 10, 10, 0.98);
        backdrop-filter: blur(30px);
        -webkit-backdrop-filter: blur(30px);
        flex-direction: column;
        padding: 40px 20px;
        text-align: center;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-20px);
        transition: all 0.6s var(--transition-smooth);
        z-index: 999;
    }
    
    .main-nav ul.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    .main-nav a {
        font-size: 1.2rem;
        padding: 15px 30px;
        width: 100%;
        justify-content: center;
        border-radius: 15px;
    }
    
    .dropdown-menu {
        position: static;
        background: rgba(255, 255, 255, 0.05);
        box-shadow: none;
        border: none;
        margin-top: 10px;
        opacity: 1;
        visibility: visible;
        transform: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s var(--transition-smooth);
    }
    
    .dropdown.active .dropdown-menu {
        max-height: 300px;
    }
    
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .header-actions {
        gap: 12px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    :root {
        --header-height: 65px;
    }
    
    .logo {
        font-size: 1.6rem;
    }
    
    .cart-btn,
    .theme-btn {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
    
    .cart-count {
        min-width: 18px;
        height: 18px;
        font-size: 0.7rem;
    }
}

/* ===== DARK/LIGHT THEME SUPPORT ===== */
[data-theme="light"] .main-header {
    --header-bg: rgba(255, 255, 255, 0.97);
    --text-primary: #1a1a1a;
    --text-secondary: rgba(26, 26, 26, 0.8);
    --border-color: rgba(0, 0, 0, 0.1);
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .main-header {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* ===== PRINT OPTIMIZATION ===== */
@media print {
    .main-header {
        position: static;
        background: white !important;
        border-bottom: 2px solid #000;
    }
    
    .main-nav,
    .header-actions {
        display: none !important;
    }
}