/* ══════════════════════════════════════════════════════
 * SIDEBAR FILTER — shared across all pages
 * ══════════════════════════════════════════════════════ */

/* ── Base sidebar ── */
.filter-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--g2);
  padding: 20px 16px 40px;
  position: sticky;
  top: 107px;
  height: calc(100vh - 107px);
  overflow-y: auto;
  z-index: 10;
  scrollbar-width: thin;
  scrollbar-color: var(--g2) transparent;
}
.filter-sidebar::-webkit-scrollbar { width: 3px; }
.filter-sidebar::-webkit-scrollbar-thumb { background: var(--g2); border-radius: 2px; }

.sb-mobile-header { display: none; padding-right: 40px; }
.sb-mobile-title { font-size: 16px; font-weight: 900; color: var(--d); }
.sb-mobile-close {
  position: absolute; top: 12px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: var(--g1); cursor: pointer; display: flex;
  align-items: center; justify-content: center; color: var(--g5);
  transition: background .2s, color .2s; z-index: 2;
}
.sb-mobile-close:hover { background: var(--g2); color: var(--d); }

/* ── Search input ── */
.sb-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--g1); border: 1.5px solid var(--g2);
  border-radius: 50px; padding: 9px 14px; margin-bottom: 18px;
  transition: border-color .15s;
}
.sb-search:focus-within { border-color: var(--y); background: #fff; }
.sb-search input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 12.5px; color: var(--d); font-family: inherit;
}
.sb-search input::placeholder { color: var(--g4); }
.sb-search-clear {
  background: none; border: none; cursor: pointer; color: var(--g4);
  padding: 2px; display: flex; align-items: center;
}

/* ── Section headings ── */
.sb-section-title {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; color: var(--g4); margin-bottom: 0;
}
.sb-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.sb-section-clear {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 11px; color: var(--r); font-weight: 600; padding: 0;
  text-decoration: underline; text-underline-offset: 2px;
  transition: opacity .15s;
}
.sb-section-clear:hover { opacity: .7; }
.sb-section-clear--inside {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 11px; color: var(--r); font-weight: 600; padding: 0;
  margin-left: auto; margin-right: 8px;
  text-decoration: underline; text-underline-offset: 2px;
}
.sb-section-clear--inside:hover { opacity: .7; }
.sb-field-label {
  display: block; font-size: 10px; font-weight: 700; color: var(--g4);
  margin-bottom: 4px; letter-spacing: .02em;
}

/* ── Brand grid ── */
.sb-brand-grid {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 6px; margin-bottom: 10px;
}
.sb-brand-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; border: 1.5px solid var(--g2);
  border-radius: 10px; cursor: pointer; transition: all .15s;
  background: #fff; font-family: inherit;
}
.sb-brand-btn:hover, .sb-brand-btn.active {
  border-color: var(--y); background: var(--yl);
}
.sb-brand-logo {
  width: 32px; height: 26px; display: flex;
  align-items: center; justify-content: center;
}
.sb-brand-logo img { border-radius: 4px; }
.sb-brand-initial {
  font-size: 16px; font-weight: 900; color: var(--d);
  width: 32px; height: 26px; display: flex;
  align-items: center; justify-content: center;
  background: var(--g1); border-radius: 4px;
}
.sb-brand-btn span {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em; color: var(--g6);
}

/* ── Collapsible sections ── */
.sb-collapse-section { margin: 0; }
.sb-collapse-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 0; border: none; border-radius: 0;
  background: none; cursor: pointer; font-family: inherit;
  font-size: 14px; font-weight: 800; color: var(--d);
  transition: all .15s;
}
.sb-collapse-toggle:hover { color: var(--r); }
.sb-collapse-label { flex: 1; text-align: left; }
.sb-collapse-icon {
  transition: transform .25s ease; flex-shrink: 0;
  color: var(--r);
}
.sb-collapse-toggle.open .sb-collapse-icon { transform: rotate(180deg); }
.sb-collapse-body { display: none; overflow: hidden; }
.sb-collapse-body.open {
  display: block; padding-top: 12px;
  animation: sbSlideDown .25s ease;
}
.sb-collapse-clear { display: block; margin-top: 8px; margin-left: auto; }
@keyframes sbSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Body type grid ── */
.sb-body-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.sb-body-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; border: 1.5px solid var(--g2);
  border-radius: 10px; cursor: pointer; transition: all .15s;
  background: #fff; font-family: inherit;
}
.sb-body-btn:hover, .sb-body-btn.active { border-color: var(--y); background: var(--yl); }
.sb-body-btn img { width: 48px; height: 28px; object-fit: contain; }
.sb-body-btn span { font-size: 9px; font-weight: 700; color: var(--g6); text-align: center; line-height: 1.2; }

/* ── Select / Range ── */
.sb-select-wrap { position: relative; margin-bottom: 6px; }
.sb-select-wrap select {
  width: 100%; padding: 9px 32px 9px 12px;
  border: 1.5px solid var(--g2); border-radius: 10px;
  font-size: 12.5px; color: var(--d); background: #fff;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  font-family: inherit; transition: border-color .15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.sb-select-wrap select:focus { outline: none; border-color: var(--y); }
.sb-range-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.sb-range-row .sb-select-wrap { flex: 1; margin-bottom: 0; }
.sb-range-sep { color: var(--g4); font-size: 13px; flex-shrink: 0; }

/* ── Price fields ── */
.sb-price-field { flex: 1; }
.sb-price-field input {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--g2); border-radius: 10px;
  font-size: 12.5px; color: var(--d); font-family: inherit; background: #fff;
}
.sb-price-field input:focus { outline: none; border-color: var(--y); }
.sb-price-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; margin-bottom: 4px; }
.sb-chip {
  padding: 5px 10px; border-radius: 50px; border: 1.5px solid var(--g2);
  background: #fff; font-size: 11px; font-weight: 600; color: var(--g6);
  cursor: pointer; font-family: inherit; transition: all .15s; white-space: nowrap;
}
.sb-chip:hover, .sb-chip.active { border-color: var(--r); color: var(--r); background: #fff5f5; }

/* ── Divider ── */
.sb-divider { height: 1px; background: var(--g2); margin: 14px 0; }

/* ── Master toggle ── */
.sb-master-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 10px 0; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 800;
  color: var(--r); transition: opacity .15s; margin-bottom: 12px;
}
.sb-master-toggle:hover { opacity: .7; }
.sb-master-toggle-icon { color: var(--r); flex-shrink: 0; transition: transform .25s ease; }
.sb-master-toggle.collapsed .sb-master-toggle-icon { transform: rotate(90deg); }
#advancedFiltersGroup { transition: opacity .2s ease; }
#advancedFiltersGroup.hidden { display: none; }

/* ── Action buttons ── */
.sb-search-btn {
  width: 100%; padding: 12px; border-radius: 50px; border: none;
  background: var(--d); color: #fff; font-size: 14px; font-weight: 800;
  font-family: inherit; cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px; transition: all .2s; margin-bottom: 8px;
  box-shadow: 0 4px 16px rgba(27,40,56,.2);
}
.sb-search-btn:hover { background: var(--dl); transform: translateY(-1px); }
.sb-search-count {
  background: var(--y); color: var(--d); font-size: 11px;
  font-weight: 900; padding: 1px 8px; border-radius: 50px;
  min-width: 20px; text-align: center;
}
.sb-reset-btn {
  width: 100%; padding: 8px; border: none; background: none;
  font-size: 12px; color: var(--g4); cursor: pointer; font-family: inherit;
  text-decoration: underline; text-underline-offset: 3px;
}
.sb-reset-btn:hover { color: var(--g6); }

/* ── Recently viewed ── */
.sb-recent-list { display: flex; flex-direction: column; gap: 10px; }
.sb-recent-item {
  display: flex; gap: 10px; text-decoration: none; color: inherit;
  padding: 8px; border-radius: 8px; transition: background .15s;
}
.sb-recent-item:hover { background: var(--g1, #f5f5f5); }
.sb-recent-img { width: 72px; height: 52px; border-radius: 6px; object-fit: cover; background: var(--g2, #eee); flex-shrink: 0; }
.sb-recent-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.sb-recent-title { font-size: 12px; font-weight: 600; color: var(--d, #1B2838); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-recent-meta { font-size: 11px; color: var(--g4, #888); }
.sb-recent-price { font-size: 12px; font-weight: 700; color: var(--y, #F27F0C); }
.sb-recent-stars { display: inline-flex; align-items: center; gap: 2px; font-size: 10px; color: var(--g4, #999); }

/* ── Overlay ── */
.sb-overlay {
  display: none; position: fixed; inset: 0; z-index: 1400;
  background: rgba(0,0,0,.45); backdrop-filter: blur(3px);
}


/* ══════════════════════════════════════════════════════
 * RESPONSIVE — Tablet & Mobile: slide-in from right
 * ══════════════════════════════════════════════════════ */
@media (max-width: 1099px) {
  .filter-sidebar {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 1500;
    width: 300px; transform: translateX(100%);
    transition: transform .25s cubic-bezier(.32,.72,0,1);
    height: 100vh; visibility: hidden;
  }
  .filter-sidebar.open { transform: translateX(0); visibility: visible; }
  .sb-overlay.open { display: block; }
  .sb-mobile-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 0 14px; margin-bottom: 14px; border-bottom: 2px solid var(--y);
  }
}

/* ── Mobile ── */
@media (max-width: 639px) {
  .filter-sidebar { width: 100%; padding: 16px 14px 32px; }
  .sb-mobile-header { padding: 0 0 10px; margin-bottom: 10px; }
  .sb-mobile-title { font-size: 14px; }
  .sb-search { padding: 7px 12px; margin-bottom: 12px; }
  .sb-search input { font-size: 12px; }
  .sb-section-head { margin-bottom: 6px; }
  .sb-section-title { font-size: 10px; }
  .sb-brand-grid { gap: 5px; margin-bottom: 8px; }
  .sb-brand-btn { padding: 7px 4px 5px; gap: 2px; border-radius: 8px; }
  .sb-brand-logo { width: 28px; height: 22px; }
  .sb-brand-logo img { width: 24px !important; height: 24px !important; }
  .sb-brand-btn span { font-size: 8px; }
  .sb-select-wrap select { padding: 7px 28px 7px 10px; font-size: 11px; border-radius: 8px; }
  .sb-range-row { gap: 4px; margin-bottom: 4px; }
  .sb-divider { margin: 10px 0; }
  .sb-collapse-toggle { font-size: 12px; }
  .sb-collapse-body.open { padding-top: 8px; }
  .sb-price-field input { padding: 7px 10px; font-size: 11px; border-radius: 8px; }
  .sb-field-label { font-size: 9px; margin-bottom: 2px; }
  .sb-master-toggle { font-size: 12px; padding: 6px 0; margin-bottom: 8px; }
  .sb-search-btn { padding: 10px; font-size: 13px; }
  .sb-recent { display: none !important; }
}
