/* Product Filter Styles */

.product-filter-wrapper {
    display: flex;
    gap: 30px;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Sidebar Filter */
.product-filter-sidebar {
    width: 280px;
    flex-shrink: 0;
}

/* Sidebar Only Layout (for Elementor) */
.product-filter-sidebar-only {
    width: 100%;
    max-width: 280px;
}

/* Prevent flash of mobile menu on page load */
@media (max-width: 768px) {
    .product-filter-sidebar-only:not(.mobile-menu-initialized) {
        opacity: 0;
        pointer-events: none;
    }
    
    .product-filter-sidebar-only.mobile-menu-initialized {
        opacity: 1;
        transition: opacity 0.3s ease;
    }
}

.filter-section {
    background: #f7f7f7;
    padding: 25px 20px;
    margin-bottom: 30px;
    border-radius: 10px;
    clear: both;
    overflow: visible;
    display: block;
    position: relative;
}

/* Categories section must contain all categories */
.filter-section.categories-section {
    margin-bottom: 35px;
    display: block;
    width: 100%;
}

.filter-section.categories-section .category-list {
    position: static;
    display: block;
    width: 100%;
    height: auto;
}

.filter-section.price-section {
    margin-top: 10px;
    position: relative;
    z-index: 1;
    clear: both;
    display: block;
    width: 100%;
}

.filter-title {
    font-size: 20px;
    font-weight: 600;
    color: #2c2c2c;
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

/* Category List */
.category-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: block;
    width: 100%;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #e8e8e8;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.category-item:last-child {
    border-bottom: none;
}

.category-item:hover {
    padding-left: 5px;
}

.category-item.active {
    padding-left: 5px;
}

.category-item.active .category-name {
    color: #2c2c2c;
    font-weight: 600;
}

.category-name {
    font-size: 16px;
    color: #666;
    transition: color 0.2s;
}

.category-item:hover .category-name {
    color: #2c2c2c;
}

.category-count {
    background: #e0e0e0;
    color: #666;
    font-size: 13px;
    padding: 2px 10px;
    border-radius: 12px;
    min-width: 30px;
    text-align: center;
}

.category-item.active .category-count {
    background: #2c2c2c;
    color: #fff;
}

/* Price Slider Section */
.price-slider-wrapper {
    padding-top: 10px;
}

.price-slider {
    margin: 20px 0 25px;
}

.ui-slider {
    position: relative;
    text-align: left;
    height: 6px;
    background: #e0e0e0;
    border: none;
    border-radius: 3px;
}

.ui-slider .ui-slider-range {
    position: absolute;
    z-index: 1;
    height: 100%;
    display: block;
    background: #2c2c2c;
    border-radius: 3px;
}

.ui-slider .ui-slider-handle {
    position: absolute;
    z-index: 2;
    width: 18px;
    height: 18px;
    background: #2c2c2c;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    top: 50%;
    transform: translateY(-50%);
    outline: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.ui-slider .ui-slider-handle:hover,
.ui-slider .ui-slider-handle:focus {
    background: #1a1a1a;
}

/* Mobile touch-friendly slider */
@media (max-width: 768px) {
    .ui-slider .ui-slider-handle {
        width: 24px;
        height: 24px;
        border: 3px solid #fff;
    }
    
    .ui-slider {
        height: 6px;
        margin: 20px 0;
    }
    
    .price-slider {
        margin: 20px 0 25px;
        padding: 5px 0;
    }
    
    /* Compact filter title for mobile */
    .product-filter-sidebar-only.mobile-menu .filter-title {
        font-size: 14px;
        margin: 0 0 10px 0;
        padding-bottom: 10px;
    }
    
    /* Compact category items for mobile */
    .product-filter-sidebar-only.mobile-menu .category-item {
        padding: 8px 0;
    }
    
    .product-filter-sidebar-only.mobile-menu .category-name {
        font-size: 13px;
    }
    
    .product-filter-sidebar-only.mobile-menu .category-count {
        font-size: 11px;
        padding: 2px 8px;
        min-width: 24px;
    }
    
    /* Compact price display for mobile */
    .product-filter-sidebar-only.mobile-menu .price-range-display {
        font-size: 13px;
        margin-bottom: 12px;
        padding-right: 5px;
    }
    
    /* Ensure price slider doesn't get cropped */
    .product-filter-sidebar-only.mobile-menu .ui-slider {
        margin-right: 5px;
    }
}

.price-range-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 16px;
    color: #2c2c2c;
}

.price-label {
    font-weight: 500;
}

.price-separator {
    color: #999;
}

.apply-filter-btn {
    width: 100%;
    padding: 12px;
    background: #2c2c2c;
    color: #fff;
    border: none;
    border-radius: 2px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.apply-filter-btn:hover {
    background: #1a1a1a;
}

.apply-filter-btn:active {
    transform: scale(0.98);
}

/* Products Content Area */
.product-filter-content {
    flex: 1;
    min-width: 0;
}

/* Loading Indicator */
.filter-loading {
    text-align: center;
    padding: 40px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.filter-loading .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.filter-loading p {
    margin: 10px 0 0 0;
    color: #666;
    font-size: 14px;
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-top: 0;
}

.products-grid[data-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.products-grid[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.products-grid[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.product-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.product-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-4px);
}

.product-link {
    text-decoration: none;
    color: inherit;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-image {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    overflow: hidden;
    background: #f5f5f5;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-item:hover .product-image img {
    transform: scale(1.05);
}

.product-info {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: #0073aa;
    margin-top: auto;
}

.product-price del {
    color: #999;
    font-weight: 400;
    font-size: 14px;
    margin-right: 8px;
}

.product-price ins {
    text-decoration: none;
    color: #d63638;
}

.product-actions {
    padding: 0 15px 15px 15px;
}

.product-actions .button {
    width: 100%;
    padding: 10px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
    text-align: center;
}

.product-actions .button:hover {
    background: #005a87;
}

.product-actions .added_to_cart {
    display: block;
    margin-top: 8px;
    text-align: center;
    color: #0073aa;
    text-decoration: none;
    font-size: 13px;
}

/* No Products Found */
.no-products-found {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    grid-column: 1 / -1;
}

.no-products-found p {
    margin: 0;
    font-size: 16px;
    color: #666;
}

/* Mobile Select Dropdown */
.category-mobile-select {
    display: none;
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    color: #2c2c2c;
    background: white;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
    cursor: pointer;
}

.category-mobile-select:focus {
    outline: none;
    border-color: #2c2c2c;
    box-shadow: 0 0 0 2px rgba(44, 44, 44, 0.1);
}

/* Mobile Filter Button */
.mobile-filter-toggle {
    display: none;
    width: 100%;
    padding: 12px 20px;
    background: white;
    color: #2c2c2c;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s;
    margin-bottom: 20px;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Hide filter button and mobile menu on single product pages */
.single-product .mobile-filter-toggle,
.single-product .product-filter-sidebar-only.mobile-menu,
.single-product .mobile-filter-overlay {
    display: none !important;
    visibility: hidden !important;
}

.mobile-filter-toggle svg {
    vertical-align: middle;
    margin-right: 5px;
}

.mobile-filter-toggle:active {
    transform: scale(0.98);
}

.mobile-filter-toggle:hover {
    border-color: #2c2c2c;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Mobile Side Menu Overlay */
.mobile-filter-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-filter-overlay.active {
    opacity: 1;
}

/* Mobile Side Menu */
.product-filter-sidebar-only.mobile-menu {
    position: fixed !important;
    top: 0 !important;
    left: -100% !important;
    width: 75% !important;
    max-width: 320px !important;
    height: 100vh !important;
    max-height: 100vh !important;
    background: white !important;
    z-index: 9999 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    transition: left 0.3s ease-out !important;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2) !important;
    padding: 0 !important;
    -webkit-overflow-scrolling: touch !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transition: left 0.3s ease-out, opacity 0.3s ease-out, visibility 0.3s ease-out !important;
    display: flex !important;
    flex-direction: column !important;
}

.product-filter-sidebar-only.mobile-menu .filter-section {
    margin: 0 12px 12px 12px;
    padding: 12px 18px 12px 14px;
    background: #f9f9f9;
    border-radius: 8px;
    display: block;
    position: relative;
    width: calc(100% - 24px);
    box-sizing: border-box;
    flex-shrink: 0;
}

.product-filter-sidebar-only.mobile-menu .filter-section.categories-section {
    margin-bottom: 12px;
    padding-right: 30px;
}

.product-filter-sidebar-only.mobile-menu .filter-section.price-section {
    margin-top: 0;
    clear: both;
    padding-bottom: 15px;
    padding-right: 20px;
    margin-bottom: 30px;
}

.product-filter-sidebar-only.mobile-menu .price-slider-wrapper {
    width: 100%;
    box-sizing: border-box;
    padding-bottom: 10px;
    padding-right: 5px;
}

/* Add safe area padding for devices with notches */
.product-filter-sidebar-only.mobile-menu {
    padding-bottom: env(safe-area-inset-bottom, 20px) !important;
}

.product-filter-sidebar-only.mobile-menu .filter-section:first-of-type {
    margin-top: 0;
}

.product-filter-sidebar-only.mobile-menu .filter-section:last-of-type {
    margin-bottom: 30px;
    padding-bottom: 15px;
}

.product-filter-sidebar-only.mobile-menu .category-list {
    display: block;
    width: 100%;
    position: static;
}

.product-filter-sidebar-only.mobile-menu .category-item {
    position: static;
    width: 100%;
}

.product-filter-sidebar-only.mobile-menu.active,
.product-filter-sidebar-only.active {
    left: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force overlay to show */
.mobile-filter-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0,0,0,0.5) !important;
    z-index: 9998 !important;
    opacity: 0 !important;
    transition: opacity 0.3s !important;
    pointer-events: none !important;
}

.mobile-filter-overlay.active {
    opacity: 1 !important;
    pointer-events: all !important;
}

/* Mobile Menu Header */
.mobile-filter-header {
    display: none;
    padding: 14px 16px;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 12px;
    background: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

.mobile-filter-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c2c2c;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-filter-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}



/* Responsive Design */
@media (max-width: 1024px) {
    .product-filter-wrapper {
        flex-direction: column;
    }
    
    .product-filter-sidebar,
    .product-filter-sidebar-only {
        width: 100%;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .mobile-filter-toggle {
        display: block;
    }
    
    .mobile-filter-overlay {
        display: block;
    }
    
    .mobile-filter-header {
        display: block;
    }
    
    .product-filter-sidebar,
    .product-filter-sidebar-only {
        width: 100%;
    }
    
    .filter-section {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .category-list {
        max-height: none !important;
        overflow-y: visible !important;
    }
    
    /* Ensure proper spacing between filter sections on mobile */
    .product-filter-sidebar-only .filter-section.categories-section {
        margin-bottom: 30px;
        display: block;
        width: 100%;
    }
    
    .product-filter-sidebar-only .filter-section.price-section {
        margin-top: 30px;
        clear: both;
        display: block;
        width: 100%;
    }
    
    .product-filter-sidebar-only .category-list {
        display: block;
        width: 100%;
        position: static;
    }
    
    .product-filter-sidebar-only .category-item {
        position: static;
        width: 100%;
        box-sizing: border-box;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .product-title {
        font-size: 14px;
    }
    
    .product-price {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-filter-wrapper {
        gap: 15px;
    }
    
    .category-list {
        max-height: none !important;
        overflow-y: visible !important;
    }
    
    .mobile-filter-sidebar-only.mobile-menu {
        width: 90% !important;
    }
}
