/*
 * Portail etudiant : mobile d'abord. Barre du bas sur telephone, menu lateral des 992 px.
 * Palette reprise du gabarit (violet / rouge), contrastes AA, zones tactiles >= 44 px.
 */
:root {
    --p-fond: #f4f5fb; --p-carte: #fff; --p-texte: #1f2340; --p-doux: #6b7094; --p-trait: #e6e8f2;
    --p-primaire: #4a3aa7; --p-primaire-2: #6d4ad8; --p-accent: #f43b48;
    --p-ok: #1f9d55; --p-alerte: #e08a00; --p-danger: #d93a46; --p-info: #2f6fed;
    --p-rayon: 14px; --p-ombre: 0 2px 10px rgba(40, 36, 100, .08);
    --p-barre: 56px; --p-onglets: 62px; --p-menu: 244px;
}

[x-cloak] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body.portail { background: var(--p-fond); color: var(--p-texte); font-size: 15px; padding: var(--p-barre) 0 calc(var(--p-onglets) + env(safe-area-inset-bottom)); }
.portail a { color: var(--p-primaire); }
.portail-saut { position: absolute; left: -999px; } .portail-saut:focus { left: 8px; top: 8px; z-index: 3000; background: #fff; padding: 8px 12px; border-radius: 8px; }

/* Barre du haut */
.portail-barre { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; height: var(--p-barre); display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px; background: linear-gradient(90deg, #f43b48, #4a3aa7); color: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .2); }
.portail-marque { display: flex; align-items: center; gap: 10px; color: #fff !important; font-weight: 700; text-decoration: none !important; min-width: 0; }
.portail-marque img { border-radius: 50%; background: #fff; }
.portail-marque span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portail-compte { display: flex; align-items: center; gap: 10px; }
.portail-nom { font-size: 14px; font-weight: 600; }
.portail-photo img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255, 255, 255, .7); }
.portail-sortie { color: #fff !important; font-size: 24px; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.portail-sortie:hover { background: rgba(255, 255, 255, .18); }

/* Navigation */
.portail-menu { display: none; }
.portail-onglets { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; height: calc(var(--p-onglets) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    display: flex; background: #fff; border-top: 1px solid var(--p-trait); box-shadow: 0 -2px 10px rgba(40, 36, 100, .08); }
.portail-onglets a, .portail-onglets button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: transparent;
    color: var(--p-doux) !important; font-size: 11px; font-weight: 600; text-decoration: none !important; min-width: 0; }
.portail-onglets .la { font-size: 24px; }
.portail-onglets .actif { color: var(--p-primaire) !important; }
.portail-onglets .actif .la { transform: translateY(-1px); }
.portail-feuille { position: fixed; right: 10px; bottom: calc(var(--p-onglets) + 10px + env(safe-area-inset-bottom)); z-index: 1001; background: #fff; border-radius: var(--p-rayon);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .25); padding: 6px; min-width: 220px; }
.portail-feuille a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; color: var(--p-texte) !important; text-decoration: none !important; font-weight: 600; }
.portail-feuille a:hover { background: var(--p-fond); }
.portail-feuille .la { font-size: 22px; color: var(--p-primaire); }

.portail-contenu { max-width: 1100px; margin: 0 auto; padding: 16px 14px 24px; }

@media (min-width: 992px) {
    body.portail { padding: var(--p-barre) 0 0 var(--p-menu); }
    .portail-onglets, .portail-feuille { display: none !important; }
    .portail-menu { display: flex; flex-direction: column; gap: 4px; position: fixed; top: var(--p-barre); bottom: 0; left: 0; width: var(--p-menu); padding: 18px 12px; background: #fff; border-right: 1px solid var(--p-trait); overflow-y: auto; }
    .portail-menu a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; color: var(--p-texte); font-weight: 600; text-decoration: none; transition: background .15s; }
    .portail-menu a:hover { background: var(--p-fond); }
    .portail-menu a.actif { background: linear-gradient(90deg, var(--p-primaire), var(--p-primaire-2)); color: #fff; box-shadow: 0 3px 10px rgba(74, 58, 167, .35); }
    .portail-menu .la { font-size: 22px; }
    .portail-contenu { padding: 24px 28px 40px; }
}

/* Contenu */
.p-titre { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.p-sous-titre { color: var(--p-doux); margin-bottom: 16px; }
.p-carte { background: var(--p-carte); border-radius: var(--p-rayon); box-shadow: var(--p-ombre); padding: 16px; margin-bottom: 14px; }
.p-carte h2, .p-carte h3 { font-size: 15px; font-weight: 800; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.p-carte h2 .la, .p-carte h3 .la { color: var(--p-primaire); font-size: 20px; }
.p-grille { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .p-grille.deux { grid-template-columns: 1fr 1fr; } .p-grille.trois { grid-template-columns: repeat(3, 1fr); } }
.p-vide { text-align: center; color: var(--p-doux); padding: 22px 8px; } .p-vide .la { display: block; font-size: 38px; color: #c9cbe0; margin-bottom: 4px; }

.p-bienvenue { background: linear-gradient(120deg, var(--p-primaire), var(--p-primaire-2) 60%, #b0399e); color: #fff; border-radius: var(--p-rayon); padding: 20px; margin-bottom: 14px; box-shadow: 0 6px 20px rgba(74, 58, 167, .3); }
.p-bienvenue h1 { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.p-bienvenue p { margin: 0; opacity: .9; }
.p-pastille { display: inline-block; padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .2); font-size: 12px; font-weight: 700; margin-top: 8px; margin-right: 6px; }

.p-chiffre { font-size: 28px; font-weight: 800; line-height: 1.1; }
.p-etiquette { color: var(--p-doux); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.p-barre { height: 10px; border-radius: 6px; background: var(--p-trait); overflow: hidden; margin: 8px 0 4px; }
.p-barre > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--p-primaire), var(--p-primaire-2)); transition: width .4s; }
.p-barre.ok > span { background: var(--p-ok); } .p-barre.alerte > span { background: var(--p-alerte); }

.p-ligne { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--p-trait); }
.p-ligne:last-child { border-bottom: 0; }
.p-ligne .texte { flex: 1; min-width: 0; } .p-ligne .texte strong { display: block; } .p-ligne .texte small { color: var(--p-doux); }
.p-heure { flex: none; width: 74px; text-align: center; font-weight: 800; color: var(--p-primaire); font-size: 13px; line-height: 1.2; }
.p-heure small { display: block; color: var(--p-doux); font-weight: 600; }
.p-etat { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.p-etat.ok { background: #e3f6ea; color: #17733f; } .p-etat.alerte { background: #fff1d6; color: #9a5d00; } .p-etat.danger { background: #fde5e7; color: #a82832; } .p-etat.neutre { background: #eceefa; color: #4b5080; }

.p-selecteurs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.p-selecteurs label { display: block; font-size: 12px; font-weight: 700; color: var(--p-doux); margin: 0 0 3px; }
.p-selecteurs select, .p-champ { min-height: 44px; border-radius: 10px; border: 1px solid var(--p-trait); background: #fff; padding: 0 12px; width: 100%; }
.p-selecteurs > div { flex: 1 1 180px; }
.p-champ:focus, .p-selecteurs select:focus { outline: 2px solid var(--p-primaire-2); border-color: transparent; }
textarea.p-champ { padding: 10px 12px; }
.p-bouton { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 12px; font-weight: 700; cursor: pointer;
    background: linear-gradient(90deg, var(--p-primaire), var(--p-primaire-2)); color: #fff !important; text-decoration: none !important; }
.p-bouton:disabled { opacity: .55; cursor: not-allowed; }
.p-bouton.clair { background: #eceefa; color: var(--p-primaire) !important; }
.p-bouton.plein { width: 100%; }
.p-alerte { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-weight: 600; }
.p-alerte.ok { background: #e3f6ea; color: #17733f; } .p-alerte.erreur { background: #fde5e7; color: #a82832; } .p-alerte.info { background: #e8efff; color: #254fa8; }

/* Tableaux : en cartes sur telephone */
.p-table { width: 100%; border-collapse: collapse; }
.p-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--p-doux); text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--p-trait); }
.p-table td { padding: 12px 10px; border-bottom: 1px solid var(--p-trait); vertical-align: middle; }
.p-table .droite { text-align: right; }
@media (max-width: 640px) {
    .p-table thead { display: none; }
    .p-table, .p-table tbody, .p-table tr, .p-table td { display: block; width: 100%; }
    .p-table tr { padding: 10px 0; border-bottom: 1px solid var(--p-trait); }
    .p-table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .p-table td::before { content: attr(data-label); font-weight: 700; color: var(--p-doux); text-align: left; }
}

/* Emploi du temps : jours en liste */
.p-jours { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.p-jours button { flex: none; min-width: 58px; min-height: 52px; border: 1px solid var(--p-trait); border-radius: 12px; background: #fff; font-weight: 700; color: var(--p-texte); }
.p-jours button.actif { background: var(--p-primaire); border-color: var(--p-primaire); color: #fff; }
.p-jours button small { display: block; font-weight: 600; opacity: .75; }
.p-aujourdhui { box-shadow: 0 0 0 2px var(--p-primaire-2) inset; }

.p-chargement { opacity: .6; transition: opacity .15s; }

/* Appel et saisie : boutons tactiles */
.p-pointage { flex: none; width: 54px; min-height: 48px; border: 2px solid var(--p-trait); border-radius: 12px; background: #fff; color: var(--p-doux); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; margin-left: 6px; line-height: 1.1; }
.p-pointage span { font-size: 11px; font-weight: 700; } .p-pointage b { font-size: 16px; }
.p-pointage.present { background: #e3f6ea; border-color: var(--p-ok); color: #17733f; }
.p-pointage.absent { background: #fde5e7; border-color: var(--p-danger); color: #a82832; }
.p-barre-action { position: sticky; bottom: calc(var(--p-onglets) + 10px + env(safe-area-inset-bottom)); z-index: 5; }
@media (min-width: 992px) { .p-barre-action { bottom: 12px; } }
.p-note { width: 78px; min-height: 44px; border-radius: 10px; border: 1px solid var(--p-trait); text-align: center; font-weight: 700; }
.p-note.invalide { border-color: var(--p-danger); background: #fff5f5; }
.p-note:focus { outline: 2px solid var(--p-primaire-2); border-color: transparent; }
