/* =====================================================================
   Plan de classe — feuille de style unique.
   Pas de framework : la page doit s'ouvrir vite sur le poste de la salle,
   souvent un vieux PC derrière un vidéoprojecteur.
   ===================================================================== */

:root {
    --fond:          #f4f6fa;
    --carte:         #ffffff;
    --bord:          #dfe4ec;
    --texte:         #1c2333;
    --texte-doux:    #5f6b80;
    --accent:        #3b5bdb;
    --accent-clair:  #edf1ff;
    --danger:        #c92a2a;
    --danger-clair:  #fff0f0;
    --succes:        #2b8a3e;
    --attention:     #b8860b;
    --attention-clair:#fff8e6;

    --pdc-fond:      #ffffff;
    --pdc-table:     #e6e9f0;
    --pdc-table-bord:#c3cad8;
    --pdc-etiquette: #4c6ef5;
    --pdc-vide:      #eef1f6;
    --pdc-grille:    #eaedf3;
    --pdc-repere:    #cfd6e4;

    --rayon: 8px;
    --ombre: 0 1px 2px rgba(20, 28, 48, .06), 0 4px 12px rgba(20, 28, 48, .05);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="clair"]) {
        --fond: #12151d; --carte: #1a1e28; --bord: #2b3140;
        --texte: #e8ecf4; --texte-doux: #98a2b6;
        --accent: #748ffc; --accent-clair: #1e2436;
        --danger: #ff8787; --danger-clair: #2a1a1c;
        --succes: #69db7c; --attention: #ffd43b; --attention-clair: #2a2418;
        --pdc-fond: #0f1219; --pdc-table: #262c39; --pdc-table-bord: #39414f;
        --pdc-vide: #1c212c; --pdc-grille: #1a1f29; --pdc-repere: #333b4a;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--fond);
    color: var(--texte);
    -webkit-text-size-adjust: 100%;
}

/* --- Structure ------------------------------------------------------ */

.entete {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 18px;
    background: var(--carte);
    border-bottom: 1px solid var(--bord);
    position: sticky; top: 0; z-index: 20;
}
.entete h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -.2px; }
.entete .marque { color: var(--accent); }
.entete nav { display: flex; gap: 2px; margin-left: 8px; flex-wrap: wrap; }
.entete .pousse { margin-left: auto; }

nav button {
    background: none; border: 0; padding: 7px 13px;
    border-radius: 6px; cursor: pointer; color: var(--texte-doux);
    font: inherit; font-weight: 500;
}
nav button:hover { background: var(--fond); color: var(--texte); }
nav button[aria-current="page"] { background: var(--accent-clair); color: var(--accent); }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

.carte {
    background: var(--carte); border: 1px solid var(--bord);
    border-radius: var(--rayon); padding: 18px; box-shadow: var(--ombre);
}
.carte + .carte { margin-top: 16px; }
.carte h2 { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.carte h2 + p.aide { margin-top: 0; }

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

.rangee { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rangee.serree { gap: 6px; }

p.aide { color: var(--texte-doux); font-size: 13.5px; margin: 6px 0 14px; }

/* --- Contrôles ------------------------------------------------------ */

button, .bouton {
    font: inherit; font-weight: 500;
    padding: 8px 14px; border-radius: 6px;
    border: 1px solid var(--bord); background: var(--carte); color: var(--texte);
    cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.principal {
    background: var(--accent); border-color: var(--accent); color: #fff;
}
button.principal:hover:not(:disabled) { filter: brightness(1.08); color: #fff; }
button.danger { color: var(--danger); border-color: transparent; }
button.danger:hover:not(:disabled) { background: var(--danger-clair); border-color: var(--danger); }
button.discret { border-color: transparent; background: none; color: var(--texte-doux); }
button.discret:hover:not(:disabled) { background: var(--fond); }
button.petit { padding: 4px 9px; font-size: 13px; }

input[type=text], input[type=password], input[type=number], input[type=date],
select, textarea {
    font: inherit; padding: 8px 10px;
    border: 1px solid var(--bord); border-radius: 6px;
    background: var(--carte); color: var(--texte); width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent-clair); border-color: var(--accent);
}
textarea { min-height: 130px; resize: vertical; font-family: ui-monospace, monospace; font-size: 13px; }
input[type=color] { width: 42px; height: 34px; padding: 2px; }

label.champ { display: block; margin-bottom: 12px; }
label.champ > span { display: block; font-size: 13px; color: var(--texte-doux); margin-bottom: 4px; }
label.case { display: flex; align-items: center; gap: 8px; cursor: pointer; }
label.case input { width: auto; }

/* --- Tableaux ------------------------------------------------------- */

table.liste { width: 100%; border-collapse: collapse; }
table.liste th {
    text-align: left; font-size: 12px; text-transform: uppercase;
    letter-spacing: .4px; color: var(--texte-doux); font-weight: 600;
    padding: 6px 10px; border-bottom: 1px solid var(--bord);
}
table.liste td { padding: 8px 10px; border-bottom: 1px solid var(--bord); }
table.liste tr:last-child td { border-bottom: 0; }
table.liste tr:hover td { background: var(--fond); }
table.liste td.actions { text-align: right; white-space: nowrap; }

.vide {
    text-align: center; padding: 34px 20px; color: var(--texte-doux);
    border: 1px dashed var(--bord); border-radius: var(--rayon);
}

/* --- Messages ------------------------------------------------------- */

.message { padding: 11px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.message.erreur     { background: var(--danger-clair); color: var(--danger); }
.message.attention  { background: var(--attention-clair); color: var(--attention); }
.message.succes     { background: #e9f7ee; color: var(--succes); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="clair"]) .message.succes { background: #142a1b; }
}
.message ul { margin: 6px 0 0; padding-left: 20px; }
.message li + li { margin-top: 4px; }

.pastille {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    vertical-align: -1px; margin-right: 6px;
}
.etiquette-info {
    display: inline-block; padding: 1px 7px; border-radius: 20px;
    background: var(--fond); border: 1px solid var(--bord);
    font-size: 12px; color: var(--texte-doux);
}

/* --- La scène ------------------------------------------------------- */

.scene-hote {
    background: var(--pdc-fond); border: 1px solid var(--bord);
    border-radius: var(--rayon); overflow: hidden;
}
svg.scene { display: block; width: 100%; height: auto; touch-action: none; }

.pdc-fond { fill: var(--pdc-fond); }
.pdc-grille line { stroke: var(--pdc-grille); stroke-width: 1; }

.pdc-table > * { fill: var(--pdc-table); stroke: var(--pdc-table-bord); stroke-width: 1.5; }
.pdc-table.est-selectionnee > * { stroke: var(--accent); stroke-width: 2.5; }

.pdc-repere rect { fill: var(--pdc-repere); stroke: none; }
.pdc-repere-tableau rect { fill: #2f3542; }
.pdc-repere-fenetre rect { fill: #a5d8ff; }
.pdc-repere-porte rect   { fill: #ffd8a8; }
.pdc-repere-texte {
    fill: #fff; font-size: 13px; font-weight: 600; text-anchor: middle;
    dominant-baseline: middle; pointer-events: none;
}
.pdc-repere:not(.pdc-repere-tableau) .pdc-repere-texte { fill: #333; }

.pdc-place { cursor: grab; }
.pdc-place.est-saisi { cursor: grabbing; opacity: .85; }
.pdc-etiquette {
    fill: var(--pdc-etiquette);
    stroke: rgba(0, 0, 0, .12); stroke-width: 1;
}
.pdc-place.est-vide .pdc-etiquette {
    fill: var(--pdc-vide); stroke: var(--pdc-table-bord);
    stroke-dasharray: 4 3;
}
.pdc-place.est-condamnee { opacity: .35; }
.pdc-place.est-condamnee .pdc-etiquette { fill: none; stroke-dasharray: 2 4; }
.pdc-place.est-survolee .pdc-etiquette { stroke: var(--accent); stroke-width: 3; }
.pdc-place.est-selectionnee .pdc-etiquette { stroke: var(--accent); stroke-width: 3; }
.pdc-place.est-absent { opacity: .45; }
.pdc-place.est-verrouille .pdc-etiquette { stroke: #f59f00; stroke-width: 2.5; }

.pdc-prenom {
    fill: #fff; font-size: 15px; font-weight: 650; text-anchor: middle;
    dominant-baseline: middle; pointer-events: none;
}
.pdc-initiale {
    fill: rgba(255, 255, 255, .85); font-size: 12px; text-anchor: middle;
    dominant-baseline: middle; pointer-events: none;
}
.pdc-place-libelle {
    fill: var(--texte-doux); font-size: 12px; text-anchor: middle;
    dominant-baseline: middle; pointer-events: none;
}
.pdc-barre-absent { stroke: #fff; stroke-width: 3; opacity: .8; }
.pdc-photo { pointer-events: none; }

/* --- Projection -----------------------------------------------------
   Grand écran, fond de salle, vidéoprojecteur souvent fatigué : plus de
   contraste, plus grand, et aucun élément d'interface qui traîne.
   ------------------------------------------------------------------- */

body.projection {
    background: #0b0d13; color: #f0f3fa;
    height: 100vh; overflow: hidden;
    display: flex; flex-direction: column;
}
body.projection .barre {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; background: #151a25; border-bottom: 1px solid #232a38;
    flex: 0 0 auto;
    transition: opacity .25s, transform .25s;
}
/* La barre s'efface quand la souris la quitte : pendant le cours, les
   élèves regardent le plan, pas les boutons. */
body.projection.repos .barre { opacity: 0; transform: translateY(-100%); height: 0; padding: 0; }
body.projection .barre button { background: #1d2432; border-color: #2c3546; color: #dbe2f0; }
body.projection .barre button:hover:not(:disabled) { border-color: #748ffc; color: #a9bcff; }
body.projection .barre .titre { font-weight: 650; margin-right: 6px; }
body.projection .barre .compte { color: #93a0b8; font-size: 13px; }

body.projection .scene-hote {
    flex: 1 1 auto; border: 0; border-radius: 0;
    display: flex; align-items: center; justify-content: center;
    background: #0b0d13; min-height: 0;
}
body.projection svg.scene { width: 100%; height: 100%; }
body.projection {
    --pdc-fond: #0b0d13; --pdc-table: #202736; --pdc-table-bord: #333d51;
    --pdc-vide: #161c27; --pdc-grille: #141926; --pdc-repere: #3a4356;
}
body.projection .pdc-prenom  { font-size: 16px; }
body.projection .pdc-etiquette { stroke: rgba(255, 255, 255, .18); }

/* --- Connexion ------------------------------------------------------ */

.connexion {
    max-width: 380px; margin: 12vh auto; padding: 0 20px;
}
.connexion h1 { font-size: 22px; margin: 0 0 4px; }
.connexion .aide { margin-bottom: 22px; }

/* --- Divers --------------------------------------------------------- */

.chargement { color: var(--texte-doux); padding: 30px; text-align: center; }

dialog {
    border: 1px solid var(--bord); border-radius: var(--rayon);
    background: var(--carte); color: var(--texte);
    padding: 20px; max-width: 520px; width: calc(100% - 40px);
    box-shadow: 0 12px 40px rgba(10, 15, 30, .25);
}
dialog::backdrop { background: rgba(10, 14, 24, .45); }
dialog h2 { margin-top: 0; }
dialog .pied { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.reglage { display: grid; grid-template-columns: 1fr 92px; gap: 8px; align-items: center; margin-bottom: 8px; }
.reglage > span { font-size: 13.5px; }

@media print {
    .entete, nav, .barre, button { display: none !important; }
    body, .scene-hote { background: #fff; }
}
