/* WC Smart Filter – Digikala-style filter panel. */

:root {
    --wcsf-accent: #ef4056;
    --wcsf-text: #3d3d3d;
    --wcsf-muted: #9e9e9e;
    --wcsf-border: #ebebeb;
    --wcsf-bg: #ffffff;
    --wcsf-chip-bg: #f5f5f5;
    --wcsf-scroll: #d6d6d6;
    --wcsf-scroll-hover: #b8b8b8;
    --wcsf-radius: 12px;
}

/* ---------- Layout ---------- */

.wcsf-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    width: 100%;
    margin-bottom: 24px;
}

.wcsf-layout .wcsf-main {
    min-width: 0;
    transition: opacity 0.2s ease;
}

.wcsf-main.is-loading {
    opacity: 0.45;
    pointer-events: none;
}

/* Breadcrumb and sub-category rows: full width, above the filter and products. */
.wcsf-top {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    order: -2 !important;
    margin-bottom: 16px;
}

/* Docked: the filter fills the theme's sidebar column, products keep the rest. */
.wcsf-layout.is-docked {
    grid-template-columns: minmax(0, 1fr);
}

/* ---------- Panel ---------- */

.wcsf-sidebar {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    /* No overscroll-behavior here: when the panel reaches its end, the wheel must go on to the page. */
    padding: 0 16px 0;
    border: 1px solid var(--wcsf-border);
    border-radius: var(--wcsf-radius);
    background: var(--wcsf-bg);
    color: var(--wcsf-text);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.7;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    scrollbar-width: thin;
    scrollbar-color: var(--wcsf-scroll) transparent;
}

.wcsf-sidebar::-webkit-scrollbar,
.wcsf-list::-webkit-scrollbar {
    width: 6px;
}

.wcsf-sidebar::-webkit-scrollbar-track,
.wcsf-list::-webkit-scrollbar-track {
    background: transparent;
}

.wcsf-sidebar::-webkit-scrollbar-thumb,
.wcsf-list::-webkit-scrollbar-thumb {
    background: var(--wcsf-scroll);
    border-radius: 999px;
}

.wcsf-sidebar::-webkit-scrollbar-thumb:hover,
.wcsf-list::-webkit-scrollbar-thumb:hover {
    background: var(--wcsf-scroll-hover);
}

.wcsf-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0 12px;
    background: var(--wcsf-bg);
}

.wcsf-head h3 {
    flex: 1;
    margin: 0;
    padding: 0;
    color: var(--wcsf-text);
    font-family: inherit;
    font-size: 16px;
    font-weight: 800;
}

.wcsf-reset {
    color: var(--wcsf-accent);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.wcsf-reset:hover {
    text-decoration: underline;
}

.wcsf-close {
    display: none;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: var(--wcsf-text);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

/* Active chips */
.wcsf-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 12px;
}

.wcsf-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 0;
    border-radius: 8px;
    background: var(--wcsf-chip-bg);
    color: var(--wcsf-text);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.wcsf-chip span[aria-hidden="true"] {
    font-size: 15px;
    line-height: 1;
    color: var(--wcsf-muted);
}

.wcsf-chip:hover {
    color: var(--wcsf-accent);
}

/* ---------- Sections (accordion) ---------- */

.wcsf-group {
    margin: 0;
    padding: 14px 0;
    border-top: 1px solid var(--wcsf-border);
}

.wcsf-group-head {
    margin: 0;
}

.wcsf-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0 0 8px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--wcsf-text);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    text-align: start;
    cursor: pointer;
}

.wcsf-group-body {
    min-width: 0;
}

.wcsf-group.is-collapsed .wcsf-group-body {
    display: none;
}

.wcsf-chev {
    width: 7px;
    height: 7px;
    margin-inline-end: 4px;
    margin-top: -4px;
    border-right: 2px solid var(--wcsf-muted);
    border-bottom: 2px solid var(--wcsf-muted);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.wcsf-group.is-collapsed .wcsf-chev {
    margin-top: 0;
    transform: rotate(-45deg);
}

/* ---------- Checkbox lists ---------- */

.wcsf-list {
    list-style: none;
    margin: 0;
    padding: 0 4px 0 0;
    scrollbar-width: thin;
    scrollbar-color: var(--wcsf-scroll) transparent;
}

.wcsf-list:not(.is-short) {
    max-height: none;
    overflow: visible;
}

.wcsf-list.is-short li:nth-child(n + 7) {
    display: none;
}

.wcsf-list li {
    margin: 0;
}

.wcsf-list label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    color: var(--wcsf-text);
    cursor: pointer;
}

.wcsf-list label:hover .wcsf-name {
    color: var(--wcsf-accent);
}

.wcsf-name {
    flex: 1;
    min-width: 0;
}

.wcsf-count {
    flex: none;
    margin-inline-start: auto;
    padding-inline-start: 6px;
    color: var(--wcsf-muted);
    font-size: 12px;
}

/* Custom square checkbox */
.wcsf-list input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    display: inline-grid;
    place-content: center;
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1.5px solid #c4c4c4;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wcsf-list input[type="checkbox"]::before {
    content: "";
    width: 9px;
    height: 5px;
    margin-top: -2px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) scale(0);
    transition: transform 0.12s ease;
}

.wcsf-list input[type="checkbox"]:hover {
    border-color: var(--wcsf-accent);
}

.wcsf-list input[type="checkbox"]:checked {
    border-color: var(--wcsf-accent);
    background: var(--wcsf-accent);
}

.wcsf-list input[type="checkbox"]:checked::before {
    transform: rotate(-45deg) scale(1);
}

.wcsf-list input[type="checkbox"]:focus-visible {
    outline: 2px solid rgba(239, 64, 86, 0.35);
    outline-offset: 2px;
}

.wcsf-depth-1 label { padding-inline-start: 16px; }
.wcsf-depth-2 label { padding-inline-start: 32px; }
.wcsf-depth-3 label { padding-inline-start: 48px; }

.wcsf-more {
    display: block;
    margin-top: 4px;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: var(--wcsf-accent);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* ---------- Price slider ---------- */

.wcsf-range-labels {
    display: flex;
    justify-content: space-between;
    direction: ltr;
    margin-bottom: 8px;
    color: var(--wcsf-text);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.wcsf-range-slider {
    position: relative;
    height: 24px;
    direction: ltr; /* keep min on the left in RTL pages */
}

.wcsf-range-track,
.wcsf-range-fill {
    position: absolute;
    top: 50%;
    height: 4px;
    margin-top: -2px;
    border-radius: 4px;
}

.wcsf-range-track {
    left: 9px;
    right: 9px;
    background: #e3e3e3;
}

.wcsf-range-fill {
    background: var(--wcsf-accent);
}

.wcsf-range-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 24px;
    margin: 0;
    padding: 0;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.wcsf-range-input::-webkit-slider-runnable-track {
    height: 24px;
    border: 0;
    background: transparent;
}

.wcsf-range-input::-moz-range-track {
    height: 24px;
    border: 0;
    background: transparent;
}

.wcsf-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    margin-top: 3px;
    border: 2px solid var(--wcsf-accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    cursor: grab;
    pointer-events: auto;
}

.wcsf-range-input::-moz-range-thumb {
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    border: 2px solid var(--wcsf-accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    cursor: grab;
    pointer-events: auto;
}

.wcsf-range-input:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(239, 64, 86, 0.25);
}

.wcsf-range-input:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 4px rgba(239, 64, 86, 0.25);
}

/* ---------- Footer / apply ---------- */

.wcsf-footer {
    position: sticky;
    bottom: 0;
    padding: 12px 0 16px;
    background: var(--wcsf-bg);
}

.wcsf-submit {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 8px;
    background: var(--wcsf-accent);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.wcsf-submit:hover {
    filter: brightness(1.05);
}

/* ---------- Shortcode ---------- */

.wcsf-standalone {
    max-width: 300px;
    margin-bottom: 20px;
}

.wcsf-standalone .wcsf-sidebar {
    position: static;
    max-height: none;
}

/* ---------- Mobile toggle & drawer ---------- */

.wcsf-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 14px;
    border: 1px solid var(--wcsf-border);
    border-radius: 8px;
    background: var(--wcsf-bg);
    color: var(--wcsf-text);
    font: inherit;
    cursor: pointer;
}

.wcsf-badge {
    display: none;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--wcsf-accent);
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

.wcsf-badge.is-visible {
    display: inline-block;
}

.screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

/* ---------- Theme layout fixes on archives (optional setting) ---------- */

.wcsf-hide-theme #secondary,
.wcsf-hide-theme .widget-area,
.wcsf-hide-theme .woocommerce-sidebar,
.wcsf-hide-theme aside.sidebar {
    display: none !important;
}

.wcsf-hide-theme #primary,
.wcsf-hide-theme .content-area {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
}

/* Filter docked into the theme's sidebar column: keep that column visible. */
.wcsf-hide-theme .wcsf-dock-target.wcsf-dock-target {
    display: block !important;
}

/* Empty theme column (e.g. .right-side) beside the filter: remove it. */
.wcsf-hide-theme .right-side:not(:has(.wcsf-layout)):not(:has(.products)) {
    display: none !important;
}

/* ---------- Tablet & mobile (below 992px): full-screen drawer from the right ---------- */

@media (max-width: 991.98px) {
    .wcsf-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .wcsf-layout.is-drawer .wcsf-toggle {
        display: inline-flex;
    }

    /*
     * Fixed and off-screen until opened. Being fixed means the panel never takes
     * space in the page flow, whatever the sticky setting is.
     */
    .wcsf-layout.is-drawer .wcsf-sidebar,
    .wcsf-layout.is-drawer:not(.is-sticky) .wcsf-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        z-index: 99999;
        display: flex;
        flex-direction: column;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: hidden;
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.28s ease, visibility 0.28s;
    }

    .wcsf-layout.is-drawer .wcsf-sidebar.is-open,
    .wcsf-layout.is-drawer:not(.is-sticky) .wcsf-sidebar.is-open {
        transform: none;
        visibility: visible;
    }

    /* The form scrolls. The head and the apply button stay in view. */
    .wcsf-layout.is-drawer .wcsf-form {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        padding: 0 16px;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .wcsf-layout.is-drawer .wcsf-footer {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .wcsf-layout.is-drawer .wcsf-close {
        display: inline-block;
        padding: 4px 8px;
    }

    body.wcsf-open {
        overflow: hidden;
    }

    @media (prefers-reduced-motion: reduce) {
        .wcsf-layout.is-drawer .wcsf-sidebar {
            transition: none;
        }
    }
}

/* ---------- v1.0.9: sticky toggle, stock, swatches ---------- */

/* Sticky sidebar can be turned off in settings (desktop only; mobile drawer is handled above). */
@media (min-width: 992px) {
    .wcsf-layout:not(.is-sticky) .wcsf-sidebar {
        position: static;
        max-height: none;
    }
}

/* Swatch options: hidden native checkbox keeps keyboard and screen-reader support. */
.wcsf-swatches input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none;
}

.wcsf-swatches {
    list-style: none;
    margin: 0;
    padding: 6px 0 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.wcsf-swatches li {
    margin: 0;
}

.wcsf-swatches label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--wcsf-text);
    user-select: none;
}

.wcsf-swatches label:has(input:focus-visible) {
    outline: 2px solid var(--wcsf-accent);
    outline-offset: 3px;
    border-radius: 999px;
}

/* Colour swatches: circles with a name underneath. */
.wcsf-swatches-color label {
    flex-direction: column;
    gap: 5px;
    width: 58px;
    text-align: center;
}

.wcsf-swatch-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--wcsf-swatch, #e5e7eb);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.wcsf-swatch-dot.is-unknown {
    background: repeating-linear-gradient(135deg, #fff 0 4px, #e5e7eb 4px 6px);
}

.wcsf-swatches-color label:hover .wcsf-swatch-dot {
    transform: scale(1.08);
}

.wcsf-swatches-color label:has(input:checked) .wcsf-swatch-dot {
    box-shadow: 0 0 0 2px var(--wcsf-bg), 0 0 0 4px var(--wcsf-accent);
}

.wcsf-swatches-color .wcsf-swatch-text {
    max-width: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.4;
    color: var(--wcsf-muted);
}

.wcsf-swatches-color label:has(input:checked) .wcsf-swatch-text {
    color: var(--wcsf-text);
    font-weight: 700;
}

/* Button style: pills, filled with the accent when selected. */
.wcsf-swatches-button label {
    padding: 6px 14px;
    border: 1px solid var(--wcsf-border);
    border-radius: 999px;
    background: var(--wcsf-bg);
    font-size: 12px;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.wcsf-swatches-button label:hover {
    border-color: var(--wcsf-accent);
}

.wcsf-swatches-button label:has(input:checked) {
    border-color: var(--wcsf-accent);
    background: var(--wcsf-accent);
    color: #fff;
}

/* ---------- v1.0.14: attribute search box ---------- */

.wcsf-search {
    margin: 2px 0 8px;
}

.wcsf-search .wcsf-search-input {
    display: block;
    width: 100%;
    height: 30px;
    box-sizing: border-box;
    margin: 0;
    direction: rtl;
    text-align: right;
    padding: 0 30px 0 10px;
    border: 1px solid var(--wcsf-border);
    border-radius: 8px;
    background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat right 9px center;
    color: var(--wcsf-text);
    font: inherit;
    font-size: 12px;
    line-height: 28px;
    outline: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.wcsf-search .wcsf-search-input::placeholder {
    color: #94a3b8;
}

.wcsf-search .wcsf-search-input:focus {
    border-color: var(--wcsf-accent);
    background-color: #fff;
}

.wcsf-search-empty {
    margin: 4px 0 8px;
    color: var(--wcsf-muted);
    font-size: 12px;
}

/* ---------- v1.0.18: attribute lists capped at 200px, no scrolling, "show more" link ---------- */

.wcsf-group[data-key^="attr-"] ul.wcsf-list,
.wcsf-group[data-key^="attr-"] ul.wcsf-swatches {
    min-height: 0;
    max-height: 200px;
    overflow: hidden;
}

.wcsf-group[data-key^="attr-"] ul.wcsf-list.is-expanded,
.wcsf-group[data-key^="attr-"] ul.wcsf-swatches.is-expanded {
    max-height: none;
    overflow: visible;
}

/* Shown by the script only when the list is taller than 200px (or already expanded). */
.wcsf-group[data-key^="attr-"] .wcsf-more {
    display: none;
}

.wcsf-group[data-key^="attr-"] .wcsf-more.is-visible {
    display: block;
}
