/* NusukBLE — démo ShiftCore Technology */

:root {
  --page:       #f9f9f7;
  --surface:    #fcfcfb;
  --ink:        #0b0b0b;
  --ink-2:      #52514e;
  --muted:      #898781;
  --grid:       #e1e0d9;
  --baseline:   #c3c2b7;
  --border:     rgba(11, 11, 11, 0.10);
  --accent:     #067647;   /* émeraude */
  --accent-ink: #ffffff;
  --series:     #2a78d6;   /* bleu graphiques */
  --good:       #0ca30c;
  --good-text:  #006300;
  --warning:    #fab219;
  --serious:    #ec835a;
  --critical:   #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page:       #0d0d0d;
    --surface:    #1a1a19;
    --ink:        #ffffff;
    --ink-2:      #c3c2b7;
    --grid:       #2c2c2a;
    --baseline:   #383835;
    --border:     rgba(255, 255, 255, 0.12);
    --accent:     #2fbf85;
    --accent-ink: #062b1d;
    --series:     #3987e5;
    --good-text:  #0ca30c;
  }
}
:root[data-theme="dark"] {
  --page:       #0d0d0d;
  --surface:    #1a1a19;
  --ink:        #ffffff;
  --ink-2:      #c3c2b7;
  --grid:       #2c2c2a;
  --baseline:   #383835;
  --border:     rgba(255, 255, 255, 0.12);
  --accent:     #2fbf85;
  --accent-ink: #062b1d;
  --series:     #3987e5;
  --good-text:  #0ca30c;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  background: var(--page); color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
svg { display: block; }
button { font: inherit; }

.demo-ribbon {
  background: var(--accent); color: var(--accent-ink);
  text-align: center; padding: 7px 14px; font-size: 13px;
}
.demo-ribbon a { color: inherit; }

/* ================= Mise en page desktop : panneau + téléphone ================= */
.stage {
  display: flex; gap: 44px; align-items: flex-start; justify-content: center;
  padding: 34px 24px 60px;
}
.side {
  max-width: 360px; padding-top: 12px;
}
.side .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #067647, #1baf7a);
  color: #fff; font-weight: 700; font-size: 21px;
  display: flex; align-items: center; justify-content: center;
}
.side h1 { margin: 0; font-size: 20px; }
.side .sub { color: var(--muted); font-size: 12.5px; }
.side p { color: var(--ink-2); font-size: 13.5px; }
.side ul { color: var(--ink-2); font-size: 13px; padding-left: 18px; margin: 10px 0; }
.side li { margin: 5px 0; }
.side .note {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); padding: 11px 13px;
  font-size: 12.5px; color: var(--muted); margin-top: 16px;
}
.theme-row { margin-top: 14px; }
.btn {
  background: none; border: 1px solid var(--border); color: var(--ink-2);
  border-radius: 9px; padding: 8px 14px; font-size: 13px; cursor: pointer; font-weight: 500;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 5px 11px; font-size: 12px; }

/* ================= Téléphone ================= */
.phone-wrap { flex: 0 0 auto; }
.phone {
  width: 384px; height: min(806px, calc(100vh - 130px)); min-height: 560px;
  border-radius: 46px; background: var(--page);
  border: 11px solid #101010; outline: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
.punch {
  position: absolute; top: 11px; left: 50%; transform: translateX(-50%);
  width: 88px; height: 24px; border-radius: 14px; background: #101010; z-index: 20;
}
.statusbar {
  flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 22px 4px; font-size: 12.5px; font-weight: 600;
}
.statusbar .right { display: flex; gap: 6px; align-items: center; }
.statusbar svg { width: 15px; height: 15px; }

/* En-tête d'app */
.app-header { flex: 0 0 auto; padding: 8px 18px 10px; }
.app-header .row { display: flex; align-items: center; gap: 10px; }
.app-header h2 { margin: 0; font-size: 19px; flex: 1; }
.app-header .sub { font-size: 12px; color: var(--muted); }
.icon-btn {
  position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  width: 34px; height: 34px; cursor: pointer; color: var(--ink-2);
  display: flex; align-items: center; justify-content: center; flex: 0 0 34px;
}
.icon-btn svg { width: 16px; height: 16px; }

/* Corps + écrans */
.screens { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.screen {
  position: absolute; inset: 0; display: none; flex-direction: column; min-height: 0;
}
.screen.active { display: flex; }
.content { flex: 1; overflow-y: auto; padding: 4px 16px 16px; min-height: 0; }

/* Résumé chips */
.chips { display: flex; gap: 7px; flex-wrap: wrap; padding: 2px 16px 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 99px; padding: 5px 11px; font-size: 12px; color: var(--ink-2);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip strong { color: var(--ink); }
.d-ok { background: var(--good); }
.d-far { background: var(--serious); }
.d-lowbat { background: var(--warning); }
.d-offline { background: var(--critical); }

.searchbox {
  margin: 0 16px 10px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  padding: 8px 12px;
}
.searchbox input { flex: 1; border: 0; background: none; color: var(--ink); font-size: 13.5px; outline: none; min-width: 0; }
.searchbox svg { width: 15px; height: 15px; color: var(--muted); flex: 0 0 15px; }

/* Liste pèlerins */
.person {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
}
.person:active { transform: scale(0.99); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 40px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--ink); font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.avatar .st {
  position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--surface);
}
.person .mid { flex: 1; min-width: 0; }
.person .nm { font-weight: 600; font-size: 13.5px; }
.person .meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .end { text-align: right; flex: 0 0 auto; }
.person .dist { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.person .batt { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.batt.low { color: var(--critical); font-weight: 600; }

/* Carte */
.mapbox {
  margin: 2px 16px 10px; border: 1px solid var(--border); border-radius: 15px;
  overflow: hidden; background: var(--surface); position: relative;
}
.mapbox svg { width: 100%; height: auto; }
.map-legend {
  display: flex; gap: 12px; flex-wrap: wrap; padding: 0 18px 8px;
  font-size: 11.5px; color: var(--ink-2);
}
.map-legend .k { display: inline-flex; align-items: center; gap: 5px; }
.map-legend .dot { width: 9px; height: 9px; border-radius: 50%; }
.zone { fill: color-mix(in srgb, var(--ink) 4%, var(--surface)); stroke: var(--baseline); stroke-width: 0.8; }
.zone-haram { fill: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.map-lbl { font-size: 9px; fill: var(--muted); }
.map-lbl.big { font-size: 10.5px; fill: var(--ink-2); font-weight: 600; }
.pdot { cursor: pointer; }
@keyframes pulse { 0% { r: 7; opacity: 0.5; } 100% { r: 16; opacity: 0; } }
.pulse { animation: pulse 2s ease-out infinite; }

/* Bottom sheet */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 15;
  background: var(--surface); border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0; padding: 12px 18px 16px;
  transform: translateY(105%); transition: transform 0.2s ease, visibility 0.2s;
  box-shadow: 0 -8px 26px rgba(0, 0, 0, 0.18);
  visibility: hidden;
}
.sheet.open { transform: none; visibility: visible; }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--baseline); margin: 0 auto 10px; }

/* Alertes */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; padding: 11px 13px; margin-bottom: 8px;
}
.alert.acked { opacity: 0.55; }
.alert .ico { font-size: 19px; flex: 0 0 auto; margin-top: 1px; }
.alert .t { font-weight: 600; font-size: 13px; }
.alert .d { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.alert .time { font-size: 11px; color: var(--muted); margin-top: 3px; }
.alert .act { margin-left: auto; flex: 0 0 auto; }
.sev { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.sev.critical { background: var(--critical); }
.sev.serious { background: var(--serious); }
.sev.warning { background: var(--warning); }
.sev.info { background: var(--series); }

/* Cartes génériques dans l'app */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; padding: 13px 15px; margin-bottom: 10px;
}
.card h3 { margin: 0 0 2px; font-size: 13px; }
.card .sub { font-size: 11.5px; color: var(--muted); margin: 0 0 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

/* Écran Tests POC */
.hero-metric { display: flex; align-items: baseline; gap: 8px; }
.hero-metric .v { font-size: 34px; font-weight: 650; letter-spacing: -0.5px; }
.hero-metric .u { font-size: 14px; color: var(--muted); }
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--good); margin-right: 6px;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }
.chart { width: 100%; height: auto; }
.chart text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.axis-label { font-size: 9px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.base-line { stroke: var(--baseline); stroke-width: 1; }
.range-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.range-row:last-child { border-bottom: 0; }
.range-row .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.btn-row { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* Fiche pèlerin (sous-écran) */
.subscreen {
  position: absolute; inset: 0; z-index: 12;
  background: var(--page);
  transform: translateX(103%); transition: transform 0.22s ease;
  display: flex; flex-direction: column;
}
.subscreen.open { transform: none; }
.sub-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.sub-head h2 { margin: 0; font-size: 17px; flex: 1; }
.profile { text-align: center; padding: 6px 16px 2px; }
.profile .avatar { width: 66px; height: 66px; margin: 0 auto 8px; font-size: 20px; }
.profile .nm { font-size: 17px; font-weight: 700; }
.profile .meta { font-size: 12px; color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 99px;
  font-size: 11px; padding: 3px 9px; color: var(--ink-2); margin: 6px 3px 0;
}
.timeline { margin: 4px 0 0; }
.tl-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.tl-row:last-child { border-bottom: 0; }
.tl-row .time { color: var(--muted); flex: 0 0 44px; font-variant-numeric: tabular-nums; }
.tl-row .net { margin-left: auto; color: var(--muted); font-size: 11px; }

/* Barre d'onglets */
.tabbar {
  flex: 0 0 auto; display: flex; border-top: 1px solid var(--border);
  background: var(--surface); padding: 6px 6px calc(10px + env(safe-area-inset-bottom, 0px));
}
.tabbar button {
  flex: 1; background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; padding: 6px 2px; border-radius: 10px;
  position: relative;
}
.tabbar button.active { color: var(--accent); font-weight: 600; }
.tabbar svg { width: 21px; height: 21px; }
.tabbar .pill {
  position: absolute; top: 2px; right: 50%; margin-right: -22px;
  background: var(--critical); color: #fff;
  font-size: 9.5px; font-weight: 700; min-width: 15px; height: 15px;
  border-radius: 99px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* Modale (association carte) */
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.42); z-index: 25;
  display: none; align-items: flex-end;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 18px 18px 0 0;
  width: 100%; padding: 16px 20px 22px; text-align: center;
}
.scan-ring {
  width: 84px; height: 84px; margin: 14px auto; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  position: relative;
}
.scan-ring::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 3px solid var(--accent); border-color: var(--accent) transparent transparent transparent;
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast (dans le téléphone) */
.toast {
  position: absolute; bottom: 86px; left: 50%; transform: translate(-50%, 12px);
  background: var(--ink); color: var(--page);
  border-radius: 9px; padding: 9px 15px; font-size: 12.5px;
  opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 30;
  max-width: 85%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 13px; }

/* ================= Responsive ================= */
@media (max-width: 900px) { .side { display: none; } .stage { padding: 20px 10px 40px; } }
@media (max-width: 500px) {
  .stage { padding: 0; display: block; }
  .phone-wrap { width: 100%; }
  .phone {
    width: 100%; height: calc(100vh - 34px); min-height: 0;
    border: 0; border-radius: 0; box-shadow: none; outline: none;
  }
  .punch, .statusbar { display: none; }
}
