/* product_list.css — Premium Sidebar-First E-commerce Listing */

:root {
    --ink: #111827;
    --ink-light: #6b7280;
    --ink-faint: #9ca3af;
    --paper: #f8fafc;
    --surface: #ffffff;
    --accent: #2563eb;
    --accent-soft: #eff6ff;
    --accent-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #f59e0b;
    --border: #e5e7eb;
    --border-light: #f1f5f9;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.03);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --transition: 200ms cubic-bezier(.4,0,.2,1);
    --transition-slow: 350ms cubic-bezier(.4,0,.2,1);
    /* ── Standardized sidebar tokens ── */
    --sidebar-gap: 12px;
    --card-header-h: 42px;
    --input-h: 36px;
    --input-border: 1.5px;
    --input-radius: var(--radius-sm);
    --input-px: 10px;
    --input-font: 13px;
    --item-py: 7px;
    --item-px: 8px;
    --item-font: 13px;
    --item-gap: 8px;
    --section-icon-size: 14px;
    --chevron-size: 22px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-primary);
    background: var(--paper);
    color: var(--ink);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════ */
.page-wrap {
    display: grid;
    /* 🟢 اصلاح: عرض سایدبار ثابت و محتوای اصلی منعطف */
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 24px 80px;
    align-items: start; /* 🟢 این دستور از کشیده شدن سایدبار در ارتفاع جلوگیری میکند */
}

/* ═══════════════════════════════════════
   SIDEBAR & CARDS
   ═══════════════════════════════════════ */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--sidebar-gap);
    position: sticky;
    top: 80px;
    align-self: start;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding-bottom: 40px;
    width: 100%; /* استفاده کامل از ستون 280 پیکسلی */
}

/* ── Filter Card ── */
.filter-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition), border-color var(--transition);
    /* 🟢 overflow:hidden از اینجا حذف شد تا سایه‌های فوکوس قطع نشود */
}

/* ── Filter Card Header ── */
.filter-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    min-height: 48px; /* 🟢 تضمین می‌کند که هدر در حالت بسته هم ارتفاع استاندارد دارد */
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
    background: #fafbfc;
    border-bottom: 1px solid var(--border-light);
}

/* ── Filter Card Body ── */
.filter-card-body {
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.3s ease;
    max-height: 1000px; /* مقدار کافی برای حالت باز */
    opacity: 1;
    padding: 14px;
}

/* 🟢 حالت Collapsed استاندارد */
.filter-card.collapsed .filter-card-body {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin: 0 !important;
    border-top-color: transparent !important;
}

/* ═══════════════════════════════════════
   SCROLLABLE LISTS (حداکثر 10 آیتم)
   ═══════════════════════════════════════ */
/* 🟢 اعمال اسکرول بار داخلی برای تمامی فیلترهای لیستی */
.filter-checkbox-list, 
.filter-cat-tree, 
.rating-options,
.badge-chip-list {
    max-height: 320px; /* ارتفاع تقریبی 10 آیتم */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding-right: 4px; /* فضای تنفس اسکرول */
}

/* 🟢 کلاس‌های مربوط به دکمه "نمایش بیشتر" JS را می‌توانید پاک کنید یا نادیده بگیرید */
.btn-show-more, .overflow-items { display: none !important; }

/* ═══════════════════════════════════════
   RESPONSIVE PREVENT SQUISH
   ═══════════════════════════════════════ */
@media (max-width: 1024px) and (min-width: 901px) {
    .page-wrap {
        grid-template-columns: 260px minmax(0, 1fr);
        gap: 16px;
    }
}
/* ═══════════════════════════════════════
   SEARCH — Main sidebar search
   ═══════════════════════════════════════ */
.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    border: var(--input-border) solid var(--border);
    border-radius: var(--input-radius);
    padding: 0 var(--input-px);
    height: var(--input-h);
    background: var(--paper);
    transition: all var(--transition);
}
.search-input-wrap:focus-within {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.search-input-wrap > i {
    color: var(--ink-faint);
    font-size: 14px;
    flex-shrink: 0;
}
.search-input-wrap input {
    border: none;
    background: none;
    outline: none;
    font-size: var(--input-font);
    font-family: var(--font-primary);
    color: var(--ink);
    width: 100%;
    height: 100%;
}
.search-input-wrap input::placeholder { color: var(--ink-faint); }
.search-clear-btn {
    background: none;
    border: none;
    color: var(--ink-faint);
    cursor: pointer;
    padding: 2px;
    font-size: 14px;
    transition: color var(--transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.search-clear-btn:hover { color: var(--danger); }

/* ═══════════════════════════════════════
   ACTIVE FILTER BAR
   ═══════════════════════════════════════ */
.active-filter-bar { margin: 0; }
.active-filter-bar:empty { display: none; }
.active-filter-bar-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    background: var(--accent-soft);
    border: 1px solid rgba(37,99,235,.12);
    border-radius: var(--radius);
}
.active-filter-bar-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}
.active-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.filter-chip-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--surface);
    color: var(--accent);
    border: 1px solid rgba(37,99,235,.15);
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}
.filter-chip-item button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    line-height: 1;
    opacity: .7;
    transition: opacity var(--transition);
    display: flex;
    align-items: center;
}
.filter-chip-item button:hover { opacity: 1; }
.clear-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: none;
    color: var(--danger);
    border: 1px solid rgba(220,38,38,.15);
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all var(--transition);
    align-self: flex-start;
    line-height: 1;
}
.clear-all-btn:hover {
    background: #fef2f2;
    border-color: rgba(220,38,38,.3);
}

/* ═══════════════════════════════════════
   SORT OPTIONS
   ═══════════════════════════════════════ */
.sort-options { display: flex; flex-direction: column; gap: 2px; }
.sort-option {
    display: flex;
    align-items: center;
    gap: var(--item-gap);
    padding: var(--item-py) var(--item-px);
    border-radius: var(--radius-xs);
    font-size: var(--item-font);
    font-weight: 500;
    color: var(--ink-light);
    text-decoration: none;
    transition: all var(--transition);
    cursor: pointer;
}
.sort-option:hover {
    background: var(--paper);
    color: var(--ink);
}
.sort-option.active {
    color: var(--accent);
    font-weight: 700;
    background: var(--accent-soft);
}
.sort-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: all var(--transition);
}
.sort-option.active .sort-dot {
    background: var(--accent);
    box-shadow: 0 0 6px rgba(37,99,235,.4);
}

/* ═══════════════════════════════════════
   INLINE SEARCH — within filter sections
   ═══════════════════════════════════════ */
.filter-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    border: var(--input-border) solid var(--border);
    border-radius: var(--input-radius);
    padding: 0 var(--input-px);
    height: 32px;
    background: var(--paper);
    margin-bottom: 10px;
    transition: all var(--transition);
}
.filter-search-wrap:focus-within {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(37,99,235,.06);
}
.filter-search-wrap i {
    color: var(--ink-faint);
    font-size: 12px;
    flex-shrink: 0;
}
.filter-search-wrap input {
    border: none;
    background: none;
    outline: none;
    font-size: 12px;
    font-family: var(--font-primary);
    color: var(--ink);
    width: 100%;
    height: 100%;
}

/* ═══════════════════════════════════════
   CATEGORY TREE
   ═══════════════════════════════════════ */
.filter-cat-tree, .cat-subtree { list-style: none; padding: 0; margin: 0; }
.cat-item { margin-bottom: 0; }
.cat-link-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--item-py) var(--item-px);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
}
.cat-link-wrapper:hover {
    background: var(--paper);
}
.cat-link-wrapper.active {
    background: var(--accent-soft);
}
.cat-link-wrapper.active .cat-name { color: var(--accent); font-weight: 700; }
.cat-name {
    font-size: var(--item-font);
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}
.cat-name a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cat-name a:hover { color: var(--accent); }
.filter-cat-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: var(--item-py) var(--item-px);
    border-radius: var(--radius-xs);
    font-size: var(--item-font);
    color: var(--ink-light);
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1.4;
}
.filter-cat-link:hover { background: var(--paper); color: var(--ink); }
.filter-cat-link.active { color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.filter-cat-link i { font-size: 12px; }
.cat-right { display: flex; align-items: center; gap: 4px; }
.cat-toggle {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-faint);
    font-size: 9px;
    transition: all var(--transition);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
}
.cat-toggle:hover { background: var(--border-light); color: var(--ink); }
.cat-item.open > .cat-link-wrapper .cat-toggle {
    transform: rotate(-90deg);
    color: var(--accent);
}
.cat-subtree {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow), opacity var(--transition);
    opacity: 0;
    padding-right: 14px;
}
.cat-subtree.show { max-height: 2000px; opacity: 1; }

/* ═══════════════════════════════════════
   PRICE RANGE
   ═══════════════════════════════════════ */
.price-range-inputs { display: flex; flex-direction: column; gap: 10px; }
.price-input-group { display: flex; flex-direction: column; gap: 4px; }
.price-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-light);
    line-height: 1;
}
.price-input-wrap {
    display: flex;
    align-items: center;
    border: var(--input-border) solid var(--border);
    border-radius: var(--input-radius);
    padding: 0 var(--input-px);
    height: var(--input-h);
    background: var(--paper);
    transition: all var(--transition);
}
.price-input-wrap:focus-within {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(37,99,235,.06);
}
.filter-price-input {
    border: none;
    background: none;
    outline: none;
    font-size: var(--input-font);
    font-family: var(--font-primary);
    color: var(--ink);
    width: 100%;
    height: 100%;
}
.filter-price-input::placeholder { color: var(--ink-faint); }
.price-unit {
    font-size: 11px;
    color: var(--ink-faint);
    white-space: nowrap;
    font-weight: 500;
    flex-shrink: 0;
}
.price-separator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
}
.price-sep-line {
    flex: 1;
    height: 1px;
    background: var(--border-light);
}
.price-separator span {
    font-size: 11px;
    color: var(--ink-faint);
    font-weight: 500;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════
   CHECKBOX LIST — Brands, etc.
   ═══════════════════════════════════════ */
.filter-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: var(--item-gap);
    padding: var(--item-py) var(--item-px);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background var(--transition);
    font-size: var(--item-font);
    color: var(--ink);
}
.filter-checkbox-item:hover { background: var(--paper); }
.filter-checkbox-item input[type="checkbox"] {
    display: none;
}
.filter-checkbox-mark {
    width: 16px;
    height: 16px;
    border: var(--input-border) solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
    position: relative;
}
.filter-checkbox-mark::after {
    content: '';
    width: 8px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) scale(0);
    transition: transform var(--transition);
    position: absolute;
    top: 2px;
    left: 2px;
}
.filter-checkbox-item.checked .filter-checkbox-mark,
.filter-checkbox-item:has(input:checked) .filter-checkbox-mark {
    background: var(--accent);
    border-color: var(--accent);
}
.filter-checkbox-item.checked .filter-checkbox-mark::after,
.filter-checkbox-item:has(input:checked) .filter-checkbox-mark::after {
    transform: rotate(-45deg) scale(1);
}
.filter-checkbox-label { flex: 1; min-width: 0; }

/* Show More */
.btn-show-more {
    display: block;
    width: 100%;
    background: none;
    border: none;
    border-top: 1px solid var(--border-light);
    margin-top: 2px;
    padding: 8px 0 0;
    font-size: 11px;
    font-family: var(--font-primary);
    color: var(--accent);
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    transition: opacity var(--transition);
}
.btn-show-more:hover { opacity: .7; }
.overflow-items {
    overflow: hidden;
    max-height: calc(6 * 34px);
}
.overflow-items.show-all { max-height: none; }

/* ═══════════════════════════════════════
   TOGGLE SWITCHES
   ═══════════════════════════════════════ */
.filter-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--item-py) 0;
    cursor: pointer;
    gap: 12px;
}
.filter-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--item-font);
    font-weight: 500;
    color: var(--ink);
}
.filter-toggle-label i {
    color: var(--accent);
    font-size: 13px;
}
.filter-toggle-item input { display: none; }
.filter-toggle-switch {
    width: 38px;
    height: 22px;
    border-radius: 11px;
    background: var(--border);
    position: relative;
    transition: background var(--transition);
    flex-shrink: 0;
}
.filter-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
    transition: transform var(--transition);
}
.filter-toggle-item input:checked + .filter-toggle-switch {
    background: var(--accent);
}
.filter-toggle-item input:checked + .filter-toggle-switch::after {
    transform: translateX(16px);
}

/* ═══════════════════════════════════════
   RATING OPTIONS
   ═══════════════════════════════════════ */
.rating-options { display: flex; flex-direction: column; gap: 0; }
.rating-option {
    display: flex;
    align-items: center;
    gap: var(--item-gap);
    padding: var(--item-py) var(--item-px);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background var(--transition);
    font-size: var(--item-font);
}
.rating-option:hover { background: var(--paper); }
.rating-option.active { background: var(--accent-soft); }
.rating-option input { display: none; }
.rating-stars-display {
    display: flex;
    gap: 1px;
    font-size: 11px;
}
.rating-stars-display .filled { color: #f59e0b; }
.rating-stars-display i:not(.filled) { color: var(--border); }
.rating-label {
    font-size: 11px;
    color: var(--ink-faint);
    font-weight: 500;
}
.rating-all-label {
    font-size: var(--item-font);
    color: var(--ink-light);
    font-weight: 500;
    padding: 0 2px;
}

/* ═══════════════════════════════════════
   BADGE CHIPS
   ═══════════════════════════════════════ */
.badge-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.badge-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: var(--input-border) solid var(--border);
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-primary);
    color: var(--ink-light);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface);
    line-height: 1;
}
.badge-chip:hover {
    border-color: var(--ink-faint);
    color: var(--ink);
}
.badge-chip.active,
.badge-chip:has(input:checked) {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.badge-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.badge-chip.active .badge-chip-dot,
.badge-chip:has(input:checked) .badge-chip-dot {
    box-shadow: 0 0 0 2px rgba(255,255,255,.4);
}

/* ═══════════════════════════════════════
   ATTRIBUTE TEXT INPUT
   ═══════════════════════════════════════ */
.filter-text-input {
    width: 100%;
    border: var(--input-border) solid var(--border);
    border-radius: var(--input-radius);
    padding: 0 var(--input-px);
    height: var(--input-h);
    font-size: var(--input-font);
    font-family: var(--font-primary);
    color: var(--ink);
    background: var(--paper);
    outline: none;
    transition: all var(--transition);
}
.filter-text-input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(37,99,235,.06);
}

/* ═══════════════════════════════════════
   FILTER ACTIONS
   ═══════════════════════════════════════ */
.filter-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.filter-btn-apply {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 40px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(37,99,235,.2);
}
.filter-btn-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(37,99,235,.3);
}
.filter-btn-reset {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 36px;
    background: var(--surface);
    color: var(--ink-light);
    border: var(--input-border) solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all var(--transition);
}
.filter-btn-reset:hover {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--ink-faint);
}

/* ═══════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════ */
.main-content { min-width: 0; }

/* ═══════════════════════════════════════
   WELCOME BANNER
   ═══════════════════════════════════════ */
.welcome-banner {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #ff006e, #8338ec, #3a86ff);
    color: #fff;
    padding: 1.2rem 0;
    text-align: center;
    border-radius: 16px;
    margin-bottom: 0.5rem;
}
.welcome-banner h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
    color: #fff;
}
.welcome-banner p {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.85);
    font-weight: 300;
    margin: 0;
}

@media (max-width: 768px) {
    .welcome-banner { padding: 0.9rem 0; border-radius: 12px; }
    .welcome-banner h1 { font-size: 1.2rem; }
    .welcome-banner p { font-size: 0.75rem; }
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-title .title-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.page-title-text {
    font-size: 20px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -.3px;
}
.count-chip {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-light);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 14px;
}

/* ═══════════════════════════════════════
   SORT BAR (Top — Minimal Tabs)
   ═══════════════════════════════════════ */
.sort-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 20px;
    border-bottom: 1.5px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.sort-bar::-webkit-scrollbar { display: none; }

.sort-bar-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-faint);
    background: transparent;
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -1.5px;
}
.sort-bar-item i {
    font-size: 13px;
    opacity: .6;
    transition: opacity var(--transition);
}
.sort-bar-item:hover {
    color: var(--ink-light);
}
.sort-bar-item:hover i {
    opacity: .8;
}
.sort-bar-item.active {
    color: var(--accent);
    font-weight: 700;
    border-bottom-color: var(--accent);
}
.sort-bar-item.active i {
    opacity: 1;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}

/* ═══════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════ */
.pagination-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 36px;
    flex-wrap: wrap;
}
.page-link {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-light);
    text-decoration: none;
    transition: all var(--transition);
    background: var(--surface);
    cursor: pointer;
}
.page-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}
.page-link.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.page-link.arrow { font-size: 11px; }

/* ═══════════════════════════════════════
   INFINITE SCROLL
   ═══════════════════════════════════════ */
#infiniteScrollSentinel {
    height: 1px;
    width: 100%;
}
.next-page-container {
    display: flex;
    justify-content: center;
    padding: 2.5rem 0;
}
.btn-next-page {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 2.5rem;
    background: var(--accent, #2563eb);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-next-page:hover {
    background: var(--accent-hover, #1d4ed8);
    transform: translateY(-1px);
    color: #fff;
}

/* ═══════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════ */
.empty-state { text-align: center; padding: 80px 24px; }
.empty-state .empty-icon {
    width: 80px; height: 80px;
    margin: 0 auto 20px;
    background: var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: var(--ink-faint);
}
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--ink-light); margin-bottom: 24px; }
.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    text-decoration: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
    font-family: var(--font-primary);
    background: none;
    cursor: pointer;
}
.btn-outline:hover { background: var(--accent); color: #fff; }

/* ═══════════════════════════════════════
   SKELETON LOADER — moved to static/css/loading.css
   Legacy classes kept here for backward compatibility.
   ═══════════════════════════════════════ */

.product-area-loading { position: relative; }
.product-area-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.7);
    z-index: 10;
    pointer-events: none;
    border-radius: var(--radius);
}

/* ═══════════════════════════════════════
   MOBILE ACTION BAR
   ═══════════════════════════════════════ */
.mobile-action-bar { display: none; }
@media (max-width: 900px) {
    .mobile-action-bar {
        display: flex;
        gap: 10px;
        padding: 0 14px 12px;
        position: sticky;
        top: 0;
        z-index: 50;
        background: var(--paper);
        border-bottom: 1px solid var(--border);
        padding-top: 10px;
    }
    .sidebar { display: none !important; }
}
.btn-mob {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 22px;
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-primary);
    cursor: pointer;
    border: 1.5px solid var(--border);
    transition: all var(--transition);
    position: relative;
}
.btn-mob-filter {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    flex: 1;
    justify-content: center;
}
.btn-mob-sort {
    background: var(--surface);
    color: var(--ink);
    flex: 1;
    justify-content: center;
}
.sort-active-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 8px;
    border-radius: 10px;
}
.filter-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════
   OFF-CANVAS DRAWER (Mobile)
   ═══════════════════════════════════════ */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    align-items: stretch;
    justify-content: flex-end;
}
.drawer-overlay.open {
    display: flex;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.drawer-panel {
    background: var(--surface);
    width: 85%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    animation: slideIn .25s cubic-bezier(.4,0,.2,1);
    box-shadow: -8px 0 30px rgba(0,0,0,.15);
}
@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.drawer-panel-sort { max-width: 320px; }

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.drawer-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.drawer-header-left i {
    color: var(--accent);
    font-size: 16px;
}
.drawer-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--ink);
}
.drawer-filter-count {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
.drawer-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--ink-light);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition);
}
.drawer-close:hover { background: var(--paper); }

.drawer-body {
    overflow-y: auto;
    flex: 1;
    padding: 0;
    scrollbar-width: thin;
}
.drawer-body .filter-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: 6px solid var(--paper);
    box-shadow: none;
}
.drawer-body .filter-card:hover {
    box-shadow: none;
}
.drawer-body .filter-card-header { border-bottom: none; }

.drawer-footer {
    display: flex;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}
.drawer-btn-reset {
    padding: 0 16px;
    height: 42px;
    background: var(--surface);
    color: var(--ink-light);
    border: var(--input-border) solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}
.drawer-btn-reset:hover { background: var(--paper); color: var(--ink); }
.drawer-btn-apply {
    flex: 1;
    height: 42px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.drawer-btn-apply:hover { background: var(--accent-hover); }

/* Sort in drawer */
.drawer-body .sort-options { padding: 8px 0; }
.drawer-body .sort-option { padding: 12px 18px; font-size: 14px; }
.sort-check { color: var(--accent); font-size: 16px; margin-right: auto; }

/* ═══════════════════════════════════════
   MOBILE ACTION BAR & RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 900px) {
    .mobile-action-bar {
        display: flex;
        gap: 10px;
        padding: 0 14px 12px;
        position: sticky;
        top: 0;
        z-index: 50;
        background: var(--paper);
        border-bottom: 1px solid var(--border);
        padding-top: 10px;
    }

    /* 🔴 کد قبلی که باعث خرابی میشد:
       .sidebar { display: none !important; } 
    */

    /* 🟢 راه حل صحیح: 
       سایدبار فقط زمانی مخفی شود که در ساختار اصلی صفحه (page-wrap) است. */
    .page-wrap > .sidebar { 
        display: none !important; 
    }

    /* 🟢 اطمینان از نمایش و رفتار صحیح سایدبار زمانی که داخل کشوی موبایل است */
    .drawer-body .sidebar {
        display: flex !important; /* خنثی کردن مخفی بودن */
        max-height: none !important; /* جلوگیری از اسکرول تو در تو */
        overflow-y: visible !important;
        padding-bottom: 20px;
    }

    /* حذف اسکرول تو در تو برای لیست‌های طولانی در موبایل */
    .drawer-body .filter-checkbox-list,
    .drawer-body .filter-cat-tree,
    .drawer-body .rating-options,
    .drawer-body .badge-chip-list {
        max-height: none !important;
        overflow-y: visible !important;
    }
}

/* ═══════════════════════════════════════
   RESPONSIVE — <=640px
   ═══════════════════════════════════════ */
@media (max-width: 640px) {
    .page-wrap { padding: 12px 10px 60px; gap: 12px; display: block; }
    .page-header { margin-bottom: 12px; }
    .page-title-text { font-size: 16px; }
    .count-chip { font-size: 11px; padding: 3px 10px; }
    .sort-bar { margin-bottom: 14px; gap: 0; }
    .sort-bar-item { padding: 9px 12px; font-size: 12px; }
    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .skeleton-grid,
    .ayak-skeleton-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .pagination-wrap { gap: 5px; margin-top: 24px; }
    .page-link { min-width: 32px; height: 32px; font-size: 12px; }
    .empty-state { padding: 60px 12px; }
}
