:root {
  --bg: #12161c;
  --panel: #1b212b;
  --panel-light: #232b38;
  --border: #2c3542;
  --text: #e8ecf1;
  --text-muted: #8a94a3;
  --accent: #4a90d9;
  --danger: #c0392b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html {
  /* Barre de défilement verticale toujours visible et son espace toujours
     réservé, pour que le contenu ne se redimensionne pas/ne "saute" pas
     horizontalement quand une liste (ex. thèmes) grandit et dépasse la
     hauteur de la fenêtre. */
  overflow-y: scroll;
  scrollbar-gutter: stable;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.hint { color: var(--text-muted); font-size: 12.5px; margin: 4px 0 12px; }
.hint.danger { color: #e08a80; }

/* ---- Connexion ---- */
#vue-connexion {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.carte-connexion {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.carte-connexion h1 { margin: 0 0 4px; font-size: 22px; }
.sous-titre { color: var(--text-muted); margin: 0 0 20px; font-size: 13px; }
.message-erreur { color: #e08a80; font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---- Structure générale ---- */
.carte {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.carte h2 { margin: 0 0 10px; font-size: 15px; }
.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.entete-titre { display: flex; flex-direction: column; }
.entete-titre .hint { margin: 0; }
.entete-controles { display: flex; align-items: center; gap: 12px; }
.select-app-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }

.onglets {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.onglet {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13.5px;
  border-radius: 8px 8px 0 0;
}
.onglet:hover { color: var(--text); }
.onglet.actif { color: var(--accent); background: var(--panel-light); font-weight: 600; }

.sous-onglets { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.sous-onglet {
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12.5px;
}
.sous-onglet.actif { background: var(--accent); border-color: var(--accent); color: #fff; }

.contenu { padding: 20px; max-width: 1000px; margin: 0 auto; }
.panneau { display: none; }
.panneau.actif { display: block; }

/* ---- Formulaires ---- */
.champ { margin-bottom: 14px; text-align: left; }
.champ label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--text-muted); }
input, select, button {
  font-family: inherit;
  font-size: 14px;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-light);
  color: var(--text);
}
input[type="color"] { width: 44px; height: 38px; padding: 2px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-light); }
textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-light);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.formulaire-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.formulaire-inline input, .formulaire-inline select { width: auto; flex: 1; min-width: 140px; }
.case-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); flex: none; min-width: 0; white-space: nowrap; }
.case-inline input { width: auto; flex: none; min-width: 0; }

.bouton {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-light);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.bouton-principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.bouton-fantome { background: none; }
.bouton-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.bouton-danger:disabled { opacity: .5; cursor: not-allowed; }
.bouton-sm { padding: 5px 10px; font-size: 12px; }
.bouton-icone { display: inline-flex; align-items: center; justify-content: center; font-size: 36px; line-height: 1; padding: 4px 10px; text-decoration: none; }
/* Petit bouton "X" rouge compact (ex. suppression d'un message accueil, en bout de ligne). */
.bouton-x {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--danger);
  background: #fff;
  color: var(--danger);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.bouton-x:hover { background: var(--danger); color: #fff; }

/* Bouton de sauvegarde clignotant (fort contraste noir/rouge, texte blanc)
   tant qu'une modification n'a pas été enregistrée sur cette ligne (voir
   activerIndicateurModification()). steps(1) = bascule nette, pas de fondu,
   pour un clignotement bien visible. */
@keyframes clignoter-a-sauvegarder {
  0%, 49% { background: #000; border-color: #000; }
  50%, 100% { background: #c0392b; border-color: #c0392b; }
}
.a-sauvegarder {
  color: #fff !important;
  font-weight: 700;
  animation: clignoter-a-sauvegarder 0.6s steps(1) infinite;
}

/* ---- Mot de passe : bouton œil (même principe que l'appli principale) ---- */
.password-field-wrapper { position: relative; }
.password-field-wrapper input { padding-right: 40px; }
.password-toggle-btn {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px; padding: 8px; color: var(--text-muted);
}

/* ---- Tableaux ---- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.table th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
.table input[type="number"], .table input[type="text"] { padding: 5px 7px; font-size: 12.5px; }
.pastille-couleur { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }

/* Défilement interne à la liste des taxonomies (au lieu de faire défiler
   toute la page), pour garder la rubrique "Ajouter" toujours visible en bas. */
.table-scroll {
  max-height: 46vh;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.table-scroll thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }

/* Défilement horizontal interne pour les tableaux trop larges (beaucoup de colonnes),
   pour que la rubrique reste dans la largeur de l'écran plutôt que de déborder du
   navigateur. */
.table-scroll-x { max-width: 100%; overflow-x: auto; }

/* ---- Accès visiteurs : une rubrique (carte) par palier, services listés en dessous,
   toujours dans la largeur de l'écran (pas de défilement horizontal). ---- */
.carte-palier { }
.carte-palier.en-cours-glissement { opacity: .4; }
.lien-document { color: #fff; text-decoration: none; }
.lien-document:hover { color: #fff; text-decoration: none; }
.carte-palier.repliee { padding-top: 9px; padding-bottom: 9px; }
.carte-palier.repliee .entete-palier { margin-bottom: 0; }
.carte-palier.repliee .entete-palier input[type="text"] { padding: 4px 6px; }
.entete-palier { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.entete-palier .poignee-glisser { cursor: grab; color: var(--text-muted); font-size: 22.5px; letter-spacing: -1px; user-select: none; flex: none; }
.entete-palier .poignee-glisser:active { cursor: grabbing; }
.bouton-repli {
  margin-left: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 37.5px;
  line-height: 1;
  padding: 0 8px;
  transition: transform .15s ease;
}
/* Clignote en rouge tant que la rubrique est dépliée. */
@keyframes clignoter-fleche-repli-rouge {
  0%, 49% { color: var(--text-muted); }
  50%, 100% { color: var(--danger); }
}
.bouton-repli.ouvert {
  animation: clignoter-fleche-repli-rouge 0.6s steps(1) infinite;
}
.bouton-repli.ouvert { transform: rotate(180deg); }

/* Clignote en bleu ICILAGO (#191557, couleur de marque) la ligne d'une fiche à valider,
   pour attirer l'œil au retour depuis la fiche détaillée (onglet Annonces / Validation de
   contenus). Retirée automatiquement après quelques secondes (voir chargerEvenementsAModerer). */
@keyframes clignoter-fiche-icilago {
  0%, 49% { background: transparent; border-color: var(--border); }
  50%, 100% { background: rgba(25, 21, 87, 0.35); border-color: #191557; }
}
.clignote-icilago {
  border: 1px solid var(--border);
  border-radius: 10px;
  animation: clignoter-fiche-icilago 0.6s steps(1) infinite;
}

/* Survol d'une fiche à valider (onglet Annonces / Validation de contenus) : fond bleu
   ICILAGO transparent, même couleur de marque que le clignotement ci-dessus. */
#liste-evenements-a-moderer .carte-palier:hover { background: rgba(25, 21, 87, 0.3); }
.entete-palier input[type="text"] { flex: 1; font-weight: 600; }
.badge-code { display: inline-block; width: 120px; overflow: hidden; text-overflow: ellipsis; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--text-muted); background: var(--panel-light); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; white-space: nowrap; flex: none; }
.grille-services { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 30px 16px; }
.case-service { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.case-service input[type="checkbox"] { flex: none; }
.champ-service { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.champ-service input[type="number"] { width: 100%; }
.section-title { margin: 18px 0 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 14px; }

.rubrique-titre-ligne { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; border-top: 1px solid var(--border); padding-top: 14px; }
.rubrique-titre-ligne .section-title { margin: 0; border-top: none; padding-top: 0; }

.notif-param-ligne { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.notif-param-ligne:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.notif-param-titre { font-size: 14px; font-weight: 700; margin-bottom: 4px; }

/* ---- Structure : organigramme glisser-déposer ---- */
.organigramme-canvas {
  position: relative;
  min-height: 460px;
  overflow: auto;
  background:
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 24px 24px;
  background-color: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.organigramme-contenu { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.organigramme-lignes { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.organigramme-guide-h {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px dashed var(--accent);
  pointer-events: none;
  z-index: 4;
}
.organigramme-boite {
  position: absolute;
  width: 170px;
  padding: 10px;
  border-radius: 8px;
  color: #fff;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  text-align: center;
  user-select: none;
  z-index: 1;
}
.organigramme-boite.en-glissement { cursor: grabbing; z-index: 5; opacity: .9; }
.organigramme-boite .organigramme-photo { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; margin: 0 auto 6px; display: block; border: 2px solid rgba(255,255,255,.7); }
.organigramme-boite .organigramme-poste { display: block; font-weight: 700; font-size: 13px; }
.organigramme-boite .organigramme-personne { display: block; font-size: 11.5px; opacity: .9; margin-top: 2px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.organigramme-boite .organigramme-personne:hover { opacity: 1; }

/* ---- Fiches postes (liste éditable, sous l'organigramme) ---- */
/* Format photo d'identité (35 x 45 mm, portrait rectangulaire). */
.poste-photo-actuelle { width: 90px; height: 116px; border-radius: 4px; object-fit: cover; border: 1px solid var(--border); }

/* ---- Glisser-déposer pour réordonner (taxonomies) ---- */
.ligne-groupe td { background: var(--panel-light); font-weight: 600; font-size: 12px; color: var(--text-muted); padding-top: 12px; }
.taxo-ligne { cursor: default; }
.taxo-ligne.en-cours-glissement { opacity: .4; }
.poignee-glisser {
  cursor: grab;
  color: var(--text-muted);
  font-size: 22.5px;
  letter-spacing: -1px;
  user-select: none;
  padding: 4px 6px;
}
.poignee-glisser:active { cursor: grabbing; }
.ma-ligne.en-cours-glissement { opacity: .4; }

/* ---- Popup import mentions légales (centré à l'écran, pas en feuille du bas) ---- */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.popup-overlay.hidden { display: none; }
.popup-sheet {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: calc(100% - 40px);
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}
.popup-sheet h2 { margin: 0 0 8px; font-size: 16px; }

/* ---- Toasts ---- */
#toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #2c3542; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.toast.erreur { background: var(--danger); }

@media (max-width: 640px) {
  .entete { flex-direction: column; align-items: flex-start; padding-top: 114px; } /* +100px (14px de base) : meilleure lecture du haut de l'écran sur smartphone */
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
