/* ============================================================
   DakarSafe — Mobile-First Design System v3
   ============================================================ */

/* ── Variables ── */
:root {
  --bg:       #0a0a0f;
  --surface:  #12121a;
  --card:     #1c1c2e;
  --card2:    #22223a;
  --danger:   #ff3b30;
  --warning:  #ff9500;
  --safe:     #30d158;
  --primary:  #0a84ff;
  --text:     #ffffff;
  --muted:    #8e8e93;
  --border:   #2c2c3e;
  --topbar-h: 52px;
  --nav-h:    60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --r:        14px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: -apple-system, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  height: 100%; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px;
}
input, textarea { font-family: inherit; }

/* ════════════════════════════════════════════════
   SPLASH SCREEN
════════════════════════════════════════════════ */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 32px;
  transition: opacity 0.4s ease;
}
.splash-shield { display: flex; align-items: center; justify-content: center; animation: splashBounce 0.6s ease; }
.splash-name { font-size: 28px; font-weight: 900; color: #0a84ff; letter-spacing: 2px; }
.splash-sub { font-size: 14px; color: var(--muted); margin-top: -20px; }
.splash-loader { width: 140px; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.splash-bar { height: 100%; width: 0; background: var(--danger); border-radius: 2px; animation: splashLoad 1.1s ease forwards; }
@keyframes splashBounce { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes splashLoad { to { width: 100%; } }

/* ════════════════════════════════════════════════
   MODAL CGU — Conditions d'utilisation
════════════════════════════════════════════════ */
.cgu-overlay {
  position: fixed; inset: 0; z-index: 9990;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(6px);
  animation: cgufadein 0.3s ease;
}
.cgu-overlay.hidden { display: none; }
@keyframes cgufadein { from { opacity: 0; } to { opacity: 1; } }

.cgu-sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 540px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  animation: cguslidein 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes cguslidein { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }

.cgu-header {
  padding: 24px 20px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cgu-logo { display: flex; justify-content: center; margin-bottom: 10px; }
.cgu-title { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.cgu-subtitle { font-size: 13px; color: var(--muted); line-height: 1.4; }

.cgu-body {
  flex: 1; overflow-y: auto; padding: 20px;
  -webkit-overflow-scrolling: touch;
}
.cgu-section { margin-bottom: 20px; }
.cgu-section h2 {
  font-size: 13px; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.cgu-section p, .cgu-section li {
  font-size: 13px; color: var(--muted); line-height: 1.6;
}
.cgu-section ul { padding-left: 16px; margin-top: 6px; }
.cgu-section li { margin-bottom: 4px; }
.cgu-section strong { color: var(--text); }

.cgu-footer {
  padding: 16px 20px calc(16px + var(--safe-bot));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.cgu-check-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.cgu-check-label input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; cursor: pointer;
}
.cgu-btn {
  width: 100%; padding: 14px;
  background: var(--primary); color: #fff;
  font-size: 16px; font-weight: 700;
  border-radius: 12px;
  transition: opacity 0.2s, transform 0.15s;
}
.cgu-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cgu-btn:not(:disabled):active { transform: scale(0.97); }

/* ════════════════════════════════════════════════
   BANNIÈRES
════════════════════════════════════════════════ */
.update-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8000;
  background: #1e40af; color: #fff; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600;
}
.update-banner button {
  background: #3b82f6; color: #fff; padding: 6px 14px;
  border-radius: 8px; font-size: 12px; font-weight: 700;
}
.update-banner.hidden { display: none; }

.pwa-banner {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-bot) + 8px); left: 12px; right: 12px;
  z-index: 700; background: var(--card);
  border: 1.5px solid var(--primary); border-radius: 16px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  cursor: pointer; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: slideUp 0.3s ease;
}
.pwa-banner.hidden { display: none; }
.pwa-icon { font-size: 26px; flex-shrink: 0; }
.pwa-text { flex: 1; }
.pwa-text strong { display: block; font-size: 14px; color: var(--text); }
.pwa-text span { font-size: 12px; color: var(--muted); }
.pwa-close { color: var(--muted); font-size: 18px; padding: 4px 8px; flex-shrink: 0; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ════════════════════════════════════════════════
   EN-TÊTE
════════════════════════════════════════════════ */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 16px; padding-right: 16px;
  z-index: 1000;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.brand-shield { display: flex; align-items: center; }
.brand-name { font-size: 18px; font-weight: 900; color: #0a84ff; letter-spacing: 0.5px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--safe); flex-shrink: 0;
}
.live-dot.offline { background: var(--muted); }
.live-dot:not(.offline) { animation: livePing 1.5s ease-in-out infinite; }
@keyframes livePing {
  0%,100% { box-shadow: 0 0 0 0 rgba(48,209,88,0.6); }
  50%      { box-shadow: 0 0 0 6px rgba(48,209,88,0); }
}
.live-label { font-size: 10px; font-weight: 800; letter-spacing: 1.5px; color: var(--safe); }
.live-dot.offline + .live-label { color: var(--muted); }

/* ════════════════════════════════════════════════
   PAGES
════════════════════════════════════════════════ */
.page {
  display: none; position: fixed;
  top: var(--topbar-h); left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bot));
  overflow-y: auto; background: var(--bg);
  -webkit-overflow-scrolling: touch;
}
.page.active { display: block; }
#page-carte.active { overflow: hidden; }

.page-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.page-header h1 { font-size: 24px; font-weight: 800; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ════════════════════════════════════════════════
   PAGE CARTE
════════════════════════════════════════════════ */
#map {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #1a1a2e;
}

/* Google Maps InfoWindow */
.gm-style .gm-style-iw-c {
  background: var(--card) !important;
  border: 1px solid var(--danger) !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
  padding: 0 !important;
}
.gm-style .gm-style-iw-d {
  overflow: hidden !important;
  padding: 14px !important;
  color: var(--text) !important;
}
.gm-style .gm-style-iw-t::after {
  background: var(--card) !important;
}
/* Bouton fermer de l'InfoWindow */
.gm-style .gm-ui-hover-effect {
  top: 2px !important; right: 2px !important;
}
.gm-style .gm-ui-hover-effect img { filter: invert(1); }
.popup-type  { font-weight: 700; font-size: 14px; color: var(--danger); margin-bottom: 4px; }
.popup-meta  { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.popup-desc  { font-size: 13px; margin-bottom: 6px; }
.popup-time  { font-size: 11px; color: var(--muted); margin-bottom: 10px; }

/* Badge de statut dans le popup */
.popup-statut { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; margin-bottom: 6px; }
.popup-statut-resolu  { background: rgba(48,209,88,.18);  color: #30d158; }
.popup-statut-urgent  { background: rgba(255,59,48,.15);  color: #ff3b30; }
.popup-statut-fausse  { background: rgba(142,142,147,.15); color: #8e8e93; }
.popup-statut-attente { background: rgba(255,149,0,.12);  color: #ff9500; }

/* Badge de statut dans la liste alertes */
.alert-statut { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: rgba(255,255,255,.08); }

/* Réactions popup */
.popup-reactions { display: flex; gap: 12px; align-items: center; padding: 6px 0; border-top: 1px solid rgba(255,255,255,0.08); margin-bottom: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.popup-reaction-item { display: flex; align-items: center; gap: 4px; }
.popup-vote { display: flex; gap: 6px; margin-top: 2px; }
.popup-btn-confirm, .popup-btn-faux {
  flex: 1; padding: 8px; border-radius: 9px;
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: opacity .15s, transform .1s; border: 1px solid transparent;
}
.popup-btn-confirm:active, .popup-btn-faux:active { transform: scale(0.95); }
.popup-btn-confirm { background: rgba(48,209,88,.15); color: var(--safe); border-color: rgba(48,209,88,.3); }
.popup-btn-faux    { background: rgba(255,59,48,.12); color: #ff6b6b; border-color: rgba(255,59,48,.25); }
.popup-btn-confirm:disabled, .popup-btn-faux:disabled { opacity: .4; cursor: not-allowed; }
.popup-voted { font-size: 12px; font-weight: 700; color: var(--safe); text-align: center; padding: 6px 0; border-top: 1px solid rgba(255,255,255,.08); }

/* Marqueurs */
.pulse-marker { position: relative; width: 20px; height: 20px; }
.pulse-dot { position: absolute; top: 4px; left: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); z-index: 2; }
.pulse-ring { position: absolute; top: 0; left: 0; width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; animation: markerPulse 2s ease-out infinite; }
@keyframes markerPulse { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(2.5); opacity: 0; } }
.pulse-new .pulse-dot { animation: newFlash .6s ease-in-out 3 alternate; }
@keyframes newFlash { 0% { transform: scale(1); } 100% { transform: scale(1.5); box-shadow: 0 0 8px 3px currentColor; } }

/* Bouton localiser */
.fab-heatmap {
  position: absolute; right: 12px;
  top: 64px; z-index: 500;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
  transition: background .15s, transform .1s, border-color .15s;
}
.fab-heatmap:active { transform: scale(.92); }
.fab-heatmap.active { background: rgba(255,59,48,.18); border-color: #ff3b30; }

.fab-locate {
  position: absolute; right: 12px;
  top: 12px; z-index: 500;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  transition: background .15s, transform .1s;
}
.fab-locate:active { transform: scale(.92); }
.fab-locate.locating { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Drawer */
.drawer {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 70px;
  background: var(--surface); border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  transition: height .35s cubic-bezier(.4,0,.2,1);
  z-index: 500; overflow: hidden;
}
.drawer.expanded { height: 55vh; }
.drawer-handle {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 8px; cursor: pointer; user-select: none;
}
.drawer-pill {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 4px; border-radius: 2px; background: var(--border);
}
.drawer-title { font-size: 14px; font-weight: 700; margin-top: 4px; }
.badge-count {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
}
.feed-list { overflow-y: auto; height: calc(55vh - 70px); padding: 0 0 12px; -webkit-overflow-scrolling: touch; }
.feed-card {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent; cursor: pointer; transition: background .15s;
}
.feed-card:active { background: var(--card2); }
.feed-card.severity-danger  { border-left-color: var(--danger); }
.feed-card.severity-warning { border-left-color: var(--warning); }
.feed-card.severity-caution { border-left-color: #ffcc00; }
.feed-card.severity-muted   { border-left-color: var(--muted); }
.feed-icon { font-size: 22px; flex-shrink: 0; }
.feed-type { font-size: 13px; font-weight: 700; }
.feed-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.feed-reactions { font-size: 11px; color: var(--muted); margin-top: 3px; font-weight: 600; }

/* Zone tooltip */
.zone-tooltip {
  background: rgba(12,12,20,.9) !important; border: 1px solid var(--border) !important;
  color: var(--text) !important; font-size: 12px; font-weight: 600;
  border-radius: 6px !important; padding: 4px 8px !important;
}
.user-location-dot {
  width: 16px; height: 16px; background: var(--primary);
  border: 3px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(10,132,255,.25), 0 2px 8px rgba(0,0,0,.5);
}

/* ════════════════════════════════════════════════
   PAGE ALERTES
════════════════════════════════════════════════ */
.filter-scroll {
  display: flex; gap: 8px; padding: 12px 16px;
  overflow-x: auto; scrollbar-width: none;
  position: sticky; top: 68px; background: var(--bg); z-index: 9;
}
.filter-scroll::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; border-radius: 20px; padding: 7px 16px;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
  border: 1.5px solid var(--border); background: var(--card); color: var(--muted);
  transition: all .2s;
}
.chip.active { background: var(--danger); color: #fff; border-color: var(--danger); }
.chip:active:not(.active) { background: var(--card2); }

.alertes-list { padding: 8px 0 20px; }
.alert-card {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card); margin: 8px 16px;
  border-radius: var(--r); padding: 14px;
  border-left: 4px solid var(--muted);
  transition: background .15s; cursor: pointer;
}
.alert-card:active { background: var(--card2); }
.alert-icon { font-size: 26px; flex-shrink: 0; margin-top: 2px; }
.alert-body { flex: 1; min-width: 0; }
.alert-type { font-size: 15px; font-weight: 700; }
.alert-meta { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.alert-reactions { font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 4px; }
.alert-time { font-size: 11px; color: var(--muted); flex-shrink: 0; white-space: nowrap; margin-top: 2px; }

.empty-state {
  text-align: center; color: var(--muted); font-size: 14px;
  padding: 60px 20px; line-height: 2;
}
.empty-icon { font-size: 36px; display: block; }

/* ════════════════════════════════════════════════
   PAGE SIGNALER
════════════════════════════════════════════════ */
.cat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; padding: 16px 16px 8px;
}
.cat-btn {
  background: var(--card); border: 2px solid var(--border);
  border-radius: var(--r); padding: 16px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  transition: all .2s; min-height: 80px;
}
.cat-btn:active { background: var(--card2); }
.cat-btn.selected { border-color: var(--danger); background: rgba(255,59,48,.1); }
.cat-emoji { font-size: 26px; }
.cat-name { font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; line-height: 1.3; }
.cat-btn.selected .cat-name { color: var(--danger); }

.report-form { padding: 0 16px calc(var(--safe-bot) + 24px); }
.form-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); padding: 16px 16px 0;
}
.field { margin: 16px 0; }
.field > label {
  display: block; font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px;
}
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; }
.field input, .field textarea {
  width: 100%; background: var(--card); border: 1.5px solid var(--border);
  color: var(--text); padding: 13px 14px; border-radius: 12px;
  font-size: 15px; outline: none; transition: border-color .2s;
  -webkit-appearance: none;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 80px; }

#picker-map {
  height: 170px; border-radius: 12px; border: 1.5px solid var(--border);
  overflow: hidden; margin-bottom: 8px;
}
.coords-hint {
  font-size: 12px; color: var(--muted); padding: 8px 12px;
  background: var(--card); border-radius: 8px; text-align: center; margin-bottom: 8px;
}
.coords-hint.set { color: var(--safe); }

.btn-gps {
  width: 100%; padding: 13px 14px; margin-bottom: 10px;
  border-radius: 12px; border: 1.5px solid rgba(10,132,255,.4);
  background: rgba(10,132,255,.1); color: var(--primary);
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .2s, border-color .2s, color .2s;
}
.btn-gps:active { background: rgba(10,132,255,.2); }
.btn-gps.gps-ok    { border-color: rgba(48,209,88,.5); background: rgba(48,209,88,.1); color: var(--safe); }
.btn-gps.gps-error { border-color: rgba(255,59,48,.4); background: rgba(255,59,48,.08); color: var(--danger); }

.coords-manual { display: flex; gap: 8px; margin-top: 8px; }
.coord-field { flex: 1; }
.coord-label {
  display: block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); margin-bottom: 4px;
}
.coord-input {
  width: 100%; background: var(--card); border: 1.5px solid var(--border);
  color: var(--text); padding: 10px; border-radius: 10px; font-size: 14px;
  outline: none; transition: border-color .2s; -webkit-appearance: none;
  -moz-appearance: textfield;
}
.coord-input::-webkit-outer-spin-button,
.coord-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.coord-input:focus { border-color: var(--primary); }

/* Toggle anonymat */
.toggle-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; margin: 20px 0;
  background: var(--card); border-radius: var(--r);
  border: 1.5px solid var(--border); cursor: pointer;
}
.toggle-row input[type=checkbox] { display: none; }
.toggle-track {
  width: 44px; height: 26px; border-radius: 13px;
  background: var(--border); position: relative;
  flex-shrink: 0; transition: background .25s;
}
.toggle-row input:checked ~ .toggle-track { background: var(--danger); }
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .25s; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.toggle-row input:checked ~ .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle-label { font-size: 14px; font-weight: 600; }

.btn-submit {
  width: 100%; padding: 15px; border-radius: var(--r);
  background: var(--danger); color: #fff;
  font-size: 16px; font-weight: 800;
  transition: background .2s, transform .1s;
  letter-spacing: .3px;
}
.btn-submit:active { transform: scale(.98); background: #e0322a; }
.btn-submit:disabled { opacity: .5; cursor: not-allowed; }

.feedback {
  margin-top: 12px; padding: 13px; border-radius: 12px;
  font-size: 13px; font-weight: 600; text-align: center;
}
.feedback.hidden { display: none; }
.feedback.success { background: rgba(48,209,88,.15); color: var(--safe); border: 1px solid rgba(48,209,88,.3); }
.feedback.error   { background: rgba(255,59,48,.15); color: var(--danger); border: 1px solid rgba(255,59,48,.3); }

/* ════════════════════════════════════════════════
   PAGE STATS
════════════════════════════════════════════════ */
.kpi-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; padding: 16px; }
.kpi-card {
  background: var(--card); border-radius: var(--r); padding: 16px 10px;
  text-align: center; border: 1.5px solid var(--border);
}
.kpi-card.danger  { border-color: var(--danger); background: rgba(255,59,48,.08); }
.kpi-card.warning { border-color: var(--warning); background: rgba(255,149,0,.08); }
.kpi-value { font-size: 30px; font-weight: 900; }
.kpi-card.danger  .kpi-value { color: var(--danger); }
.kpi-card.warning .kpi-value { color: var(--warning); }
.kpi-label { font-size: 10px; color: var(--muted); font-weight: 700; margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

.section-title {
  font-size: 12px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); padding: 20px 16px 10px;
}
.risk-legend { display: flex; align-items: center; gap: 16px; padding: 0 16px 12px; font-size: 12px; font-weight: 600; color: var(--muted); flex-wrap: wrap; }
.risk-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.risk-dot.high { background: var(--danger); }
.risk-dot.medium { background: var(--warning); }
.risk-dot.low { background: var(--safe); }

.zone-bars { padding: 0 16px 8px; }
.zone-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.zone-bar-name { font-size: 13px; font-weight: 600; width: 130px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-bar-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.zone-bar-fill { height: 100%; border-radius: 4px; transition: width .8s ease; min-width: 4px; }
.zone-bar-fill.high { background: var(--danger); }
.zone-bar-fill.medium { background: var(--warning); }
.zone-bar-fill.low { background: var(--safe); }
.zone-bar-count { font-size: 13px; font-weight: 700; width: 24px; text-align: right; flex-shrink: 0; }
.zone-bar-badge { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }
.zone-bar-badge.high   { background: rgba(255,59,48,.2); color: var(--danger); }
.zone-bar-badge.medium { background: rgba(255,149,0,.2); color: var(--warning); }
.zone-bar-badge.low    { background: rgba(48,209,88,.2); color: var(--safe); }

.type-chart { padding: 0 16px 80px; }
.chart-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.chart-label { font-size: 12px; font-weight: 600; width: 130px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.chart-track { flex: 1; height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.chart-bar { height: 100%; border-radius: 5px; transition: width .8s ease; min-width: 4px; }
.chart-count { font-size: 13px; font-weight: 700; width: 24px; text-align: right; flex-shrink: 0; }

/* ════════════════════════════════════════════════
   BOUTON SOS — intégré dans la nav
════════════════════════════════════════════════ */
.nav-sos-wrap {
  flex: 1.2;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.nav-sos-btn {
  width: 62px; height: 62px; border-radius: 50%;
  background: linear-gradient(145deg, #ff3b30, #c0392b);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(255,59,48,.65);
  position: relative;
  /* Dépasse au-dessus de la barre */
  margin-bottom: 20px;
  transition: transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.nav-sos-btn:active { transform: scale(.88); }
.sos-ring {
  position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid rgba(255,59,48,.45);
  animation: sosPing 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sosPing {
  0%,100% { transform: scale(1); opacity: .8; }
  50%      { transform: scale(1.25); opacity: 0; }
}
.sos-text { font-size: 12px; font-weight: 900; color: #fff; letter-spacing: 1.5px; z-index: 1; }

/* Overlay SOS */
.sos-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.sos-overlay.hidden { display: none; }
.sos-modal {
  background: #1a0505; border: 2px solid rgba(255,59,48,.55);
  border-radius: 24px; padding: 32px 24px 24px;
  max-width: 340px; width: 90%; text-align: center;
  box-shadow: 0 24px 64px rgba(255,59,48,.3);
  animation: modalIn .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn { from { transform: scale(.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sos-modal-icon  { font-size: 56px; margin-bottom: 12px; }
.sos-modal-title { font-size: 22px; font-weight: 900; color: var(--danger); letter-spacing: 2px; margin-bottom: 10px; }
.sos-modal-sub   { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }
.sos-countdown {
  font-size: 15px; font-weight: 700;
  background: rgba(255,59,48,.1); border: 1px solid rgba(255,59,48,.3);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 14px;
}
.sos-timer { font-size: 32px; font-weight: 900; color: var(--danger); }
.sos-status { font-size: 13px; font-weight: 600; min-height: 22px; margin-bottom: 14px; color: var(--muted); line-height: 1.4; }
.sos-status.loading { color: var(--warning); }
.sos-status.success { color: var(--safe); font-size: 15px; }
.sos-status.error   { color: var(--danger); }
.sos-numbers { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 22px; }
.sos-num { text-align: center; }
.sos-num span { display: block; margin-bottom: 2px; }
.sos-num strong { font-size: 22px; font-weight: 900; color: var(--text); }
.sos-cancel {
  width: 100%; padding: 14px; border-radius: 14px;
  background: rgba(255,255,255,.07); border: 1.5px solid rgba(255,255,255,.13);
  color: var(--text); font-size: 15px; font-weight: 700;
  transition: background .2s;
}
.sos-cancel:active { background: rgba(255,255,255,.14); }

/* ════════════════════════════════════════════════
   NAVIGATION BAS D'ÉCRAN
════════════════════════════════════════════════ */
#bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  z-index: 1000;
  overflow: visible; /* permet au SOS de dépasser vers le haut */
}
/* Ligne de fond derrière le SOS pour ne pas couper visuellement */
#bottomnav::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px; background: var(--border);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); font-size: 10px; font-weight: 600;
  padding: 8px 4px; transition: color .2s;
  min-height: 44px;
}
.nav-item.active { color: var(--danger); }
.nav-item:active:not(.active) { color: var(--text); }
.nav-icon { width: 22px; height: 22px; flex-shrink: 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ════════════════════════════════════════════════
   PAGE PROFIL
════════════════════════════════════════════════ */

/* Conteneur scrollable de la page */
.profil-page {
  flex-direction: column;
  overflow: hidden;
}
/* Override display:block → flex uniquement quand active */
#page-profil.active { display: flex; }

/* Zone hero (avatar + nom) */
.profil-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}
.profil-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--danger);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
}
.profil-hero-info { flex: 1; min-width: 0; }
.profil-hero-name {
  font-size: 18px; font-weight: 800;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profil-hero-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.profil-saved-badge {
  position: absolute; top: 12px; right: 14px;
  background: var(--safe); color: #000;
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
  animation: slideUp .25s ease;
}
.profil-saved-badge.hidden { display: none; }

/* Zone scrollable */
.profil-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px;
}

/* Labels de section */
.profil-section-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted);
  margin: 18px 4px 8px;
  display: flex; align-items: center; gap: 8px;
}
.section-badge {
  background: var(--card2);
  color: var(--warning);
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
  text-transform: uppercase;
}
.section-badge.sos {
  background: rgba(255,59,48,.15);
  color: var(--danger);
}

/* Boîte d'info */
.profil-info-box {
  background: rgba(10,132,255,.1);
  border: 1px solid rgba(10,132,255,.3);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px; color: #a0c8ff;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 10px;
}
.profil-info-box.sos {
  background: rgba(255,59,48,.08);
  border-color: rgba(255,59,48,.25);
  color: #ffb3ae;
}
.info-box-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

/* Carte formulaire */
.profil-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 4px;
  display: flex; flex-direction: column; gap: 12px;
}

/* Ligne 2 colonnes */
.profil-row { display: flex; gap: 10px; }
.field.half { flex: 1; min-width: 0; }

/* Labels et inputs */
.field-label {
  display: block;
  font-size: 12px; font-weight: 600; color: var(--muted);
  margin-bottom: 5px;
}
.field-required {
  color: var(--danger); font-size: 10px; font-weight: 700;
}
.profil-input {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .2s;
  -webkit-appearance: none;
}
.profil-input:focus { border-color: var(--primary); }
.profil-select { cursor: pointer; padding-right: 28px; }
.profil-textarea { resize: none; line-height: 1.5; }

/* Bouton sauvegarder */
.profil-save-btn {
  width: 100%;
  background: var(--danger);
  color: #fff;
  font-size: 16px; font-weight: 800;
  border-radius: 14px;
  padding: 16px;
  margin-top: 18px;
  box-shadow: 0 4px 20px rgba(255,59,48,.4);
  transition: opacity .2s, transform .1s;
}
.profil-save-btn:active { transform: scale(.98); opacity: .9; }
.profil-save-btn:disabled { opacity: .6; }

/* Feedback */
.profil-feedback {
  text-align: center;
  font-size: 13px; font-weight: 600;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 10px;
}
.profil-feedback.success { background: rgba(48,209,88,.15); color: var(--safe); }
.profil-feedback.warn    { background: rgba(255,149,0,.15); color: var(--warning); }
.profil-feedback.hidden  { display: none; }

/* ════════════════════════════════════════════════
   HISTORIQUE SIGNALEMENTS
════════════════════════════════════════════════ */
.histo-loading {
  display: flex; align-items: center; gap: 10px;
  justify-content: center;
  padding: 24px 0; color: var(--muted); font-size: 14px;
}
.histo-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.histo-empty {
  text-align: center; padding: 28px 16px;
  color: var(--muted); font-size: 14px;
}
.histo-empty-icon { font-size: 36px; margin-bottom: 8px; }
.histo-empty p    { font-size: 13px; }

.histo-list { display: flex; flex-direction: column; gap: 10px; }
.histo-list.hidden { display: none; }
.histo-loading.hidden { display: none; }
.histo-empty.hidden   { display: none; }

.histo-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.histo-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}
.histo-card.statut-urgent::before    { background: var(--danger); }
.histo-card.statut-en_attente::before { background: var(--warning); }
.histo-card.statut-resolu::before    { background: var(--safe); }
.histo-card.statut-other::before     { background: var(--muted); }

.histo-card-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 8px;
  margin-bottom: 6px;
}
.histo-type {
  font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.histo-statut {
  font-size: 10px; font-weight: 800;
  padding: 3px 8px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap; flex-shrink: 0;
}
.statut-urgent    .histo-statut { background: rgba(255,59,48,.15);  color: var(--danger);  }
.statut-en_attente .histo-statut { background: rgba(255,149,0,.15); color: var(--warning); }
.statut-resolu    .histo-statut { background: rgba(48,209,88,.15);  color: var(--safe);    }
.statut-other     .histo-statut { background: rgba(142,142,147,.15); color: var(--muted);  }

.histo-quartier {
  font-size: 12px; color: var(--muted); margin-bottom: 4px;
  display: flex; align-items: center; gap: 4px;
}
.histo-desc {
  font-size: 12px; color: rgba(255,255,255,.55);
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 8px;
}
.histo-footer {
  display: flex; align-items: center;
  justify-content: space-between;
  font-size: 11px; color: var(--muted);
}
.histo-votes {
  display: flex; align-items: center; gap: 10px;
}
.histo-vote { display: flex; align-items: center; gap: 3px; }

/* ════════════════════════════════════════════════
   SECTION MON COMPTE (profil)
════════════════════════════════════════════════ */
#compte-section { margin-bottom: 20px; }
.compte-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1.5px solid var(--primary);
  border-radius: var(--r); padding: 14px 16px;
}
.compte-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(10,132,255,.15); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.compte-info { flex: 1; min-width: 0; }
.compte-email { font-size: 13px; font-weight: 700; color: var(--text); truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.compte-name  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.compte-logout {
  font-size: 11px; font-weight: 700; color: var(--danger);
  background: rgba(255,59,48,.1); border: 1px solid rgba(255,59,48,.3);
  padding: 6px 12px; border-radius: 8px; flex-shrink: 0;
}

/* ════════════════════════════════════════════════
   MODALE AUTHENTIFICATION
════════════════════════════════════════════════ */
.auth-modal-overlay {
  position: fixed; inset: 0; z-index: 8500;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.auth-modal-overlay.hidden { display: none; }

.auth-modal-box {
  width: 100%; max-width: 480px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 1.5px solid var(--border);
  padding: 0 0 24px;
  max-height: 90vh; overflow-y: auto;
}

.auth-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px;
}
.auth-modal-title { font-size: 17px; font-weight: 800; color: var(--text); }
.auth-modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--card); color: var(--muted);
  font-size: 14px; display: flex; align-items: center; justify-content: center;
}

.auth-tabs {
  display: flex; gap: 4px;
  margin: 0 20px 20px;
  background: var(--card); border-radius: 10px; padding: 4px;
}
.auth-tab {
  flex: 1; padding: 8px; border-radius: 7px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  transition: all .15s;
}
.auth-tab.active { background: var(--primary); color: #fff; }

.auth-form { padding: 0 20px; }
.auth-form.hidden { display: none; }
.auth-row { display: flex; gap: 10px; }
.auth-field { margin-bottom: 14px; }
.auth-field.half { flex: 1; }
.auth-label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 6px;
}
.auth-hint { font-size: 10px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.auth-input {
  width: 100%; background: var(--card);
  border: 1.5px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 15px; padding: 12px 14px;
  outline: none; transition: border-color .15s;
}
.auth-input:focus { border-color: var(--primary); }
.auth-error {
  font-size: 12px; font-weight: 600; color: var(--danger);
  background: rgba(255,59,48,.1); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 12px;
}
.auth-error.hidden { display: none; }
.auth-submit {
  width: 100%; background: var(--primary); color: #fff;
  font-size: 15px; font-weight: 800; padding: 14px;
  border-radius: 12px; margin-top: 4px;
  transition: opacity .15s;
}
.auth-submit:active { opacity: .8; }
.auth-submit:disabled { opacity: .5; }

/* ── Consentement médical ──────────────────────────────────────────── */
.profil-consent-box {
  background: rgba(255,149,0,.08);
  border: 1px solid rgba(255,149,0,.3);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.consent-label {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 12.5px; color: #ffd580; line-height: 1.5;
  cursor: pointer;
}
.consent-label input[type="checkbox"] {
  flex-shrink: 0; margin-top: 3px;
  width: 16px; height: 16px; accent-color: var(--primary);
}
.consent-link {
  color: #5ac8fa; text-decoration: underline;
}
/* Champs médicaux grisés si non-consentement */
#profil-medical-card.medical-locked .profil-input {
  opacity: 0.4; pointer-events: none;
}
#profil-medical-card.medical-locked::after {
  content: '🔒 Activez le consentement ci-dessus pour renseigner ces champs.';
  display: block; text-align: center;
  font-size: 12px; color: var(--muted); padding: 4px 0 8px;
}

/* ── Mentions légales ─────────────────────────────────────────────── */
.mentions-legales-section { margin-top: 8px; }
.mentions-legales-section.hidden { display: none; }
.mentions-legales-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  font-size: 12px; color: var(--muted);
  line-height: 1.6;
  display: flex; flex-direction: column; gap: 8px;
}
.mentions-legales-card p { margin: 0; }
.mentions-legales-card strong { color: var(--text); }
.mentions-close-btn {
  align-self: flex-end;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 16px;
  color: var(--text); font-size: 13px; cursor: pointer;
  margin-top: 4px;
}

/* ════════════════════════════════════════════════
   TOAST GLOBAL (erreurs réseau, géoloc, etc.)
════════════════════════════════════════════════ */
.app-toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-bot) + 12px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  max-width: calc(100vw - 32px); width: auto;
  padding: 10px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 600; line-height: 1.4;
  z-index: 8000; pointer-events: none; text-align: center;
  opacity: 0; transition: opacity 0.25s, transform 0.25s;
}
.app-toast.visible {
  opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto;
}
.app-toast.error   { background: #3a1111; color: #ff6b6b; border: 1px solid #5a2020; }
.app-toast.warning { background: #3a2a0a; color: #ffb84d; border: 1px solid #5a4020; }
.app-toast.success { background: #0a2a14; color: #5ae67a; border: 1px solid #1a4a2a; }
.app-toast.info    { background: #0a1a3a; color: #6bb8ff; border: 1px solid #1a3050; }

/* ════════════════════════════════════════════════
   PREFERS-REDUCED-MOTION
════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ════════════════════════════════════════════════
   RESPONSIVE — TABLET (768px+)
════════════════════════════════════════════════ */
@media (min-width: 768px) {
  /* Pages pleine largeur — pas de max-width ni de marges */
  .page { max-width: none; margin: 0; padding: 0; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  /* Alertes : 2 colonnes */
  .alertes-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px 16px; }
  .alert-card { margin: 0; }
  /* CGU centrée */
  .cgu-overlay { align-items: center; }
  .cgu-sheet { border-radius: 20px; max-height: 80vh; }
}

/* ════════════════════════════════════════════════
   RESPONSIVE — DESKTOP (1024px+)
════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  /* Alertes : 3 colonnes */
  .alertes-list { grid-template-columns: repeat(3, 1fr); }
  /* Formulaire signaler */
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  /* Toast */
  .app-toast { bottom: calc(var(--nav-h) + var(--safe-bot) + 24px); }
}
