/* detection-bureaux — design pro avec relief, ombres, transitions
   Palette : anthracite, beige, accents bleu profond + rouge alerte
*/

:root {
  --bg:           #f4f1ec;
  --bg-elevated: #ffffff;
  --bg-sidebar:  #1f2433;
  --ink:         #14181f;
  --ink-soft:    #4a5263;
  --line:        #d8d1c7;
  --line-strong: #b9b1a3;
  --accent:      #2c5282;
  --accent-2:    #1a365d;
  --warn:        #c05621;
  --alert:       #c53030;
  --ok:          #2f855a;

  --shadow-sm: 0 1px 3px rgba(20,24,31,0.08), 0 1px 2px rgba(20,24,31,0.06);
  --shadow-md: 0 4px 12px rgba(20,24,31,0.10), 0 2px 4px rgba(20,24,31,0.06);
  --shadow-lg: 0 12px 32px rgba(20,24,31,0.14), 0 4px 8px rgba(20,24,31,0.08);

  --radius:    8px;
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

/* ────────── TOPBAR ────────── */
.topbar {
  background: linear-gradient(180deg, #14181f 0%, #1f2433 100%);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  color: var(--alert);
  font-size: 18px;
  text-shadow: 0 0 8px rgba(197,48,48,0.6);
}
.brand-name {
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 16px;
}
.brand-zone {
  color: #9ba3b3;
  font-size: 12px;
  padding-left: 12px;
  border-left: 1px solid #3a4156;
  margin-left: 4px;
}
.topbar-stats {
  font-size: 12px;
  color: #c8cdd9;
  font-variant-numeric: tabular-nums;
}

/* ────────── LAYOUT ────────── */
.layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ────────── SIDEBAR ────────── */
.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--line);
  padding: 18px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  box-shadow: inset -3px 0 8px rgba(0,0,0,0.03);
}
.filter-group {
  border: none;
  margin: 0 0 18px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group legend {
  font-weight: 600;
  color: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  padding: 0;
}
.filter-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}
.filter-group label:hover { color: var(--ink); }
.filter-group input[type="checkbox"],
.filter-group input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}
.filter-group input[type="number"],
.filter-group input[type="search"],
.filter-group select {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(44,82,130,0.12);
}
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
}
.grid-2 input { min-width: 0; }
.hint {
  font-size: 11px;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 2px;
}

.btn-primary, .btn-secondary {
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all var(--transition);
  width: 100%;
}
.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
  margin-top: 6px;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: transparent;
  color: var(--ink-soft);
  margin-top: 6px;
  border: 1px solid var(--line-strong);
}
.btn-secondary:hover { background: var(--bg); }

/* ────────── RÉSULTATS ────────── */
.results {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.results-header {
  padding: 12px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.results-count {
  font-size: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.results-count strong { color: var(--accent); font-size: 16px; }
.results-views { display: flex; gap: 4px; }
.tab {
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-soft);
  border-radius: 6px;
  transition: all var(--transition);
  font-family: inherit;
  font-weight: 500;
}
.tab:hover { color: var(--ink); }
.tab-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.results-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.list-view, .map-view {
  height: 100%;
  overflow: auto;
}
.list-view { padding: 14px 20px; }
.map-view #map { height: 100%; width: 100%; }

/* ────────── ANNONCE (carte) ────────── */
.ad {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  cursor: pointer;
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 14px;
  align-items: stretch;
}
.ad-thumb-wrap {
  position: relative;
  width: 140px;
  height: 100px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.ad-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 320ms ease;
}
.ad:hover .ad-thumb { transform: scale(1.04); }
.ad-thumb-count {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(20,24,31,0.78);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.ad-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 22px;
  font-weight: 300;
  background: repeating-linear-gradient(45deg, #f4f1ec 0 8px, #ede8df 8px 16px);
}
.ad-content { min-width: 0; }
.ad:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-color: var(--line-strong);
}
.ad-title {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.3;
}
.ad-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.ad-loc { color: var(--ink); font-weight: 500; }
.ad-signals {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.signal {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.signal-anonymized { background: #fed7d7; color: var(--alert); }
.signal-decreased  { background: #feebc8; color: var(--warn); }
.signal-big        { background: #c6e2f0; color: var(--accent-2); }
.signal-traineur   { background: var(--alert); color: #fff; }

.ad-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ad-price-main {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}
.ad-price-pps {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.ad-surface {
  font-size: 13px;
  color: var(--accent-2);
  font-weight: 600;
  margin-top: 6px;
}

.ad-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
  font-style: italic;
}

/* ────────── MODALE DÉTAIL ────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,24,31,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.detail-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 30px;
  max-width: 720px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.detail-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--ink-soft);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: background var(--transition);
}
.detail-close:hover { background: var(--bg); color: var(--ink); }

.detail-card h2 {
  margin: 0 0 6px 0;
  font-size: 20px;
  color: var(--ink);
}
.detail-card .detail-meta { color: var(--ink-soft); font-size: 13px; margin-bottom: 16px; }
.detail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  margin: 16px 0;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.detail-gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  transition: transform var(--transition);
  background: var(--line);
}
.detail-gallery img:hover { transform: scale(1.02); }

.phone-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.phone-link:hover { text-decoration: underline; }
.muted { color: var(--ink-soft); font-style: italic; font-size: 12px; }

/* ────────── LIGHTBOX ────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 25, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
}
.lb-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  background: #1a1a1a;
}
.lb-close, .lb-prev, .lb-next {
  position: absolute;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  transition: background var(--transition), transform var(--transition);
  font-family: inherit;
  backdrop-filter: blur(4px);
}
.lb-close {
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  font-size: 22px;
}
.lb-prev, .lb-next {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  font-size: 30px;
  line-height: 1;
  padding: 0;
}
.lb-prev { left: 24px; }
.lb-next { right: 24px; }
.lb-close:hover, .lb-prev:hover, .lb-next:hover {
  background: rgba(255,255,255,0.22);
}
.lb-prev:hover, .lb-next:hover { transform: translateY(-50%) scale(1.05); }
.lb-counter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.detail-card .detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin: 16px 0;
  padding: 14px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.detail-card .detail-grid dt { color: var(--ink-soft); font-size: 12px; }
.detail-card .detail-grid dd { margin: 0 0 6px 0; font-weight: 600; }
.detail-card .detail-desc {
  margin-top: 12px;
  padding: 14px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--line);
}
.detail-card .detail-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.detail-card .detail-link:hover { text-decoration: underline; }
.detail-card .price-timeline {
  margin-top: 12px;
  padding: 14px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--line);
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

/* ────────── SCROLLBAR fine ────────── */
.sidebar::-webkit-scrollbar,
.list-view::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-thumb,
.list-view::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}

/* ────────── Responsive ────────── */

/* Écran moyen : sidebar plus étroite */
@media (max-width: 1200px) {
  .layout {
    grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  }
  .ad {
    grid-template-columns: 110px 1fr auto;
    gap: 10px;
    padding: 10px 12px;
  }
  .ad-thumb-wrap { width: 110px; height: 82px; }
}

/* Tablette : on garde split-view mais sidebar compacte */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  }
  .topbar-stats { font-size: 11px; }
}

/* Mobile : on empile (sidebar en haut, résultats en-dessous) */
@media (max-width: 700px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: calc(100vh - 56px);
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 50vh;
    box-shadow: inset 0 -3px 8px rgba(0,0,0,0.03);
  }
  .results { min-height: 60vh; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .brand-zone { display: none; }
  .ad {
    grid-template-columns: 100px 1fr;
    grid-template-rows: auto auto;
  }
  .ad-thumb-wrap { width: 100px; height: 76px; grid-row: 1 / 3; }
  .ad-price {
    grid-column: 2;
    text-align: left;
    display: flex;
    gap: 10px;
    align-items: baseline;
    flex-wrap: wrap;
  }
  .ad-price-main { font-size: 15px; }
  .ad-price-pps, .ad-surface { font-size: 12px; }
  .detail-card { padding: 20px; max-height: 95vh; }
  .detail-card .detail-grid { grid-template-columns: 1fr; }
  .results-header { padding: 10px 14px; }
  .list-view { padding: 12px 14px; }
}
