/* Product Attribute Filter Styles - Enhanced Version */

.product-attribute-filter {
    background: #fff;
    padding: 22px 20px;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
    margin-bottom: 30px;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    padding-bottom: 18px;
    border-bottom: 1px solid #c2c2c2;
}

.filter-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #2f2f2f;
    text-transform: none;
}

/* Ensure Elementor typography doesn't override filter titles */
.elementor-widget-container .product-attribute-filter .filter-header h3 {
    font-size: 15px !important;
    font-weight: 600 !important;
    text-transform: none !important;
}

.clear-filters {
    background-color: var(--e-global-color-545aebd) !important;
    border-style: solid !important;
    border-width: 1px 1px 1px 1px !important;
    border-color: var(--e-global-color-primary) !important;
    border-radius: 8px 8px 8px 8px !important;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 15px !important;
    text-decoration: none !important;
    transition: all 0.3s ease;
}

.elementor-kit-14 .product-attribute-filter .clear-filters {
    background-color: var(--e-global-color-545aebd) !important;
    border-style: solid !important;
    border-width: 1px 1px 1px 1px !important;
    border-color: var(--e-global-color-primary) !important;
    border-radius: 8px 8px 8px 8px !important;
    padding: 6px 14px !important;
    font-size: 15px !important;
    text-decoration: none !important;
}

.clear-filters:hover {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}

.filter-group {
    margin: 0 -20px 0;
    padding: 6px 20px 10px;
    border-bottom: 1px solid #c9c9c9;
    transition: opacity 0.3s ease, max-height 0.3s ease, transform 0.3s ease;
    transform-origin: top;
    overflow: hidden;
}

.filter-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Animation for hiding entire filter groups */
.filter-group[style*="display: none"] {
    animation: fadeOutGroup 0.2s ease-out;
}

@keyframes fadeOutGroup {
    0% {
        opacity: 1;
        transform: scaleY(1);
    }
    100% {
        opacity: 0;
        transform: scaleY(0);
    }
}

.filter-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 -20px 10px;
    padding: 12px 20px;
    color: #4a4a4a;
    text-transform: none;
    letter-spacing: 0.03em;
    background: transparent;
}

.elementor-widget-container .product-attribute-filter .filter-title {
    font-size: 15px !important;
    font-weight: 600 !important;
    text-transform: none !important;
    margin: 0 -20px 10px !important;
    padding: 12px 20px !important;
    background: transparent !important;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}


.filter-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 4px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
}

/* Enhanced animation for individual filter options */
.filter-option[style*="display: none"] {
    animation: slideOut 0.2s ease-out;
}

@keyframes slideOut {
    0% {
        opacity: 1;
        transform: translateX(0);
        max-height: 40px;
    }
    50% {
        opacity: 0.5;
        transform: translateX(-10px);
    }
    100% {
        opacity: 0;
        transform: translateX(-20px);
        max-height: 0;
    }
}

/* Disabled state for unavailable options (alternative approach) */
.filter-option.unavailable {
    opacity: 0.3;
    pointer-events: none;
}

.filter-option.unavailable input[type="checkbox"] {
    cursor: not-allowed;
}

.filter-option.unavailable span {
    text-decoration: line-through;
    color: #999;
}

.filter-option:hover:not(.unavailable) {
    color: #2f2f2f;
    background: #f7f7f7;
}

.filter-option input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    margin: 0 10px 0 0;
    cursor: pointer;
    width: 18px;
    height: 18px;
    border: 2px solid #d4d4d4;
    border-radius: 999px;
    background: #fafafa;
    box-shadow: inset 0 0 0 0 #5a5a5a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.filter-option span {
    font-size: 12px;
    line-height: 1.45;
    color: #5b5b5b;
    text-transform: none;
}

.filter-option input[type="checkbox"]:checked {
    border-color: #5a5a5a;
    background: #fff;
    box-shadow: inset 0 0 0 5px #5a5a5a;
}

.filter-option input[type="checkbox"]:focus-visible {
    outline: 2px solid rgba(34, 113, 177, 0.35);
    outline-offset: 2px;
}

/* Loading indicator */
.filter-loading {
    text-align: center;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
    margin-top: 15px;
    font-style: italic;
    color: #666;
    position: relative;
}

.filter-loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* No products message */
.no-products-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.no-products-message p {
    margin: 0;
    color: #856404;
    font-size: 15px;
}

/* Filter counter badge (optional enhancement) */
.filter-title .filter-count {
    display: inline-block;
    background: #2271b1;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    margin-left: 8px;
    min-width: 18px;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .product-attribute-filter {
        padding: 14px;
    }
    
    .filter-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 0;
        padding-bottom: 14px;
    }

    .filter-group {
        margin: 0;
        padding: 0;
        border-bottom: 1px solid #d6d6d6;
    }

    .filter-title {
        margin: 0;
        padding: 14px 0;
        background: transparent;
    }

    .filter-group .filter-title {
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .filter-group .filter-title::after {
        content: '-';
        font-size: 12px;
        color: #7a7a7a;
    }

    .filter-group.is-collapsed .filter-title::after {
        content: '+';
    }

    .filter-group.is-collapsed .filter-options {
        display: none;
    }

    .filter-options {
        padding: 0 0 12px 0;
    }

    .clear-filters {
        width: 100%;
    }
    
    .filter-option {
        padding: 4px 4px;
    }

    .filter-option span {
        font-size: 12px;
        line-height: 1.45;
    }

    .elementor-widget-container .product-attribute-filter .filter-title {
        margin: 0 !important;
        padding: 14px 0 !important;
        background: transparent !important;
    }

}

/* Sidebar Widget Styles */
.widget .product-attribute-filter {
    border: none;
    padding: 0;
}

.widget .filter-header {
    margin: 0 0 0;
    padding-bottom: 16px;
}

.widget .filter-group {
    margin: 0 0 0;
    padding: 6px 0 10px;
}

.widget .filter-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.widget .filter-title {
    margin: 0 0 10px;
    padding: 12px 12px;
}

/* Keep option text sizing consistent under Elementor on mobile */
@media (max-width: 768px) {
    .elementor-widget-container .product-attribute-filter .filter-option span {
        font-size: 12px !important;
        line-height: 1.45 !important;
    }
}

/* Elementor Widget Compatibility */
.elementor-widget-container .product-attribute-filter {
    margin-bottom: 20px;
}

/* Hide pagination when filters are active */
body.filters-active .woocommerce-pagination,
body.filters-active .elementor-pagination,
body.filters-active nav.navigation {
    display: none !important;
}

/* Helper text for variation attributes */
.filter-group .variation-note {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin-top: 5px;
    padding: 8px 10px;
    background: #f9f9f9;
    border-radius: 3px;
    border-left: 3px solid #2271b1;
}

/* Animation for filtered products */
.products .product,
ul.products > li,
.elementor-loop-container > .elementor-element,
.elementor-loop-container > article,
.elementor-posts-container > .elementor-post,
.e-loop-item {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.products .product[style*="display: none"],
ul.products > li[style*="display: none"],
.elementor-loop-container > .elementor-element[style*="display: none"],
.elementor-loop-container > article[style*="display: none"],
.elementor-posts-container > .elementor-post[style*="display: none"],
.e-loop-item[style*="display: none"] {
    opacity: 0;
    transform: scale(0.95);
}

/* Enhanced visual feedback for active filters */
.filter-option input[type="checkbox"]:checked + span {
    font-weight: 600;
    color: #2f2f2f;
}

/* Visual indicator for filters with active selections */
.filter-group.has-active-filters .filter-title {
    color: #2f2f2f;
    font-weight: 600;
}

.filter-group.has-active-filters .filter-title::after {
    content: ' *';
    color: #9b9b9b;
    font-size: 16px;
}

/* Smooth transitions for all filter states */
* {
    transition-property: opacity, transform, max-height;
    transition-duration: 0.2s;
    transition-timing-function: ease-out;
}

/* Tooltip for disabled filters (optional) */
.filter-option.unavailable::after {
    content: 'No products with this option';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-left: 10px;
}

.filter-option.unavailable:hover::after {
    opacity: 1;
}
