/**
 * Category Slide-Out Menu Styles
 * Mobile-style left-to-right slide animation for product categories
 */

/* ============================================
   Sticky Category Widget
   ============================================ */

/* Main sidebar widget - will be sticky when JS adds the class */
.widget_product_categories.is-sticky-enabled {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 20px !important;
    z-index: 99 !important;
    align-self: flex-start !important;
}

/* Popup modals should NOT be sticky - use normal fixed positioning */
.wc-category-modal-content {
    position: fixed !important;
    /* Modals are NOT sticky, they use fixed positioning as before */
}

/* ============================================
   Main Category Widget Styles
   ============================================ */

.widget_product_categories {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.widget_product_categories .product-categories {
    margin: 0;
    padding: 0;
    list-style: none;
}

.widget_product_categories .product-categories li {
    display: flex;
    align-items: center;
    padding: 20px 25px;
    margin: 0;
    border-bottom: 1px solid #e5e5e5;
    position: relative;
    transition: background-color 0.3s ease;
}

.widget_product_categories .product-categories li:last-child {
    border-bottom: none;
}

.widget_product_categories .product-categories li:hover {
    background-color: #f8f8f8;
    cursor: pointer;
}

/* Category link */
.widget_product_categories .product-categories li > a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #333;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    width: 100%;
}

/* Category thumbnail/icon - LEFT SIDE */
.widget_product_categories .product-categories li .category-image-link {
    width: 60px;
    height: 60px;
    margin-right: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 0;
    order: -1;
}

.widget_product_categories .product-categories li .category-image-link img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0;
}

/* Arrow indicator for categories with children */
.widget_product_categories .product-categories li.cat-parent > a .cat-arrow {
    font-size: 10px;
    margin-left: 8px;
    display: inline-block;
    transform: rotate(0deg);
    transition: transform 0.3s ease, color 0.3s ease;
}

/* Active arrow state - rotate back to right and change color */
.widget_product_categories .product-categories li.cat-parent.active-main-category > a .cat-arrow {
    transform: rotate(-90deg);
    color: #ff6b35;
}

/* Hide count and subcategories in main widget */
.widget_product_categories .product-categories li .count {
    display: none;
}

.widget_product_categories .product-categories li ul.children {
    display: none !important;
}

/* ============================================
   Slide-Out Modal Container (Contextual)
   ============================================ */

.wc-category-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    visibility: hidden;
    pointer-events: none;
}

.wc-category-modal.active {
    visibility: visible;
    /* Don't block pointer events - modal content will handle its own pointer events */
    pointer-events: none;
}

/* Modal content needs pointer events enabled */
.wc-category-modal.active .wc-category-modal-content {
    pointer-events: auto;
}

/* Overlay also needs pointer events if it exists (click mode only) */
.wc-category-modal.active .wc-category-modal-overlay {
    pointer-events: auto;
}

/* Stack multiple modals - each gets higher z-index */
.wc-category-modal:nth-of-type(1) {
    z-index: 99999;
}

.wc-category-modal:nth-of-type(2) {
    z-index: 100010;
}

.wc-category-modal:nth-of-type(3) {
    z-index: 100020;
}

.wc-category-modal:nth-of-type(4) {
    z-index: 100030;
}

/* Overlay background - doesn't block pointer events so sidebar remains interactive */
.wc-category-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* First overlay is darker, subsequent ones are lighter to show layering */
.wc-category-modal:nth-of-type(1) .wc-category-modal-overlay {
    background: rgba(0, 0, 0, 0.5);
}

.wc-category-modal:nth-of-type(2) .wc-category-modal-overlay {
    background: rgba(0, 0, 0, 0.2);
}

.wc-category-modal:nth-of-type(3) .wc-category-modal-overlay {
    background: rgba(0, 0, 0, 0.1);
}

.wc-category-modal.active .wc-category-modal-overlay {
    opacity: 1;
}

/* ============================================
   Slide-Out Panel Content (From Widget Position)
   ============================================ */

.wc-category-modal-content {
    position: fixed !important;
    background: #fff !important;
    overflow: visible;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border-radius: 0;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(0) !important;
    transition: none;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 100000 !important;
    min-width: 300px;
    display: block !important;
}

.wc-category-modal.active .wc-category-modal-content {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(0) !important;
    display: block !important;
}

/* ============================================
   Modal Header (Top Bar)
   ============================================ */

.wc-category-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: #2b2b28;
    color: #fff;
    border-bottom: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.wc-category-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    flex: 1;
    text-align: center;
    letter-spacing: 1px;
    color: #fff !important;
}

/* Back button (left arrow) */
.wc-category-modal-back {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
    padding: 5px 10px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.wc-category-modal-back:hover {
    opacity: 0.7;
}

/* Close button (X) */
.wc-category-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
    padding: 0;
    width: 32px;
    height: 32px;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.wc-category-modal-close:hover {
    opacity: 0.7;
}

/* ============================================
   Modal Body (Category List) - FORCE SINGLE COLUMN
   ============================================ */

.wc-category-modal-body {
    padding: 0;
    height: calc(100% - 60px);
    overflow-y: auto;
    background: #fff;
}

/* FORCE single column layout - NUCLEAR OPTION - override ALL theme/plugin styles */
.wc-category-modal-body,
.wc-category-modal-body * {
    box-sizing: border-box !important;
}

/* Remove ALL flex and grid layouts */
.wc-category-modal-body,
.wc-category-modal-body * {
    display: block !important;
}

/* Override for items that NEED flex */
.wc-category-modal-body ul.children li,
.wc-category-modal-body ul li {
    display: flex !important;
}

.wc-category-modal-body ul.children,
.wc-category-modal-body ul,
.wc-category-modal-body .children {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    width: 100% !important;
    columns: initial !important;
    column-count: 1 !important;
    column-width: auto !important;
    -webkit-columns: initial !important;
    -moz-columns: initial !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    grid-template-columns: none !important;
    overflow: visible !important;
}

.wc-category-modal-body ul.children li,
.wc-category-modal-body ul li,
.wc-category-modal-body .children li,
.wc-category-modal-body li {
    border-bottom: 1px solid #f0f0f0 !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    transition: background-color 0.2s ease;
    background: #fff !important;
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    clear: both !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    position: relative !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
}

.wc-category-modal-body ul.children li:last-child,
.wc-category-modal-body ul li:last-child {
    border-bottom: none !important;
}

.wc-category-modal-body ul.children li:hover,
.wc-category-modal-body ul li:hover {
    background-color: #f8f8f8 !important;
}

.wc-category-modal-body ul.children li > a,
.wc-category-modal-body ul li > a {
    display: flex !important;
    align-items: center !important;
    text-decoration: none !important;
    color: #333 !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    padding: 20px 25px !important;
    width: 100% !important;
    position: relative !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    gap: 10px !important;
}

/* When category has arrow (subcategories), add extra padding for the arrow */
.wc-category-modal-body ul.children li.cat-parent > a,
.wc-category-modal-body ul li.cat-parent > a {
    padding-right: 50px !important;
}

/* Right arrow indicator for categories with subcategories */
.wc-category-modal-body ul.children li.cat-parent > a .cat-arrow-right,
.wc-category-modal-body ul li.cat-parent > a .cat-arrow-right {
    position: absolute !important;
    right: 25px !important;
    font-size: 14px !important;
    color: #999 !important;
    margin-left: auto !important;
    transform: rotate(90deg) !important;
    transition: transform 0.3s ease, color 0.3s ease !important;
}

/* Active arrow state - rotate back to right and change color */
.wc-category-modal-body ul.children li.cat-parent.active-submenu > a .cat-arrow-right,
.wc-category-modal-body ul li.cat-parent.active-submenu > a .cat-arrow-right {
    transform: rotate(0deg) !important;
    color: #ff6b35 !important;
}

.wc-category-modal-body ul.children li .category-image-link,
.wc-category-modal-body ul li .category-image-link {
    width: 60px !important;
    height: 60px !important;
    margin-left: 20px !important;
    margin-right: 0 !important;
    position: relative !important;
    right: auto !important;
    top: auto !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    order: 1 !important;
    overflow: hidden !important;
}

.wc-category-modal-body ul.children li .category-image-link img,
.wc-category-modal-body ul li .category-image-link img,
.wc-category-modal-body ul.children li > a img,
.wc-category-modal-body ul li > a img {
    max-width: 60px !important;
    max-height: 60px !important;
    width: 60px !important;
    height: 60px !important;
    object-fit: contain !important;
    border-radius: 0 !important;
}

/* Hide any nested ul.children inside modal (they're shown in next modal) */
.wc-category-modal-body ul.children ul.children,
.wc-category-modal-body ul ul.children,
.wc-category-modal-body ul ul {
    display: none !important;
}

.wc-category-modal-body ul.children li .category-image-link img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.wc-category-modal-body ul.children li .count {
    display: none !important;
}

/* CRITICAL FIX: Hide standalone category-image-link anchors that appear as siblings */
.wc-category-modal-body ul.children > li > a.category-image-link,
.wc-category-modal-body ul > li > a.category-image-link {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    visibility: hidden !important;
}

/* ============================================
   Second Level Subcategories
   ============================================ */

.wc-category-modal-body ul.children li ul.children {
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
    display: block !important;
    background: #f9f9f9;
}

.wc-category-modal-body ul.children li ul.children li {
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}

.wc-category-modal-body ul.children li ul.children li > a {
    padding: 18px 25px 18px 50px;
    font-size: 15px;
}

.wc-category-modal-body ul.children li ul.children li .category-image-link {
    width: 50px !important;
    height: 50px !important;
    margin-right: 18px !important;
}

/* ============================================
   Third Level Categories (Deep Nesting)
   ============================================ */

.wc-category-modal-body ul.children li ul.children li ul.children {
    background: #f0f0f0;
}

.wc-category-modal-body ul.children li ul.children li ul.children li {
    background: #f0f0f0;
}

.wc-category-modal-body ul.children li ul.children li ul.children li > a {
    padding: 15px 20px 15px 70px;
    font-size: 14px;
    font-weight: normal;
}

.wc-category-modal-body ul.children li ul.children li ul.children li .category-image-link {
    width: 40px !important;
    height: 40px !important;
    margin-right: 15px !important;
}

/* ============================================
   Responsive Design - Tablets
   ============================================ */

@media screen and (max-width: 768px) {
    .widget_product_categories .product-categories li {
        padding: 15px 20px;
    }
    
    .widget_product_categories .product-categories li .category-image-link {
        width: 50px;
        height: 50px;
        margin-right: 15px;
    }
    
    .widget_product_categories .product-categories li > a {
        font-size: 14px;
    }
    
    .wc-category-modal-content {
        width: 90% !important;
        left: 5% !important;
        right: 5% !important;
    }
    
    .wc-category-modal-header {
        padding: 12px 15px;
    }
    
    .wc-category-modal-header h3 {
        font-size: 16px;
    }
    
    .wc-category-modal-body ul.children li > a {
        padding: 18px 20px;
        font-size: 15px;
    }
    
    .wc-category-modal-body ul.children li .category-image-link {
        width: 50px !important;
        height: 50px !important;
        margin-right: 18px !important;
    }
    
    .wc-category-modal-body ul.children li ul.children li > a {
        padding: 15px 20px 15px 45px;
        font-size: 14px;
    }
    
    .wc-category-modal-body ul.children li ul.children li .category-image-link {
        width: 45px !important;
        height: 45px !important;
    }
    
    .wc-category-modal-body ul.children li ul.children li ul.children li > a {
        padding: 12px 15px 12px 65px;
        font-size: 13px;
    }
}

/* ============================================
   Responsive Design - Mobile
   ============================================ */

@media screen and (max-width: 480px) {
    .widget_product_categories .product-categories li {
        padding: 12px 15px;
    }
    
    .widget_product_categories .product-categories li .category-image-link {
        width: 40px;
        height: 40px;
        margin-right: 12px;
    }
    
    .widget_product_categories .product-categories li > a {
        font-size: 13px;
    }
    
    .wc-category-modal-content {
        width: 95% !important;
        left: 2.5% !important;
        right: 2.5% !important;
    }
    
    .wc-category-modal-header h3 {
        font-size: 14px;
    }
    
    .wc-category-modal-body ul.children li > a {
        padding: 15px 18px;
        font-size: 14px;
    }
    
    .wc-category-modal-body ul.children li .category-image-link {
        width: 45px !important;
        height: 45px !important;
        margin-right: 15px !important;
    }
    
    .wc-category-modal-body ul.children li ul.children li > a {
        padding: 12px 18px 12px 40px;
        font-size: 13px;
    }
    
    .wc-category-modal-body ul.children li ul.children li .category-image-link {
        width: 40px !important;
        height: 40px !important;
    }
}
