/**
 * WCSF - WooCommerce Smart Filters
 * CSS Ottimizzato con Mobile Smart Design
 */

/* ===================================
   VARIABILI GLOBALI
   =================================== */
:root {
    --wcsf-primary: #ff9800;
    --wcsf-primary-dark: #e68900;
    --wcsf-secondary: #3b0f62;
    --wcsf-success: #27ae60;
    --wcsf-danger: #e74c3c;
    --wcsf-gray-100: #f8f9fa;
    --wcsf-gray-200: #e9ecef;
    --wcsf-gray-300: #dee2e6;
    --wcsf-gray-400: #ced4da;
    --wcsf-gray-500: #adb5bd;
    --wcsf-gray-600: #6c757d;
    --wcsf-gray-700: #495057;
    --wcsf-gray-800: #343a40;
    --wcsf-gray-900: #212529;
    --wcsf-border-radius: 16px;
    --wcsf-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================
   CONTENITORE PRINCIPALE
   =================================== */
.wcsf-filters-content {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ===================================
   SEZIONI FILTRI
   =================================== */
.wcsf-section {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--wcsf-gray-200);
    padding-bottom: 20px;
    background: white;
    overflow: hidden;
}

.wcsf-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Titolo sezione */
.wcsf-section-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--wcsf-gray-800);
    position: relative;
}

.wcsf-section-title i {
    margin-right: 8px;
    color: var(--wcsf-primary);
}

.wcsf-section-title::after {
    content: '\ea4e';
    font-family: 'remixicon';
    margin-left: auto;
    transition: transform 0.3s ease;
    transform: rotate(-90deg);
}

.wcsf-section:not(.collapsed) .wcsf-section-title::after {
    transform: rotate(0deg);
}

/* Contenuto sezione */
.wcsf-section .wcsf-section-content {
    display: none;
}

.wcsf-section:not(.collapsed) .wcsf-section-content {
    display: block;
}

/* ===================================
   FORM ELEMENTS
   =================================== */

/* Checkbox */
.wcsf-checkbox {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s ease;
}

.wcsf-checkbox:hover {
    color: var(--wcsf-primary);
}

.wcsf-checkbox input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--wcsf-primary);
}

.wcsf-checkbox span {
    flex: 1;
}

/* Search input */
.wcsf-search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--wcsf-gray-200);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.wcsf-search-input:focus {
    outline: none;
    border-color: var(--wcsf-primary);
}

/* Price range */
.wcsf-price-display {
    font-weight: 700;
    margin-bottom: 15px;
    text-align: center;
    font-size: 16px;
    color: var(--wcsf-primary);
}

.wcsf-price-inputs {
    position: relative;
    height: 40px;
}

.wcsf-price-range {
    position: absolute;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: transparent;
    outline: none;
    pointer-events: none;
}

.wcsf-price-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--wcsf-primary);
    cursor: pointer;
    border-radius: 50%;
    pointer-events: all;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ===================================
   UTILITIES
   =================================== */

/* Hint text */
.wcsf-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--wcsf-gray-600);
}

/* Show more/less */
.wcsf-show-more {
    display: inline-block;
    margin-top: 10px;
    color: var(--wcsf-primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}

.wcsf-show-more:hover {
    color: var(--wcsf-primary-dark);
}

.wcsf-options-list.has-more:not(.expanded) .wcsf-checkbox:nth-child(n+6) {
    display: none;
}

/* Reset button */
.wcsf-actions {
    margin-top: 20px;
    text-align: center;
}

.wcsf-reset {
    background: var(--wcsf-danger);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wcsf-reset:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.wcsf-reset i {
    margin-right: 8px;
}

/* Loading state */
#wcsf-products.loading {
    position: relative;
    min-height: 400px;
    opacity: 0.5;
    pointer-events: none;
}

#wcsf-products.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--wcsf-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Infinite scroll loader */
.infinite-scroll-loader {
    text-align: center;
    padding: 40px 20px;
    clear: both;
}

.spinner-border {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--wcsf-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Hide pagination */
.woocommerce-pagination {
    display: none;
}

/* ===================================
   DESKTOP STYLES
   =================================== */
@media (min-width: 769px) {
    /* Sticky sidebar */
    #wcsf-filters,
    .wcsf-filters-content {
        position: sticky;
        top: 20px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    /* Custom scrollbar */
    #wcsf-filters::-webkit-scrollbar {
        width: 6px;
    }
    
    #wcsf-filters::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }
    
    #wcsf-filters::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 3px;
    }
    
    .wcsf-section-title:hover {
        color: var(--wcsf-primary);
    }
}

/* ===================================
   MOBILE STYLES (< 768px)
   =================================== */

/* Mobile Toggle Button */
.wcsf-mobile-toggle {
    display: none;
}

@media (max-width: 768px) {
    .wcsf-mobile-toggle {
        display: flex !important;
        position: fixed;
        bottom: 90px;
        right: 20px;
        background: var(--wcsf-primary);
        color: white;
        border: none;
        border-radius: 30px;
        padding: 14px 24px;
        font-weight: 600;
        font-size: 15px;
        align-items: center;
        gap: 8px;
        box-shadow: 0 4px 20px rgba(255, 152, 0, 0.4);
        z-index: 997;
        transition: var(--wcsf-transition);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    .wcsf-mobile-toggle:active {
        transform: scale(0.95);
    }
    
    .wcsf-mobile-toggle i {
        font-size: 20px;
    }
    
    .filter-count {
        background: white;
        color: var(--wcsf-primary);
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 12px;
        font-weight: 700;
        min-width: 22px;
        text-align: center;
    }
}

/* Mobile Overlay */
.wcsf-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 998;
    transition: background-color 0.3s ease;
}

.wcsf-mobile-overlay.active {
    display: block;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Mobile Panel */
@media (max-width: 768px) {
    /* Hide desktop filters */
    aside .wcsf-filters-content,
    #wcsf-filters:not(.mobile-active) {
        display: none !important;
    }
    
    /* Mobile slide panel */
    .wcsf-filters-content.mobile-active,
    #wcsf-filters.mobile-active {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85%;
        max-width: 360px;
        background: white;
        z-index: 99999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        padding: 0;
        border-radius: 0;
    }
    
    .wcsf-filters-content.mobile-active.active,
    #wcsf-filters.mobile-active.active {
        transform: translateX(0);
    }
    
    /* Prevent body scroll */
    body.filters-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* Mobile Header */
.wcsf-mobile-header {
    display: none;
}

@media (max-width: 768px) {
    .wcsf-mobile-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 20px;
        background: var(--wcsf-primary);
        color: white;
        flex-shrink: 0;
    }
    
    .wcsf-mobile-header h3 {
        font-size: 20px;
        font-weight: 700;
        margin: 0;
        letter-spacing: -0.5px;
    }
    
    .wcsf-mobile-close {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.2);
        border: none;
        border-radius: 12px;
        color: white;
        font-size: 24px;
        cursor: pointer;
        transition: var(--wcsf-transition);
        -webkit-tap-highlight-color: transparent;
    }
    
    .wcsf-mobile-close:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0.9);
    }

    body > div.zampa-bottom-menu > div > div:nth-child(4) > a > span.zampa-menu-icon-wrap > span.cart-counter {
    display: none !important;
}
}

/* Mobile Content Wrapper */
@media (max-width: 768px) {
    .wcsf-section-wrapper {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 0;
        background: var(--wcsf-gray-100);
        scroll-behavior: smooth;
    }
    
    .wcsf-section-wrapper::-webkit-scrollbar {
        width: 0;
    }
}

/* Mobile Section Styles */
@media (max-width: 768px) {
    .wcsf-section {
        margin-bottom: 1px;
        padding: 0;
        border-bottom: none;
    }
    
    .wcsf-section:first-of-type {
        border-top: 1px solid var(--wcsf-gray-200);
    }
    
    /* Section title mobile */
    .wcsf-section-title {
        padding: 18px 20px;
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 0;
        background: white;
        text-transform: none;
        letter-spacing: normal;
    }
    
    .wcsf-section-title:active {
        background: var(--wcsf-gray-100);
    }
    
    .wcsf-section-title i {
        font-size: 20px;
    }
    
    .wcsf-section-title::after {
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%) rotate(-90deg);
        width: 24px;
        height: 24px;
        background: var(--wcsf-gray-100);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        content: '\ea50';
        font-size: 16px;
        color: var(--wcsf-gray-600);
    }
    
    .wcsf-section:not(.collapsed) .wcsf-section-title::after {
        transform: translateY(-50%) rotate(0deg);
        background: var(--wcsf-primary);
        color: white;
    }
    
    /* Section content mobile */
    .wcsf-section-content {
        padding: 0 20px 20px;
        background: white;
    }
    
    /* Form elements mobile */
    .wcsf-checkbox {
        padding: 14px 0;
        margin: 0 -8px;
        padding-left: 8px;
        padding-right: 8px;
        border-radius: 8px;
        -webkit-tap-highlight-color: transparent;
    }
    
    .wcsf-checkbox:active {
        background: var(--wcsf-gray-100);
    }
    
    .wcsf-checkbox input[type="checkbox"] {
        width: 24px;
        height: 24px;
        margin-right: 14px;
        flex-shrink: 0;
    }
    
    .wcsf-checkbox span {
        font-size: 15px;
        color: var(--wcsf-gray-700);
        line-height: 1.4;
    }
    
    .wcsf-search-input {
        padding: 14px 20px;
        font-size: 16px;
        border: 2px solid var(--wcsf-gray-200);
        border-radius: 14px;
        background: var(--wcsf-gray-100);
        -webkit-appearance: none;
    }
    
    .wcsf-search-input:focus {
        background: white;
    }
}

/* Mobile Footer */
.wcsf-mobile-footer {
    display: none;
}

@media (max-width: 768px) {
    .wcsf-mobile-footer {
        display: flex !important;
        gap: 12px;
        padding: 16px 20px;
        background: white;
        border-top: 1px solid var(--wcsf-gray-200);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
        flex-shrink: 0;
    }
    
    .wcsf-apply,
    .wcsf-reset {
        flex: 1;
        padding: 16px 20px;
        font-size: 14px;
        font-weight: 700;
        border-radius: 14px;
        border: none;
        cursor: pointer;
        transition: var(--wcsf-transition);
        -webkit-tap-highlight-color: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    
    .wcsf-apply {
        background: var(--wcsf-primary);
        color: white;
        flex: 2;
    }
    
    .wcsf-apply:active {
        background: var(--wcsf-primary-dark);
        transform: scale(0.97);
    }
    
    .wcsf-reset {
        background: var(--wcsf-gray-100);
        color: var(--wcsf-gray-700);
        flex: 1;
    }
    
    .wcsf-reset:active {
        background: var(--wcsf-gray-200);
        transform: scale(0.97);
    }
    
    .wcsf-active-count {
        background: white;
        color: var(--wcsf-primary);
        padding: 2px 8px;
        border-radius: 10px;
        font-size: 13px;
        margin-left: 4px;
    }
}

/* Toast Notifications */
.wcsf-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--wcsf-gray-900);
    color: white;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.wcsf-toast.show {
    transform: translateX(-50%) translateY(0);
}

.wcsf-toast.success {
    background: var(--wcsf-success);
}

.wcsf-toast.error {
    background: var(--wcsf-danger);
}

/* Responsive adjustments */
@media (max-width: 400px) {
    .wcsf-filters-content.mobile-active,
    #wcsf-filters.mobile-active {
        width: 90%;
    }
    
    .wcsf-mobile-header {
        padding: 16px;
    }
    
    .wcsf-section-title {
        padding: 16px;
        font-size: 15px;
    }
    
    .wcsf-section-content {
        padding: 0 16px 16px;
    }
}

/* Safe area for iPhone */
@media (max-width: 768px) {
    .wcsf-mobile-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    
    .wcsf-mobile-toggle {
        bottom: calc(90px + env(safe-area-inset-bottom));
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .wcsf-filters-content.mobile-active,
    #wcsf-filters.mobile-active,
    .wcsf-section,
    .wcsf-section-title,
    .wcsf-section-content,
    .wcsf-mobile-footer {
        background: var(--wcsf-gray-900);
        color: var(--wcsf-gray-100);
    }
    
    .wcsf-section-wrapper {
        background: #000;
    }
    
    .wcsf-search-input {
        background: var(--wcsf-gray-800);
        border-color: var(--wcsf-gray-700);
        color: white;
    }
}