/* Mobile Category Menu Fixes */

/* Ensure category menu overlays Request Custom Furniture button and Tidio chat */
@media (max-width: 991px) {
    .mobile-category-list.active {
        z-index: 10000 !important; /* Higher than floating button (1000) and Tidio chat (1001) */
    }
    
    /* Hide floating button and Tidio chat when category menu is active */
    body:has(.mobile-category-list.active) .floating-button,
    body:has(.mobile-category-list.active) #tidio-chat {
        display: none !important; /* Hide completely when category menu is open */
        z-index: 500 !important; /* Much lower than category menu */
    }
    
    /* Fallback for browsers that don't support :has() */
    .mobile-category-list.active ~ .floating-button,
    .mobile-category-list.active ~ #tidio-chat {
        display: none !important;
        z-index: 500 !important;
    }
}

/* Ensure category menu fits mobile screen and is scrollable */
@media (max-width: 991px) {
    /* Reduce padding on mobile category list container */
    .mobile-category-list {
        padding: 10px !important; /* Reduced from 20px */
    }
    
    /* Ensure category nav fits within viewport with space for close button and bottom nav */
    .mobile-category-list .category-nav {
        max-height: calc(100vh - 160px) !important; /* Account for close button (50px) + bottom nav (60px) + padding (50px) */
        height: auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        padding-bottom: 80px !important; /* Add bottom padding so last items aren't hidden behind close button */
    }
    
    /* Ensure close button is always visible and accessible - positioned above bottom nav bar */
    .mobile-category-list .mobile-menu-close-btn {
        position: fixed !important;
        bottom: 80px !important; /* Position above bottom navigation bar (nav is ~60px high) */
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 226 !important; /* Higher than category-nav and bottom nav */
        width: 40px !important; /* Moderate size for mobile */
        height: 40px !important;
        line-height: 40px !important;
        font-size: 16px !important; /* Adjusted font size */
        color: #ffffff !important;
        background: #fe5502 !important;
        box-shadow: 0px 3px 15px 3px rgba(254, 85, 2, 0.4) !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
    }
    
    /* Make category title sticky so it stays visible when scrolling */
    .mobile-category-list .category-nav .title {
        position: sticky !important;
        top: 0 !important;
        background: #ffffff !important;
        z-index: 10 !important;
        padding: 10px 0 !important;
        margin-bottom: 10px !important;
    }
    
    /* Ensure category items are touch-friendly */
    .mobile-category-list .category-nav .category-item {
        min-height: 45px !important;
    }
    
    .mobile-category-list .category-nav .category-item a {
        min-height: 45px !important;
        padding: 8px 0 !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .mobile-category-list {
        padding: 5px !important; /* Even less padding on very small screens */
    }
    
    .mobile-category-list .category-nav {
        max-height: calc(100vh - 150px) !important; /* Less space on very small screens */
        max-width: 95vw !important;
        padding-bottom: 80px !important; /* Keep bottom padding for close button */
    }
    
    .mobile-category-list .mobile-menu-close-btn {
        bottom: 75px !important; /* Position above bottom nav on small screens */
        width: 38px !important; /* Slightly smaller on very small screens */
        height: 38px !important;
        line-height: 38px !important;
        font-size: 15px !important;
    }
}

