/* ============================================================
   TAO — Annuaire des entreprises (Bac pro TAO / BTS PO)
   Thème clair/sombre + 4 couleurs d'accent, pilotés par les
   attributs data-theme / data-accent sur <html> (js/theme.js).
   Pile de polices système : aucun fichier de police, chargement
   instantané (le site vise des lycées, souvent sur réseau limité).
============================================================ */

:root {
  --header-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;

  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --accent-contrast: #ffffff;
}

[data-accent="vert"]   { --accent: #15803d; --accent-strong: #166534; --accent-soft: #dcfce7; }
[data-accent="violet"] { --accent: #7c3aed; --accent-strong: #6d28d9; --accent-soft: #ede9fe; }
[data-accent="orange"] { --accent: #c2410c; --accent-strong: #9a3412; --accent-soft: #ffedd5; }

:root,
[data-theme="clair"] {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --text: #17253a;
  --muted: #5d6c83;
  --border: #d9e1ec;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #92400e;
  --warn-soft: #fef3c7;
}

[data-theme="sombre"] {
  color-scheme: dark;
  --bg: #0d1522;
  --surface: #151f30;
  --surface-2: #1c2940;
  --text: #e8eef7;
  --muted: #96a5bc;
  --border: #273954;
  --danger: #f87171;
  --danger-soft: #451a1a;
  --ok: #4ade80;
  --ok-soft: #14351f;
  --warn: #fbbf24;
  --warn-soft: #3a2c0a;
}

[data-theme="sombre"][data-accent="bleu"]   { --accent: #3b82f6; --accent-strong: #60a5fa; --accent-soft: #1e3a5f; }
[data-theme="sombre"][data-accent="vert"]   { --accent: #22c55e; --accent-strong: #4ade80; --accent-soft: #14351f; }
[data-theme="sombre"][data-accent="violet"] { --accent: #8b5cf6; --accent-strong: #a78bfa; --accent-soft: #2e2447; }
[data-theme="sombre"][data-accent="orange"] { --accent: #f97316; --accent-strong: #fb923c; --accent-soft: #3a2410; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

img, svg { max-width: 100%; }

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
a:hover { text-decoration-color: currentColor; }

.container { width: min(1100px, 100% - 32px); margin-inline: auto; }

h1, h2, h3 { line-height: 1.25; }

/* ============ En-tête / navigation (injectés par js/header.js) ============ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.brand .logo {
  width: 32px;
  height: 32px;
  flex: none;
  color: var(--accent);
}

.brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

.main-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.main-nav a {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
}

.main-nav a:hover { color: var(--text); background: var(--surface-2); }

.main-nav a.active { color: var(--accent-strong); background: var(--accent-soft); }

.header-auth { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.header-user { font-size: 13.5px; color: var(--muted); }

/* ============ Boutons ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  font-weight: 600;
  font-size: 15.5px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .05s;
}

.btn:hover { background: var(--accent-strong); }
.btn:active { transform: translateY(1px); }

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover { background: var(--surface-2); }

.btn.ghost {
  background: transparent;
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.btn.ghost:hover { background: var(--accent-soft); }

.btn.small { padding: 7px 12px; font-size: 14px; }

/* Pictogrammes de la filière (prothèse, orthèse, semelle) */
.footer-icon { width: 14px; height: 14px; fill: var(--accent); opacity: .6; vertical-align: -2px; margin-right: 3px; }

/* Décor flottant des héros (accueil, CV) : grands pictos sur les côtés */
.hero { position: relative; overflow: hidden; }
.hero-decor { position: absolute; inset: 0; pointer-events: none; }
.hero-decor svg { position: absolute; fill: var(--accent); }
.decor-p { width: 130px; left: 2%; top: 8%; opacity: .12; transform: rotate(-6deg); }
.decor-o { width: 120px; right: 3%; top: 12%; opacity: .13; transform: rotate(8deg); }
.decor-s { width: 105px; left: 13%; bottom: -14%; opacity: .09; transform: rotate(-14deg); }
@media (max-width: 900px) { .hero-decor { display: none; } }
@media (prefers-reduced-motion: no-preference) {
  .hero-decor svg { animation: decor-flotte 8s ease-in-out infinite; }
  .hero-decor svg:nth-child(2) { animation-delay: -3s; }
  .hero-decor svg:nth-child(3) { animation-delay: -5.5s; }
  @keyframes decor-flotte { 0%, 100% { translate: 0 0; } 50% { translate: 0 -12px; } }
}

/* Questionnaire de signalement : confort de lecture et de sélection. */
#signaler-form {
  font-size: 16px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-top: 10px;
}
#signaler-form .checkbox-line {
  font-size: 16px;
  padding: 8px 10px;
  margin: 4px 0;
  border-radius: 6px;
  cursor: pointer;
}
#signaler-form .checkbox-line:hover { background: var(--accent-soft); }
#signaler-form input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin-right: 4px;
}
#signaler-form textarea { font-size: 16px; min-height: 70px; }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Connexions externes : style « marque » (fond blanc, bord gris), comme
   les boutons officiels Google/Microsoft — lisible dans les deux thèmes. */
.btn-ext {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 1px solid #dadce0;
  border-radius: 8px;
  background: #ffffff;
  color: #1f1f1f;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: box-shadow .15s, background .15s;
}
.btn-ext:hover { background: #f6f9ff; box-shadow: 0 1px 3px rgba(60, 64, 67, .25); }
.btn-ext svg { flex: none; }

/* ============ Cartes / sections ============ */

.page { padding: 28px 0 56px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.hero {
  padding: 48px 0 40px;
  text-align: center;
}

.hero h1 { font-size: clamp(26px, 5vw, 40px); margin: 0 0 12px; }
.hero p { color: var(--muted); font-size: 18px; max-width: 640px; margin: 0 auto 24px; }
.hero .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.stat-band {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 24px 0 8px;
  color: var(--muted);
  font-size: 14.5px;
}

.stat-band strong { color: var(--accent); font-size: 18px; }

/* ============ Badges & chips ============ */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 500;
}

/* ============ Formulaires ============ */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text);
}

.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="tel"], input[type="url"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

textarea { resize: vertical; min-height: 70px; }

.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

.form-msg { font-size: 14px; margin-top: 10px; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--ok); }

.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 14.5px; margin: 6px 0; }

/* ============ Annuaire : recherche d'abord, carte compacte à droite ============ */

.search-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.search-form { display: grid; gap: 10px; }

.search-form .field { margin-bottom: 0; }

@media (min-width: 900px) {
  .search-form { grid-template-columns: 1.3fr 1.1fr 110px 1.1fr auto; align-items: end; }
}

.results-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}

.map-col {
  position: sticky;
  top: calc(var(--header-h) + 12px);
}

.map-zone {
  position: relative;
  height: calc(100dvh - var(--header-h) - 80px);
  min-height: 320px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#map { position: absolute; inset: 0; background: var(--surface-2); }

.map-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 900;
  display: none;
}

/* Plein écran de la carte (mobile surtout). */
.results-layout.map-full .map-col {
  position: fixed;
  inset: var(--header-h) 12px 12px 12px;
  z-index: 950;
}
.results-layout.map-full .map-zone { height: 100%; }

@media (max-width: 1023px) {
  .results-layout { grid-template-columns: 1fr; }
  .map-col { position: static; }
  .map-zone { height: 38dvh; min-height: 240px; }
  .map-toggle { display: inline-flex; }
}

/* Autocomplete ville */
.ville-box { position: relative; }
.ville-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 260px;
  overflow-y: auto;
}
.ville-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.ville-list button:hover, .ville-list button[aria-selected="true"] { background: var(--accent-soft); }
.ville-list button small { display: block; color: var(--muted); font-size: 12px; }

.selected-ville {
  font-size: 13px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.selected-ville button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; }

.compteur { font-size: 14px; color: var(--muted); margin: 12px 0 8px; }

.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.result-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.result-card header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.result-num {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.result-card h3 { font-size: 15.5px; margin: 0; }
.result-card .ville { color: var(--muted); font-size: 13px; }
.result-card .actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.result-card .actions a { font-size: 13.5px; }

details.hors-zone { margin-top: 14px; font-size: 13.5px; color: var(--muted); }

/* Pastilles de regroupement (vue d'ensemble France) : clic = zoom sur le
   groupe, sinon points individuels plus gros et faciles à cliquer. */
.tao-cluster {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 88%, transparent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  border: 2px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}

/* Marqueurs Leaflet (divIcon, pas d'images) */
.tao-pin {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.tao-pin span { transform: rotate(45deg); }
.tao-pin--approx { background: transparent; color: var(--accent); border-style: dashed; }
.tao-pin--active { transform: rotate(-45deg) scale(1.18); z-index: 1000; }

.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content { margin: 12px 14px; font: inherit; }
.popup-nom { font-weight: 700; margin-bottom: 4px; }
.popup-addr { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* ============ Fiche entreprise ============ */

#fiche-map { height: 240px; border-radius: var(--radius-sm); border: 1px solid var(--border); z-index: 1; }


.fiche-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.fiche-head h1 { margin: 0; font-size: clamp(22px, 4vw, 32px); }

.fiche-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

@media (max-width: 860px) { .fiche-grid { grid-template-columns: 1fr; } }

.contact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.contact-list li { display: flex; gap: 10px; align-items: baseline; }
.contact-list .label { flex: none; width: 92px; font-size: 13px; color: var(--muted); font-weight: 600; }

.back-link { display: inline-block; margin-bottom: 14px; font-size: 14px; }

/* ============ Suivi (3 colonnes) ============ */

.suivi-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: start;
}

@media (max-width: 860px) { .suivi-columns { grid-template-columns: 1fr; } }

.suivi-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.suivi-col > h2 {
  font-size: 15px;
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.suivi-col > h2 .count {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 13px;
}

.suivi-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}

.suivi-card h3 { font-size: 15px; margin: 0 0 2px; }
.suivi-card .ville { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.suivi-card textarea { margin-top: 8px; font-size: 13.5px; }
.suivi-card .card-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.save-state { font-size: 12px; color: var(--ok); min-height: 16px; margin-top: 4px; }

/* ============ Paramètres ============ */

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }

.theme-options { display: flex; gap: 10px; }
.theme-options label {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
}
.theme-options input { margin-right: 6px; }
.theme-options label.checked { border-color: var(--accent); background: var(--accent-soft); }

.accent-options { display: flex; gap: 10px; }
.accent-swatch {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.accent-swatch.checked { border-color: var(--text); }

/* ============ Admin ============ */

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 16px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
table.data td .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.admin-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 700px) { .admin-form-grid { grid-template-columns: 1fr; } }

/* ============ Divers ============ */

.notice {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.notice.error { background: var(--danger-soft); color: var(--danger); }

.page-title { margin: 0 0 6px; font-size: clamp(22px, 4vw, 30px); }
.page-sub { color: var(--muted); margin: 0 0 22px; }

.section-title { font-size: 19px; margin: 26px 0 10px; }

.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 18px 0 26px; color: var(--muted); font-size: 13px; }
.site-footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-legal { flex-basis: 100%; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.footer-legal h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.footer-legal ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-legal a { color: var(--muted); }
.footer-legal a:hover { color: var(--text); }
.footer-legal .copyright { margin: 10px 0 0; }

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 2000;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
