/* Feuille unique : site public + admin + login */
:root {
  --fond: #f7f4ee;
  --surface: #ffffff;
  --texte: #2b2723;
  --discret: #6f675e;
  --bord: #e2dcd2;
  --primaire: #2f6f8f;
  --primaire-texte: #ffffff;
  --accent: #c8642a;
  --ok: #2e7d4f;
  --danger: #b33a3a;
  --ombre: 0 1px 3px rgba(40, 30, 20, .08), 0 4px 14px rgba(40, 30, 20, .06);
  --rayon: 10px;
  color-scheme: light;
}
/* Thème : data-theme="light" | "dark" posé sur <html> par le serveur (cookie pc_theme, voir theme_courant()) ;
   sans attribut, le thème suit le système. Les deux blocs sombres doivent rester identiques. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #1d1b19;
    --surface: #282522;
    --texte: #ece6dd;
    --discret: #a69d92;
    --bord: #3b3733;
    --primaire: #5aa3c7;
    --primaire-texte: #10202a;
    --accent: #e08a52;
    --ok: #5cbf86;
    --danger: #e07070;
    --ombre: 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #1d1b19;
  --surface: #282522;
  --texte: #ece6dd;
  --discret: #a69d92;
  --bord: #3b3733;
  --primaire: #5aa3c7;
  --primaire-texte: #10202a;
  --accent: #e08a52;
  --ok: #5cbf86;
  --danger: #e07070;
  --ombre: 0 1px 3px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
}
body:is(.public, .admin, .admin-login) {
  --fond: light-dark(#e1d3bd, #151b28);
  --surface: light-dark(#eee1cd, #1e2637);
  --texte: light-dark(#2c2119, #f4e6d6);
  --discret: light-dark(#594535, #c0bdc5);
  --bord: light-dark(#c4ad92, #424856);
  --primaire: light-dark(#923f18, #efaa6e);
  --primaire-texte: light-dark(#fff3e2, #27180f);
  --accent: light-dark(#9b471e, #efaa6e);
  --ok: light-dark(#286347, #327752);
  --ombre: 0 10px 28px #21140b24;
  --rayon: 16px;
}
a { color: var(--primaire); }
img { max-width: 100%; height: auto; display: block; }
h1 { font-size: 1.6rem; margin: .2em 0 .5em; }
h2 { font-size: 1.2rem; margin: .2em 0 .6em; }
[hidden] { display: none !important; }

/* ---------- Barre du haut ---------- */
/* Barre de menu fixée en haut de l'écran au défilement */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .7rem 1rem;
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
  box-shadow: var(--ombre);
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; color: var(--texte); text-decoration: none; }
.topbar .brand i { color: var(--accent); }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.profils { display: flex; gap: .15rem; }
.profils i { font-size: .75em; opacity: .7; }
.topbar nav a, .langues a, .profils a, .deconnexion {
  padding: .35rem .7rem; border-radius: 6px; text-decoration: none; color: var(--discret);
}
.topbar nav a.actif, .langues a.actif { background: var(--fond); color: var(--texte); font-weight: 600; }
.langues, .themes { display: flex; gap: .15rem; }
.themes button {
  font: inherit; padding: .35rem .55rem; border: 0; border-radius: 6px; cursor: pointer;
  background: none; color: var(--discret);
}
.themes button.actif { background: var(--fond); color: var(--texte); }

.contenu { max-width: 1280px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.pied-site { max-width: 1280px; margin: 0 auto; padding: 1rem; border-top: 1px solid var(--bord); text-align: center; font-size: .85rem; }
.pied-site a, .pied-site span { color: var(--discret); }
.pied-site span { margin: 0 .5rem; }

/* Bandeau d'information cookies (assets/cookies.js), en bas de l'écran */
.bandeau-cookies {
  position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 150; max-width: 760px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .9rem 1.1rem;
  background: var(--surface); color: var(--texte); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
.bandeau-cookies[hidden] { display: none; }
.bandeau-cookies p { margin: 0; flex: 1 1 320px; font-size: .92rem; }
.bandeau-cookies i { color: var(--accent); }
.confidentialite { max-width: 820px; }
.choix-stats { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.choix-stats [data-stats-etat] { font-weight: 600; }
.confidentialite table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.confidentialite th, .confidentialite td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--bord); vertical-align: top; }

/* ---------- Éléments communs ---------- */
.bouton {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1rem; border: 0; border-radius: 6px;
  background: var(--primaire); color: var(--primaire-texte);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.bouton.secondaire { background: var(--fond); color: var(--texte); border: 1px solid var(--bord); }
.bouton.danger { background: var(--danger); color: #fff; margin-left: auto; }
.aide, .intro { color: var(--discret); }
.vide { color: var(--discret); text-align: center; padding: 2rem; }
.flash { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border-left: 4px solid var(--ok); background: var(--surface); }
.flash.erreur { border-color: var(--danger); }

.stats { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.stats span {
  background: var(--surface); padding: .45rem .9rem; border-radius: 999px;
  box-shadow: var(--ombre); font-weight: 600;
}
.stats i { color: var(--accent); margin-right: .2rem; }
.stats a { color: inherit; text-decoration: none; }

.sans-photo {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  aspect-ratio: 3 / 2; background: var(--fond); color: var(--discret); font-size: .85rem;
}
.sans-photo i { font-size: 1.8rem; }
.sans-photo.grand { min-height: 260px; border-radius: var(--rayon); }

/* ---------- Carte du monde ---------- */
.mode-switch, .filtres, .onglets { display: inline-flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1rem; }
.mode-switch button, .filtres button, .onglets a {
  font: inherit; padding: .4rem .9rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte); text-decoration: none;
}
.mode-switch button.actif, .filtres button.actif, .onglets a.actif {
  background: var(--primaire); color: var(--primaire-texte); border-color: var(--primaire);
}

/* Grille et panneau des résultats. */
.carte-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.pied-carte { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .3rem 1rem; }
.note-carte { margin: .6rem 0 0; font-size: .9rem; }
.aide-clic { margin: 0; padding: .2rem .5rem; font-size: .8rem; color: var(--discret); }
.panneau-titre { display: flex; justify-content: space-between; align-items: start; gap: .5rem; }
.panneau-titre button { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--discret); cursor: pointer; padding: 0 .2rem; }
.carte-monde { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: .5rem; position: relative; }
#map { width: 100%; aspect-ratio: 2 / 1.1; min-height: 260px; max-height: 68vh; }
/* Frontières : liseré blanc + trait foncé central, en couche au-dessus des zones (.pc-frontieres, voir map.js),
   épaisseurs fixes en pixels quel que soit le zoom ; couleurs fixes, identiques en thème clair et sombre */
#map .jvm-region { vector-effect: non-scaling-stroke; shape-rendering: geometricPrecision; }
#map .pc-frontieres { pointer-events: none; }
#map .pc-frontieres path { fill: none; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#map .pc-liseres path { stroke: #fff; stroke-width: 3px; }
#map .pc-traits path { stroke: #2b2723; stroke-width: 1px; }
/* Fond monde : les pays voisins ne partagent pas exactement leurs contours, chaque frontière est donc
   tracée deux fois côte à côte. Liseré et trait de 1 px sans anticrénelage : un trait plus fin qu'un
   pixel, ou deux traits lissés côte à côte, donnent une impression de flou */
#map[data-fond="world"] .pc-frontieres path { shape-rendering: crispEdges; }
#map[data-fond="world"] .pc-liseres path { stroke-width: 1px; }
#map[data-fond="world"] .pc-traits path { stroke-width: 1px; }
/* Cadres des encarts (Hawaï, territoires) : zones « _… » du fond USA & Canada, décoratives */
#map .jvm-region[data-code^="_"] { fill: none !important; stroke: var(--discret) !important; stroke-width: 1px; stroke-opacity: .55; stroke-dasharray: 4 3; pointer-events: none; }
.jvm-tooltip { font-family: inherit; font-size: .85rem; background: var(--texte); color: var(--fond); }
.jvm-zoom-btn { background: var(--primaire); }
.legende { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .8rem; color: var(--discret); padding: .2rem .5rem; }
.legende i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }

.panneau {
  background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre);
  padding: 1rem; transition: opacity .2s; scroll-margin-top: 1rem;
}
.panneau.charge { opacity: .5; }
.vignettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; }
.vignette {
  display: block; border-radius: 6px; overflow: hidden; background: var(--fond);
  color: var(--texte); text-decoration: none; border: 1px solid var(--bord);
}
.vignette img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.vignette .meta { display: block; padding: .3rem .45rem; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vignette .meta i { color: var(--accent); }
.vignette em { color: var(--discret); }

.liste-pays { margin-top: 2rem; }
.liste-pays ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .4rem; }
.liste-pays button {
  width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: var(--surface); color: var(--texte); border: 1px solid var(--bord); border-radius: 6px; padding: .45rem .7rem;
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
}
.liste-pays button:hover { border-color: var(--primaire); }
.liste-pays small { color: var(--discret); white-space: nowrap; }

/* ---------- Fiche carte ---------- */
.fiche { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem; }
.galerie { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-content: start; }
.galerie img { border-radius: 6px; box-shadow: var(--ombre); cursor: zoom-in; }
.infos { background: var(--surface); border-radius: var(--rayon); padding: 1.2rem; box-shadow: var(--ombre); align-self: start; }
.badge { display: inline-block; padding: .25rem .7rem; border-radius: 999px; background: var(--fond); font-weight: 600; }
.badge i { color: var(--accent); }
.details { list-style: none; padding: 0; }
.details li { padding: .2rem 0; }
.details i { width: 1.4em; color: var(--discret); }
.description { margin: 1rem 0; white-space: normal; }

/* ---------- Swaps ---------- */
.grille-swaps { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.swap { background: var(--surface); border-radius: var(--rayon); overflow: hidden; box-shadow: var(--ombre); }
.swap-photos { position: relative; }
.swap-photos img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; cursor: zoom-in; }
.nb-photos { position: absolute; right: .5rem; bottom: .5rem; background: rgba(0,0,0,.6); color: #fff; font-size: .8rem; padding: .1rem .45rem; border-radius: 4px; }
.swap-infos { padding: .7rem .9rem 1rem; position: relative; }
.swap-infos h3 { margin: .2rem 0; font-size: 1.05rem; }
.swap-infos p { margin: .3rem 0; font-size: .92rem; }
.numero { font-weight: 700; color: var(--accent); }
.etat { float: right; font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: var(--ok); color: #fff; }
.swap.reservee { opacity: .65; }
.swap.reservee .etat { background: var(--discret); }
.theme { color: var(--discret); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; border: 0; background: transparent; color: #fff;
  padding: calc(3.75rem + env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px))
    calc(4rem + env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
}
.lightbox[open] { display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; }
.lightbox::backdrop { background: rgba(10, 8, 6, .94); }
body:has(.lightbox[open]) { overflow: hidden; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; min-height: 0; }
.lightbox button {
  min-width: 44px; min-height: 44px; padding: 0 .5rem; border: 1px solid #ffffff55;
  background: #232128; color: #fff; border-radius: 999px; font-size: 1.65rem; cursor: pointer;
}
.lightbox-fermer {
  position: absolute; top: calc(.5rem + env(safe-area-inset-top, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
}
.lightbox-commandes {
  position: absolute; bottom: calc(.5rem + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: .8rem;
}

/* ---------- Admin ---------- */
.deconnexion { margin-left: auto; }
.filtres-admin { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
input, select, textarea {
  font: inherit; color: var(--texte); background: var(--surface);
  border: 1px solid var(--bord); border-radius: 6px; padding: .45rem .6rem; max-width: 100%;
}
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--primaire); }
.filtres-admin input[type=search] { min-width: 240px; flex: 1; }

.table-cartes { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--rayon); overflow: hidden; box-shadow: var(--ombre); }
.table-cartes th, .table-cartes td { padding: .5rem .6rem; border-bottom: 1px solid var(--bord); text-align: left; vertical-align: middle; }
.table-cartes th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--discret); }
.table-cartes td small { display: block; color: var(--discret); }
.table-cartes .mini { width: 72px; }
.table-cartes .mini img { width: 64px; height: 44px; object-fit: cover; border-radius: 4px; }
.table-cartes tr.privee td, .table-cartes tr.etat-echangee td { opacity: .6; }
.table-cartes .icones { white-space: nowrap; color: var(--discret); }
.table-cartes .icones > * { margin-left: .4rem; }
.pastille { font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: var(--fond); }
.pastille.disponible { background: var(--ok); color: #fff; }
.pagination { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: 1rem; }
.pagination a { padding: .3rem .6rem; border-radius: 4px; background: var(--surface); text-decoration: none; }
.pagination a.actif { background: var(--primaire); color: var(--primaire-texte); }

.formulaire { background: var(--surface); padding: 1.2rem; border-radius: var(--rayon); box-shadow: var(--ombre); }
.grille-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem 1.2rem; }
.grille-form label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .92rem; }
.grille-form label small { font-weight: 400; color: var(--discret); }
.grille-form .large { grid-column: 1 / -1; }
.grille-form label:has(> input[type=checkbox]) { flex-direction: row; align-items: center; gap: .5rem; }
fieldset { border: 1px solid var(--bord); border-radius: 6px; margin: 0; }
.choix-sens { display: flex; gap: 1.2rem; align-items: center; }
.choix-sens label { flex-direction: row; align-items: center; gap: .35rem; font-weight: 600; }

.photos-admin { margin-top: 1.2rem; padding: 1rem; }
.photos-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; }
.photo-item { border: 1px solid var(--bord); border-radius: 6px; padding: .4rem; display: flex; flex-direction: column; gap: .4rem; }
.photo-item img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px; }
.photo-item.privee { border-style: dashed; }
.photo-item.privee img { opacity: .6; }
.photo-options { display: flex; flex-wrap: wrap; gap: .3rem .7rem; font-size: .85rem; align-items: center; }
.photo-options input[type=number] { width: 4em; padding: .15rem .3rem; }
.photo-options .danger { color: var(--danger); }
.ajout-photos { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; margin-top: .8rem; }
.ajout-photos label { display: flex; flex-direction: column; gap: .3rem; font-size: .92rem; }
.ajout-photos label:has(> input[type=checkbox]) { flex-direction: row; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin-top: 1.2rem; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card {
  background: var(--surface); padding: 2rem; border-radius: var(--rayon); box-shadow: var(--ombre);
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: .9rem;
  border-top: 4px solid var(--accent);
}
.login-card h1 { font-size: 1.3rem; text-align: center; }
.login-card h1 i { color: var(--accent); }
.login-card label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; }
.login-card .bouton { justify-content: center; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .fiche { grid-template-columns: minmax(0, 1fr); }
  .vignettes { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .deconnexion { margin-left: 0; }
}

/* ---------- Installeur ---------- */
.installeur { max-width: 520px; }
.installeur form { display: flex; flex-direction: column; gap: .8rem; }
.installeur label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; }
.etapes { display: flex; gap: .3rem; padding: 0; margin: 0; list-style: none; counter-reset: etape; font-size: .8rem; }
.etapes li { flex: 1; text-align: center; padding: .35rem .2rem; border-radius: 6px; background: var(--fond); color: var(--discret); counter-increment: etape; }
.etapes li::before { content: counter(etape) ". "; }
.etapes li.courant { background: var(--primaire); color: var(--primaire-texte); font-weight: 600; }
.etapes li.fait { color: var(--ok); }
.etapes li.fait::before { content: "✓ "; }
.verifs { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.verifs li { padding: .15rem 0; }
.verifs .ok i { color: var(--ok); }
.verifs .ko { color: var(--danger); font-weight: 600; }
.verifs .avert i { color: var(--accent); }
.config-a-copier { width: 100%; font-family: ui-monospace, monospace; font-size: .85rem; }

/* ---------- Admin : statistiques de visite ---------- */
.filtres-periode { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1rem; }
.filtres-periode a { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--bord); color: var(--discret); text-decoration: none; background: var(--surface); }
.filtres-periode a.actif { background: var(--primaire); border-color: var(--primaire); color: var(--primaire-texte); }
.tuiles-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.5rem; }
.tuiles-stats div { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: .9rem 1rem; color: var(--discret); font-size: .85rem; }
.tuiles-stats span { display: block; font-size: 1.6rem; font-weight: 700; color: var(--texte); line-height: 1.2; }
.histo { margin: 0 0 1.5rem; background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 1.6rem 1rem .6rem; }
.histo-barres { display: grid; grid-template-columns: repeat(var(--nb), minmax(0, 1fr)); gap: 2px; align-items: end; height: 200px; border-bottom: 1px solid var(--bord); }
.histo-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.histo-col i { display: block; width: 100%; max-width: 28px; min-height: 0; background: var(--accent); border-radius: 4px 4px 0 0; }
.histo-col:hover i { filter: brightness(1.15); }
.histo-val { font-size: .7rem; color: var(--discret); margin-bottom: 2px; }
.histo-axe { display: flex; justify-content: space-between; font-size: .75rem; color: var(--discret); padding-top: .3rem; }
.stats-colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; align-items: start; }
