/* style.css — UI inspirée SNCF Connect : header navy, cartes lavande, score façon prix. */
:root {
  --navy: #0c1b2a;
  --navy-2: #182c42;
  --navy-3: #223a55;
  --lavender: #eef0f9;
  --card: #ffffff;
  --blue: #1173b5;
  --blue-dark: #0d5f96;
  --gold: #f5c944;
  --ink: #16202c;
  --muted: #5d6b7a;
  --line: #e3e6f2;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: "Nunito Sans", -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--lavender);
  display: flex;
  flex-direction: column;
}
button { font: inherit; }

#banner {
  background: #fdecec; color: #8f1d1d;
  border-bottom: 1px solid #f5c2c2;
  padding: 10px 24px; font-size: 14px;
}

/* ---------- header navy ---------- */
#topbar { background: var(--navy); color: #fff; padding: 18px 24px 14px; }
.topbar-row1 { display: flex; align-items: baseline; gap: 16px; margin-bottom: 14px; }
.topbar-row1 h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.tagline { font-size: 14px; color: #b9c4d4; font-weight: 400; }

.topbar-row2 { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.field {
  position: relative; flex: 1; min-width: 260px;
  display: flex; align-items: center; gap: 8px;
  background: var(--navy-2); border: 1px solid var(--navy-3);
  border-radius: 10px; padding: 0 14px; min-height: 46px; flex-wrap: wrap;
}
.field-label { color: #8fa2b8; font-size: 15px; font-weight: 600; white-space: nowrap; }
#naf-search {
  flex: 1; min-width: 140px; background: none; border: 0; outline: none;
  color: #fff; font: inherit; font-size: 15px; font-weight: 600; padding: 12px 0;
}
#naf-search::placeholder { color: #6d8098; font-weight: 400; }
.field:focus-within { border-color: var(--blue); }
#naf-chips { display: contents; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--navy-3); color: #dfe8f2;
  border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600;
  margin: 6px 0;
}
.chip button {
  border: 0; background: none; cursor: pointer; color: #9db1c7;
  font-size: 15px; line-height: 1; padding: 0;
}
.chip button:hover { color: #fff; }
#naf-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--card); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(12, 27, 42, 0.25);
  max-height: 260px; overflow-y: auto;
}
#naf-results:empty { display: none; }
#naf-results button {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  cursor: pointer; padding: 10px 14px; font-size: 14px; color: var(--ink);
}
#naf-results button:hover, #naf-results button:focus-visible { background: var(--lavender); }

#export-csv {
  display: flex; align-items: center; gap: 8px;
  background: var(--navy-2); border: 1px solid var(--navy-3); border-radius: 10px;
  color: #fff; font-size: 15px; font-weight: 700; padding: 0 18px; cursor: pointer;
}
#export-csv:hover:not(:disabled) { border-color: var(--blue); }
#export-csv:disabled { color: #5c7089; cursor: default; }

.topbar-row3 { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.filter-label { font-size: 14px; font-weight: 700; margin-right: 4px; }
.wpill {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: 1.5px solid var(--navy-3); border-radius: 999px;
  color: #fff; font-size: 13.5px; font-weight: 600; padding: 7px 13px; cursor: pointer;
}
.wpill b { font-weight: 800; }
.wpill .plus {
  display: inline-flex; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; color: var(--navy); align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; line-height: 1;
}
.wpill:hover, .wpill[aria-expanded="true"] { border-color: var(--blue); background: var(--navy-2); }

/* ---------- contenu ---------- */
main { flex: 1; padding: 18px 24px 24px; display: flex; flex-direction: column; gap: 16px; min-height: 0; }

.preset-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.pcard {
  background: var(--card); border: 0; border-radius: 10px; cursor: pointer;
  padding: 10px 22px; text-align: center; min-width: 150px;
  box-shadow: 0 1px 3px rgba(12, 27, 42, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.pcard:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(12, 27, 42, 0.12); }
.pcard .pcard-name { display: block; font-size: 14px; font-weight: 700; }
.pcard .pcard-sub { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.pcard.on { background: var(--blue); color: #fff; position: relative; }
.pcard.on .pcard-sub { color: #cfe6f6; }
.pcard.on::after {
  content: ""; position: absolute; left: 50%; bottom: -5px;
  width: 10px; height: 10px; background: var(--blue);
  transform: translateX(-50%) rotate(45deg); border-radius: 2px;
}

#content { flex: 1; display: flex; gap: 16px; min-height: 0; }
#results-col { width: 460px; display: flex; flex-direction: column; min-height: 0; }
#map-col { flex: 1; min-width: 0; }
#map {
  height: 100%; min-height: 420px; border-radius: 14px; overflow: hidden;
  background: #dfe4f0; box-shadow: 0 1px 3px rgba(12, 27, 42, 0.08);
}

.list-tabs {
  display: flex; align-items: flex-end; gap: 22px;
  border-bottom: 2px solid var(--line); margin-bottom: 12px; padding: 0 4px;
}
.list-tabs .tab {
  background: none; border: 0; cursor: pointer;
  font-size: 15px; font-weight: 700; color: var(--muted);
  padding: 8px 2px 10px; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.list-tabs .tab.on { color: var(--blue); border-bottom-color: var(--blue); }
.cols-head { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--muted); padding-bottom: 10px; }

#top10 { list-style: none; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 2px; }
.rcard {
  background: var(--card); border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(12, 27, 42, 0.08);
  display: grid; grid-template-columns: 52px 1fr auto auto; gap: 14px; align-items: center;
}
.rcard .dept-badge {
  width: 52px; height: 52px; border-radius: 10px;
  border: 1.5px solid var(--line); display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.rcard .dept-badge .code { font-size: 17px; font-weight: 800; color: #a0233c; letter-spacing: 0.02em; }
.rcard .dept-badge .rank { font-size: 10px; font-weight: 700; color: var(--muted); }
.rcard .body .name { font-size: 15.5px; font-weight: 800; }
.rcard .body .stats {
  display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px;
  font-size: 12.5px; color: var(--muted); font-weight: 600;
}
.rcard .stats svg { width: 12px; height: 12px; vertical-align: -1.5px; margin-right: 3px; stroke: var(--muted); fill: none; stroke-width: 1.8; }
.rcard .score { text-align: right; min-width: 64px; }
.rcard .score .des { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.rcard .score .val { font-size: 21px; font-weight: 800; }
.rcard .score .val small { font-size: 12px; font-weight: 700; color: var(--muted); }
.rcard .best {
  display: inline-block; background: var(--gold); color: #4d3a00;
  font-size: 11.5px; font-weight: 800; border-radius: 6px; padding: 2px 8px; margin-bottom: 3px;
}
.rcard .expand {
  border: 0; background: var(--lavender); color: var(--blue); cursor: pointer;
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
}
.rcard .expand svg { width: 14px; height: 14px; transition: transform 0.15s ease; stroke: var(--blue); fill: none; stroke-width: 2.4; }
.rcard.open .expand svg { transform: rotate(180deg); }
.rcard .breakdown {
  grid-column: 1 / -1; display: none; border-top: 1px solid var(--line);
  padding-top: 10px; margin-top: 2px;
}
.rcard.open .breakdown { display: grid; gap: 6px; }
.brow { display: grid; grid-template-columns: 120px 1fr 34px; gap: 10px; align-items: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.brow .bar { height: 7px; border-radius: 999px; background: var(--lavender); overflow: hidden; }
.brow .bar i { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.brow .bval { text-align: right; color: var(--ink); }
.rcard-cta {
  border: 1.5px solid #bcd6ea; background: #f3f8fc; color: var(--blue);
  font-size: 13px; font-weight: 700; border-radius: 9px; padding: 8px 12px; cursor: pointer;
  white-space: nowrap;
}
.rcard-cta:hover { background: #e6f1f9; }

.empty-card {
  background: var(--card); border-radius: 12px; padding: 22px;
  color: var(--muted); font-size: 14px; font-weight: 600; text-align: center;
}

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media (max-width: 900px) {
  #content { flex-direction: column-reverse; }
  #results-col { width: 100%; }
  #map { min-height: 300px; height: 320px; }
}
.maplibregl-popup-content {
  font-family: inherit; font-size: 12.5px; line-height: 1.55;
  border-radius: 10px; box-shadow: 0 6px 20px rgba(12, 27, 42, 0.2);
}

/* ---------- filtres d'intention + mode expert ---------- */
.wpill.active { background: var(--blue); border-color: var(--blue); }
#expert-toggle {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  color: #8fa2b8; font-size: 13px; font-weight: 700; text-decoration: underline;
  padding: 6px 4px;
}
#expert-toggle:hover { color: #fff; }
#filter-panel {
  margin-top: 12px; background: var(--card); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 8px;
}
#filter-panel[hidden] { display: none; }
.fopt {
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.fopt:hover { border-color: var(--blue); color: var(--blue); }
.fopt.on { background: var(--blue); border-color: var(--blue); color: #fff; }
#expert-panel {
  margin-top: 12px; background: var(--card); border-radius: 12px;
  padding: 14px 18px; color: var(--ink);
}
#expert-panel[hidden] { display: none; }
#expert-summary { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 12px; }
.expert-sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px 24px; }
.expert-sliders label { font-size: 13px; font-weight: 700; color: var(--muted); }
.expert-sliders output { float: right; color: var(--ink); }
.expert-sliders input[type="range"] { width: 100%; accent-color: var(--blue); }
.expert-note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.expert-note code { font-family: ui-monospace, monospace; }

/* ---------- analyse de problématique (modal) ---------- */
#analyse-open {
  display: flex; align-items: center; gap: 8px;
  background: var(--blue); border: 1px solid var(--blue); border-radius: 10px;
  color: #fff; font-size: 15px; font-weight: 700; padding: 0 18px; cursor: pointer;
}
#analyse-open:hover { background: var(--blue-dark); }
#analyse-modal {
  border: 0; border-radius: 16px; padding: 22px 24px;
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  box-shadow: 0 24px 64px rgba(12, 27, 42, 0.35);
  font-family: inherit; color: var(--ink);
}
#analyse-modal::backdrop { background: rgba(12, 27, 42, 0.55); }
.an-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.an-head h2 { font-size: 18px; font-weight: 800; }
.an-actions { display: flex; gap: 8px; }
.an-badge {
  border: 1.5px solid var(--line); border-radius: 8px; align-self: center;
  font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 10px;
}
#analyse-close {
  border: 0; background: var(--lavender); border-radius: 8px; width: 30px; height: 30px;
  font-size: 18px; cursor: pointer; color: var(--muted);
}
.an-sub { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
#analyse-input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 14px; resize: vertical;
}
#analyse-input:focus { outline: none; border-color: var(--blue); }
.an-go {
  margin-top: 10px; background: var(--navy); color: #fff; border: 0; border-radius: 10px;
  font-size: 15px; font-weight: 700; padding: 10px 22px; cursor: pointer;
}
.an-go:hover { background: var(--navy-2); }
#analyse-result { margin-top: 14px; }
.an-block { border-top: 1px solid var(--line); padding: 12px 0; }
.an-block h3 { font-size: 14px; font-weight: 800; margin-bottom: 8px; }
.an-hint { font-size: 12px; color: var(--muted); font-weight: 600; }
.an-block.win { background: #f3f8fc; border-radius: 10px; padding: 12px 14px; border-top: 0; }
.an-icp, .an-sol {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  font-size: 13.5px;
}
.an-icp.win, .an-sol.win { border-color: var(--gold); background: #fffdf2; }
.an-icp-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.an-type {
  font-size: 11px; font-weight: 800; color: var(--blue); background: #eaf3fa;
  border-radius: 5px; padding: 2px 6px;
}
.an-score { margin-left: auto; font-size: 16px; font-weight: 800; }
.an-score small { font-size: 11px; color: var(--muted); }
.an-axes { color: var(--muted); font-size: 12px; font-weight: 700; margin: 4px 0; }
.an-err { color: #8f1d1d; font-size: 13.5px; font-weight: 600; }
.an-wait { color: var(--muted); font-size: 13.5px; font-weight: 600; }
