/*
 * Shop sidebar filters — price, attribute swatches, brand/tag lists.
 * Shares the visual language of the category nav: same title rule, same accent, same 3px radius.
 */
.sf-widget {
    --sf-accent: var(--color-1st, #9b2321);
    --sf-border: #e7e9ee;
    --sf-text: #2c3340;
    --sf-muted: #8b93a3;
}

/* Section title — matches the category nav header exactly. */
.sf-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--sf-border);
    font-size: 15px;
    font-weight: 700;
    color: var(--sf-text);
    text-transform: none;
}

.sf-title::after {
    content: '';
    flex: none;
    width: 26px;
    height: 3px;
    margin-left: auto;
    border-radius: 3px;
    background: var(--sf-accent);
}

/* How many values are selected in this group — the old design showed nothing. */
.sf-title__count {
    flex: none;
    min-width: 20px;
    padding: 1px 7px;
    border-radius: 3px;
    background: var(--sf-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

/* ===== Price ============================================================== */
.sf-price .nonlinear-wrapper { padding: 6px 8px 0; }

/* noUiSlider, rebuilt: thin track, red fill, real handles. */
.sf-price .noUi-target {
    height: 4px;
    border: none;
    border-radius: 4px;
    background: #eceef1;
    box-shadow: none;
}

.sf-price .noUi-connect { background: var(--sf-accent); }

.sf-price .noUi-horizontal .noUi-handle {
    width: 16px;
    height: 16px;
    right: -8px;
    top: -6px;
    border: 2px solid var(--sf-accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(16, 25, 43, .25);
    cursor: grab;
    transition: transform .12s ease;
}

.sf-price .noUi-horizontal .noUi-handle:hover { transform: scale(1.12); }
.sf-price .noUi-horizontal .noUi-handle:active { cursor: grabbing; }

/* The default handle has two decorative lines through it — remove them. */
.sf-price .noUi-handle::before,
.sf-price .noUi-handle::after { display: none; }

.sf-price .noUi-handle:focus-visible {
    outline: 2px solid var(--sf-accent);
    outline-offset: 2px;
}

/* Min / max as two readable boxes instead of a run-on line of text.
 *
 * Scoped with `.sf-price` (two classes) on purpose: the theme ships
 * `.widget_shop .ps-slider__meta { margin-top: 5px }`, which outranks a bare `.sf-price__meta` —
 * the boxes ended up 5px under the track, with the round handles overlapping them. Matching the
 * theme's specificity and loading afterwards is what actually wins the cascade here. */
.sf-price .sf-price__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    /* The handles are 16px and hang ~6px below the 4px track, so this is clearance from the
       handle, not from the track. */
    margin-top: 24px;
}

.sf-price .sf-price__box {
    flex: 1;
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    margin-top: 0;
    padding: 8px 6px;
    border: 1px solid var(--sf-border);
    border-radius: 3px;
    background: #fbfbfc;
    color: var(--sf-text);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.sf-price .sf-price__box em {
    font-style: normal;
    font-weight: 600;
    font-size: 11px;
    color: var(--sf-muted);
}

.sf-price .sf-price__dash {
    flex: none;
    margin-top: 0;
    color: var(--sf-muted);
}

/* ===== Attribute swatches (text) ========================================== */
.sf-swatches__scroll {
    /* Tall enough that a typical size list fits with no scrolling at all; longer lists still
       scroll rather than pushing the rest of the sidebar off the screen. */
    max-height: 520px;
    overflow-y: auto;
    /* A thin native scrollbar instead of the grey slab the mCustomScrollbar plugin drew. */
    scrollbar-width: thin;
    scrollbar-color: #d3d7de transparent;
    padding-right: 4px;
}

.sf-swatches__scroll::-webkit-scrollbar { width: 5px; }
.sf-swatches__scroll::-webkit-scrollbar-track { background: transparent; }
.sf-swatches__scroll::-webkit-scrollbar-thumb { background: #d3d7de; border-radius: 5px; }
.sf-swatches__scroll::-webkit-scrollbar-thumb:hover { background: #b9bfc9; }

/*
 * A grid, not flex-wrap: equal columns keep the chips aligned in tidy rows. With flex the
 * different label widths ("1 L" next to "5 KG (0,5+0,25+4,25)") produced ragged, messy rows.
 */
.sf-chips {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.sf-chips li { margin: 0; display: flex; }

.sf-chip { display: flex; width: 100%; margin: 0; cursor: pointer; }

/* The checkbox stays in the DOM for keyboard and for the filter JS; only the chip is visible. */
.sf-chip input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.sf-chip span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 34px;
    padding: 5px 8px;
    border: 1px solid var(--sf-border);
    border-radius: 3px;
    background: #fff;
    color: var(--sf-text);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.sf-chip:hover span { border-color: var(--sf-accent); color: var(--sf-accent); }

/* Selected: filled, so it reads as "on" from across the room. */
.sf-chip input:checked + span {
    border-color: var(--sf-accent);
    background: var(--sf-accent);
    color: #fff;
}

.sf-chip input:focus-visible + span {
    outline: 2px solid var(--sf-accent);
    outline-offset: 2px;
}

/* ===== Attribute swatches (colour) ======================================== */
.sf-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.sf-color { display: block; margin: 0; cursor: pointer; }
.sf-color input { position: absolute; opacity: 0; width: 0; height: 0; }

.sf-color span {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(16, 25, 43, .15);
    box-shadow: 0 0 0 0 var(--sf-accent);
    transition: box-shadow .15s ease, transform .12s ease;
}

.sf-color:hover span { transform: scale(1.08); }

.sf-color input:checked + span {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--sf-accent);
}

/* ===== Brand / tag checkbox lists ========================================= */
.sf-checks__scroll {
    max-height: 420px;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #d3d7de transparent;
}

.sf-checks__scroll::-webkit-scrollbar { width: 5px; }
.sf-checks__scroll::-webkit-scrollbar-thumb { background: #d3d7de; border-radius: 5px; }

.sf-checks .ps-checkbox { position: relative; margin: 0; }

.sf-checks .ps-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.sf-checks .ps-checkbox label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 8px 10px;
    border-radius: 3px;
    color: var(--sf-text);
    font-size: 13px;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.sf-checks .ps-checkbox label::before {
    content: '';
    flex: none;
    width: 16px;
    height: 16px;
    border: 1px solid #cfd4dc;
    border-radius: 3px;
    background: #fff center/10px no-repeat;
    transition: background-color .15s ease, border-color .15s ease;
}

.sf-checks .ps-checkbox label:hover { background: #f6f7f9; }

.sf-checks .ps-checkbox input:checked + label {
    color: var(--sf-accent);
    font-weight: 600;
}

.sf-checks .ps-checkbox input:checked + label::before {
    border-color: var(--sf-accent);
    background-color: var(--sf-accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 6.2 4.8 8.5 9.5 3.8' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.sf-checks .ps-checkbox input:focus-visible + label::before {
    outline: 2px solid var(--sf-accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .sf-chip span, .sf-color span, .sf-price .noUi-handle { transition: none; }
}

/* ===== Filtering spinner ==================================================
 * The theme shows a 60px half-circle pinned near the top of the listing
 * (`margin: 50px auto`). Replace it with the small round spinner used in the
 * admin, centred over the product list.
 *
 * The overlay's `display` is set inline by backend.js (`.show()` -> display:block),
 * so centring is done by absolutely positioning the spinner rather than by
 * turning the overlay into a flex container — which the inline style would beat.
 */
.ps-layout--shop .ps-tabs .loading {
    inset: 0;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: rgba(255, 255, 255, .72);
}

/*
 * `sticky`, not `absolute`: the overlay covers the whole product list, which is often taller than
 * the screen — an absolutely centred spinner would land halfway down the list, below the fold.
 * Sticky keeps it in the middle of the *visible* part of the list while the request runs.
 */
.ps-layout--shop .ps-tabs .loading .half-circle-spinner {
    position: sticky;
    top: 50vh;
    width: 34px;
    height: 34px;
    margin: 0 auto;
    border: 3px solid color-mix(in srgb, var(--color-1st, #9b2321) 22%, transparent);
    border-top-color: var(--color-1st, #9b2321);
    border-radius: 50%;
    animation: sfSpin .7s linear infinite;
}

/* The theme's spinner is built from two rotating half-circles — hide them. */
.ps-layout--shop .ps-tabs .loading .half-circle-spinner .circle {
    display: none;
}

@keyframes sfSpin {
    from { transform: translateY(-50%) rotate(0deg); }
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Browsers without color-mix still get a visible ring. */
@supports not (border-color: color-mix(in srgb, red 22%, transparent)) {
    .ps-layout--shop .ps-tabs .loading .half-circle-spinner {
        border-color: #e3d1d1;
        border-top-color: var(--color-1st, #9b2321);
    }
}
