/* === Thème par défaut : CLAIR === */
:root{
  --bg: #f7f8fb;
  --card: #ffffff;
  --muted: #556070;
  --text: #111827;
  --primary: #2f6df6;
  --accent: #16a34a;
  --ring: rgba(47,109,246,.25);
  --border: #e5e7eb;
  --warning:#d97706;

  /* Entêtes de sections */
  --hdr-bg:#eef2f7;   /* fond h2 (sections I/II/III…) */
  --line:#e5e7eb;     /* traits fins */
}

/* Forçage manuel clair */
html[data-theme="light"]{
  --bg:#f7f8fb; --card:#fff; --muted:#556070; --text:#111827;
  --primary:#2f6df6; --accent:#16a34a; --ring:rgba(47,109,246,.25);
  --border:#e5e7eb; --warning:#d97706;
  --hdr-bg:#eef2f7; --line:#e5e7eb;
}

/* Forçage manuel sombre */
html[data-theme="dark"]{
  --bg:#0b1220; --card:#0f172a; --muted:#94a3b8; --text:#e2e8f0;
  --primary:#5b9cff; --accent:#22c55e; --ring:rgba(91,156,255,.45);
  --border:#1f2a44; --warning:#f59e0b;

  /* Entêtes visibles en dark */
  --hdr-bg:#16223a;   /* fond h2 plus soutenu */
  --line:#223054;     /* bordure h2/traits */
}

/* Mode AUTO (suit l’OS) */
@media (prefers-color-scheme: light){
  html[data-theme="auto"]{
    --bg:#f7f8fb; --card:#fff; --muted:#556070; --text:#111827;
    --primary:#2f6df6; --accent:#16a34a; --ring:rgba(47,109,246,.25);
    --border:#e5e7eb; --warning:#d97706;
    --hdr-bg:#eef2f7; --line:#e5e7eb;
  }
}
@media (prefers-color-scheme: dark){
  html[data-theme="auto"]{
    --bg:#0b1220; --card:#0f172a; --muted:#94a3b8; --text:#e2e8f0;
    --primary:#5b9cff; --accent:#22c55e; --ring:rgba(91,156,255,.45);
    --border:#1f2a44; --warning:#f59e0b;
    --hdr-bg:#16223a; --line:#223054;
  }
}

/* (le reste) */
*{box-sizing:border-box}
body{
  font-family:Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(1200px 1200px at 0% 0%, rgba(47,109,246,.08), transparent 40%),
    radial-gradient(1200px 1200px at 100% 0%, rgba(34,197,94,.08), transparent 40%),
    var(--bg);
  color: var(--text);
  margin:0;
}
a{color:var(--primary); text-decoration:none}
a:hover{text-decoration:underline}

/* Assure-toi que les titres de sections utilisent bien les variables */
.section h2{
  background: var(--hdr-bg);
  border: 1px solid var(--line);
  color: var(--text);
}

/* Form controls de base */
input, select, textarea {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .42rem .6rem;
}

/* Icône chevron + suppression du style natif trop pâle */
select{
  appearance: none;           /* -webkit-appearance pour Safari si besoin */
  background-image: url("data:image/svg+xml;utf8,\<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23556070' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right .55rem center;
  background-size: 12px 12px;
  padding-right: 1.6rem;
}

/* Liste déroulante : couleurs lisibles (selon le thème) */
select option, select optgroup{
  background: var(--card);
  color: var(--text);
}

/* Focus visible */
input:focus, select:focus, textarea:focus{
  outline: 2px solid var(--ring);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Placeholders moins vifs */
input::placeholder, textarea::placeholder{
  color: color-mix(in srgb, var(--muted) 70%, transparent);
  opacity: 1;
}

/* Au cas où certains navigateurs ignorent var() dans la liste :
   on redéclare explicitement en dark */
html[data-theme="dark"] select,
html[data-theme="dark"] option,
html[data-theme="dark"] optgroup{
  background-color: #0f172a;   /* = --card */
  color: #e2e8f0;              /* = --text */
}

/* Layout */
.nav{
  position: sticky; top:0; z-index:50;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,0));
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border);
}
.nav-inner{max-width:1100px; margin:0 auto; padding:.6rem 1rem; display:flex; align-items:center; gap:1rem; justify-content:space-between;}
.brand{display:flex; align-items:center; gap:.6rem; font-weight:700; letter-spacing:.2px;}
.brand-badge{display:inline-grid; place-items:center; width:32px; height:32px; border-radius:10px; background:linear-gradient(135deg,var(--primary),#8ab7ff); color:white; font-weight:700}
.nav-links{display:flex; gap:.8rem; align-items:center}
.nav-links a{padding:.3rem .6rem; border-radius:8px}
.nav-links a:hover{background:color-mix(in oklab, var(--primary) 10%, transparent)}
.theme-toggle{cursor:pointer; padding:.3rem .6rem; border:1px solid var(--border); border-radius:8px; background:var(--card); color:var(--text);}

.container{max-width:1100px; margin:1.2rem auto 3rem; padding:0 1rem;}

/* Cards / Panels */
.panel{border:1px solid var(--border); border-radius:16px; background:var(--card); overflow:hidden; margin:1rem 0;}
.panel summary{
  list-style:none; cursor:pointer; padding:1rem 1.1rem; display:flex; align-items:center; justify-content:space-between; gap:1rem;
  font-weight:600; background:linear-gradient(180deg, color-mix(in oklab, var(--card) 85%, white 15%), var(--card));
}
.panel summary::-webkit-details-marker{display:none}
.panel[open] summary{border-bottom:1px solid var(--border)}
.panel-title{display:flex; align-items:center; gap:.65rem;}
.panel-badge{font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color:var(--muted); background:transparent; border:1px dashed var(--border); padding:.2rem .4rem; border-radius:6px}
.chev{transition:transform .2s ease}
.panel[open] .chev{transform:rotate(180deg)}
.panel-body{padding:1rem 1.1rem}

/* Form */
label{font-weight:600; color:var(--muted)}
input, select, textarea{
  width:100%; padding:.6rem .7rem; border:1px solid var(--border); border-radius:10px; background:transparent; color:var(--text);
  outline:none; transition: box-shadow .2s ease, border-color .2s ease;
}
input:focus, select:focus, textarea:focus{
  border-color: var(--primary);
  box-shadow: 0 0 0 .25rem var(--ring);
}
.grid{display:grid; gap:1rem}
.grid-2{grid-template-columns:repeat(2, minmax(0,1fr))}
.grid-3{grid-template-columns:repeat(3, minmax(0,1fr))}
@media (max-width: 860px){ .grid-2, .grid-3{grid-template-columns:1fr} }

.hint{font-size:.85rem; color:var(--muted)}
.chip{display:inline-block; padding:.15rem .5rem; border-radius:999px; border:1px solid var(--border); font:12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color:var(--muted)}
.required::after{content:" *"; color:var(--warning);}

/* Map */
.map{ height:260px; border:1px solid var(--border); border-radius:12px; }
.map-box { display: grid; gap: .5rem; }
.map-head { display:flex; align-items:center; gap:.5rem; justify-content: space-between; }
.coords { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; opacity:.8; }
.btn { padding:.5rem .8rem; border:1px solid var(--border); border-radius:10px; cursor:pointer; background:transparent; color:var(--text);}
.btn:hover{background:color-mix(in oklab, var(--primary) 8%, transparent)}
.btn-primary{background:linear-gradient(135deg, var(--primary), color-mix(in oklab, var(--primary) 40%, #000 0%)); color:white; border-color:transparent}
.btn-primary:hover{filter:saturate(1.05) brightness(1.05)}


/* Actions bar */
.actions-bar{
  position: sticky; bottom:0; z-index:40; margin-top:1rem;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.04));
  padding: .8rem 0;
}
.actions{display:flex; gap:.6rem; justify-content:flex-end}
.msg{padding:.75rem 1rem; border-radius:10px; background:color-mix(in oklab, var(--primary) 12%, transparent); border:1px solid var(--border); margin:1rem 0;}

/* Table (list) */
table{width:100%; border-collapse:separate; border-spacing:0; overflow:hidden; border-radius:12px; border:1px solid var(--border); background:var(--card)}
thead th{background:linear-gradient(180deg, color-mix(in oklab, var(--card) 85%, white 15%), var(--card)); text-align:left; padding:.7rem; border-bottom:1px solid var(--border); position:sticky; top:0; z-index:1}
tbody td{padding:.6rem .7rem; border-bottom:1px solid var(--border)}
tbody tr:hover{background:color-mix(in oklab, var(--primary) 7%, transparent)}
.filters input{width:100%; border:1px dashed var(--border); border-radius:8px; padding:.4rem .5rem}


.nav-links .linklike{
  background:transparent;
  border:0;
  color:var(--primary);
  padding:.3rem .6rem;
  border-radius:8px;
  cursor:pointer;
}
.nav-links .linklike:hover{
  background:color-mix(in oklab, var(--primary) 10%, transparent);
  text-decoration:underline;
}

/* Zone centrée en haut */
.flash-zone{
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: min(92vw, 720px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none; /* la zone ignore les clics... */
}

/* ...sauf les cartes */
.flash{
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #16a34a;     /* vert CIE */
  background: #e8f7ef;           /* fond vert très clair */
  color: #065f46;                 /* texte vert foncé */
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  transition: opacity .25s ease, transform .25s ease;
}

/* Variantes (si tu utilises messages.error, etc.) */
.flash-success { background:#e8f7ef; border-color:#16a34a; color:#065f46; }
.flash-error   { background:#fde8e8; border-color:#ef4444; color:#7f1d1d; }
.flash-warning { background:#fff7ed; border-color:#f59e0b; color:#7c2d12; }
.flash-info    { background:#eff6ff; border-color:#3b82f6; color:#1e3a8a; }

/* Bouton fermer */
.flash-close{
  all: unset;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  margin-left: 6px;
  opacity: .7;
}
.flash-close:hover{ opacity: 1; }

/* Animation de sortie */
.flash.is-hiding{ opacity: 0; transform: translateY(-6px); }