/* ============================================================
   فیلترها و مرتب‌سازی - صفحه محصولات
   ============================================================ */

/* ===== دکمه فیلتر ===== */
.filter-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: #ffffff;
    border: 2px solid #e8e8e8;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    color: #2a3923;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    height: 40px;
    box-sizing: border-box;
}

.filter-toggle-btn:hover {
    border-color: #c1a88a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(193, 168, 138, 0.2);
}

.filter-toggle-btn svg {
    color: #6f7863;
    flex-shrink: 0;
}

.filter-badge-active {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #e8483c;
    border-radius: var(--radius-full);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #e8483c;
    margin-right: -2px;
}

/* ===== مرتب‌سازی دسکتاپ ===== */
.sort-desktop {
    background: transparent;
    padding: 0;
    align-items: center;
    gap: 8px;
}

.sort-segmented {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: #eeede6;
    border-radius: var(--radius-md);
    flex-wrap: nowrap;
    height: 40px !important;
    box-sizing: border-box;
}

.sort-label {
    font-size: 0.8rem;
    color: #9a9a8e;
    font-weight: 500;
    white-space: nowrap;
}

.sort-segmented-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    height: calc(100% - 8px);
    width: 0;
    background: #ffffff;
    border-radius: calc(var(--radius-md) - 3px);
    box-shadow: 0 1px 6px rgba(83, 89, 69, 0.15);
    transition: right 0.3s cubic-bezier(0.34, 1.2, 0.64, 1), width 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
    pointer-events: none;
    z-index: 0;
}

.sort-item {
    position: relative;
    z-index: 1;
    padding: 0 16px;
    border-radius: calc(var(--radius-md) - 3px);
    font-size: 0.8rem;
    font-weight: 500;
    color: #888578;
    text-decoration: none;
    transition: color 0.25s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    height: 100%;
}

.sort-item:hover {
    color: #2a3923;
}

.sort-item.active {
    color: #2a3923;
    font-weight: 600;
}

/* ===== دکمه مرتب‌سازی موبایل ===== */
.sort-mobile-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 40px;
    background: #ffffff;
    border: 2px solid #e8e8e8;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    color: #2a3923;
    cursor: pointer;
    transition: all 0.3s ease;
    box-sizing: border-box;
    position: relative;
}

.sort-mobile-btn:hover {
    border-color: #c1a88a;
}

/* ===== مودال مرتب‌سازی ===== */
.sort-modal .modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: 0 16px 50px rgba(83, 89, 69, 0.18);
    overflow: hidden;
}

.sort-modal .modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid #f0f0eb;
}

.sort-modal .modal-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: #2a3923;
}

.sort-list-mobile {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 2px;
}

.sort-item-mobile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    text-decoration: none;
    color: #44483a;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.2s ease, color 0.2s ease;
    border-radius: var(--radius-md);
    position: relative;
}

.sort-item-mobile:hover {
    background: #f6f7f3;
}

.sort-item-mobile.active {
    background: #f0f2ec;
    color: #2a3923;
    font-weight: 600;
}

.sort-item-mobile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: #f3f4f1;
    color: #9a9a8e;
    flex-shrink: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.sort-item-mobile.active .sort-item-mobile-icon {
    background: #6f7863;
    color: #fff;
}

.sort-check {
    margin-right: auto;
    color: #6f7863;
    font-weight: 700;
}

/* ===== پنل فیلتر ===== */
.filter-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30, 35, 20, 0.45);
    z-index: 1040;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.35s ease;
}
.filter-overlay.is-open {
    display: block;
    opacity: 1;
}

.filter-panel {
    position: fixed;
    z-index: 1050;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
}

/* دسکتاپ */
@media (min-width: 769px) {
    .filter-panel {
        top: 0;
        right: 0;
        bottom: 0;
        width: 340px;
        border-radius: var(--radius-lg) 0 0 var(--radius-lg);
        box-shadow: -8px 0 40px rgba(0,0,0,0.12);
        transform: translateX(100%);
    }
    .filter-panel.is-open {
        transform: translateX(0);
    }
    .filter-panel__drag-handle { display: none; }
}

/* موبایل */
@media (max-width: 768px) {
    .filter-panel {
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 88vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.14);
        transform: translateY(100%);
    }
    .filter-panel.is-open {
        transform: translateY(0);
    }
    .filter-panel__drag-handle {
        display: flex;
        justify-content: center;
        padding: 10px 0 4px;
        cursor: grab;
        flex-shrink: 0;
    }
    .filter-panel__drag-handle span {
        display: block;
        width: 40px;
        height: 4px;
        background: #d8d8d0;
        border-radius: var(--radius-xs);
    }
}

.filter-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0eb;
    flex-shrink: 0;
}

.filter-panel__title {
    font-size: 1rem;
    font-weight: 700;
    color: #2a3923;
}

.filter-panel__close {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    border: none;
    background: #f3f4f1;
    color: #535945;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.filter-panel__close:hover {
    background: #e5e6e0;
    transform: scale(1.08);
}

.filter-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 24px;
    overscroll-behavior: contain;
}

.filter-panel__body::-webkit-scrollbar { width: 4px; }
.filter-panel__body::-webkit-scrollbar-track { background: transparent; }
.filter-panel__body::-webkit-scrollbar-thumb { background: #c1a88a; border-radius: var(--radius-xs); }

/* ===== فیلتر آکاردئونی ===== */
.filter-accordion {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group {
    border: 1px solid #f0f0f0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #ffffff;
    transition: all 0.3s ease;
}

.filter-group:hover {
    border-color: #e0e0e0;
}

.filter-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2a3923;
}

.filter-group-header:hover {
    background: #f8f9f6;
}

.filter-group-header svg {
    color: #999;
    transition: transform 0.3s ease;
}

.filter-group-header[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.filter-group-body {
    padding: 8px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===== چک‌باکس‌ها ===== */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 0;
    transition: all 0.2s ease;
}

.filter-checkbox:hover {
    padding-right: 4px;
}

.filter-checkbox input {
    display: none;
}

.filter-checkbox-custom {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
    border: 2px solid #d0d0d0;
    background: #fff;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
}

.filter-checkbox input:checked + .filter-checkbox-custom {
    background: #6f7863;
    border-color: #6f7863;
}

.filter-checkbox input:checked + .filter-checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.filter-checkbox-label {
    font-size: 0.85rem;
    color: #333;
    font-weight: 500;
}

/* ===== قیمت ===== */
.price-range-container {
    padding: 8px 0;
}

.price-range-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 16px;
}

.price-range-display strong {
    color: #2a3923;
    font-weight: 700;
}

/* ===== دکمه‌ها ===== */
.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.filter-submit-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #6f7863;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.filter-submit-btn:hover {
    background: #535945;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(111, 120, 99, 0.3);
}

.filter-submit-btn svg {
    stroke: #fff;
}

.filter-reset-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #f5f5f5;
    color: #666;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}

.filter-reset-btn:hover {
    background: #e8e8e8;
    color: #333;
}

/* ===== NoUISlider ===== */
.noUi-target {
    background: #e8e8e8;
    border: none;
    border-radius: var(--radius-sm);
    height: 6px;
    box-shadow: none;
}

.noUi-connect {
    background: linear-gradient(90deg, #c1a88a, #6f7863);
}

.noUi-horizontal .noUi-handle {
    width: 20px !important;
    height: 20px !important;
    right: -10px !important;
    top: -7px !important;
    border-radius: var(--radius-full) !important;
    background: #ffffff !important;
    border: 3px solid #6f7863 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    cursor: pointer !important;
}

.noUi-handle:before,
.noUi-handle:after {
    display: none !important;
}

.noUi-handle:hover {
    transform: scale(1.1) !important;
}

/* ===== حالت لودینگ ===== */
.wood-products-grid.grid-loading {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.2s ease;
    position: relative;
    min-height: 200px;
}

/* ============================================================
   نوار ابزار فیلتر و مرتب‌سازی - هم‌ترازی کامل
   ============================================================ */
.products-toolbar {
    display: flex !important;
    align-items: center;
    flex-wrap: nowrap !important;
    gap: 12px;
    margin-block: 1.5rem;
    width: 100%;
    margin: 1.5rem;
}

.products-toolbar * {
    box-sizing: border-box;
}

/* ===== دسکتاپ ===== */
@media (min-width: 992px) {
    .products-toolbar .sort-desktop {
        display: flex !important;
        align-items: center;
        gap: 8px;
        flex: 1;
        min-width: 0;
        margin-top: 0;
    }
    .products-toolbar .sort-mobile-btn {
        display: none !important;
    }
    .products-toolbar .filter-toggle-btn {
        flex-shrink: 0;
    }
}

/* ===== موبایل و تبلت ===== */
@media (max-width: 991px) {
    .products-toolbar {
        gap: 10px;
    }
    .products-toolbar .sort-desktop {
        display: none !important;
    }
    .products-toolbar .filter-toggle-btn,
    .products-toolbar .sort-mobile-btn {
        display: inline-flex !important;
        flex: 1 1 0 !important;
        width: 50% !important;
        max-width: 50% !important;
        min-width: 0 !important;
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
        padding: 0 12px !important;
    }
}

/* ===== موبایل کوچک ===== */
@media (max-width: 576px) {
    .products-toolbar {
        gap: 8px;
        margin-bottom: 1rem;
    }
    .products-toolbar .filter-toggle-btn,
    .products-toolbar .sort-mobile-btn {
        height: 38px !important;
        min-height: 38px !important;
        max-height: 38px !important;
        padding: 0 8px !important;
        font-size: 0.78rem;
        gap: 4px;
    }
    .products-toolbar .filter-toggle-btn svg {
        width: 15px;
        height: 15px;
    }
    .products-toolbar .sort-mobile-btn lord-icon {
        width: 18px !important;
        height: 18px !important;
    }
}

@media (max-width: 380px) {
    .products-toolbar .filter-toggle-btn,
    .products-toolbar .sort-mobile-btn {
        font-size: 0.72rem;
        padding: 0 6px !important;
    }
}

/* ===== ریسپانسیو ===== */
@media (max-width: 991px) {
    .sort-modal .modal-dialog {
        margin: auto 8px;
    }
}