/* ==========================================================================
   WC Smart Filters — Frontend Styles
   All colours are CSS variables — override in Settings → עיצוב or Custom CSS.
   ========================================================================== */

/* ── Variables (defaults — overridden via wp_head inline style) ──────────── */
:root {
    --wcf-primary:         #1a1a1a;
    --wcf-accent:          #2271b1;
    --wcf-bg:              #ffffff;
    --wcf-text:            #444444;
    --wcf-muted:           #999999;
    --wcf-border:          #dde1e7;
    --wcf-heading-color:   #1a1a1a;
    --wcf-radius:          4px;
    --wcf-font-size:       14px;
    --wcf-section-spacing: 24px;
    --wcf-swatch-size:     26px;
    --wcf-btn-bg:          #2271b1;
    --wcf-btn-color:       #ffffff;
    --wcf-btn-radius:      4px;
    --wcf-active-bg:       #eef4fb;
    --wcf-active-border:   #2271b1;
    --wcf-chip-bg:         #e8f0fb;
    --wcf-chip-color:      #2271b1;
}

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.wcf-filters {
    position: relative;
    font-size: var(--wcf-font-size);
    color: var(--wcf-text);
    background: var(--wcf-bg);
}

/* ── Active chips row ────────────────────────────────────────────────────── */
.wcf-active-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    align-items: center;
}

.wcf-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--wcf-chip-bg);
    color: var(--wcf-chip-color);
    border-radius: 20px;
    font-size: calc(var(--wcf-font-size) - 1px);
    line-height: 1.4;
}

.wcf-chip-remove {
    color: inherit;
    text-decoration: none;
    font-size: 11px;
    opacity: .7;
    line-height: 1;
}
.wcf-chip-remove:hover { opacity: 1; }

.wcf-clear-all {
    font-size: calc(var(--wcf-font-size) - 1px);
    color: var(--wcf-muted);
    text-decoration: underline;
    margin-inline-start: 4px;
}
.wcf-clear-all:hover { color: var(--wcf-accent); }

/* ── Section ─────────────────────────────────────────────────────────────── */
.wcf-section {
    border-bottom: 1px solid var(--wcf-border);
    padding-bottom: var(--wcf-section-spacing);
    margin-bottom: var(--wcf-section-spacing);
}
.wcf-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

/* ── Section heading ─────────────────────────────────────────────────────── */
.wcf-section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0;
    margin: 0 0 12px;
    background: none;
    border: none;
    cursor: default;
    font-size: var(--wcf-font-size);
    font-weight: 600;
    color: var(--wcf-heading-color);
    text-align: start;
    line-height: 1.4;
}

button.wcf-section-heading {
    cursor: pointer;
}
button.wcf-section-heading:focus-visible {
    outline: 2px solid var(--wcf-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Chevron icon */
.wcf-chevron {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .2s ease;
    flex-shrink: 0;
}
.wcf-toggle.is-closed .wcf-chevron {
    transform: rotate(-45deg);
}

/* ── Section body collapse ───────────────────────────────────────────────── */
.wcf-section-body {
    overflow: hidden;
    transition: max-height .25s ease, opacity .2s ease;
    max-height: 2000px;
    opacity: 1;
}
.wcf-section-body.is-collapsed {
    max-height: 0 !important;
    opacity: 0;
}

/* ── Checkbox list ───────────────────────────────────────────────────────── */
.wcf-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wcf-list--scroll {
    max-height: calc(var(--wcf-font-size) * 2.6 * var(--wcf-items-scroll, 8));
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--wcf-border) transparent;
}
.wcf-list--scroll::-webkit-scrollbar        { width: 4px; }
.wcf-list--scroll::-webkit-scrollbar-thumb  { background: var(--wcf-border); border-radius: 4px; }

.wcf-list li { margin: 0; padding: 0; }

.wcf-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: var(--wcf-radius);
    cursor: pointer;
    transition: background .15s;
    line-height: 1.4;
}
.wcf-item:hover      { background: var(--wcf-active-bg); }
.wcf-item.is-active  { background: var(--wcf-active-bg); font-weight: 500; }

/* Custom checkbox */
.wcf-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--wcf-border);
    border-radius: calc(var(--wcf-radius) * 0.5);
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
    background: var(--wcf-bg);
    transition: background .15s, border-color .15s;
}
.wcf-item input[type="checkbox"]:checked {
    background: var(--wcf-accent);
    border-color: var(--wcf-accent);
}
.wcf-item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 4px;
    width: 4px;
    height: 8px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}
.wcf-item input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--wcf-accent);
    outline-offset: 1px;
}

.wcf-item-name { flex: 1; }
.wcf-count { color: var(--wcf-muted); font-size: .85em; }

/* ── Price slider ────────────────────────────────────────────────────────── */
.wcf-price-wrap { padding: 4px 0 8px; }

.wcf-price-track {
    position: relative;
    height: 4px;
    background: var(--wcf-border);
    border-radius: 4px;
    margin: 16px 8px;
}

.wcf-price-fill {
    position: absolute;
    height: 100%;
    background: var(--wcf-accent);
    border-radius: 4px;
    pointer-events: none;
}

.wcf-range {
    position: absolute;
    top: -7px;
    width: 100%;
    height: 18px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    pointer-events: none;
    margin: 0;
    padding: 0;
}
.wcf-range::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--wcf-accent);
    border: 2px solid var(--wcf-bg);
    box-shadow: 0 0 0 1px var(--wcf-accent);
    cursor: pointer;
    pointer-events: all;
    transition: transform .15s;
}
.wcf-range::-webkit-slider-thumb:hover  { transform: scale(1.15); }
.wcf-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--wcf-accent);
    border: 2px solid var(--wcf-bg);
    box-shadow: 0 0 0 1px var(--wcf-accent);
    cursor: pointer;
    pointer-events: all;
}
.wcf-range:focus-visible::-webkit-slider-thumb {
    outline: 2px solid var(--wcf-accent);
    outline-offset: 2px;
}

.wcf-price-labels {
    display: flex;
    justify-content: space-between;
    font-size: .875em;
    color: var(--wcf-text);
    margin-top: 6px;
}

/* ── Color swatches ──────────────────────────────────────────────────────── */
.wcf-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wcf-swatch-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.wcf-swatch-wrap input[type="checkbox"] { display: none; }

.wcf-swatch {
    display: block;
    width: var(--wcf-swatch-size);
    height: var(--wcf-swatch-size);
    border-radius: 50%;
    border: 2px solid var(--wcf-border);
    transition: transform .15s, border-color .15s;
}
.wcf-swatch-wrap:hover .wcf-swatch {
    transform: scale(1.12);
    border-color: var(--wcf-accent);
}
.wcf-swatch-wrap.is-active .wcf-swatch {
    border-color: var(--wcf-active-border);
    box-shadow: 0 0 0 2px var(--wcf-active-border);
}

.wcf-swatch-name {
    font-size: .75em;
    color: var(--wcf-muted);
    text-align: center;
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Size buttons ────────────────────────────────────────────────────────── */
.wcf-size-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.wcf-size-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 5px 10px;
    border: 1.5px solid var(--wcf-border);
    border-radius: var(--wcf-radius);
    cursor: pointer;
    font-size: .875em;
    font-weight: 500;
    background: var(--wcf-bg);
    color: var(--wcf-text);
    transition: border-color .15s, background .15s, color .15s;
    user-select: none;
}
.wcf-size-btn input[type="checkbox"] { display: none; }
.wcf-size-btn:hover {
    border-color: var(--wcf-accent);
    color: var(--wcf-accent);
}
.wcf-size-btn.is-active {
    border-color: var(--wcf-active-border);
    background: var(--wcf-active-bg);
    color: var(--wcf-active-border);
}

/* ── Apply button ────────────────────────────────────────────────────────── */
.wcf-apply-btn {
    width: 100%;
    margin-top: calc(var(--wcf-section-spacing) * 0.5);
    padding: 10px 16px;
    background: var(--wcf-btn-bg) !important;
    color: var(--wcf-btn-color) !important;
    border-radius: var(--wcf-btn-radius) !important;
    border: none !important;
    font-size: var(--wcf-font-size) !important;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
    text-align: center;
}
.wcf-apply-btn:hover { opacity: .88; }
.wcf-apply-btn:disabled { opacity: .5; cursor: default; }
.wcf-apply-btn.is-counting { opacity: .7; }

/* ── Apply bar: only in the mobile panel (batch mode) ────────────────────── */
.wcf-apply-bar { display: none; }
.wcf-filters.is-batch .wcf-apply-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: var(--wcf-section-spacing);
    padding: 12px 0;
    background: var(--wcf-bg);
    box-shadow: 0 -8px 12px -8px rgba(0,0,0,.12);
}
.wcf-filters.is-batch .wcf-apply-btn { margin-top: 0; }
/* Mobile browsers (iOS Safari's floating toolbar, Android nav bars) cover the
   bottom of a 100vh panel, so lift the bar by the hidden part of the viewport
   (large viewport minus dynamic viewport) plus the safe-area inset. */
.wcf-filters.is-batch .wcf-apply-bar {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    padding: 12px 12px 14px;
    margin-left: -12px;
    margin-right: -12px;
    border-radius: 12px 12px 0 0;
}
@supports (height: 100dvh) {
    .wcf-filters.is-batch .wcf-apply-bar {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px) + (100lvh - 100dvh));
    }
}
.wcf-filters.is-batch .wcf-apply-btn {
    min-height: 48px;
    font-size: calc(var(--wcf-font-size) + 2px) !important;
}
.wcf-filters.is-batch .wcf-filter-form {
    padding-bottom: 24px;
}
.wcf-apply-clear {
    text-align: center;
    font-size: var(--wcf-font-size);
    color: var(--wcf-muted);
    text-decoration: underline;
}

/* ── Copy of the active chips on the page (mobile, outside the panel) ─── */
.wcf-page-chips { width: 100%; margin: 10px 0 4px; }
.wcf-page-chips .wcf-active-chips { margin-bottom: 0; }
/* Elementor hides by class only inside its own widgets; mirror it here. */
@media (max-width: 767px) { .wcf-page-chips.elementor-hidden-mobile { display: none; } }
@media (min-width: 768px) and (max-width: 1024px) { .wcf-page-chips.elementor-hidden-tablet { display: none; } }
@media (min-width: 1025px) { .wcf-page-chips.elementor-hidden-desktop { display: none; } }

/* ── Options that would leave no products ────────────────────────────────── */
.wcf-item.is-empty,
.wcf-swatch-wrap.is-empty,
.wcf-size-btn.is-empty {
    opacity: .4;
    cursor: not-allowed;
}

/* ── Loading overlay ─────────────────────────────────────────────────────── */
.wcf-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.5);
    z-index: 999;
    align-items: center;
    justify-content: center;
}
.wcf-filters.is-loading .wcf-overlay {
    display: flex;
}

.wcf-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--wcf-border);
    border-top-color: var(--wcf-accent);
    border-radius: 50%;
    animation: wcf-spin .7s linear infinite;
}
@keyframes wcf-spin { to { transform: rotate(360deg); } }

/* ── Products loading state (applied to products grid) ───────────────────── */
.wcf-products-loading {
    opacity: .5;
    pointer-events: none;
    transition: opacity .2s;
}

/* ── Hide subcategory tiles when filters are active ──────────────────────── */
/* Hides Elementor Pro WC Categories widget and standard WC subcategory loop
   tiles whenever the body has wcf-has-filters class (added by PHP and JS). */
body.wcf-has-filters .elementor-widget-wc-categories,
body.wcf-has-filters ul.products li.product-category,
body.wcf-has-filters ul.products .product-category {
    display: none !important;
}

/* ── RTL support ─────────────────────────────────────────────────────────── */
[dir="rtl"] .wcf-chevron,
.rtl .wcf-chevron {
    border-right: none;
    border-left: 2px solid currentColor;
}
[dir="rtl"] .wcf-item input[type="checkbox"]:checked::after,
.rtl .wcf-item input[type="checkbox"]:checked::after {
    left: auto;
    right: 4px;
}

/* v1.0.6 stability helpers */
.wcf-no-products-found,
.woocommerce-info.wcf-no-products-found {
    width: 100%;
    text-align: center;
    padding: 40px 20px;
    margin: 30px 0;
    font-size: 20px;
    font-weight: 600;
}
