/* ===================================================================
   ALL CATEGORIES MENU - Desktop Only
   =================================================================== */

/* Hide by default */
#all-menu-overlay,
#all-menu-wrapper {
    display: none;
}

@media (min-width: 768px) {
    /* Overlay */
    #all-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 3;
        display: none;
    }

    #all-menu-overlay.active {
        display: block;
    }

    /* Menu Wrapper - Slides from left */
    #all-menu-wrapper {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 365px;
        background-color: #ffffff;
        z-index: 4;
        transition: left 0.5s cubic-bezier(0, 1, 0.5, 1);
        display: block;
        overflow: visible; /* 🔥 CHANGED: allow content to overflow on all sides */
    }

    #all-menu-wrapper.in {
        left: 0;
    }
}

/* ===================================================================
   MENU STRUCTURE
   =================================================================== */

.all-categories-menu {
    background-color: #ffffff !important;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 1;
    position: relative;
    overflow: visible; /* 🔥 ADDED: ensure content can overflow */
}

/* ===================================================================
   HEADER (blue bar + X sitting outside)
   =================================================================== */

.all-menu-header {
    position: relative;
    display: flex;
    align-items: center;
    overflow: visible; /* 🔥 ADDED: critical for X button visibility */
}

/* FULL BLUE HEADER BUTTON */
.all-categories-menu .close-menu {
    width: 100%;
    height: 56px;
    min-height: 56px;

    display: flex;
    align-items: center;
    gap: 10px;

    padding: 0 16px;

    background-color: #232f3e;
    border: none;
    color: #ffffff;

    font-size: 15px;
    font-weight: 600;

    cursor: pointer;
    box-sizing: border-box;
}

/* icon sizing */
.all-categories-menu .close-menu i {
    font-size: 20px;
}

/* label */
.all-categories-menu .menu-account-text {
    white-space: nowrap;
}

/* =========================================================
   X button - positioned outside the menu on the right
   ========================================================= */

.all-categories-menu .menu-close-x {
    position: absolute;
    top: 50%;
    right: -48px; /* pushes it outside to the right */
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 4px;
    font-size: 36px;
    font-weight: 300;
    line-height: 0.85;
    font-family: Arial, sans-serif;
    cursor: pointer;
    z-index: 10;
    pointer-events: auto;
    padding: 0;
    margin: 0;
}

.all-categories-menu .menu-close-x:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* ===================================================================
   MENU CONTENT (scroll area)
   =================================================================== */

.all-categories-menu .menu-group {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: visible; /* 🔥 ADDED: prevent horizontal clipping */
    -webkit-overflow-scrolling: touch;

    /* Fix last item being covered by browser bottom UI */
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
}

.all-categories-menu .navbar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: block !important;
}

/* ===================================================================
   MENU ITEMS
   =================================================================== */

.all-categories-menu .nav-item {
    border-bottom: 1px solid #eeeeee;
    display: block !important;
}

.all-categories-menu .nav-item .nav-link {
    display: block;
    padding: 12px 16px;
    color: #333333;
    text-decoration: none;
    position: relative;
}

.all-categories-menu .nav-item .nav-link:hover {
    background-color: #f7f7f7;
}

/* Section Headers */
.all-categories-menu .section-header {
    display: block;
    padding: 12px 16px;
    background-color: #f3f3f3;
    font-weight: 700;
    font-size: 14px;
    color: #111111;
}

/* ===================================================================
   DROPDOWN BASE
   =================================================================== */

.all-categories-menu .dropdown {
    display: block !important;
    position: static !important;
}

.all-categories-menu .dropdown-toggle {
    padding-right: 40px;
    position: relative;
}

/* Arrow indicator */
.all-categories-menu .dropdown-toggle::after {
    content: "";
    border-top: 0.3em solid transparent;
    border-bottom: 0.3em solid transparent;
    border-left: 0.3em solid #666666;

    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

/* ===================================================================
   DROPDOWN MENU - CLICK ONLY (NO HOVER)
   =================================================================== */

.all-categories-menu .dropdown-menu {
    position: absolute !important;
    left: -100% !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;

    border: 0 !important;
    transition: left 0.5s cubic-bezier(0, 1, 0.5, 1) !important;

    display: block !important;
    background-color: #ffffff !important;

    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;

    visibility: hidden !important;
    z-index: 1000 !important;
    overflow-y: auto !important;
}

/* Back button wrapper */
.all-categories-menu .back-button-wrapper {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: #ffffff;
}

/* Back button for subcategory menus */
.all-categories-menu .back-button {
    display: block;
    padding: 12px 16px;
    background-color: #f3f3f3;
    border: none;
    border-bottom: 1px solid #dddddd;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #111111;
}

.all-categories-menu .back-button::before {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 0.3em solid transparent;
    border-bottom: 0.3em solid transparent;
    border-right: 0.3em solid #666666;
    margin-right: 8px;
    vertical-align: middle;
}

.all-categories-menu .back-button:hover {
    background-color: #e8e8e8;
}

/* View All link styling */
.all-categories-menu .view-all-item {
    border-bottom: 2px solid #dddddd;
}

.all-categories-menu .view-all-link {
    font-weight: 700;
    padding-left: 16px !important;
}

/* Level-based indentation for all subcategories */
.all-categories-menu .level-1 .level-1-link {
    font-weight: 600;
    padding-left: 16px !important;
}

.all-categories-menu .level-2 .level-2-link {
    padding-left: 32px !important;
    font-weight: 400;
}

.all-categories-menu .level-3 .level-3-link {
    padding-left: 48px !important;
    font-weight: 400;
    color: #555555;
}

.all-categories-menu .level-4 .level-4-link {
    padding-left: 64px !important;
    font-weight: 400;
    color: #666666;
}

.all-categories-menu .level-5 .level-5-link {
    padding-left: 80px !important;
    font-weight: 400;
    color: #777777;
}

/* Show when active */
.all-categories-menu .dropdown.show > .dropdown-menu,
.all-categories-menu .nav-item.show > .dropdown-menu,
.all-categories-menu li.show > .dropdown-menu,
#all-menu-wrapper .all-categories-menu .dropdown.show > .dropdown-menu,
#all-menu-wrapper .all-categories-menu .nav-item.show > .dropdown-menu {
    left: 0 !important;
    visibility: visible !important;
}

/* HARD BLOCK hover */
.all-categories-menu .dropdown:hover > .dropdown-menu,
.all-categories-menu .dropdown:hover .dropdown-menu,
.all-categories-menu .nav-item:hover > .dropdown-menu,
.all-categories-menu li:hover > .dropdown-menu {
    left: -100% !important;
    visibility: hidden !important;
}

/* ===================================================================
   SUBCATEGORY ITEMS
   =================================================================== */

.all-categories-menu .dropdown-item {
    border-bottom: 1px solid #eeeeee;
    display: block !important;
}

.all-categories-menu .dropdown-item .dropdown-link {
    display: block;
    padding: 12px 16px 12px 32px;
    color: #333333;
    text-decoration: none;
    position: relative;
}

.all-categories-menu .dropdown-item .dropdown-link:hover {
    background-color: #f7f7f7;
}

/* Arrow alignment for nested dropdowns */
.all-categories-menu .dropdown-item > .dropdown-link.dropdown-toggle {
    padding-right: 40px;
}

.all-categories-menu .dropdown-item > .dropdown-link.dropdown-toggle::after {
    content: "";
    border-top: 0.3em solid transparent;
    border-bottom: 0.3em solid transparent;
    border-left: 0.3em solid #666666;

    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

/* ===================================================================
   TOP CATEGORY ("View All")
   =================================================================== */

.all-categories-menu .dropdown-item.top-category {
    font-weight: 700;
    border-top: none;
}

.all-categories-menu .dropdown-item.top-category .dropdown-link,
.all-categories-menu .dropdown-item.top-category a {
    padding-left: 16px;
    font-weight: 700;
}

/* ===================================================================
   DESKTOP "ALL" BUTTON
   =================================================================== */

@media (min-width: 768px) {
    .desktop-all-toggle {
        background: none;
        border: none;
        cursor: pointer;
        font-size: inherit;
        padding: 0.5rem 1rem;
        color: inherit;
    }

    .desktop-all-toggle:hover {
        opacity: 0.8;
    }

    .desktop-all-toggle:focus {
        outline: 2px solid #007bff;
        outline-offset: 2px;
    }
}

/* ===================================================================
   SCROLLBAR STYLING
   =================================================================== */

.all-categories-menu .menu-group::-webkit-scrollbar {
    width: 8px;
}

.all-categories-menu .menu-group::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.all-categories-menu .menu-group::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.all-categories-menu .menu-group::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===================================================================
   USER ACCOUNT DROPDOWN (for logged-in state) - HOVER + VERTICAL STACK
   =================================================================== */

.all-categories-menu .user-menu-wrapper {
    position: relative;
    width: 100%;
}

/* Hide dropdown by default */
.all-categories-menu .user-menu-wrapper .popover {
    display: none !important;
    position: absolute !important;
    left: 0 !important;
    top: 100% !important;
    width: 100% !important;
    background-color: #ffffff !important;
    border: 1px solid #dddddd !important;
    border-top: none !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
    z-index: 1000 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Show dropdown on hover - most specific selector */
.all-categories-menu .user-menu-wrapper:hover .popover,
.all-categories-menu .user-menu-wrapper:hover > .popover {
    display: block !important;
}

.all-categories-menu .user-menu-wrapper .popover .nav {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.all-categories-menu .user-menu-wrapper .popover .nav-item {
    border-bottom: 1px solid #eeeeee !important;
    display: block !important;
    width: 100% !important;
}

.all-categories-menu .user-menu-wrapper .popover .nav-item:last-child {
    border-bottom: none !important;
}

.all-categories-menu .user-menu-wrapper .popover .nav-item a {
    display: block !important;
    padding: 12px 16px !important;
    color: #333333 !important;
    text-decoration: none !important;
    font-size: 14px !important;
    width: 100% !important;
}

.all-categories-menu .user-menu-wrapper .popover .nav-item a:hover {
    background-color: #f7f7f7 !important;
}

/* Keep the header button styling */
.all-categories-menu .user-menu-wrapper .close-menu {
    width: 100%;
    display: flex;
    align-items: center;
}

/* User icon - keep at 20px */
.all-categories-menu .user-menu-wrapper .close-menu i.fa-user-circle {
    font-size: 20px;
    margin-right: 10px;
}

/* Dropdown indicator icon - override to be smaller and positioned closer */
.all-categories-menu .user-menu-wrapper .close-menu i.dropdown-indicator {
    font-size: 10px !important;
    margin-left: 6px;
    margin-right: 0;
    transition: transform 0.3s ease;
}

/* Rotate chevron when hovering (optional visual feedback) */
.all-categories-menu .user-menu-wrapper:hover .dropdown-indicator {
    transform: rotate(180deg);
}
