/* Générateur d'emploi du temps — feuille unique.
   Parti pris : sobre et classique, à l'image de l'école (enseignement structuré,
   sans écrans). Serif pour l'identité, linéale pour les données, papier chaud.
   Aucune dépendance, aucune police à charger : tout tient dans les polices système. */

:root {
  --papier:      #FAF8F5;
  --surface:     #FFFFFF;
  --encre:       #1E2328;
  --attenue:     #6B7280;
  --trait:       #E4DFD8;
  --trait-fort:  #C9C2B8;
  --accent:      #7A2E3B;
  --accent-clair:#F3E9EA;
  --succes:      #2F6B4F;
  --succes-clair:#E8F2ED;
  --alerte:      #8A5A12;
  --alerte-clair:#FBF1DF;
  --erreur:      #A03028;
  --erreur-clair:#FAEAE8;
  --rayon: 6px;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--papier); color: var(--encre);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Filet anti-glissière : sans lui, un tableau large pousse TOUTE la page et
     l'on se retrouve à faire défiler l'écran entier pour lire le menu. Les
     débordements légitimes sont traités par .defilable, qui fait défiler le seul
     tableau concerné. `clip` plutôt que `hidden` : n'introduit pas de contexte
     de défilement et ne casse donc pas le `position: sticky` du bandeau. */
  overflow-x: clip;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0; }
h1 { font-size: 30px; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
a { color: var(--accent); }
p { margin: 0 0 12px; }

/* ---------- ossature ---------- */
.bandeau {
  background: var(--surface); border-bottom: 1px solid var(--trait);
  position: sticky; top: 0; z-index: 20;
}
.bandeau .dedans {
  max-width: 1220px; margin: 0 auto; padding: 12px 22px;
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
}
.marque { font-family: var(--serif); font-weight: 700; font-size: 16px; text-decoration: none; color: var(--encre); }
.marque small { display: block; font-family: var(--sans); font-weight: 400; font-size: 11.5px;
  color: var(--attenue); letter-spacing: .04em; text-transform: uppercase; }
nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
nav a {
  padding: 7px 13px; border-radius: var(--rayon); text-decoration: none;
  color: var(--attenue); font-size: 14px; font-weight: 500;
}
nav a:hover { background: var(--papier); color: var(--encre); }
nav a.actif { background: var(--accent-clair); color: var(--accent); font-weight: 600; }

main { max-width: 1220px; margin: 0 auto; padding: 26px 22px 80px; }

.titre-page { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 6px; }
.titre-page .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.sous-titre { color: var(--attenue); font-size: 14px; margin-bottom: 22px; }

/* ---------- blocs ---------- */
.carte {
  background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: 20px 22px; margin-bottom: 18px;
}
.carte > h2 { margin-bottom: 4px; }
.carte .aide { color: var(--attenue); font-size: 13.5px; margin-bottom: 16px; }
details.carte > summary {
  cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px;
  font-family: var(--serif); font-size: 20px; font-weight: 700;
}
details.carte > summary::-webkit-details-marker { display: none; }
details.carte > summary::after {
  content: "afficher"; margin-left: auto; font-family: var(--sans); font-size: 13px;
  font-weight: 500; color: var(--accent);
}
details.carte[open] > summary::after { content: "masquer"; }
details.carte[open] > summary { margin-bottom: 14px; }
details.carte > summary .rappel { font-family: var(--sans); font-size: 13.5px;
  font-weight: 400; color: var(--attenue); }

.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grille-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .grille-2, .grille-3 { grid-template-columns: 1fr; } }

/* ---------- messages ---------- */
.avis { padding: 12px 16px; border-radius: var(--rayon); margin-bottom: 16px;
  font-size: 14px; border: 1px solid; white-space: pre-line; }
.avis.ok    { background: var(--succes-clair); border-color: #BFD8CB; color: var(--succes); }
.avis.souci { background: var(--erreur-clair); border-color: #EFC6C2; color: var(--erreur); }
.avis.note  { background: var(--alerte-clair); border-color: #EBD9B4; color: var(--alerte); }
.avis ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- formulaires ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--attenue);
  margin-bottom: 4px; letter-spacing: .01em; }
input[type=text], input[type=time], input[type=number], input[type=password],
input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--trait-fort);
  border-radius: var(--rayon); font: inherit; font-size: 14px;
  background: var(--surface); color: var(--encre);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-clair); outline-offset: 0; border-color: var(--accent);
}
input[type=color] { width: 42px; height: 34px; padding: 2px; border: 1px solid var(--trait-fort);
  border-radius: var(--rayon); background: var(--surface); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.champ { margin-bottom: 12px; }
.ligne-champs { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.ligne-champs > * { flex: 1; min-width: 110px; }
.case { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--encre); }
.case input { width: auto; }
.case label { margin: 0; font-size: 14px; font-weight: 400; color: var(--encre); }

/* ---------- boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px;
  border: 1px solid var(--trait-fort); border-radius: var(--rayon);
  background: var(--surface); color: var(--encre); font: inherit; font-size: 14px;
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.bouton:hover { background: var(--papier); border-color: var(--attenue); }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.bouton.principal:hover { background: #642430; }
.bouton.discret { border-color: transparent; color: var(--attenue); padding: 6px 10px; }
.bouton.discret:hover { background: var(--papier); color: var(--encre); }
.bouton.danger { color: var(--erreur); border-color: #EFC6C2; }
.bouton.danger:hover { background: var(--erreur-clair); }
.bouton.petit { padding: 5px 10px; font-size: 13px; }

/* ---------- tableaux de saisie ---------- */
/* Un tableau plus large que l'écran défile DANS SA BOÎTE, pas en poussant la page. */
.defilable { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Un tableau qui déborde sans le dire laisse croire qu'il n'y a rien de plus à voir.
   L'indice n'apparaît qu'aux largeurs où le débordement est effectivement possible. */
.indice-defilement { display: none; font-size: 12.5px; color: var(--attenue);
  margin: 8px 2px 0; }
@media (max-width: 780px) { .indice-defilement.simple { display: block; } }
@media (max-width: 1160px) { .indice-defilement.large { display: block; } }
.defilable > table { min-width: 520px; }
.defilable > table.edt { min-width: 660px; }

table.liste { width: 100%; border-collapse: collapse; font-size: 14px; }
table.liste th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--attenue); font-weight: 600; padding: 0 8px 7px; border-bottom: 1px solid var(--trait);
}
table.liste td { padding: 5px 8px; border-bottom: 1px solid var(--papier); vertical-align: middle; }
table.liste tr:hover td { background: #FCFBF9; }
table.liste td.serre { width: 1%; white-space: nowrap; }

.etiquette {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px;
  font-weight: 600; background: var(--papier); color: var(--attenue); border: 1px solid var(--trait);
}
.etiquette.ok    { background: var(--succes-clair); color: var(--succes); border-color: #BFD8CB; }
.etiquette.souci { background: var(--erreur-clair); color: var(--erreur); border-color: #EFC6C2; }
.etiquette.note  { background: var(--alerte-clair); color: var(--alerte); border-color: #EBD9B4; }
.etiquette.dur   { background: #EDEAFB; color: #463E86; border-color: #D5CFF3; }
.etiquette.souple{ background: #E9F1F7; color: #2A5875; border-color: #CBDEEC; }

.jauge { height: 5px; background: var(--trait); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.jauge span { display: block; height: 100%; background: var(--succes); }
.jauge span.pleine { background: var(--alerte); }
.jauge span.debord { background: var(--erreur); }

.chiffre { font-family: var(--serif); font-size: 26px; font-weight: 700; line-height: 1; }
.chiffre small { display: block; font-family: var(--sans); font-size: 12px;
  font-weight: 500; color: var(--attenue); margin-top: 5px; letter-spacing: .02em; }

/* ---------- la grille horaire ---------- */
.onglets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.onglets a {
  padding: 6px 14px; border: 1px solid var(--trait-fort); border-radius: 20px;
  text-decoration: none; color: var(--attenue); font-size: 13.5px; font-weight: 500;
  background: var(--surface);
}
.onglets a.actif { background: var(--encre); border-color: var(--encre); color: #fff; }

table.edt { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--surface); }
table.edt th {
  font-family: var(--serif); font-size: 15px; font-weight: 700; padding: 9px 6px;
  background: #F6F4F1; border: 1px solid var(--trait-fort); border-bottom-width: 2px;
}
table.edt th.col-heure { width: 74px; }
table.edt td { border: 1px solid var(--trait); padding: 0; height: 26px; vertical-align: top; }
table.edt td.heure {
  font-size: 11.5px; color: var(--attenue); text-align: right; padding: 0 8px 0 0;
  border-color: transparent; border-right-color: var(--trait-fort);
  vertical-align: top; line-height: 1; padding-top: 2px; white-space: nowrap;
}
table.edt tr.pause td { background: #F1EFEC; height: 20px; text-align: center;
  font-size: 11.5px; color: var(--attenue); font-style: italic; border-color: var(--trait-fort); }
table.edt td.libre { background: repeating-linear-gradient(45deg,
  transparent, transparent 7px, #F7F5F2 7px, #F7F5F2 14px); }

/* ── Vue de contrôle : une colonne par classe ─────────────────────────────── */
table.edt th.jour { border-bottom-width: 1px; }
table.edt th.classe {
  font-family: var(--sans); font-size: 12.5px; font-weight: 600; padding: 5px 4px;
  color: var(--attenue); background: #FAF9F7; border-bottom-width: 2px;
}
/* Un filet plus marqué sépare les jours : sans lui, douze colonnes se lisent comme
   une bouillie et l'on ne sait plus où finit le lundi. */
table.edt.general col.sep-jour { border-left: 2px solid var(--trait-fort); }
table.edt.general th.classe.debut-jour { border-left: 2px solid var(--trait-fort); }
table.edt.general th.jour + th.jour { border-left: 2px solid var(--trait-fort); }
/* Largeur minimale sous laquelle le tableau devient illisible, donc défile.
   Trois colonnes (un jour) tiennent dans 560 px : la vue de relecture quotidienne
   s'affiche entière dès la tablette. Douze colonnes (la semaine) en réclament 1080 :
   elle tient d'un écran d'ordinateur, et défile ailleurs — c'est assumé. */
.defilable > table.edt.general { min-width: 560px; }
.defilable > table.edt.general.dense { min-width: 1080px; }
/* Vue semaine : la densité s'ajuste à la place réellement disponible.
   Sur téléphone, seule la matière survit — un nom de professeur à 8 px dans une
   colonne de 6 mm ne se lit pas, il encombre. Sur ordinateur, tout tient, en plus
   petit. Le PDF, lui, n'a pas ce compromis : il a toujours la place. */
table.edt.general.dense td { height: 21px; }
table.edt.general.dense .case-cours { padding: 2px 3px; gap: 0; }
table.edt.general.dense .matiere { font-size: 11.5px; line-height: 1.1; }
table.edt.general.dense .detail { font-size: 10px; line-height: 1.15; }
table.edt.general.dense .horaire { display: none; }
table.edt.general.dense .detail.second-plan { display: none; }
@media (min-width: 900px) {
  table.edt.general.dense .detail.second-plan { display: block; font-size: 9.5px; color: #5A6068; }
}

.case-cours { height: 100%; padding: 5px 6px; display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center; gap: 2px; }
.case-cours .matiere { font-weight: 700; font-size: 13.5px; line-height: 1.15; }
.case-cours .detail { font-size: 11.5px; color: #4B5158; line-height: 1.2; }
.case-cours .horaire { font-size: 10.5px; color: #6B7280; margin-top: 2px; }

/* ---------- notice ---------- */
.notice { max-width: 820px; }
.notice h2 { margin: 32px 0 10px; padding-bottom: 7px; border-bottom: 1px solid var(--trait); }
.notice h3 { margin: 20px 0 6px; }
.notice ul, .notice ol { margin: 0 0 14px; padding-left: 20px; }
.notice li { margin-bottom: 7px; }
.notice code { background: var(--papier); border: 1px solid var(--trait);
  border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.encadre { background: var(--accent-clair); border-left: 3px solid var(--accent);
  padding: 14px 18px; border-radius: 0 var(--rayon) var(--rayon) 0; margin: 16px 0; }
.encadre p:last-child { margin-bottom: 0; }

/* ---------- connexion ---------- */
.connexion { max-width: 380px; margin: 90px auto; }
.connexion .carte { text-align: center; padding: 34px 30px; }
.connexion h1 { font-size: 22px; margin-bottom: 6px; }

/* ---------- impression : seule la grille survit ---------- */
@media print {
  .bandeau, .onglets, .actions, .sans-impression, footer { display: none !important; }
  body { background: #fff; font-size: 11px; }
  main { max-width: none; padding: 0; }
  .carte { border: none; padding: 0; margin-bottom: 10px; break-inside: avoid; }
  table.edt { break-inside: avoid; }
  table.edt td, table.edt th { border-color: #999 !important; }
  @page { size: A4 landscape; margin: 12mm; }
}

@media (max-width: 640px) {
  main { padding: 18px 14px 60px; }
  h1 { font-size: 24px; }
  .carte { padding: 16px 15px; }
  .bandeau .dedans { padding: 10px 14px; gap: 10px 16px; }
  nav { margin-left: 0; width: 100%; overflow-x: auto; padding-bottom: 2px; }
  nav a { padding: 6px 11px; font-size: 13.5px; }
  .titre-page .actions { margin-left: 0; width: 100%; }
  .sous-titre { font-size: 13.5px; }
  /* Les champs à 16 px empêchent iOS de zoomer à la mise au point. */
  input[type=text], input[type=time], input[type=number], input[type=password],
  select, textarea { font-size: 16px; }
}

footer { border-top: 1px solid var(--trait); margin-top: 40px; padding-top: 16px;
  color: var(--attenue); font-size: 12.5px; text-align: center; }
