/* =============================================================================
 * css/style.css — Balise
 * -----------------------------------------------------------------------------
 * Système de design repris de BiblioPrompt v2 (mêmes patrons : appbar, cartes,
 * dialogues, FAB, splash) avec un accent orange (signal/sécurité) à la place
 * du rouge. Palette : orange (accent unique) + gris + blanc + noir.
 * Thèmes pilotés par [data-theme] ; bascule auto via JS.
 * Variable sentinelle --app-loaded pour le garde-fou de décompression.
 * ========================================================================== */

:root { --app-loaded: 1; }

/* ---------- THÈME CLAIR ---------- */
:root, :root[data-theme="light"] {
  --accent:        #e8590c;
  --accent-strong: #b3450a;
  --accent-soft:   #fde8d8;
  --on-accent:     #ffffff;

  --bg:            #f4f4f5;
  --surface:       #ffffff;
  --surface-2:     #ededf0;
  --surface-3:     #e3e3e7;
  --on-surface:    #1f1b18;
  --on-surface-var:#5f5f66;
  --outline:       #d2d2d7;
  --outline-soft:  #e8e8ec;

  --shadow-1: 0 1px 2px rgba(0,0,0,.10);
  --shadow-2: 0 4px 12px rgba(0,0,0,.12);
  --shadow-3: 0 12px 30px rgba(0,0,0,.20);
}

/* ---------- THÈME SOMBRE ---------- */
:root[data-theme="dark"] {
  --accent:        #ff8a3d;
  --accent-strong: #ffa564;
  --accent-soft:   #4a2a14;
  --on-accent:     #1a0d04;

  --bg:            #0e0e10;
  --surface:       #1a1a1d;
  --surface-2:     #232327;
  --surface-3:     #2c2c31;
  --on-surface:    #f1f1f3;
  --on-surface-var:#a1a1aa;
  --outline:       #38383e;
  --outline-soft:  #2a2a2f;

  --shadow-1: 0 1px 2px rgba(0,0,0,.5);
  --shadow-2: 0 4px 14px rgba(0,0,0,.55);
  --shadow-3: 0 14px 34px rgba(0,0,0,.65);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--on-surface);
  font-family: "Inter", "Roboto", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Icônes Material auto-hébergées. Repli si la police ne charge pas : masquer
   le texte de ligature plutôt que d'afficher des noms bruts. */
.mi {
  font-family: "Material Icons"; font-weight: normal; font-style: normal;
  font-size: 20px; line-height: 1; vertical-align: middle; white-space: nowrap;
  -webkit-font-feature-settings: "liga"; font-feature-settings: "liga";
}
.no-icons .mi { font-size: 0 !important; }

/* ======================= BARRE D'APPLICATION ======================= */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--outline-soft); box-shadow: var(--shadow-1);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-1);
}
.brand-mark .mi { font-size: 22px; }
.brand h1 { font-size: 20px; letter-spacing: .2px; }
.brand .sub { font-size: 12px; color: var(--on-surface-var); margin-top: -2px; }
.appbar-spacer { flex: 1; }
.appbar-actions { display: flex; align-items: center; gap: 4px; }

/* ======================= BOUTONS ======================= */
.btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 10px 20px; font-size: 14px; font-weight: 600;
  background: var(--surface-2); color: var(--on-surface);
  transition: background .15s, box-shadow .15s, transform .05s, border-color .15s;
}
.btn:active { transform: scale(.98); }
.btn .mi { font-size: 18px; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--accent-strong); box-shadow: var(--shadow-2); }
.btn-ghost { background: transparent; border-color: var(--outline); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-text { background: transparent; }
.btn-text:hover { background: var(--surface-2); }
.btn-danger { background: var(--accent-strong); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: none; border-radius: 50%; background: transparent; color: var(--on-surface-var);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--on-surface); }
.icon-btn.active, .icon-btn[aria-pressed="true"] { color: var(--accent); }

/* ======================= GRILLE + CARTES ======================= */
.toolbar { max-width: 1180px; margin: 0 auto; padding: 24px 24px 0; }
.statusbar {
  max-width: 1180px; margin: 18px auto 0; padding: 0 24px;
  display: flex; align-items: center; gap: 12px; color: var(--on-surface-var); font-size: 13px;
}
.grid {
  max-width: 1180px; margin: 12px auto 120px; padding: 0 24px;
  display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
}
.card {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--outline-soft); border-radius: 18px;
  padding: 20px; box-shadow: var(--shadow-1);
  transition: box-shadow .2s, transform .1s, border-color .2s;
}
.card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-title { flex: 1; font-size: 17px; line-height: 1.3; word-break: break-word; }
.card-desc, .meta { margin: 0; color: var(--on-surface-var); font-size: 13.5px; }
.card-foot {
  margin-top: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 4px;
}
.card-actions, .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--outline); border-radius: 999px;
  padding: 5px 13px; font-size: 12.5px; font-weight: 600;
  background: var(--surface); color: var(--on-surface);
}
.chip-active { background: var(--accent); color: var(--on-accent); border-color: transparent; }

/* ======================= PARTAGE PAR LIEN ======================= */
.share-link-row { display: flex; gap: 8px; margin-bottom: 4px; }
.share-link {
  flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--outline);
  background: var(--surface-2); color: var(--on-surface-var); font-size: 12.5px;
  word-break: break-all; font-family: "Roboto Mono", ui-monospace, monospace;
}

/* ======================= CONTACTS ======================= */
.contact-list { display: flex; flex-direction: column; }
.contact-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--outline-soft);
}
.contact-row:last-child { border-bottom: none; }
.contact-row .name { font-weight: 600; }
.contact-row .phone { color: var(--on-surface-var); font-size: 13px; margin-left: 8px; }
.contact-checklist { display: flex; flex-direction: column; gap: 10px; margin: 4px 0; }
.contact-checklist label { display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* ======================= BANNIÈRES (suivi, vérification email…) ======================= */
#persist-banner, #verify-banner, .tracking-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  max-width: 1180px; margin: 16px auto 0; padding: 14px 20px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 14px; color: var(--on-surface); font-size: 13.5px;
}
#persist-banner[hidden], #verify-banner[hidden], .tracking-banner[hidden] { display: none; }
.persist-banner-icon { color: var(--accent); font-size: 22px; flex-shrink: 0; }
.persist-banner-msg, .tracking-banner span:first-child { flex: 1; min-width: 200px; }
.tracking-banner:not(.stale) { background: var(--surface-2); border-color: var(--outline-soft); }
@media (max-width: 640px) {
  #persist-banner, #verify-banner, .tracking-banner { margin: 12px 16px 0; border-radius: 12px; }
}

/* ======================= ÉTAT VIDE ======================= */
.empty { max-width: 460px; margin: 60px auto; text-align: center; padding: 0 24px; }
.empty .mi { font-size: 64px; color: var(--on-surface-var); opacity: .5; }
.empty h2 { font-size: 20px; margin: 16px 0 8px; }
.empty p { color: var(--on-surface-var); margin: 0 0 24px; }

/* ======================= FAB ======================= */
.fab {
  position: fixed; right: 28px; bottom: 28px; z-index: 30;
  display: inline-flex; align-items: center; gap: 10px;
  border: none; border-radius: 16px; padding: 16px 22px; font-size: 15px; font-weight: 700;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-3);
  transition: transform .12s, box-shadow .2s, background .15s;
}
.fab:hover { transform: translateY(-2px); background: var(--accent-strong); }
.fab .mi { font-size: 22px; }

/* ======================= DIALOGUES ======================= */
dialog {
  border: none; border-radius: 22px; padding: 0;
  background: var(--surface); color: var(--on-surface); box-shadow: var(--shadow-3);
  max-width: 520px; width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 24px 24px 8px; }
.dialog-head h2 { font-size: 20px; flex: 1; }
.dialog-body { padding: 8px 24px; max-height: 64vh; overflow: auto; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 16px 24px 24px; flex-wrap: wrap; }
.dialog-foot .spacer { flex: 1; }

.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--on-surface-var); margin-bottom: 6px; }
.field input[type="text"], .field input[type="tel"], .field input[type="datetime-local"],
.field textarea, .field select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--outline); border-radius: 10px;
  background: var(--surface); color: var(--on-surface); font-family: inherit; font-size: 14px; resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint { font-size: 12px; color: var(--on-surface-var); margin-top: 5px; }

/* ======================= TOAST ======================= */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  z-index: 60; max-width: 90vw; background: var(--on-surface); color: var(--surface);
  padding: 13px 20px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
#toast.toast-show { opacity: 1; transform: translate(-50%, 0); }

/* ======================= SPLASH ======================= */
#splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--bg); transition: opacity .4s;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-mark {
  width: 64px; height: 64px; border-radius: 16px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; animation: pulse 1.1s ease-in-out infinite; box-shadow: var(--shadow-2);
}
.splash-mark .mi { font-size: 34px; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .splash-mark { animation: none; } .card:hover { transform: none; } }

/* ======================= GARDE-FOU DE DÉCOMPRESSION ======================= */
#unzip-error {
  position: fixed; inset: 0; z-index: 200; display: none; place-items: center; padding: 24px;
  background: #0e0e10; color: #fff;
}
#unzip-error .box { max-width: 480px; background: #1a1a1d; border-radius: 14px; padding: 28px; border: 1px solid var(--accent); }
#unzip-error h2 { color: #ff8a3d; margin-bottom: 12px; }
#unzip-error p { color: #d0d0d4; line-height: 1.6; }

/* ======================= ÉCRAN D'AUTHENTIFICATION ======================= */
#auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
#auth-screen[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--outline); border-radius: 18px;
  padding: 32px 28px; box-shadow: var(--shadow-2); text-align: center;
}
.auth-card h1 { margin: 12px 0 4px; font-size: 22px; }
.auth-card .sub { color: var(--on-surface-var); font-size: 14px; margin-bottom: 20px; }
.auth-card .brand-mark { margin: 0 auto 8px; }
.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; border: none; background: transparent; padding: 8px 0; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--on-surface-var); cursor: pointer;
}
.auth-tab.active { background: var(--surface); color: var(--on-surface); box-shadow: var(--shadow-1); }
.auth-form { text-align: left; }
.auth-form[hidden] { display: none; }
.auth-form .field input { width: 100%; }
.auth-submit { width: 100%; justify-content: center; margin-top: 4px; }
.auth-error, .auth-info {
  font-size: 13px; padding: 10px 12px; border-radius: 10px; margin-bottom: 16px; text-align: left;
}
.auth-error { background: var(--accent-soft); color: var(--accent-strong); border: 1px solid var(--accent); }
.auth-info { background: var(--surface-2); color: var(--on-surface); border: 1px solid var(--outline); }
.auth-error[hidden], .auth-info[hidden] { display: none; }
.auth-remember {
  display: flex; align-items: center; gap: 8px; margin: -6px 0 14px;
  font-size: 13px; color: var(--on-surface-var); cursor: pointer;
}
.auth-remember input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ======================= ZONE ADMIN ======================= */
.admin-page { max-width: 800px; margin: 0 auto; padding: 16px; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.admin-table th, .admin-table td {
  text-align: left; padding: 8px; border-bottom: 1px solid var(--outline-soft);
}

/* ======================= PAGE PUBLIQUE DE SUIVI (proche) ======================= */
.shared-page { max-width: 640px; margin: 0 auto; padding: 16px; }
#map { height: 360px; border-radius: 18px; border: 1px solid var(--outline-soft); }
.no-map-fallback { padding: 16px; background: var(--surface-2); border-radius: 12px; }

/* ======================= RESPONSIVE ======================= */
@media (max-width: 640px) {
  .appbar { padding: 10px 16px; }
  .brand .sub { display: none; }
  .toolbar, .statusbar, .grid { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: 1fr; }
  .fab { right: 16px; bottom: 16px; padding: 14px 18px; }
  .appbar h1 { font-size: 18px; }
  .fab .label { display: none; }
}
