/* Mobile Fixes - Validated */
@media (max-width: 768px) {

    /* 1. Theme Toggle Visibility */
    #themeToggle {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        color: #333 !important;
        /* Dark icon */
        background: rgba(255, 255, 255, 0.9) !important;
        border: 1px solid #ddd !important;
        width: 40px !important;
        height: 40px !important;
        margin-right: 8px !important;
        border-radius: 50% !important;
        z-index: 9999 !important;
        position: relative !important;
    }

    /* 0. Global Overflow Fix */
    body,
    html {
        overflow-x: hidden !important;
        width: 100% !important;
        position: relative !important;
    }

    #themeToggle svg {
        width: 20px !important;
        height: 20px !important;
        display: block !important;
        color: #333 !important;
    }

    /* 2. Nav Actions container */
    .nav-actions {
        display: flex !important;
        gap: 2px !important;
        /* Minimal gap */
        align-items: center !important;
        width: auto !important;
        overflow: visible !important;
        flex-shrink: 0 !important;
    }

    /* Cart Icon */
    .nav-actions .cart-link,
    .nav-actions a[href*="Cart"] {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        width: 36px !important;
        /* Slightly smaller touch target */
        height: 36px !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Header container fix */
    .navbar,
    nav.navbar {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 8px 8px !important;
        /* Reduced padding */
        width: 100% !important;
        flex-wrap: nowrap !important;
    }

    /* Shrink Brand on Mobile to fit */
    .navbar-brand {
        font-size: 1.1rem !important;
        margin-right: 0 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        flex-shrink: 1 !important;
    }

    /* 3. Pizza Background Visibility */
    .hero-image-wrapper {
        position: absolute !important;
        /* Moves with content */
        top: 20px !important;
        /* Start slightly below top of hero */
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 320px !important;
        /* Fixed width */
        height: 320px !important;
        /* Fixed height - SQUARE */
        z-index: 0 !important;
        opacity: 0.15 !important;
        display: flex !important;
        margin: 0 !important;
        pointer-events: none !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .rotating-pizza-container {
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        animation: spin-slow 60s linear infinite !important;
    }

    .hero-pizza-img {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
        object-fit: contain !important;
        /* Keep aspect ratio inside square */
    }

    /* Define keyframes locally to ensure they exist */
    @keyframes spin-slow {
        from {
            transform: rotate(0deg);
        }

        to {
            transform: rotate(360deg);
        }
    }

    /* 4. Hide Overlay Text (BodanFood) */
    .hero-overlay-text {
        display: none !important;
    }

    /* 5. Hero Section Overflow - visible */
    .hero-section {
        overflow: visible !important;
        position: relative !important;
        padding-bottom: 20px !important;
        background: transparent !important;
        /* Ensure transparent so fixed pizza shows */
    }

    /* Ensure categories don't block it */
    #categories {
        position: relative !important;
        z-index: 2 !important;
        background: transparent !important;
    }

    /* 6. Content z-index */
    .hero-content {
        position: relative !important;
        z-index: 2 !important;
    }

    /* 7. Burger Menu & Drawer Enhancements */
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        border: 1px solid var(--border-color);
        background: var(--surface-color);
        color: var(--text-color);
        z-index: 9999 !important;
        transition: all 0.2s ease;
    }

    .mobile-menu-btn:active {
        transform: scale(0.95);
        background: var(--primary-color);
        color: white;
    }

    /* GLASSMORPHISM DRAWER */
    .mobile-drawer {
        position: fixed;
        top: 0;
        right: -300px;
        /* Start off-screen */
        width: 300px;
        height: 100vh;
        background: rgba(255, 255, 255, 0.85);
        /* Light mode glass */
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
        z-index: 10000;
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        padding: 20px;
        border-left: 1px solid rgba(255, 255, 255, 0.2);
    }

    [data-theme="dark"] .mobile-drawer {
        background: rgba(30, 30, 30, 0.85);
        /* Dark mode glass */
        border-left: 1px solid rgba(255, 255, 255, 0.05);
    }

    .mobile-drawer.open {
        right: 0;
    }

    /* Drawer Header */
    .mobile-drawer-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 30px;
        padding-bottom: 15px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    [data-theme="dark"] .mobile-drawer-header {
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .drawer-user-avatar {
        width: 48px;
        height: 48px;
        background: linear-gradient(135deg, var(--primary-color), #ff9f43);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        box-shadow: 0 4px 12px rgba(234, 124, 105, 0.3);
    }

    .mobile-drawer-close {
        background: transparent;
        border: none;
        color: var(--text-muted);
        padding: 8px;
        border-radius: 50%;
        transition: all 0.2s;
    }

    .mobile-drawer-close:hover {
        background: rgba(0, 0, 0, 0.05);
        color: var(--primary-color);
        transform: rotate(90deg);
    }

    /* Navigation Links */
    .mobile-drawer-nav {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .mobile-nav-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        border-radius: 16px;
        color: var(--text-color);
        font-weight: 600;
        text-decoration: none;
        transition: all 0.2s ease;
        font-size: 1.05rem;
    }

    .mobile-nav-link .icon {
        font-size: 1.2rem;
        width: 24px;
        text-align: center;
    }

    .mobile-nav-link:hover,
    .mobile-nav-link:active {
        background: rgba(234, 124, 105, 0.1);
        /* Primary color tint */
        color: var(--primary-color);
        transform: translateX(5px);
    }

    /* Overlay */
    .mobile-drawer-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        z-index: 9999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s ease;
    }

    .mobile-drawer-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    /* 8. Search Input Padding */
    #hero-search input {
        padding-right: 50px !important;
        font-size: 14px !important;
    }
}