/* ════════════════════════════════════════
   PAGE LAYOUT
════════════════════════════════════════ */
.page-wrapper {
  display: flex;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--space-xl);
  gap: var(--space-xl);
  align-items: flex-start;
}

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: -webkit-sticky;
  position: sticky;
  top: calc(var(--banner-h) + var(--header-h));
  max-height: calc(100vh - var(--banner-h) - var(--header-h) - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  border: 1px solid var(--gray-200);
  box-shadow: none;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
  align-self: flex-start;
  z-index: 10;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

/* ── Filter Group ── */
.filter-group {
  border-bottom: 1px solid var(--gray-200);
}
.filter-group:last-child { border-bottom: none; }

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px var(--space-md);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  min-height: 56px;
}
.filter-header:hover { background: var(--gray-50); }

.filter-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--black);
}

.filter-chevron {
  width: 18px;
  height: 18px;
  color: var(--gray-500);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.filter-group.open .filter-chevron { transform: rotate(180deg); }

/* ── Filter Body ── */
.filter-body {
  display: none;
  padding: 4px var(--space-md) var(--space-md);
}
.filter-group.open .filter-body { display: block; }

/* ════════════════════════════════════════
   DEALS — checkbox simple "On sale"
════════════════════════════════════════ */
.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 14px;
  color: var(--black);
  line-height: 1.4;
  transition: color var(--transition);
}
.filter-option:hover { color: var(--gray-700); }

/* Checkbox custom — carré arrondi */
.filter-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  background: var(--white);
  transition: all var(--transition);
}
.filter-option input[type="checkbox"]:checked {
  background: var(--black);
  border-color: var(--black);
}
.filter-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: 2px solid var(--white);
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}
.filter-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--gray-400);
}

/* ════════════════════════════════════════
   PRICE & PAYMENT
════════════════════════════════════════ */

/* Toggle Cash / Finance */
.price-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-pill);
  padding: 3px;
  margin-bottom: var(--space-md);
  width: 100%;
}
.price-toggle-btn {
  flex: 1;
  height: 34px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: var(--fw-medium);
  color: var(--gray-500);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.price-toggle-btn.active {
  background: var(--white);
  color: var(--black);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-sm);
}

/* Label "Price range" */
.price-range-label {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--black);
  margin-bottom: 10px;
  display: block;
}

/* Inputs min/max */
.price-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-md);
}
.price-input {
  flex: 1;
  height: 38px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: 0 10px;
  font-size: 14px;
  color: var(--black);
  background: var(--white);
  text-align: left;
  outline: none;
  transition: border-color var(--transition);
  width: 0; /* flex override */
}
.price-input:focus { border-color: var(--black); }
.price-input-sep {
  font-size: 16px;
  color: var(--gray-400);
  flex-shrink: 0;
}

/* Histogramme de distribution */
.price-histogram {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
  margin-bottom: 8px;
}
.histo-bar {
  flex: 1;
  background: var(--black);
  border-radius: 1px 1px 0 0;
  min-width: 3px;
  opacity: 0.85;
  transition: opacity var(--transition);
}
.histo-bar.out-range {
  background: var(--gray-300);
  opacity: 1;
}

/* Double range slider */
.range-wrap {
  position: relative;
  padding-top: 4px;
}
.range-track {
  position: relative;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
}
.range-fill {
  position: absolute;
  height: 100%;
  background: var(--black);
  border-radius: 2px;
}
input[type="range"].slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: transparent;
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  margin: 0;
}
input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--black);
  cursor: pointer;
  pointer-events: all;
  margin-top: -8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.20);
}
input[type="range"].slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--black);
  cursor: pointer;
  pointer-events: all;
}

/* ════════════════════════════════════════
   MAKE & MODEL — checkboxes liste
════════════════════════════════════════ */
.make-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}
/* Les filter-option dans make-list sont identiques aux autres */


/* ════════════════════════════════════════════════════════════
   ═══════════════  MOBILE / TABLET RESPONSIVE  ═══════════════
   Tout ce qui suit est additif. Aucune règle desktop ci-dessus
   n'est modifiée. Sous le breakpoint, .sidebar devient un
   drawer plein écran déclenché par le bouton "Filter".
════════════════════════════════════════════════════════════ */

@media (max-width: 1100px) {

  /* ── Overlay sombre derrière le drawer filtres ── */
  .filter-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
  }
  .filter-drawer-overlay.show {
    opacity: 1;
    visibility: visible;
  }

  /* ── La sidebar devient le drawer "Filters" ── */
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    z-index: 401;
    transform: translateX(100%);
    transition: transform .3s ease;
    display: flex;
    flex-direction: column;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* ── Header "Filters" avec bouton fermer ── */
  .filter-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px var(--space-md);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
  }
  .filter-drawer-header h2 {
    font-size: 18px;
    font-weight: var(--fw-bold);
    color: var(--black);
  }
  .filter-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    border: none;
    transition: background .15s;
    flex-shrink: 0;
  }
  .filter-drawer-close:hover { background: var(--gray-100); }
  .filter-drawer-close svg { width: 18px; height: 18px; color: var(--black); }

  /* ── Zone scrollable des groupes de filtres ── */
  .filter-drawer-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* ── Footer du drawer : bouton "Show results" ── */
  .filter-drawer-footer {
    flex-shrink: 0;
    padding: var(--space-md);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 10px;
  }
  .btn-clear-filters {
    flex-shrink: 0;
    height: 48px;
    padding: 0 18px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--black);
    font-size: 14px;
    font-weight: var(--fw-semibold);
    cursor: pointer;
    white-space: nowrap;
  }
  .btn-show-results {
    flex: 1;
    height: 48px;
    border-radius: var(--radius-pill);
    border: none;
    background: var(--black);
    color: var(--white);
    font-size: 14px;
    font-weight: var(--fw-semibold);
    cursor: pointer;
  }
}

@media (max-width: 480px) {
  .sidebar { max-width: 100%; }
}

/* ════════════════════════════════════════════════════════════
   SORT DROPDOWN / SHEET
════════════════════════════════════════════════════════════ */
.sort-dropdown {
  position: absolute;
  z-index: 250;
  background: var(--bg-white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}
.sort-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.sort-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 14.5px;
  color: var(--black);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background .15s;
}
.sort-option:hover { background: var(--gray-50); }
.sort-option.active {
  font-weight: var(--fw-semibold);
  background: var(--gray-100);
}
.sort-option.active::after {
  content: '✓';
  color: var(--black);
  font-weight: 700;
}

/* Sur mobile : le sort dropdown devient une sheet ancrée sous le bouton,
   pleine largeur disponible, comme dans l'aperçu iPhone fourni. */
@media (max-width: 1100px) {
  .sort-dropdown {
    right: var(--space-md);
    left: auto;
  }
}