/* ============ GR Réunion Planner ============ */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #5f6b76;
  --line: #e1e6eb;
  --accent: #e63946;
  --header: #14313d;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 40, 60, .12);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
header {
  height: 54px;
  flex: 0 0 54px;
  background: var(--header);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  z-index: 20;
}
header .brand { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; white-space: nowrap; }
header .brand small { font-weight: 400; opacity: .75; margin-left: 8px; }
header .spacer { flex: 1; }
.seg {
  display: flex; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; overflow: hidden;
}
.seg button {
  background: transparent; color: #fff; border: 0; padding: 7px 14px; cursor: pointer; font-size: .85rem;
}
.seg button.on { background: #fff; color: var(--header); font-weight: 600; }
.hbtn {
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: .85rem;
}
.hbtn:hover { background: rgba(255,255,255,.22); }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 260px;
  background: var(--panel); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.dropdown-menu[hidden] { display: none; }
.dropdown-menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 7px;
  padding: 8px 10px; cursor: pointer; font-size: .82rem; color: var(--ink);
}
.dropdown-menu button:hover { background: var(--bg); }
.dropdown-menu button small { display: block; color: var(--muted); font-size: .68rem; font-weight: 400; }

/* ---------- Layout ---------- */
#layout { flex: 1; display: flex; min-height: 0; }
aside {
  width: 430px; flex: 0 0 430px; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
#map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

/* ---------- GR cards ---------- */
#gr-cards { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.gr-card {
  flex: 1; text-align: left; border: 2px solid var(--line); border-radius: var(--radius);
  background: #fff; padding: 8px 10px; cursor: pointer; transition: border-color .15s;
}
.gr-card:hover { border-color: #b9c4cd; }
.gr-card.on { border-color: var(--gr, var(--accent)); background: color-mix(in srgb, var(--gr, var(--accent)) 6%, #fff); }
.gr-card .gr-ref { font-weight: 700; font-size: .95rem; color: var(--gr, var(--accent)); }
.gr-card .gr-name { font-size: .72rem; color: var(--muted); margin-top: 2px; line-height: 1.25; }
.gr-card .gr-meta { font-size: .7rem; color: var(--ink); margin-top: 4px; font-weight: 600; }

/* ---------- Tabs ---------- */
#tabs { display: flex; border-bottom: 1px solid var(--line); }
#tabs button {
  flex: 1; background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 10px 4px; cursor: pointer; font-size: .85rem; color: var(--muted); font-weight: 600;
}
#tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.panel { flex: 1; overflow-y: auto; padding: 14px; min-height: 0; }
.panel[hidden] { display: none; }

/* ---------- Formulaire ---------- */
.gr-desc { font-size: .82rem; color: var(--muted); line-height: 1.45; margin: 0 0 12px; }
.cfg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 12px; }
.cfg label { display: flex; flex-direction: column; gap: 4px; font-size: .75rem; font-weight: 600; color: var(--muted); }
.cfg select, .cfg input[type=number] {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; font-size: .85rem;
  background: #fff; color: var(--ink); width: 100%;
}
.cfg .full { grid-column: 1 / -1; }
.chk { display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 500; color: var(--ink); flex-direction: row !important; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; }
.hint { font-size: .72rem; color: var(--muted); font-weight: 400; }

.box {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 12px;
}
.box > summary {
  font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .4px; cursor: pointer; user-select: none;
}
.box[open] > summary { margin-bottom: 6px; }
.box > div { padding-top: 2px; }
.st-row { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0 0; font-size: .82rem; }
.st-row .st-meta { color: var(--muted); font-size: .74rem; }
.st-timing {
  display: block; margin: 2px 0 8px 26px; font-size: .74rem; padding: 2px 4px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
.st-timing:disabled { opacity: .4; }
.night-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: .82rem; }
.night-row span { flex: 1; }
.night-row select { border: 1px solid var(--line); border-radius: 6px; font-size: .76rem; padding: 3px 4px; background: #fff; }
.night-row.flash { animation: night-flash 1.6s ease; border-radius: 6px; }
@keyframes night-flash {
  0%, 100% { background: transparent; }
  15%, 60% { background: #fff3cd; }
}

/* ---------- Alerte / résumé ---------- */
.warn {
  background: #fff6e5; border: 1px solid #f0d9a8; color: #7a5b13;
  border-radius: 8px; padding: 8px 10px; font-size: .8rem; margin-bottom: 10px;
}
.error-box { background: #fdecec; border: 1px solid #f2b8bc; color: #8f2430; border-radius: 8px; padding: 10px; font-size: .85rem; margin-bottom: 10px; }
#summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 6px; margin-bottom: 12px;
}
#summary .stat {
  background: var(--bg); border-radius: 8px; padding: 8px 6px; text-align: center;
}
#summary .stat b { display: block; font-size: .92rem; }
#summary .stat span { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
#summary .stat-hardest { border-left: 3px solid var(--muted); }
#summary .stat-hardest.d1 { border-left-color: #3a9d5d; }
#summary .stat-hardest.d2 { border-left-color: #e0a10c; }
#summary .stat-hardest.d3 { border-left-color: #e0670c; }
#summary .stat-hardest.d4 { border-left-color: #cb2431; }

/* ---------- Météo ---------- */
#weather { margin-bottom: 12px; }
#weather h4 { margin: 0 0 6px; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.wx-row { display: flex; gap: 6px; }
.wx-card { flex: 1; background: var(--bg); border-radius: 8px; text-align: center; padding: 6px 2px; font-size: .72rem; }
.wx-card .wx-emo { font-size: 1.2rem; display: block; }
.wx-card .wx-t { font-weight: 600; }
.wx-card .wx-p { color: var(--muted); }

/* ---------- Étapes ---------- */
.day-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  box-shadow: var(--shadow); padding: 12px; margin-bottom: 10px;
}
.day-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.day-head .day-num { font-weight: 700; font-size: .92rem; }
.badge { font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 20px; color: #fff; }
.badge.d1 { background: #3a9d5d; }
.badge.d2 { background: #e0a10c; }
.badge.d3 { background: #e0670c; }
.badge.d4 { background: #cb2431; }
.day-route { font-size: .92rem; font-weight: 600; margin: 2px 0; }
.day-via { font-size: .76rem; color: var(--muted); margin: 0 0 6px; }
.day-depart { font-size: .78rem; color: var(--ink); background: var(--bg); border-radius: 6px; padding: 4px 8px; margin: 0 0 6px; }
.day-depart em { color: var(--muted); font-style: normal; font-size: .72rem; }
.day-st { font-size: .78rem; color: #7a4bb8; margin: 2px 0 6px; }
.day-legs { list-style: none; margin: 4px 0 8px; padding: 0; border-left: 2px solid var(--line); }
.day-legs li { font-size: .78rem; padding: 3px 0 3px 10px; margin-left: -2px; border-left: 2px solid transparent; }
.day-legs li b { color: var(--muted); font-weight: 700; margin-right: 3px; }
.day-legs li span { display: block; color: var(--muted); font-size: .72rem; margin-left: 18px; }
.day-legs li.leg-st { border-left-color: #7a4bb8; color: #7a4bb8; }
.day-legs li.leg-st span { color: #7a4bb8; opacity: .8; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { background: var(--bg); border-radius: 6px; padding: 4px 8px; font-size: .76rem; font-weight: 600; }
.chip small { font-weight: 400; color: var(--muted); margin-right: 3px; }
.day-night { font-size: .78rem; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.day-night b { color: var(--ink); }
.day-night .addr { color: var(--muted); }
.day-actions { display: flex; gap: 8px; margin-top: 8px; }
.mini-btn {
  background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px;
  font-size: .73rem; cursor: pointer; color: var(--muted);
}
.mini-btn:hover { border-color: #9fb0bd; color: var(--ink); }
.profil { width: 100%; height: 64px; margin-top: 8px; display: block; }
.profil-area { fill: color-mix(in srgb, var(--gr, var(--accent)) 18%, #fff); stroke: none; }
.profil-line { fill: none; stroke: var(--gr, var(--accent)); stroke-width: 2; }
.profil-txt { font-size: 10px; fill: var(--muted); }

/* ---------- Infos pratiques ---------- */
.info-section h3 { font-size: .95rem; margin: 16px 0 8px; }
.info-section h3:first-child { margin-top: 0; }
.lodge { border-bottom: 1px solid var(--line); padding: 8px 0; font-size: .82rem; cursor: pointer; }
.lodge:hover { background: #fafbfc; }
.lodge b { display: block; }
.lodge .alt { color: var(--muted); font-weight: 400; font-size: .74rem; }
.lodge .g { color: var(--muted); margin-top: 2px; }
.poi-item { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .82rem; cursor: pointer; }
.poi-item:hover { background: #fafbfc; }
.poi-item .emo { font-size: 1.1rem; }
.poi-item p { margin: 2px 0 0; color: var(--muted); font-size: .76rem; }
.poi-item.water-broken b { color: #c62828; }
.addr-cat { margin-bottom: 10px; }
.addr-cat h4 { margin: 10px 0 4px; font-size: .8rem; }
.addr-item { font-size: .8rem; padding: 3px 0; }
.addr-item b { font-weight: 600; }
.addr-item .val { color: var(--accent); font-weight: 600; }

/* ---------- Préparation ---------- */
details.prep { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; background: #fff; }
details.prep summary {
  cursor: pointer; padding: 10px 12px; font-weight: 600; font-size: .88rem; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
details.prep summary::-webkit-details-marker { display: none; }
details.prep[open] summary { border-bottom: 1px solid var(--line); }
details.prep .prep-body { padding: 10px 14px; font-size: .82rem; line-height: 1.5; }
details.prep .prep-body h5 { margin: 12px 0 4px; font-size: .82rem; }
details.prep .prep-body p { margin: 4px 0; color: var(--ink); }
details.prep .prep-body ul { margin: 4px 0; padding-left: 18px; color: var(--ink); }
.ck { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.ck input { margin-top: 2px; accent-color: var(--accent); }
.ck .dtl { color: var(--muted); font-size: .75rem; display: block; }

/* ---------- Footer note ---------- */
.foot-note { padding: 8px 14px; font-size: .68rem; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- Marqueurs carte ---------- */
.mk { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.mk-night {
  width: 26px; height: 26px; border-radius: 50%; background: var(--header); color: #fff;
  font-weight: 700; font-size: .8rem; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.mk-start, .mk-end {
  width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 800; font-size: .85rem;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.mk-start { background: #2e7d32; }
.mk-end { background: #c62828; }
.mk-dot { width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 3px solid var(--gr-dot, #555); box-shadow: 0 0 4px rgba(0,0,0,.5); }
.mk-lodge {
  width: 25px; height: 25px; border-radius: 50%; background: #fff; font-size: 13px;
  border: 2px solid var(--gr-dot, #555); box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.mk-poi {
  width: 27px; height: 27px; border-radius: 50%; background: #fff; font-size: 15px;
  border: 2px solid #7a4bb8; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.mk-water {
  width: 22px; height: 22px; border-radius: 50%; background: #fff; font-size: 12px;
  border: 2px solid #1976d2; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.mk-water-broken { border-color: #c62828; }
.mk-sidetrip {
  width: 25px; height: 25px; border-radius: 50%; background: #fff; font-size: 13px;
  border: 2px dashed #555; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.nav-extra button { font-size: 15px; }
#map-legend {
  position: absolute; left: 10px; bottom: 28px; z-index: 5;
  background: rgba(255,255,255,.93); border-radius: 8px; padding: 8px 11px;
  font-size: .72rem; box-shadow: var(--shadow); color: var(--ink);
}
#map-legend .lg { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
#map-legend .lg-toggle { cursor: pointer; user-select: none; }
#map-legend .lg-toggle input { margin: 0; }
#map-legend .lg-toggle:has(input:not(:checked)) { opacity: .45; }
#map-legend .sym {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
}
#map-legend .sym-line {
  width: 20px; height: 0; flex: 0 0 20px; border-top: 3px dashed var(--muted);
}
.maplibregl-popup-content { font-family: inherit; font-size: .8rem; line-height: 1.4; padding: 10px 12px; border-radius: 8px; }
.maplibregl-popup-content b { font-size: .85rem; }
.maplibregl-popup-content .p-alt { color: var(--muted); }
.maplibregl-popup-content ul { margin: 4px 0 0; padding-left: 16px; }

/* ---------- Responsive ---------- */
.map-toggle { display: none; }
@media (max-width: 920px) {
  #layout { flex-direction: column; }
  aside { width: 100%; flex: 1 1 55%; order: 2; border-right: 0; border-top: 1px solid var(--line); }
  #map-wrap { flex: 1 1 45%; order: 1; min-height: 300px; transition: flex-basis .25s ease, min-height .25s ease; }
  header .brand small { display: none; }

  .map-toggle {
    display: block; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 6;
    background: rgba(20,49,61,.85); color: #fff; border: 0; border-radius: 20px;
    padding: 6px 14px; font-size: .75rem; cursor: pointer;
  }
  body.map-collapsed #map-wrap { flex: 0 0 64px; min-height: 64px; }
  body.map-collapsed aside { flex: 1 1 auto; }
}

/* ---------- Impression ---------- */
@media print {
  header .seg, header .hbtn, #map-wrap, #tabs, .day-actions, .mini-btn, #gr-cards, .cfg, .box, .foot-note { display: none !important; }
  body { display: block; background: #fff; }
  #layout { display: block; }
  aside { width: 100%; border: 0; }
  .panel { overflow: visible; padding: 0; }
  .panel[hidden] { display: none !important; }
  .day-card { break-inside: avoid; box-shadow: none; }
  header { background: none; color: #000; height: auto; padding: 0 0 10px; }
}
