/* ═══════════════════════════════════════════════════════════════
   WC AJAX FILTERS — Styles
   ═══════════════════════════════════════════════════════════════ */

:root {
    --wcaf-primary: #2563eb;
    --wcaf-primary-hover: #1d4ed8;
    --wcaf-text: #1e293b;
    --wcaf-text-light: #64748b;
    --wcaf-border: #e2e8f0;
    --wcaf-bg: #ffffff;
    --wcaf-bg-hover: #f8fafc;
    --wcaf-radius: 6px;
    --wcaf-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --wcaf-transition: 0.2s ease;
}

/* ─── WRAPPER ───────────────────────────────────────────────── */
.wcaf-filters-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--wcaf-text);
    line-height: 1.5;
}

.wcaf-vertical {
    max-width: 280px;
}

.wcaf-horizontal {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    max-width: 100%;
}

.wcaf-horizontal .wcaf-filter-group {
    flex: 1 1 200px;
    min-width: 180px;
}

/* ─── LOADING ───────────────────────────────────────────────── */
.wcaf-filters-loading {
    padding: 20px;
    text-align: center;
    color: var(--wcaf-text-light);
}

.wcaf-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--wcaf-border);
    border-top-color: var(--wcaf-primary);
    border-radius: 50%;
    animation: wcaf-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* ─── FILTER GROUP ──────────────────────────────────────────── */
.wcaf-filter-group {
    background: var(--wcaf-bg);
    border: 1px solid var(--wcaf-border);
    border-radius: var(--wcaf-radius);
    margin-bottom: 12px;
    box-shadow: var(--wcaf-shadow);
    overflow: hidden;
}

.wcaf-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background var(--wcaf-transition);
}

.wcaf-filter-header:hover {
    background: var(--wcaf-bg-hover);
}

.wcaf-filter-title {
    margin: 0;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--wcaf-text);
}

.wcaf-toggle-icon {
    font-size: 18px;
    font-weight: 300;
    color: var(--wcaf-text-light);
    line-height: 1;
}

.wcaf-filter-body {
    padding: 8px 16px 16px;
    border-top: 1px solid var(--wcaf-border);
}

/* ─── LINK LIST (Categories — redirect) ─────────────────────── */
.wcaf-link-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wcaf-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--wcaf-transition), color var(--wcaf-transition);
    text-decoration: none;
    color: var(--wcaf-text);
}

.wcaf-link-item:hover {
    background: var(--wcaf-bg-hover);
    color: var(--wcaf-primary);
}

.wcaf-link-item::before {
    content: '';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--wcaf-border);
    border-radius: 4px;
    background: var(--wcaf-bg);
    transition: all var(--wcaf-transition);
    font-size: 12px;
    line-height: 1;
}

.wcaf-link-item:hover::before {
    border-color: var(--wcaf-primary);
    background: var(--wcaf-primary);
    content: '→';
    color: #fff;
}

.wcaf-link-name {
    font-size: 13px;
}

/* ─── CHECKBOX LIST ─────────────────────────────────────────── */
.wcaf-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wcaf-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--wcaf-transition);
    margin: 0;
}

.wcaf-checkbox-item:hover {
    background: var(--wcaf-bg-hover);
}

.wcaf-checkbox-item input[type="checkbox"] {
    display: none;
}

.wcaf-checkmark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--wcaf-border);
    border-radius: 4px;
    transition: all var(--wcaf-transition);
    background: var(--wcaf-bg);
}

.wcaf-checkbox-item input:checked + .wcaf-checkmark {
    background: var(--wcaf-primary);
    border-color: var(--wcaf-primary);
}

.wcaf-checkbox-item input:checked + .wcaf-checkmark::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.wcaf-item-name {
    font-size: 13px;
    color: var(--wcaf-text);
}

.wcaf-item-count {
    font-size: 11px;
    color: var(--wcaf-text-light);
    margin-left: auto;
}

.wcaf-hidden-item {
    display: none;
}

.wcaf-show-more {
    display: inline-block;
    margin-top: 8px;
    padding: 0;
    background: none;
    border: none;
    color: var(--wcaf-primary);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
}

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

/* ─── COLOR SWATCHES ────────────────────────────────────────── */
.wcaf-color-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wcaf-color-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--wcaf-radius);
    transition: all var(--wcaf-transition);
    min-width: 48px;
}

.wcaf-color-item:hover {
    background: var(--wcaf-bg-hover);
}

.wcaf-color-swatch {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all var(--wcaf-transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.wcaf-color-item.wcaf-color-active .wcaf-color-swatch {
    box-shadow: 0 0 0 3px var(--wcaf-primary) !important;
    transform: scale(1.1);
}

.wcaf-color-name {
    font-size: 10px;
    color: var(--wcaf-text-light);
    text-align: center;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── ACTIVE FILTERS ────────────────────────────────────────── */
.wcaf-active-filters {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f0f4ff;
    border: 1px solid #c7d6fe;
    border-radius: var(--wcaf-radius);
}

.wcaf-active-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.wcaf-active-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--wcaf-primary);
}

.wcaf-reset-all {
    background: none;
    border: none;
    color: var(--wcaf-primary);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.wcaf-reset-all:hover {
    color: var(--wcaf-primary-hover);
}

.wcaf-active-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.wcaf-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--wcaf-bg);
    border: 1px solid var(--wcaf-border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--wcaf-text);
}

.wcaf-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    background: none;
    border: none;
    color: var(--wcaf-text-light);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: all var(--wcaf-transition);
}

.wcaf-tag-remove:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* ─── RESULTS ───────────────────────────────────────────────── */
.wcaf-results-count {
    font-size: 13px;
    color: var(--wcaf-text-light);
    margin-bottom: 12px;
}

.wcaf-no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--wcaf-text-light);
}

.wcaf-no-results p {
    margin-bottom: 16px;
    font-size: 15px;
}

.wcaf-no-results .button,
.wcaf-no-results .wcaf-reset-all {
    display: inline-block;
    padding: 8px 20px;
    background: var(--wcaf-primary);
    color: #fff;
    border: none;
    border-radius: var(--wcaf-radius);
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
}

.wcaf-no-results .button:hover {
    background: var(--wcaf-primary-hover);
}

/* ─── PAGINATION ────────────────────────────────────────────── */
.wcaf-pagination {
    margin-top: 24px;
    text-align: center;
}

.wcaf-pagination ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 4px;
}

.wcaf-pagination li {
    display: inline;
}

.wcaf-pagination a,
.wcaf-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--wcaf-border);
    border-radius: var(--wcaf-radius);
    font-size: 13px;
    color: var(--wcaf-text);
    text-decoration: none;
    transition: all var(--wcaf-transition);
}

.wcaf-pagination a:hover {
    background: var(--wcaf-primary);
    color: #fff;
    border-color: var(--wcaf-primary);
}

.wcaf-pagination .current {
    background: var(--wcaf-primary);
    color: #fff;
    border-color: var(--wcaf-primary);
}

/* ─── ERROR ─────────────────────────────────────────────────── */
.wcaf-error {
    color: #dc2626;
    font-size: 13px;
}

/* ─── MOBILE TOOLBAR (hidden on desktop) ───────────────────── */
.wcaf-mobile-toolbar {
    display: none;
}

/* ─── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .wcaf-vertical {
        max-width: 100%;
    }

    .wcaf-horizontal {
        flex-direction: column;
    }

    .wcaf-horizontal .wcaf-filter-group {
        flex-basis: 100%;
    }

    .wcaf-color-swatch {
        width: 28px;
        height: 28px;
    }

    /* ── Mobile toolbar: two buttons ── */
    .wcaf-mobile-toolbar {
        display: flex;
        gap: 10px;
        margin-bottom: 16px;
    }

    .wcaf-mobile-btn {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 12px 16px;
        border: 1px solid var(--wcaf-border);
        border-radius: var(--wcaf-radius);
        background: var(--wcaf-bg);
        color: var(--wcaf-text);
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: all var(--wcaf-transition);
        box-shadow: var(--wcaf-shadow);
    }

    .wcaf-mobile-btn:active {
        transform: scale(0.97);
    }

    .wcaf-mobile-btn-filter {
        background: var(--wcaf-primary);
        color: #fff;
        border-color: var(--wcaf-primary);
    }

    .wcaf-mobile-btn-filter:hover {
        background: var(--wcaf-primary-hover);
    }

    .wcaf-mobile-btn-reset {
        background: var(--wcaf-bg);
        color: var(--wcaf-text-light);
        border-color: var(--wcaf-border);
    }

    .wcaf-mobile-btn-reset:hover {
        color: #dc2626;
        border-color: #dc2626;
    }

    .wcaf-mobile-btn-icon {
        font-size: 16px;
        line-height: 1;
    }

    /* Badge contatore filtri attivi */
    .wcaf-mobile-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        border-radius: 10px;
        background: rgba(255,255,255,0.25);
        font-size: 11px;
        font-weight: 700;
        line-height: 1;
    }

    .wcaf-mobile-badge:empty {
        display: none;
    }

    /* ── Hide filters by default, slide from bottom ── */
    .wcaf-filters-inner,
    .wcaf-active-filters {
        display: none;
    }

    .wcaf-filters-wrapper.wcaf-mobile-open .wcaf-filters-inner {
        display: block;
        animation: wcaf-slide-up 0.3s ease;
    }

    .wcaf-filters-wrapper.wcaf-mobile-open .wcaf-active-filters {
        display: block;
    }

    /* ── Overlay panel ── */
    .wcaf-mobile-panel {
        display: none;
    }

    .wcaf-filters-wrapper.wcaf-mobile-open .wcaf-mobile-panel {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9998;
        background: rgba(0, 0, 0, 0.45);
        animation: wcaf-fade-in 0.2s ease;
    }

    .wcaf-filters-wrapper.wcaf-mobile-open .wcaf-filters-inner {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: var(--wcaf-bg);
        max-height: 75vh;
        overflow-y: auto;
        padding: 0 16px 24px;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    }

    /* ── Drawer header (drag handle + close) ── */
    .wcaf-mobile-drawer-header {
        display: none;
    }

    .wcaf-filters-wrapper.wcaf-mobile-open .wcaf-mobile-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 0;
        background: var(--wcaf-bg);
        padding: 12px 0 8px;
        z-index: 1;
        border-bottom: 1px solid var(--wcaf-border);
        margin-bottom: 12px;
    }

    .wcaf-drawer-handle {
        width: 40px;
        height: 4px;
        background: var(--wcaf-border);
        border-radius: 2px;
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
    }

    .wcaf-drawer-title {
        font-size: 15px;
        font-weight: 700;
        color: var(--wcaf-text);
        margin: 0;
        padding-top: 4px;
    }

    .wcaf-drawer-close {
        background: none;
        border: none;
        font-size: 24px;
        color: var(--wcaf-text-light);
        cursor: pointer;
        padding: 4px 8px;
        line-height: 1;
        border-radius: 4px;
    }

    .wcaf-drawer-close:hover {
        color: var(--wcaf-text);
        background: var(--wcaf-bg-hover);
    }

    @keyframes wcaf-slide-up {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }

    @keyframes wcaf-fade-in {
        from { opacity: 0; }
        to   { opacity: 1; }
    }
}
