/* --- Desktop Menu Styles --- */
.header-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 24px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    width: auto;
}
        /* Keep nav hidden and off-layout until opened */
        .header-nav { display: none !important; }
        /* Nav becomes fixed overlay only when opened */
        .header-nav.mobile-open {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            transition: left 0.3s ease;
            overflow-y: auto;
            z-index: 1100;
            box-shadow: 0 4px 20px rgba(0,0,0,0.15);
            /* Add safe-area padding for iOS notch */
            padding-top: env(safe-area-inset-top, 0px);
            display: flex !important;
            flex-direction: column;
        }
        /* Hide desktop CTA on mobile */
        .header-cta { display: none; }
        /* show hamburger on mobile */
        .mobile-menu-toggle { display: block; z-index: 1202; }
        /* show mobile header actions (icons) */
        .mobile-header-actions { display: flex; align-items: center; gap: 1rem; justify-content: flex-end; flex: 0 0 auto; }
        .header-nav.mobile-open { left: 0 !important; }
        .mobile-menu-close {
            position: fixed;
            top: calc(env(safe-area-inset-top, 0px) + 8px);
            right: 1rem;
            background: none;
            border: none;
            color: white;
            font-size: 2rem;
            z-index: 1202;
            cursor: pointer;
        }
        .nav-menu { flex-direction: column; align-items: stretch; z-index: 9999; width: 100%; padding-top: calc(env(safe-area-inset-top, 0px) + 4px); margin-top: 0; }
        .nav-item-content { display: flex; align-items: center; justify-content: space-between; gap: 0.25rem; width: 100%; padding: 0 1rem; }
        .nav-link { color: white; text-decoration: none; padding: 0.75rem 0; flex: 1; text-align: left; }
        .submenu-toggle { display: block; margin-left: 1rem; background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; }
        .nav-item.level-0 { width: 100%; border-bottom: 1px solid rgba(255,255,255,0.1); }
        .sub-menu { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; background: rgba(255, 255, 255, 0.1); border-radius: 0; max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
        .nav-item.active > .sub-menu { max-height: 2000px; }
        .sub-menu .nav-link { color: rgba(255, 255, 255, 0.9); padding-left: 2.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
        .sub-menu.level-2 .nav-link { padding-left: 3.5rem; }
        .mobile-header-actions .order-icon { font-size: 1.5rem; color: white; }
        .mobile-header-actions .mobile-login,
        .mobile-header-actions .mobile-order { display: flex; align-items: center; justify-content: center; background: none; border: none; padding: 0.25rem 0.5rem; }
        /* Ensure nested submenus stack vertically on mobile */
        .sub-menu.level-2, .sub-menu.level-3 { position: static !important; left: auto !important; top: auto !important; margin: 0 !important; transform: none !important; box-shadow: none !important; }
        /* Disable hover-based offset behavior on mobile */
        .nav-item.level-0:hover > .sub-menu.level-1,
        .nav-item.level-1:hover > .sub-menu.level-2,
        .nav-item.level-2:hover > .sub-menu.level-3 { opacity: 1; visibility: visible; transform: none; }
        max-height: 2000px;
    }
}
/* Header background and text color fix */
.header-wrapper {
    position: sticky;
    top: 0;
    z-index: 1200;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}
.header-container,
.header-logo .logo-link,
.nav-link,
.mobile-header-actions .user-icon,
.mobile-header-actions .order-icon {
    color: white;
}
/* --- Mobile Menu Overlay --- */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 1099;
}

/* --- Mobile Menu --- */
@media (max-width: 968px) {
    /* Keep nav hidden and off-layout until opened */
    .header-nav {
        display: none !important;
    }
    /* Nav becomes fixed overlay only when opened */
    .header-nav.mobile-open {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        transition: left 0.3s ease;
        overflow-y: auto;
        z-index: 1100;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        /* Add safe-area padding for iOS notch */
        padding-top: env(safe-area-inset-top, 0px);
        display: flex !important;
        flex-direction: column;
    }
    /* Hide desktop CTA on mobile */
    .header-cta { display: none; }
    /* show hamburger on mobile */
    .mobile-menu-toggle {
        display: block;
        z-index: 1202;
    }
    /* show mobile header actions (icons) */
    .mobile-header-actions {
        display: flex;
        align-items: center;
        gap: 1rem;
        justify-content: flex-end;
        flex: 0 0 auto;
    }
    .header-nav.mobile-open {
        left: 0 !important;
    }
    .mobile-menu-close {
        position: fixed;
        /* Close button respects safe area and stays close to top */
        top: calc(env(safe-area-inset-top, 0px) + 8px);
        right: 1rem;
        background: none;
        border: none;
        color: white;
        font-size: 2rem;
        z-index: 1202;
        cursor: pointer;
    }
    .nav-menu {
        flex-direction: column;
        align-items: stretch;
        z-index: 9999;
        width: 100%;
        /* Sit close to the X while accounting for notch */
        padding-top: 8px;
        margin-top: 0;
    }
    .nav-item-content {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.25rem;
        width: 100%;
        padding: 0 1rem;
    }
    /* Correct mobile link styles */
    .nav-link {
        color: white;
        text-decoration: none;
        padding: 0.75rem 0;
        flex: 1;
        text-align: left;
    }
    .submenu-toggle {
        display: block;
        margin-left: 1rem;
        background: none;
        border: none;
        color: white;
        font-size: 1.2rem;
        cursor: pointer;

    /* Ensure nested submenus stack vertically on mobile */
    .sub-menu.level-2,
    .sub-menu.level-3 {
        position: static !important;
        left: auto !important;
        top: auto !important;
        margin: 0 !important;
        transform: none !important;
        box-shadow: none !important;
    }

    /* Disable hover-based offset behavior on mobile */
    .nav-item.level-0:hover > .sub-menu.level-1,
    .nav-item.level-1:hover > .sub-menu.level-2,
    .nav-item.level-2:hover > .sub-menu.level-3 {
        opacity: 1;
        visibility: visible;
        transform: none;
    }
    }
    .nav-item.level-0 {
        width: 100%;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    .nav-item.active > .sub-menu {
        max-height: 2000px;
    }
    .sub-menu .nav-link {
        color: rgba(255, 255, 255, 0.9);
        padding-left: 2.5rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    .sub-menu.level-2 .nav-link {
        padding-left: 3.5rem;
    }
    .mobile-header-actions .order-icon {
        font-size: 1.5rem;
        color: white;
    }

    .mobile-header-actions .mobile-login,
    .mobile-header-actions .mobile-order {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        padding: 0.25rem 0.5rem;
    }

/* Hide desktop CTA on small screens, show mobile actions */
/* these rules are handled inside the mobile menu media block above */

/* Header container layout */
.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

/* Mobile header actions (login, order, menu icon) default hidden on desktop */
.mobile-header-actions {
    display: none;
    align-items: center;
    gap: 1rem;
    justify-content: flex-end;
    width: auto;
    padding-right: 1.5rem;
}

/* Navigation Styles */
.header-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

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

/* Level 0 - Top Level Items */
.nav-item.level-0 {
    position: relative;
}

.nav-item-content {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.75rem 1rem;
    display: block;
    transition: all 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
}

.nav-item.level-0 > .nav-item-content > .nav-link {
    font-size: 1rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Submenu Toggle Button (for mobile) */
.submenu-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    display: none;
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.nav-item.active > .nav-item-content > .submenu-toggle .toggle-icon {
    transform: rotate(180deg);
    display: inline-block;
}

/* Sub-menus (Levels 1, 2, 3) */
.sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 8px;
    min-width: 250px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 2000;
}
@media (max-width: 968px) {
    .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    .nav-item.active > .sub-menu {
        max-height: 2000px;
    }
}
.user-icon, .order-icon, .login-text, .order-text {
    display: inline-block;
    vertical-align: middle;
}

/* Show submenu on hover (desktop) */
.nav-item.level-0:hover > .sub-menu.level-1 {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Level 1 submenu items */
.sub-menu.level-1 .nav-item {
    position: relative;
}

.sub-menu .nav-link {
    color: #333;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
}

.sub-menu .nav-link:hover {
    background: #f8f9fa;
    color: #667eea;
}

/* Level 2 submenu (nested dropdown) */
.sub-menu.level-2 {
    top: 0;
    left: 100%;
    margin-left: 0.5rem;
}

.nav-item.level-1:hover > .sub-menu.level-2 {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Level 3 submenu (deeply nested) */
.sub-menu.level-3 {
    top: 0;
    left: 100%;
    margin-left: 0.5rem;
}

.nav-item.level-2:hover > .sub-menu.level-3 {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Indicator for items with children */
.nav-item.has-children > .nav-item-content > .nav-link::after {
    content: ' ▼';
    font-size: 0.7rem;
    margin-left: 0.25rem;
    opacity: 0.7;
}

.sub-menu .nav-item.has-children > .nav-item-content > .nav-link::after {
    content: ' ▶';
    float: right;
}

/* CTA Button */
.header-cta .btn {
    background: white;
    color: #667eea;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    white-space: nowrap;
}

.header-cta .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
    font-size: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 6px;
    transition: background 0.2s;
}

.hamburger {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    position: relative;
    transition: all 0.3s ease;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 3px;
    background: white;
    transition: all 0.3s ease;
}

.hamburger::before {
    top: -8px;
}

.hamburger::after {
    top: 8px;
}

 

/* Accessibility improvements */
.nav-link:focus,
.btn:focus,
.mobile-menu-toggle:focus,
.submenu-toggle:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Ensure proper stacking */
.header-wrapper {
    isolation: isolate;
}

/* Prevent body scroll when mobile menu is open */
body.menu-open {
    overflow: hidden;
}

/* Final mobile overrides to ensure hamburger visibility */
@media (max-width: 968px) {
    .mobile-header-actions {
        display: flex !important;
        width: auto !important;
        justify-content: flex-end !important;
        gap: 0.75rem !important;
        flex: 0 0 auto !important;
    }
    .mobile-menu-toggle {
        display: block !important;
    }
    /* Align logo + login + order + hamburger in one row */
    .header-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 0 12px !important;
        gap: 0.75rem !important;
    }
    .header-logo {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: auto !important;
    }
    .logo-img {
        max-height: 36px;
        height: auto;
        width: auto;
    }
    /* Avoid stretching actions to full width */
    .header-actions {
        display: none !important;
        width: auto !important;
    }
}

/* Explicit desktop layout to ensure logo left, menu right */
@media (min-width: 969px) {
    .header-container {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
    }
    .header-logo {
        flex: 0 0 auto;
        min-width: 0;
        width: auto;
        max-width: 200px;
    }
    .logo-img { max-height: 40px; height: auto; width: auto; }
    .mobile-header-actions { display: none !important; }
    .header-nav { display: flex !important; flex: 1 1 auto; justify-content: flex-end; }
    .nav-menu { display: flex !important; flex-direction: row; align-items: center; gap: 1rem; }
    .nav-link { white-space: nowrap; }
}

/* Fallback header styles (hidden once React mounts) */
.header-fallback {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.react-header-mounted .header-fallback { display: none; }
