/* ============================================================
   GESTION DE CITÉ UNIVERSITAIRE — Système de design
   Inspiré du "registre" administratif : papier, encre, tampon.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
    --papier:      #F7F6F2;
    --papier-fonce:#EFEDE6;
    --encre:       #1C2333;
    --encre-douce: #4B5468;
    --teal:        #2F5D62;
    --teal-clair:  #E4EEEC;
    --or:          #B8892B;
    --or-clair:    #F3E9D2;
    --brique:      #B3432B;
    --brique-clair:#F7E4DE;
    --bordure:     #DCD7C9;
    --blanc:       #FFFFFF;
    --radius:      10px;
    --ombre:       0 2px 10px rgba(28,35,51,0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--papier);
    color: var(--encre);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3, .titre-registre {
    font-family: 'Source Serif 4', serif;
    color: var(--encre);
    letter-spacing: 0.01em;
}

.chiffre, table td.num, .badge, code {
    font-family: 'IBM Plex Mono', monospace;
    font-variant-numeric: tabular-nums;
}

/* ---------- Mise en page générale : barre latérale + contenu ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}
.contenu-principal {
    flex: 1;
    min-width: 0; /* empêche les tableaux larges de faire déborder la mise en page */
}

/* ---------- Barre latérale (remplace le bandeau + nav horizontale) ---------- */
.barre-laterale {
    width: 230px;
    flex-shrink: 0;
    background: var(--encre);
    color: var(--papier);
    display: flex;
    flex-direction: column;
    padding: 1.4rem 1.1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.barre-laterale__titre {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding-bottom: 1.2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(247,246,242,0.14);
    font-family: 'Source Serif 4', serif;
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.25;
}
.barre-laterale nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
}
.barre-laterale nav a {
    color: var(--papier);
    opacity: 0.8;
    text-decoration: none;
    font-size: 0.92rem;
    padding: 0.55rem 0.7rem;
    border-radius: 7px;
}
.barre-laterale nav a:hover { opacity: 1; background: rgba(247,246,242,0.08); }
.barre-laterale nav a.actif {
    opacity: 1;
    background: var(--teal);
    font-weight: 600;
    text-decoration: none;
}
.barre-laterale__pied {
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid rgba(247,246,242,0.14);
}
.barre-laterale__pied a {
    color: var(--papier);
    opacity: 0.75;
    text-decoration: none;
    font-size: 0.88rem;
}
.barre-laterale__pied a:hover { opacity: 1; text-decoration: underline; }

/* ---------- Bandeau (pages sans connexion : accueil, login) ---------- */
.bandeau {
    background: var(--encre);
    color: var(--papier);
    padding: 0.9rem 1.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sceau {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 2px solid var(--or);
    color: var(--or);
    font-family: 'Source Serif 4', serif;
    font-weight: 700;
    flex-shrink: 0;
}
.bandeau .sceau {
    margin-right: 0.7rem;
}
.bandeau .titre-registre {
    color: var(--papier);
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

/* ---------- Conteneurs ---------- */
.conteneur { max-width: 1400px; margin: 0 auto; padding: 2rem 1.8rem; }
.conteneur-etroit { max-width: 460px; margin: 4.5rem auto; padding: 0 1.5rem; }

.carte {
    background: var(--blanc);
    border: 1px solid var(--bordure);
    border-radius: var(--radius);
    box-shadow: var(--ombre);
    padding: 1.6rem;
}

/* ---------- Formulaires ---------- */
.champ { margin-bottom: 1.1rem; }
.champ label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--encre-douce);
    margin-bottom: 0.35rem;
}
.champ input, .champ select {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--bordure);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--papier);
}
.champ input:focus, .champ select:focus {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
    border-color: var(--teal);
}

.bouton {
    display: inline-block;
    background: var(--teal);
    color: var(--blanc);
    border: none;
    padding: 0.7rem 1.3rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.bouton:hover { background: #274c50; }
.bouton:focus-visible { outline: 2px solid var(--or); outline-offset: 2px; }
.bouton.large { width: 100%; text-align: center; padding: 0.8rem; }
.bouton.brique { background: var(--brique); }
.bouton.brique:hover { background: #8f3521; }

/* ---------- Alertes ---------- */
.alerte {
    padding: 0.8rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.1rem;
    font-size: 0.9rem;
    border-left: 3px solid;
}
.alerte.erreur  { background: var(--brique-clair); border-color: var(--brique); color: #7a2c1c; }
.alerte.succes  { background: var(--teal-clair);   border-color: var(--teal);   color: #1d3c3f; }
.alerte.info    { background: var(--or-clair);     border-color: var(--or);     color: #6b4e18; }

/* ---------- Badges (statuts) ---------- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge.success { background: var(--teal-clair); color: var(--teal); }
.badge.warning { background: var(--or-clair);   color: var(--or); }
.badge.danger  { background: var(--brique-clair); color: var(--brique); }
.badge.gray    { background: var(--papier-fonce); color: var(--encre-douce); }

/* ---------- Tableaux "registre" ---------- */
table.registre {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
table.registre th {
    text-align: left;
    padding: 0.6rem 0.7rem;
    background: var(--encre);
    color: var(--papier);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
table.registre td {
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--bordure);
}
table.registre tr:nth-child(even) td { background: var(--papier-fonce); }
table.registre tr:hover td { background: var(--teal-clair); }

.pied-page {
    text-align: center;
    color: var(--encre-douce);
    font-size: 0.8rem;
    padding: 2rem 1rem;
}

/* ============================================================
   AJOUTS FRONTEND — remplacent les styles inline dispersés dans
   les modules PHP par des classes réutilisables, et comblent les
   trous laissés par la version précédente : responsive, focus
   clavier, comportement des modales, état actif de la navigation,
   défilement des tableaux sur petit écran.
   ============================================================ */

/* ---------- Focus clavier (accessibilité) ---------- */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Note : l'état "actif" de la navigation est géré par .barre-laterale nav a.actif
   plus haut, maintenant que la navigation est verticale. */

/* ---------- Grilles réutilisables (remplacent les style="display:grid..." inline) ---------- */
.grille-cartes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.grille-2 {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 1.5rem;
}
.grille-2.egale { grid-template-columns: 1fr 1fr; }

.carte h3:first-child, .carte h2:first-child, .carte h4:first-child { margin-top: 0; }

/* ---------- Barre de filtres ---------- */
.barre-filtres {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 1.5rem;
}
.barre-filtres .champ { margin: 0; }
.barre-filtres select { width: auto; min-width: 160px; }

/* ---------- Recherche ---------- */
.barre-recherche { margin-bottom: 1rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }
.barre-recherche input[type="text"] {
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--bordure);
    border-radius: 6px;
    width: 320px;
    max-width: 100%;
    font-family: inherit;
}

/* ---------- Tableaux : défilement horizontal sur petit écran ---------- */
.tableau-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tableau-scroll table.registre { min-width: 640px; }

/* ---------- État vide ---------- */
.etat-vide { text-align: center; color: var(--encre-douce); padding: 2.2rem 1rem; }
.etat-vide .repere { font-family: 'Source Serif 4', serif; font-size: 1.8rem; color: var(--bordure); display: block; margin-bottom: 0.4rem; }

/* ---------- Modales (remplace les style="display:none/flex" inline) ---------- */
.modale-fond {
    display: none;
    position: fixed; inset: 0;
    background: rgba(28, 35, 51, 0.5);
    align-items: center; justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modale-fond.ouverte { display: flex; }
.modale-boite { max-width: 420px; width: 100%; }
.modale-actions { display: flex; gap: 0.6rem; margin-top: 0.4rem; }
.bouton.discret { background: var(--encre-douce); }
.bouton.discret:hover { background: #38405a; }
.bouton.or { background: var(--or); }
.bouton.or:hover { background: #93691f; }
.bouton.petit { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.actions-ligne { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- Astuce ---------- */
.astuce { font-size: 0.85rem; color: var(--encre-douce); margin-top: 1rem; }
.titre-connexion { margin-top: 0; margin-bottom: 1.4rem; text-align: center; }
.titre-cite {
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--or);
    color: var(--teal);
}
.titre-cite:first-child { margin-top: 0; }

/* ---------- Page d'accueil ---------- */
.accueil-hero {
    text-align: center;
    max-width: 640px;
    margin: 2.5rem auto 2rem;
    padding: 0 1rem;
}
.accueil-sceau {
    width: 60px; height: 60px;
    font-size: 1.4rem;
    margin: 0 auto 1.2rem;
    background: var(--blanc);
    box-shadow: var(--ombre);
}
.accueil-hero h1 { font-size: 1.9rem; margin-bottom: 0.8rem; }
.accueil-hero p { color: var(--encre-douce); font-size: 1rem; line-height: 1.6; margin-bottom: 1.6rem; }
.accueil-atouts { max-width: 900px; margin: 0 auto 2.5rem; }
.accueil-atouts .carte p { color: var(--encre-douce); font-size: 0.9rem; margin-bottom: 0; }

.accueil-carrousel {
    max-width: 1000px;
    margin: 0 auto 2.5rem;
    padding: 0 1rem;
}
.carrousel-principal {
    position: relative;
    border-radius: var(--radius-l, 16px);
    overflow: hidden;
    box-shadow: var(--ombre);
    background: var(--papier-fonce);
}
.carrousel-principal img {
    width: 100%;
    height: 440px;
    object-fit: cover;
    display: block;
    transition: opacity 0.18s ease;
}
.carrousel-legende {
    position: absolute;
    left: 0; bottom: 0; right: 0;
    padding: 1.6rem 1.2rem 0.9rem;
    background: linear-gradient(to top, rgba(28,35,51,0.8), transparent);
    color: var(--papier);
    font-family: 'Source Serif 4', serif;
    font-size: 1.1rem;
    font-weight: 600;
    pointer-events: none;
}
.carrousel-fleche {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(28,35,51,0.55);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.carrousel-fleche:hover { background: rgba(28,35,51,0.8); }
.carrousel-fleche--gauche { left: 14px; }
.carrousel-fleche--droite { right: 14px; }

.carrousel-vignettes {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.7rem;
    margin-top: 0.8rem;
}
.vignette {
    padding: 0;
    border: 3px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: none;
    opacity: 0.6;
    transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.vignette img { width: 100%; height: 62px; object-fit: cover; display: block; }
.vignette:hover { opacity: 0.9; transform: translateY(-2px); }
.vignette.actif { opacity: 1; border-color: var(--or); }

@media (max-width: 700px) {
    .carrousel-principal img { height: 260px; }
    .carrousel-vignettes { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
    .accueil-hero h1 { font-size: 1.5rem; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .grille-2 { grid-template-columns: 1fr; }
    .grille-2.egale { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .conteneur { padding: 1.4rem 1rem; }
    .bandeau { flex-direction: column; align-items: flex-start; gap: 0.7rem; padding: 0.9rem 1.2rem; }
    .app-shell { flex-direction: column; min-height: 0; }
    .barre-laterale {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
        padding: 0.8rem 1rem;
        overflow-x: auto;
    }
    .barre-laterale__titre { border-bottom: none; padding-bottom: 0; margin-bottom: 0; margin-right: 0.8rem; white-space: nowrap; }
    .barre-laterale nav { flex-direction: row; flex: none; }
    .barre-laterale nav a { white-space: nowrap; padding: 0.4rem 0.6rem; }
    .barre-laterale__pied { border-top: none; margin-top: 0; padding-top: 0; margin-left: auto; }
    table.registre { font-size: 0.82rem; }
    table.registre th, table.registre td { padding: 0.5rem 0.55rem; }
    .barre-recherche input[type="text"] { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition-duration: 0.001ms !important; }
}


/* Sécurité : force les cartes au premier niveau à occuper toute la largeur
   disponible du conteneur, quelle que soit la cause d'un rétrécissement. */
.conteneur > .carte {
    width: 100%;
    box-sizing: border-box;
}
