/* ========================================
   WooCommerce Custom Filter Styles
   مسیر: your-theme/css/product-filter.css
   ======================================== */

#cpf-filter-form {
    direction: rtl;
    font-family: inherit;
    background: var(--white);
    border: 1px solid var(--g4);
    border-radius: 24px;
    overflow: hidden;
}

/* Header */
.cpf-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: rgba(0, 94, 98, 0.08);
    border-bottom: 1px solid var(--g4);
}

.cpf-sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 400;
    color: var(--black);
}

/* Clear All */
.cpf-clear-all {
    width: 38%;
    display: block;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 400;
    text-align: center;
    text-decoration: none;
    color: #e44c4c;
    background: transparent;
    border: 1px solid #e44c4c;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cpf-clear-all:hover {
    color: var(--white);
    background: #e44c4c;
}

/* Filter Group */
.cpf-filter-group {
    margin: 0 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--g4);
}

.cpf-filter-group:last-of-type {
    margin-bottom: 16px;
    border-bottom: none;
}

.cpf-group-title {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 400;
    color: var(--black);
}

/* Scroll Items */
.cpf-filter-group-items {
    max-height: 200px;
    overflow-y: auto;
    padding-left: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.cpf-filter-group-items::-webkit-scrollbar {
    width: 4px;
}

.cpf-filter-group-items::-webkit-scrollbar-track {
    background: transparent;
}

.cpf-filter-group-items::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 999px;
}

.cpf-filter-group-items::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* Toggle */
.cpf-toggles {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cpf-toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
}

.cpf-toggle-text {
    font-size: 16px;
    color: var(--black);
}

.cpf-toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.cpf-toggle-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}

.cpf-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--g4);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cpf-toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease;
}

.cpf-toggle-input:checked + .cpf-toggle-track {
    background: var(--primary);
}

.cpf-toggle-input:checked + .cpf-toggle-track::after {
    transform: translateX(20px);
}

/* Checkbox */
.cpf-checkbox-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    padding-left: 8px;
    cursor: pointer;
}

.cpf-checkbox {
    display: none;
}

.cpf-checkbox-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--black);
}

.cpf-checkbox-text::before {
    content: "";
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--g4);
    border-radius: 6px;
    color: var(--white);
    font-size: 13px;
    transition: all 0.2s ease;
}

.cpf-checkbox:checked + .cpf-checkbox-text::before {
    content: "✔";
    background: var(--primary);
}

.cpf-count {
    font-size: 11px;
    color: var(--g1);
}

/* Price Slider */
#cpf-price-slider {
    margin: 8px 4px 16px;
    direction: ltr;
}

#cpf-price-slider.ui-slider {
    height: 4px;
    background: var(--g4);
    border: none;
    border-radius: 999px;
}

#cpf-price-slider .ui-slider-range {
    background: var(--primary);
    border-radius: 999px;
}

#cpf-price-slider .ui-slider-handle {
    width: 18px;
    height: 18px;
    top: -7px;
    background: var(--primary);
    border: 2px solid var(--white);
    border-radius: 5px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    cursor: grab;
    outline: none;
    transition: transform 0.15s ease;
}

#cpf-price-slider .ui-slider-handle:hover,
#cpf-price-slider .ui-slider-handle:active {
    transform: scale(1.15);
    cursor: grabbing;
}

span.ui-slider-handle.ui-corner-all.ui-state-default::after {
    content: "\E805";
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    font-family: "fontello";
    font-size: 16px;
    line-height: 1;
    color: var(--white);
    transform: translate(-50%, -50%);
}

span.ui-slider-handle.ui-corner-all.ui-state-default:last-of-type::after {
    content: "\E80B";
}

.cpf-price-inputs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    direction: rtl;
}

.cpf-price-display {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary);
}

.cpf-price-separator {
    color: var(--g2);
}

/* Submit */
.cpf-submit-btn {
    width: 38%;
    display: block;
    padding: 8px 12px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cpf-submit-btn:hover {
    background: var(--secondary);
}

/* Widget Reset */
.widget #cpf-filter-form {
    padding: 0;
}

/* Collapsible Categories */
.cpf-cat-item {
    margin-bottom: 4px;
}

.cpf-cat-children {
    display: none;
    margin-top: 4px;
}

.cpf-cat-children.is-open {
    display: block;
}

.cpf-cat-toggle {
    display: inline-block;
    width: 16px;
    flex-shrink: 0;
    font-size: 11px;
    color: var(--g1);
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, color 0.2s ease;
}

.cpf-cat-toggle:hover {
    color: var(--primary);
}

.cpf-cat-toggle.is-open {
    transform: rotate(90deg);
}

.cpf-cat-toggle-placeholder {
    display: inline-block;
    width: 16px;
    flex-shrink: 0;
}
/* ==========================================================================
   Mobile filter access — trigger button + responsive off-canvas
   ========================================================================== */
.cpf-toolbar {
    flex-wrap: wrap;
}

.cpf-filter-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid var(--g3, #cacccf);
    border-radius: 10px;
    background: #fff;
    color: var(--secondary, #2D3034);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease;
}

.cpf-filter-trigger:hover {
    border-color: var(--primary, #005e62);
    color: var(--primary, #005e62);
}

/* off-canvas panel on mobile/tablet */
@media (max-width: 991.98px) {
    .filter-offcanvas {
        --bs-offcanvas-width: min(88vw, 360px);
    }

    .filter-offcanvas .offcanvas-body {
        padding: 1rem 1.1rem 2rem;
        overflow-y: auto;
    }
}

/* desktop: keep it a plain sidebar with no off-canvas chrome */
@media (min-width: 992px) {
    .filter-offcanvas {
        visibility: visible !important;
        transform: none !important;
    }

    .filter-offcanvas .offcanvas-body {
        padding: 0;
        overflow: visible;
    }
}

/* --------------------------------------------------------------------------
   مرتب‌سازی به‌صورت تب/پیل افقی
   -------------------------------------------------------------------------- */
.wr-orderby {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    min-width: 0;
}

.wr-orderby-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--g1, #354151);
    flex: 0 0 auto;
}

.wr-orderby-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.wr-orderby-item a {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--g2, #546275);
    text-decoration: none;
    white-space: nowrap;
    transition: color .2s ease, background .2s ease;
}

.wr-orderby-item a:hover {
    color: var(--primary, #008F78);
    background: #008F781a;
}

.wr-orderby-item.is-active a {
    color: #fff;
    background: var(--primary, #008F78);
}

@media (max-width: 575.98px) {
    .wr-orderby {
        width: 100%;
    }

    .wr-orderby-list {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .wr-orderby-list::-webkit-scrollbar {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   موبایل: فیلتر + مرتب‌سازی (دراپ‌دان) به‌صورت دو دکمهٔ کنار هم
   -------------------------------------------------------------------------- */
.cpf-mobile-controls .cpf-filter-trigger {
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
}

.cpf-sort-dropdown {
    flex: 1 1 0;
    min-width: 0;
}

.cpf-sort-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--g3, #cacccf);
    border-radius: 10px;
    background: #fff;
    color: var(--g1, #354151);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease;
}

.cpf-sort-trigger:hover,
.cpf-sort-trigger[aria-expanded="true"] {
    border-color: var(--primary, #008F78);
    color: var(--primary, #008F78);
}

.cpf-sort-trigger .cpf-sort-current {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cpf-sort-trigger::after {
    margin-right: 2px;
    margin-left: 0;
    flex: 0 0 auto;
}

.cpf-sort-menu {
    min-width: 180px;
    border: 1px solid var(--g4, #D1D4D9);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .1);
}

.cpf-sort-menu .dropdown-item {
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--g2, #546275);
}

.cpf-sort-menu .dropdown-item:hover,
.cpf-sort-menu .dropdown-item:focus {
    background: #008F781a;
    color: var(--primary, #008F78);
}

.cpf-sort-menu .dropdown-item.active {
    background: var(--primary, #008F78);
    color: #fff;
}
