/* ========================================
   WooCommerce Custom Filter Styles
   رنگ‌ها فقط از متغیرهای :root قالب (style.css) گرفته می‌شوند:
   --main, --second, --bg, --text, --text2, --gold
   ======================================== */

#cpf-filter-form {
    --cpf-dark: var(--main);
    --cpf-accent: var(--second);
    --cpf-cream: var(--bg);
    --cpf-surface: #fff;
    --cpf-border: color-mix(in srgb, var(--main) 10%, transparent);
    --cpf-border-strong: color-mix(in srgb, var(--main) 20%, transparent);
    --cpf-radius: 1rem;

    direction: rtl;
    text-align: right;
    font-family: inherit;
    color: var(--text);
    background: var(--cpf-surface);
    border: 1px solid var(--cpf-border);
    border-radius: var(--cpf-radius);
    overflow: hidden;
}

/* Header */
.cpf-sidebar-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .9rem 1rem;
    background: var(--cpf-cream);
}

.cpf-sidebar-header__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cpf-surface);
}

.cpf-sidebar-header h3 {
    margin: 0;
    color: var(--cpf-dark);
    font-size: 1rem;
    font-weight: 700;
}

/* Filter Group */
.cpf-filter-group {
    margin: 0 1rem;
    padding: 1rem 0;
    border-bottom: 1px dashed var(--cpf-border-strong);
}

.cpf-filter-group:last-of-type {
    border-bottom: none;
}

.cpf-group-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .85rem;
    color: var(--cpf-dark);
    font-size: .95rem;
    font-weight: 700;
}

.cpf-group-title::before {
    content: "";
    width: 4px;
    height: 14px;
    border-radius: 4px;
    background: var(--cpf-accent);
}

/* Scroll Items */
.cpf-filter-group-items {
    max-height: 220px;
    padding-left: .4rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--cpf-border-strong) transparent;
}

.cpf-filter-group-items::-webkit-scrollbar {
    width: 4px;
}

.cpf-filter-group-items::-webkit-scrollbar-thumb {
    background: var(--cpf-border-strong);
    border-radius: 999px;
}

/* Toggle */
.cpf-toggles {
    padding: .8rem 0;
}

.cpf-toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    margin: 0;
    cursor: pointer;
}

.cpf-toggle-text {
    color: var(--text);
    font-size: .875rem;
}

.cpf-toggle-switch {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 24px;
}

.cpf-toggle-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}

.cpf-toggle-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--cpf-border-strong);
    cursor: pointer;
    transition: background .2s ease;
}

/* در RTL دکمه‌ی خاموش سمت راست است و با فعال شدن به چپ می‌رود */
.cpf-toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px color-mix(in srgb, var(--main) 25%, transparent);
    transition: transform .2s ease;
}

.cpf-toggle-input:checked + .cpf-toggle-track {
    background: var(--cpf-accent);
}

.cpf-toggle-input:checked + .cpf-toggle-track::after {
    transform: translateX(-20px);
}

.cpf-toggle-input:focus-visible + .cpf-toggle-track {
    outline: 2px solid var(--cpf-accent);
    outline-offset: 2px;
}

/* Checkbox */
.cpf-checkbox-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    margin-bottom: .35rem;
    padding: .3rem .4rem;
    border-radius: .5rem;
    cursor: pointer;
    transition: background .2s ease;
}

.cpf-checkbox-label:hover {
    background: color-mix(in srgb, var(--bg) 50%, #fff);
}

/* پنهان ولی قابل دسترس با کیبورد */
.cpf-checkbox {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.cpf-checkbox-text {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--text);
    font-size: .85rem;
    line-height: 1.6;
}

.cpf-checkbox-text::before {
    content: "";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--cpf-border-strong);
    border-radius: 6px;
    background: var(--cpf-surface);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    transition: background .2s ease, border-color .2s ease;
}

.cpf-checkbox:checked + .cpf-checkbox-text {
    color: var(--cpf-dark);
    font-weight: 700;
}

.cpf-checkbox:checked + .cpf-checkbox-text::before {
    content: "✓";
    border-color: var(--cpf-accent);
    background: var(--cpf-accent);
}

.cpf-checkbox:focus-visible + .cpf-checkbox-text::before {
    outline: 2px solid var(--cpf-accent);
    outline-offset: 2px;
}

.cpf-count {
    flex-shrink: 0;
    padding: 0 .5rem;
    border-radius: 999px;
    background: var(--cpf-cream);
    color: var(--text2);
    font-size: .7rem;
    line-height: 1.8;
}

/* Price Slider (پایه‌ی jQuery UI + ظاهر قالب) */
#cpf-price-slider {
    position: relative;
    margin: .75rem .55rem 1.1rem;
    direction: ltr;
}

#cpf-price-slider.ui-slider {
    height: 4px;
    border: none;
    border-radius: 999px;
    background: var(--cpf-border-strong);
}

#cpf-price-slider .ui-slider-range {
    position: absolute;
    top: 0;
    z-index: 1;
    height: 100%;
    border-radius: 999px;
    background: var(--cpf-accent);
}

#cpf-price-slider .ui-slider-handle {
    position: absolute;
    top: -8px;
    z-index: 2;
    width: 20px;
    height: 20px;
    margin-left: -10px;
    border: 3px solid var(--cpf-accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px color-mix(in srgb, var(--main) 20%, transparent);
    cursor: grab;
    outline: none;
    transition: transform .15s ease;
}

#cpf-price-slider .ui-slider-handle:hover,
#cpf-price-slider .ui-slider-handle:focus-visible,
#cpf-price-slider .ui-slider-handle.ui-state-active {
    transform: scale(1.15);
    cursor: grabbing;
}

.cpf-price-inputs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    direction: rtl;
}

.cpf-price-display {
    display: inline-flex;
    gap: .25rem;
    padding: .2rem .65rem;
    border-radius: .5rem;
    background: var(--cpf-cream);
    color: var(--cpf-dark);
    font-size: .8rem;
    font-weight: 700;
}

/* Actions */
.cpf-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 1rem;
    border-top: 1px solid var(--cpf-border);
}

.cpf-submit-btn,
.cpf-clear-all {
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: .4rem .9rem;
    border-radius: 999px;
    font-size: .875rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.cpf-submit-btn {
    border: 1px solid var(--cpf-dark);
    background: var(--cpf-dark);
    color: #fff;
}

.cpf-submit-btn:hover {
    border-color: var(--cpf-accent);
    background: var(--cpf-accent);
}

.cpf-clear-all {
    border: 1px solid var(--cpf-border-strong);
    background: transparent;
    color: var(--cpf-dark);
}

.cpf-clear-all:hover {
    border-color: var(--cpf-accent);
    color: var(--cpf-accent);
}

.cpf-submit-btn:focus-visible,
.cpf-clear-all:focus-visible {
    outline: 2px solid var(--cpf-accent);
    outline-offset: 2px;
}

/* Widget Reset */
.widget #cpf-filter-form {
    padding: 0;
}

/* ==========================================================================
   Mobile filter access — trigger button + responsive off-canvas
   ========================================================================== */
.cpf-toolbar {
    flex-wrap: wrap;
}

.cpf-filter-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 42px;
    padding: .4rem 1rem;
    border: 1px solid color-mix(in srgb, var(--main) 20%, transparent);
    border-radius: 999px;
    background: #fff;
    color: var(--main);
    font-size: .875rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease;
}

.cpf-filter-trigger:hover {
    border-color: var(--second);
    color: var(--second);
}

.cpf-filter-trigger__dot {
    position: absolute;
    top: 6px;
    left: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--second);
}

@media (max-width: 991.98px) {
    .filter-offcanvas {
        --bs-offcanvas-width: min(88vw, 360px);
        background: var(--bg);
    }

    .filter-offcanvas .offcanvas-header {
        color: var(--main);
    }

    .filter-offcanvas .offcanvas-body {
        padding: 0 1rem 1.5rem;
    }
}

/* Screen reader only */
#cpf-filter-form .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Attribute: color swatches (pa_color) & tag chips (pa_fasl)
   ========================================================================== */
.cpf-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

/* Color swatch */
.cpf-swatch {
    position: relative;
    display: inline-flex;
    margin: 0;
    cursor: pointer;
}

.cpf-swatch__color {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: .5rem;
    background: var(--cpf-swatch, #fff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--main) 15%, transparent);
    transition: transform .2s ease, box-shadow .2s ease;
}

/* رنگی که کد ندارد: خط مورب */
.cpf-swatch__color.is-empty {
    background: linear-gradient(135deg, #fff 45%, var(--cpf-border-strong) 45% 55%, #fff 55%);
}

.cpf-swatch:hover .cpf-swatch__color {
    transform: scale(1.08);
}

.cpf-swatch .cpf-checkbox:checked + .cpf-swatch__color {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--cpf-accent);
}

.cpf-swatch .cpf-checkbox:checked + .cpf-swatch__color::after {
    content: "✓";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 0 3px rgba(0, 0, 0, .55);
}

.cpf-swatch .cpf-checkbox:focus-visible + .cpf-swatch__color {
    outline: 2px solid var(--cpf-accent);
    outline-offset: 4px;
}

/* Tag chip */
.cpf-chip {
    position: relative;
    display: inline-flex;
    margin: 0;
    cursor: pointer;
}

.cpf-chip__text {
    display: inline-flex;
    align-items: center;
    padding: .3rem .9rem;
    border: 1px solid var(--cpf-border-strong);
    border-radius: 999px;
    background: var(--cpf-surface);
    color: var(--text);
    font-size: .8rem;
    line-height: 1.7;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.cpf-chip:hover .cpf-chip__text {
    border-color: var(--cpf-accent);
    color: var(--cpf-accent);
}

.cpf-chip .cpf-checkbox:checked + .cpf-chip__text {
    border-color: var(--cpf-dark);
    background: var(--cpf-dark);
    color: #fff;
}

.cpf-chip .cpf-checkbox:focus-visible + .cpf-chip__text {
    outline: 2px solid var(--cpf-accent);
    outline-offset: 2px;
}
