/* Charte UNSA Éducation - Note interne (portage de formation/version-php) */

:root {
  /* ── Couleurs primaires ── */
  --bleu: #009EE0;
  --bleu-action: #0079AD;
  --bleu-action-hover: #006A98;
  --bleu-10: rgba(0, 158, 224, 0.1);
  --marine: #143C6B;
  --marine-700: #0F2E52;
  --rouge: #E2001A;
  --rouge-hover: #C40017;

  /* ── Alertes (teintes) ── */
  --alert-info-bg: #E8F5FD;
  --alert-info-text: #005580;
  --alert-success-bg: #E8F7EF;
  --alert-success-text: #145C36;
  --alert-warning-bg: #FEF3E2;
  --alert-warning-text: #7A4A00;
  --alert-error-bg: #FDEAEA;
  --alert-error-text: #8A0010;

  /* ── Surfaces ── */
  --bg: #F4F7FA;
  --surface: #FFFFFF;
  --bordure: #E3E9F0;

  /* ── Texte ── */
  --texte: #1B2733;
  --texte-2: #5B6B7B;
  --texte-inverse: #FFFFFF;

  /* ── Statuts ── */
  --st-encours: #7A8B9A;
  --st-prevalide: #0079AD;
  --st-valide: #14733F;
  --st-amodifier: #A35200;
  --st-refuse: #C40017;
  --st-brouillon: #B0BAC4;

  /* ── Typographie - échelle ── */
  --fs-1: 12px;
  --fs-2: 14px;  /* base UI */
  --fs-3: 16px;
  --fs-4: 20px;
  --fs-5: 26px;
  --fs-6: 34px;

  /* ── Polices (système - pas de dépendance) ── */
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* ── Espacement (base 4 px) ── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* ── Rayons ── */
  --r-1: 6px;
  --r-2: 10px;
  --r-3: 14px;

  /* ── Ombre carte ── */
  --shadow-card: 0 1px 2px rgba(20, 60, 107, 0.06), 0 2px 8px rgba(20, 60, 107, 0.06);

  /* ── Thème (rôles dérivés) ── */
  --fond-marine: var(--marine);
  --lien: var(--bleu-action);
  --lien-hover: var(--bleu-action-hover);
  --texte-pastille-claire: #1B2733;
  --ombre-dialogue: 0 12px 40px rgba(20, 60, 107, 0.2);
  --voile: rgba(27, 39, 51, 0.4);
  --cadre-apercu: #FFFFFF;

  color-scheme: light dark;
}

:root[data-theme="light"] { color-scheme: light; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --marine: #A9D4F5;
    --fond-marine: #0F2E52;
    --bleu-10: rgba(0, 158, 224, 0.18);
    --lien: #5EC1F0;
    --lien-hover: #8AD3F5;
    --alert-info-bg: #0E2A3B;
    --alert-info-text: #A9DCF7;
    --alert-success-bg: #10291C;
    --alert-success-text: #9BDDB6;
    --alert-warning-bg: #33240C;
    --alert-warning-text: #F3C98A;
    --alert-error-bg: #3A1418;
    --alert-error-text: #F5A9B1;
    --bg: #0F161E;
    --surface: #18222D;
    --bordure: #2E3D4C;
    --texte: #E4EAF0;
    --texte-2: #A3B2C1;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    --ombre-dialogue: 0 12px 40px rgba(0, 0, 0, 0.5);
    --voile: rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --marine: #A9D4F5;
  --fond-marine: #0F2E52;
  --bleu-10: rgba(0, 158, 224, 0.18);
  --lien: #5EC1F0;
  --lien-hover: #8AD3F5;
  --alert-info-bg: #0E2A3B;
  --alert-info-text: #A9DCF7;
  --alert-success-bg: #10291C;
  --alert-success-text: #9BDDB6;
  --alert-warning-bg: #33240C;
  --alert-warning-text: #F3C98A;
  --alert-error-bg: #3A1418;
  --alert-error-text: #F5A9B1;
  --bg: #0F161E;
  --surface: #18222D;
  --bordure: #2E3D4C;
  --texte: #E4EAF0;
  --texte-2: #A3B2C1;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  --ombre-dialogue: 0 12px 40px rgba(0, 0, 0, 0.5);
  --voile: rgba(0, 0, 0, 0.6);
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-2);
  font-weight: 400;
  line-height: 1.5;
  background: var(--bg);
  color: var(--texte);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Titres ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--marine);
}

h1 { font-size: var(--fs-5); margin-bottom: var(--sp-5); }
h2 { font-size: var(--fs-4); margin: var(--sp-5) 0 var(--sp-3); }
h3 { font-size: var(--fs-3); margin: var(--sp-4) 0 var(--sp-2); }

p { margin-bottom: var(--sp-3); }

/* ── Liens ── */
a {
  color: var(--lien);
  text-decoration: none;
}

a:hover {
  color: var(--lien-hover);
  text-decoration: underline;
}

/* ── Accessibilité clavier ── */
:focus-visible {
  outline: 2px solid var(--lien);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   Mise en page
   ============================================================ */

.app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5);
}

.app-pied {
  text-align: center;
  font-size: var(--fs-1);
  color: var(--texte-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--bordure);
}

/* ── Barre de navigation principale ── */
.site-nav {
  background: var(--fond-marine);
  color: var(--texte-inverse);
}

.site-nav__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.site-nav__brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-3);
  color: var(--texte-inverse);
  margin-right: var(--sp-3);
}

.site-nav a {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  padding: var(--sp-1) 0;
}

.site-nav a:hover {
  color: var(--texte-inverse);
  text-decoration: none;
  border-bottom: 2px solid #fff;
}

.site-nav__spacer {
  margin-left: auto;
}

/* ============================================================
   Tables (cartes)
   ============================================================ */

table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--r-2);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: var(--sp-5);
  font-size: var(--fs-2);
}

thead th {
  background: var(--fond-marine);
  color: var(--texte-inverse);
  font-family: var(--font-display);
  font-weight: 600;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
}

tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--bordure);
  vertical-align: middle;
}

tbody tr:hover td {
  background: var(--bleu-10);
}

/* ── Pastille de statut (la couleur de fond reste inline) ── */
.pastille {
  display: inline-block;
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--texte-inverse);
  letter-spacing: 0.02em;
  padding: 3px var(--sp-3);
  border-radius: 999px;
  white-space: nowrap;
}

/* ============================================================
   Cartes (sections encadrées)
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-card);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
}

.card > h2:first-child,
.card > h3:first-child {
  margin-top: 0;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--bordure);
  font-size: var(--fs-4);
  color: var(--marine);
}

.card > *:last-child { margin-bottom: 0; }
/* ============================================================
   Formulaires
   ============================================================ */

form {
  margin-bottom: var(--sp-5);
}

label {
  display: block;
  font-weight: 500;
  color: var(--texte);
  margin-bottom: var(--sp-3);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="url"],
input[type="file"],
input:not([type]),
select,
textarea {
  display: block;
  width: 100%;
  max-width: 460px;
  font-family: inherit;
  font-size: var(--fs-2);
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--r-1);
  padding: var(--sp-2) var(--sp-3);
  min-height: 38px;
  margin-top: var(--sp-1);
  transition: border-color 0.15s ease;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
  margin-right: var(--sp-2);
}

select[multiple] {
  min-height: auto;
  height: auto;
  padding: var(--sp-2) var(--sp-3);
}

select[multiple] option {
  padding: var(--sp-1) var(--sp-2);
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--bleu);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg);
  opacity: 0.7;
  cursor: not-allowed;
}

::placeholder { color: var(--texte-2); }

/* Espacement des lignes de formulaire Symfony (form_row → <div>) */
form > div { margin-bottom: var(--sp-4); }

/* Thème de formulaire « charte » : champs */
.champ { margin-bottom: var(--sp-4); }
.champ > label { margin-bottom: var(--sp-1); }
.champ label.required::after { content: " *"; color: var(--rouge); }
.champ__aide {
  display: block;
  margin-top: var(--sp-1);
  color: var(--texte-2);
  font-size: var(--fs-1);
}
.champ__erreurs {
  list-style: none;
  padding-left: 0;
  margin: var(--sp-1) 0 0;
  color: var(--alert-error-text);
  font-size: var(--fs-1);
}
.champ--erreur input,
.champ--erreur select,
.champ--erreur textarea {
  border-color: var(--rouge);
}

/* Barre d'action de formulaire */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
  margin-top: var(--sp-2);
}

/* ── Boutons ── */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: inherit;
  font-size: var(--fs-2);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: none;
  border-radius: var(--r-1);
  padding: var(--sp-2) var(--sp-5);
  min-height: 38px;
  background: var(--bleu-action);
  color: var(--texte-inverse);
  transition: background 0.15s ease;
  margin-top: var(--sp-1);
}

button:hover:not(:disabled),
.btn:hover {
  background: var(--bleu-action-hover);
  color: var(--texte-inverse);
  text-decoration: none;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Variantes de boutons (s'appliquent aux <button> et aux liens .btn) */
.btn-success { background: var(--st-valide); color: var(--texte-inverse); }
.btn-success:hover:not(:disabled) { background: #0F5A31; color: var(--texte-inverse); }
.btn-warn { background: var(--st-amodifier); color: var(--texte-inverse); }
.btn-warn:hover:not(:disabled) { background: #854300; color: var(--texte-inverse); }
.btn-danger { background: var(--rouge); color: var(--texte-inverse); }
.btn-danger:hover:not(:disabled) { background: var(--rouge-hover); color: var(--texte-inverse); }
.btn-ghost {
  background: var(--surface);
  color: var(--texte-2);
  border: 1px solid var(--bordure);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--texte);
  text-decoration: none;
}

/* ============================================================
   Messages (flash + erreurs)
   ============================================================ */

.flash,
.erreur {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-1);
  border: 1px solid transparent;
  font-size: var(--fs-2);
  line-height: 1.5;
  margin-bottom: var(--sp-4);
}

.flash-success {
  background: var(--alert-success-bg);
  border-color: var(--st-valide);
  color: var(--alert-success-text);
}

.flash-error,
.erreur {
  background: var(--alert-error-bg);
  border-color: var(--rouge);
  color: var(--alert-error-text);
}

.flash-warning {
  background: var(--alert-warning-bg);
  border-color: var(--st-amodifier);
  color: var(--alert-warning-text);
}

.flash-info {
  background: var(--alert-info-bg);
  border-color: var(--bleu);
  color: var(--alert-info-text);
}

/* ── Listes de contenu ── */
.app-main ul { padding-left: var(--sp-5); margin-bottom: var(--sp-4); }

/* ── Texte secondaire ── */
.muted {
  color: var(--texte-2);
  font-weight: 400;
  font-size: var(--fs-1);
}

/* ============================================================
   Authentification (login / changement de mot de passe)
   ============================================================ */

.auth-wrapper {
  min-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-card);
  padding: var(--sp-7) var(--sp-6);
}

.auth-card h1,
.auth-title {
  font-size: var(--fs-5);
  text-align: center;
  margin-bottom: var(--sp-2);
}

.auth-sub {
  text-align: center;
  color: var(--texte-2);
  margin-bottom: var(--sp-6);
}

.auth-card form { margin-bottom: 0; }

.auth-card input { max-width: none; }

.auth-card button { width: 100%; margin-top: var(--sp-4); }

/* ── Mouvement réduit ── */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── Petits écrans ── */
@media (max-width: 640px) {
  .app-main { padding: var(--sp-5) var(--sp-4); }
  .site-nav__inner { gap: var(--sp-3); }
  table { font-size: var(--fs-1); }
  thead th, tbody td { padding: var(--sp-2) var(--sp-3); }
}

/* ── Compléments Note interne ── */
.btn-primary { background: var(--bleu-action); color: var(--texte-inverse); }
.btn-sm { padding: var(--sp-1) var(--sp-3); min-height: 30px; font-size: var(--fs-1); }
.btn-block { width: 100%; }
.table { width: 100%; }
.pastille-brouillon { background: var(--st-brouillon); color: var(--texte-pastille-claire); }
.pastille-bat { background: var(--st-amodifier); }
.pastille-envoyee { background: var(--st-valide); }
.chip { display: inline-flex; align-items: center; gap: var(--sp-1); border: 1px solid var(--bleu); background: var(--bleu-10); color: var(--marine); border-radius: 999px; padding: 2px 10px; font-size: var(--fs-1); }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grille-2 .champ { margin-bottom: 0; }
.page-entete { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-entete h1 { margin: 0; margin-right: auto; }
.site-nav img { height: 32px; background: #fff; border-radius: 4px; padding: 2px; vertical-align: middle; }
.site-nav__brand { display: inline-flex; align-items: center; gap: var(--sp-2); }
.site-nav__link.is-active { color: var(--texte-inverse); border-bottom: 2px solid #fff; }
.site-nav :focus-visible { outline-color: #fff; }
.lien-evitement { position: absolute; left: var(--sp-3); top: -100px; z-index: 10; background: var(--surface); color: var(--marine); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-1); font-weight: 600; }
.lien-evitement:focus { top: var(--sp-2); }
.site-nav__user { margin-left: auto; opacity: .85; }
.auth-card { margin: var(--sp-7) auto 0; }
.auth-logo { display: block; margin: 0 auto var(--sp-4); }
.auth-aide { text-align: center; margin-top: var(--sp-4); margin-bottom: 0; font-size: var(--fs-1); }

@media (max-width: 560px) {
  .grille-2 { grid-template-columns: 1fr; }
}

.filtres { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.filtres input[type=search] { min-width: 260px; }
.secondaire { color: var(--texte-2); font-size: var(--fs-1); }
.puce-couleur { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.actions { display: flex; gap: var(--sp-1); }
.vide { text-align: center; color: var(--texte-2); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; white-space: nowrap; clip: rect(0 0 0 0); clip-path: inset(50%); }
.page-redaction .app-main { max-width: 1440px; }
.barre-note { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; background: var(--surface); border-bottom: 1px solid var(--bordure); padding: var(--sp-3) var(--sp-4); margin: calc(-1 * var(--sp-6)) calc(-1 * var(--sp-5)) var(--sp-4); }
.barre-note__titre { font-size: var(--fs-3); margin: 0; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-note__espace { flex: 1; }
.redaction { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
.redaction__apercu { position: sticky; top: 72px; }
.redaction .card + .card { margin-top: var(--sp-3); }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.chip-case { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--bordure); border-radius: 999px; padding: 4px 12px; min-height: 30px; line-height: 1.3; white-space: nowrap; cursor: pointer; font-size: var(--fs-1); transition: border-color 0.15s ease, background-color 0.15s ease; }
.chip-case:hover { border-color: var(--bleu); }
.chip-case:has(input:checked) { border-color: var(--bleu); background: var(--bleu-10); color: var(--marine); font-weight: 600; }
.chip-case:has(input:focus-visible) { outline: 2px solid var(--bleu); outline-offset: 2px; }
.chip-case input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; margin: 0; flex: none; accent-color: var(--bleu); }
.chip-case input:focus-visible { outline: none; }
.listes-diffusion { border: 0; padding: 0; margin: 0 0 var(--sp-3); }
.champs-note input:not([type="checkbox"]):not([type="radio"]), .champs-note select, .champs-note textarea { max-width: none; width: 100%; }
@media (max-width: 1100px) { .redaction { grid-template-columns: 1fr; } .redaction__apercu { position: static; } }

.dialogue--large { width: min(560px, 92vw); }
.rapport-envoi { list-style: none; padding: 0; }
.rapport-envoi .ok { color: var(--alert-success-text); }
.rapport-envoi .ko { color: var(--alert-error-text); }
.relecteurs { border: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.controles { list-style: none; padding: 0; margin: var(--sp-3) 0; }
.controle { padding: 4px 8px; border-radius: var(--r-1); margin-bottom: 4px; font-size: var(--fs-1); }
.controle--ok { background: var(--alert-success-bg); color: var(--alert-success-text); }
.controle--avertissement { background: var(--alert-warning-bg); color: var(--alert-warning-text); }
.controle--bloquant { background: var(--alert-error-bg); color: var(--alert-error-text); }
.case-liste { display: block; padding: 6px 8px; border: 1px solid var(--bordure); border-radius: var(--r-1); }
.case-liste:has(input:checked) { border-color: var(--bleu); background: var(--bleu-10); }
.lien-bouton { background: none; border: 0; color: var(--lien); text-decoration: underline; cursor: pointer; padding: 0; min-height: 0; margin: 0; font-weight: inherit; line-height: inherit; }
.lien-bouton:hover:not(:disabled) { background: none; color: var(--lien-hover); text-decoration: underline; }
.historique { margin-top: 1rem; }
.historique summary { cursor: pointer; font-weight: 600; }
.table-defilante { overflow-x: auto; }
.table--compacte th, .table--compacte td { padding: .3rem .5rem; text-align: left; font-size: .9rem; }
.form-inline { display: inline; }
.choix-couleurs { border: 0; padding: 0; margin: 0 0 var(--sp-4); display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.choix-couleurs legend { margin-bottom: var(--sp-1); }
.pastille-choix { display: inline-flex; align-items: center; gap: 4px; }
.grille-entetes { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.grille-entetes img { display: block; max-width: 100%; height: auto; border: 1px solid var(--bordure); }
.actions-entete { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.site-nav .theme-bascule { background: transparent; border: 1px solid rgba(255, 255, 255, 0.5); color: var(--texte-inverse); padding: 0 var(--sp-2); min-width: 32px; min-height: 30px; margin: 0; font-size: var(--fs-3); line-height: 1; border-radius: var(--r-1); }
.site-nav .theme-bascule:hover:not(:disabled) { background: rgba(255, 255, 255, 0.15); color: var(--texte-inverse); }
.dialogue { background: var(--surface); color: var(--texte); border: 1px solid var(--bordure); border-radius: 12px; width: min(440px, calc(100vw - 32px)); padding: 20px; box-shadow: var(--ombre-dialogue); }
.dialogue::backdrop { background: var(--voile); }
.dialogue h2 { margin: 0 0 12px; font-size: 17px; color: var(--marine); }
.dialogue__champs label { display: block; margin-bottom: 12px; font-size: var(--fs-2); }
.dialogue__champs input, .dialogue__champs select { display: block; width: 100%; margin-top: 4px; }
.dialogue__actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialogue__message { color: var(--alert-error-text); background: var(--alert-error-bg); padding: 8px; border-radius: 6px; font-size: var(--fs-2); }
