/* localiser — interface d'administration */

:root {
  --fond: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --bord: #dde1e6;
  --texte: #1a1d21;
  --texte-2: #5c6570;
  --accent: #2563eb;
  --accent-texte: #ffffff;
  --accent-doux: #e6eefc;
  --ok: #15803d;
  --ok-doux: #e3f4e8;
  --attention: #b45309;
  --attention-doux: #fdf0dc;
  --danger: #b91c1c;
  --danger-doux: #fde8e8;
  --neutre-doux: #eceef1;
  --ombre: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .08);
  --rayon: 10px;
  --barre-h: 56px;
  color-scheme: light;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --bord: #2c333d;
    --texte: #e8ebef;
    --texte-2: #9aa4b1;
    --accent: #5b8def;
    --accent-texte: #0b1220;
    --accent-doux: #1b2a45;
    --ok: #4ade80;
    --ok-doux: #13301e;
    --attention: #fbbf24;
    --attention-doux: #3a2a0c;
    --danger: #f87171;
    --danger-doux: #3b1616;
    --neutre-doux: #232932;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--fond); color: var(--texte); }

h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 18px; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  border: 1px solid var(--bord);
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: background .12s, border-color .12s, opacity .12s;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.primaire { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
button.primaire:hover { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--bord)); }
button.danger:hover { background: var(--danger-doux); }
button.discret { border-color: transparent; background: transparent; color: var(--texte-2); }
button.discret:hover { background: var(--surface-2); color: var(--texte); }
button.lien { border: 0; background: none; padding: 4px 0; color: var(--accent); }
button.lien:hover { text-decoration: underline; background: none; }

input, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--bord);
  border-radius: 8px;
  background: var(--surface);
}
label, .etiquette { display: block; font-size: 13px; font-weight: 600; color: var(--texte-2); margin: 14px 0 6px; }

.logo {
  width: 44px; height: 44px; border-radius: 12px;
  background:
    radial-gradient(circle at 50% 42%, var(--accent-texte) 0 18%, transparent 19%),
    radial-gradient(circle at 50% 42%, var(--accent) 0 40%, transparent 41%),
    var(--accent-doux);
}
.logo.petit { width: 26px; height: 26px; border-radius: 8px; }

.erreur { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.aide { color: var(--texte-2); font-size: 13px; margin: 6px 0 0; }
.aide.consentement { margin-top: 12px; padding: 8px 10px; border-radius: 8px; background: var(--attention-doux); color: var(--texte); }

/* ---------- Connexion ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.carte-login {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--bord);
  border-radius: 14px; padding: 28px 24px; box-shadow: var(--ombre);
}
.carte-login h1 { font-size: 24px; margin-top: 14px; }
.sous-titre { color: var(--texte-2); margin: 4px 0 8px; }
.carte-login button { width: 100%; margin-top: 18px; padding: 10px; }
.carte-login .copie button { width: auto; margin-top: 0; padding: 8px 12px; }
a.bouton {
  display: block; text-align: center; text-decoration: none; font-weight: 600;
  padding: 12px; border-radius: 8px; margin: 16px 0 6px;
}
a.bouton.primaire { background: var(--accent); color: var(--accent-texte); }

/* ---------- Application ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: var(--barre-h) 1fr;
  grid-template-areas: "barre barre" "panneau carte";
}
.barre {
  grid-area: barre; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--bord);
}
.marque { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.statut-maj { color: var(--texte-2); font-size: 13px; }
.barre-actions { margin-left: auto; display: flex; gap: 8px; }

.panneau {
  grid-area: panneau; overflow-y: auto; padding: 16px;
  background: var(--surface); border-right: 1px solid var(--bord);
}
#carte { grid-area: carte; min-height: 0; background: var(--surface-2); }

.titre-section { display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-2); margin-bottom: 10px; }
.compteur { background: var(--neutre-doux); color: var(--texte-2); padding: 1px 8px; border-radius: 99px; font-size: 12px; }

.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.liste button {
  width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  padding: 12px; border-radius: var(--rayon);
}
.liste .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste .meta { grid-column: 1 / -1; color: var(--texte-2); font-size: 13px; }
.liste .selection { border-color: var(--accent); background: var(--accent-doux); }

.vide { text-align: center; color: var(--texte-2); padding: 24px 8px; }
.vide button { margin-top: 8px; }

.pastille {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 99px; white-space: nowrap; align-self: start;
}
.pastille::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pastille.en-ligne { background: var(--ok-doux); color: var(--ok); }
.pastille.recent { background: var(--attention-doux); color: var(--attention); }
.pastille.hors-ligne, .pastille.jamais { background: var(--neutre-doux); color: var(--texte-2); }

.entete-detail { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 10px 0 12px; }
.entete-detail h2 { font-size: 21px; overflow-wrap: anywhere; }

.bandeau {
  margin: 0 0 12px; padding: 9px 12px; border-radius: 8px; font-size: 14px;
  background: var(--accent-doux); display: flex; align-items: center; gap: 10px;
}
.bandeau button { margin-left: auto; padding: 4px 10px; font-size: 13px; }

.actions-principales { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions-principales button { padding: 10px; }
.actions-secondaires { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--bord); }

.infos { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 16px 0 4px; font-size: 14px; }
.infos dt { color: var(--texte-2); }
.infos dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* ---------- Dialogues ---------- */
dialog {
  border: 1px solid var(--bord); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--texte); box-shadow: var(--ombre);
}
dialog::backdrop { background: rgba(10, 14, 20, .45); }
dialog form, .dlg-contenu { padding: 22px 22px 18px; }
.pied { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.alerte { background: var(--attention-doux); padding: 9px 12px; border-radius: 8px; font-size: 14px; margin: 12px 0; }

.config-grille { display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: center; }
#config-qr { width: 240px; height: 240px; background: #fff; border-radius: 10px; border: 1px solid var(--bord); }
.etapes { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
details { margin-top: 14px; }
summary { cursor: pointer; color: var(--texte-2); font-size: 14px; }
.copie { display: flex; gap: 6px; }
.copie input { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000;
  background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--ombre); font-size: 14px; max-width: calc(100vw - 32px);
}
.toast.erreur-toast { background: var(--danger); color: #fff; }

/* ---------- Carte ---------- */
.leaflet-container { font: inherit; background: var(--surface-2); }
.popup-nom { font-weight: 600; }
.popup-meta { color: #5c6570; font-size: 12px; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--barre-h) 45vh auto;
    grid-template-areas: "barre" "carte" "panneau";
    height: auto; min-height: 100%;
  }
  .panneau { border-right: 0; border-top: 1px solid var(--bord); overflow: visible; }
  .barre { padding: 0 12px; gap: 8px; }
  .statut-maj { display: none; }
  #btn-ajouter { padding: 8px 10px; }
  .config-grille { grid-template-columns: 1fr; justify-items: center; }
}
