/* =====================================================================
   Feuille de style — Gestion d'établissement scolaire primaire
   ===================================================================== */
:root {
    --bleu:        #1e4b8f;
    --bleu-fonce:  #16386b;
    --bleu-clair:  #eaf1fb;
    --vert:        #1c8a4d;
    --rouge:       #c0392b;
    --orange:      #d98a1f;
    --gris:        #6b7280;
    --gris-clair:  #f4f6fa;
    --bordure:     #dfe3ea;
    --texte:       #1f2733;
    --ombre:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --radius:      10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--gris-clair);
    color: var(--texte);
    line-height: 1.5;
}

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

/* --- Barre supérieure --- */
.topbar { background: var(--bleu-fonce); color: #fff; }
.topbar-inner {
    max-width: 1180px; margin: 0 auto; padding: 12px 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.marque { color: #fff; font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.marque:hover { text-decoration: none; }
.logo { font-size: 1.5rem; }
.user-zone { display: flex; align-items: center; gap: 14px; }
.user-nom { font-size: .9rem; opacity: .9; }

/* --- Navigation --- */
.navbar { background: var(--bleu); box-shadow: var(--ombre); }
.navbar-inner {
    max-width: 1180px; margin: 0 auto; padding: 0 20px;
    display: flex; flex-wrap: wrap; gap: 4px;
}
.navbar a {
    color: #dbe6f7; padding: 13px 16px; font-size: .93rem; font-weight: 500;
    border-bottom: 3px solid transparent;
}
.navbar a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,.06); }
.navbar a.actif { color: #fff; border-bottom-color: #fff; background: rgba(255,255,255,.1); }

/* --- Contenu --- */
.contenu { max-width: 1180px; margin: 24px auto; padding: 0 20px; }
.entete-page { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.entete-page h1 { font-size: 1.5rem; margin: 0; color: var(--bleu-fonce); }

/* --- Cartes / statistiques --- */
.grille-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat {
    background: #fff; border: 1px solid var(--bordure); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--ombre); display: flex; align-items: center; gap: 16px;
}
.stat .ico { font-size: 2rem; width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; background: var(--bleu-clair); border-radius: 12px; }
.stat .chiffre { font-size: 1.7rem; font-weight: 700; color: var(--bleu-fonce); line-height: 1; }
.stat .libelle { color: var(--gris); font-size: .88rem; margin-top: 4px; }

.carte { background: #fff; border: 1px solid var(--bordure); border-radius: var(--radius); box-shadow: var(--ombre); padding: 22px; margin-bottom: 22px; }
.carte h2 { margin-top: 0; font-size: 1.15rem; color: var(--bleu-fonce); }

/* --- Tableaux --- */
.table-zone { background: #fff; border: 1px solid var(--bordure); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--ombre); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: var(--bleu-clair); color: var(--bleu-fonce); text-align: left;
    padding: 12px 14px; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em;
}
tbody td { padding: 11px 14px; border-top: 1px solid var(--bordure); font-size: .93rem; }
tbody tr:hover { background: #fafbfe; }
.table-vide { padding: 30px; text-align: center; color: var(--gris); }

/* --- Boutons --- */
.btn {
    display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    background: var(--bleu); color: #fff; font-size: .9rem; font-weight: 500; cursor: pointer;
    text-align: center; transition: background .15s;
}
.btn:hover { background: var(--bleu-fonce); text-decoration: none; }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-vert { background: var(--vert); }
.btn-vert:hover { background: #16673a; }
.btn-rouge { background: var(--rouge); }
.btn-rouge:hover { background: #96271b; }
.btn-clair { background: #fff; color: var(--bleu-fonce); border-color: #cdd6e4; }
.btn-clair:hover { background: #eef2f8; }
.btn-gris { background: var(--gris); }
.btn-gris:hover { background: #4b5563; }

.actions-ligne { display: flex; gap: 6px; }

/* --- Formulaires --- */
.formulaire { max-width: 720px; }
.champ { margin-bottom: 16px; }
.champ label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; color: #384355; }
.champ input, .champ select, .champ textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #cdd6e4; border-radius: 8px;
    font-size: .95rem; font-family: inherit; background: #fff;
}
.champ input:focus, .champ select:focus, .champ textarea:focus {
    outline: none; border-color: var(--bleu); box-shadow: 0 0 0 3px rgba(30,75,143,.12);
}
.champ .obligatoire { color: var(--rouge); }
.ligne-champs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* --- Alertes --- */
.alerte { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: .92rem; border: 1px solid transparent; }
.alerte-succes { background: #e6f6ec; color: #14603a; border-color: #b6e2c6; }
.alerte-erreur { background: #fbe9e7; color: #8a2015; border-color: #f2c1ba; }
.alerte-info   { background: var(--bleu-clair); color: var(--bleu-fonce); border-color: #c3d6f2; }

/* --- Badges --- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-vert { background: #e6f6ec; color: #14603a; }
.badge-gris { background: #eceff3; color: #4b5563; }
.badge-orange { background: #fcefd9; color: #8a5a13; }
.badge-bleu { background: var(--bleu-clair); color: var(--bleu-fonce); }

/* --- Barre d'outils au-dessus des tableaux --- */
.barre-outils { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.barre-outils form { display: flex; gap: 8px; }
.barre-outils input[type="search"], .barre-outils select {
    padding: 8px 12px; border: 1px solid #cdd6e4; border-radius: 8px; font-size: .9rem;
}

/* --- Connexion --- */
.page-login { min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--bleu) 0%, var(--bleu-fonce) 100%); padding: 20px; }
.carte-login { background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.2);
    padding: 38px 34px; width: 100%; max-width: 400px; }
.carte-login .titre-login { text-align: center; margin-bottom: 24px; }
.carte-login .titre-login .logo { font-size: 2.6rem; }
.carte-login h1 { font-size: 1.3rem; color: var(--bleu-fonce); margin: 8px 0 2px; }
.carte-login .sous { color: var(--gris); font-size: .9rem; }
.info-login { margin-top: 18px; padding: 12px; background: var(--gris-clair); border-radius: 8px; font-size: .82rem; color: var(--gris); text-align: center; }

/* --- Logo dans la barre supérieure --- */
.logo-img { height: 40px; width: 40px; object-fit: contain; background: #fff; border-radius: 50%; padding: 2px; }

/* --- En-tête officiel des documents (bandeau d'État + logo + nom) --- */
.entete-officiel { text-align: center; margin-bottom: 4px; }
.entete-officiel .ministere { font-size: .72rem; font-weight: 700; letter-spacing: .02em; color: #2b2b2b; text-transform: uppercase; margin-bottom: 8px; }

/* Bandeau d'État : Ministère (gauche) / République + armoiries (droite) */
.bandeau-etat { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 10px; margin-bottom: 8px; border-bottom: 1px solid var(--bordure); }
.bandeau-etat .col-ministere { flex: 1 1 48%; text-align: left; font-size: .68rem; font-weight: 700; text-transform: uppercase; color: #2b2b2b; line-height: 1.35; }
.bandeau-etat .col-republique { flex: 0 0 auto; text-align: center; }
.bandeau-etat .col-republique .rep { font-size: .72rem; font-weight: 700; text-transform: uppercase; color: #2b2b2b; }
.bandeau-etat .col-republique .dev { font-size: .68rem; font-style: italic; color: #444; }
.bandeau-etat .armoiries-doc { height: 40px; width: auto; object-fit: contain; margin-top: 3px; display: inline-block; }
.entete-officiel .logo-doc { height: 90px; width: auto; object-fit: contain; margin: 2px auto 6px; display: block; }
.entete-officiel h2 { margin: 0; color: var(--bleu-fonce); }
.entete-officiel .doc-titre { font-weight: 600; margin-top: 4px; }
.entete-officiel .doc-annee { font-size: .9rem; color: var(--gris); }

/* --- Bulletin imprimable --- */
.bulletin { background: #fff; padding: 30px; border: 1px solid var(--bordure); border-radius: var(--radius); max-width: 800px; margin: 0 auto; }
.bulletin-entete { text-align: center; border-bottom: 2px solid var(--bleu-fonce); padding-bottom: 14px; margin-bottom: 18px; }
.bulletin-entete h2 { margin: 0; color: var(--bleu-fonce); }
.bulletin-infos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; margin-bottom: 20px; font-size: .92rem; }
.bulletin table td, .bulletin table th { border: 1px solid var(--bordure); }
.bulletin .synthese { margin-top: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.bulletin .synthese .bloc { background: var(--gris-clair); border-radius: 8px; padding: 14px; text-align: center; }
.bulletin .synthese .bloc .val { font-size: 1.5rem; font-weight: 700; color: var(--bleu-fonce); }
.bulletin .synthese .bloc .lib { font-size: .8rem; color: var(--gris); }

/* --- Grille vierge (liste par classe à colonnes à remplir) --- */
.grille-vierge { table-layout: fixed; width: 100%; }
.grille-vierge th, .grille-vierge td { border: 1px solid #999; }
.grille-vierge thead th { height: 30px; background: var(--gris-clair); }
.grille-vierge tbody td { height: 34px; }
.grille-vierge th:nth-child(2), .grille-vierge td:nth-child(2) { width: 30%; }
.grille-vierge th:nth-child(n+3), .grille-vierge td:nth-child(n+3) { width: 13%; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.moyenne-forte { color: var(--vert); font-weight: 600; }
.moyenne-faible { color: var(--rouge); font-weight: 600; }

/* ===================== RESPONSIVE (mobile / tablette) ===================== */
@media (max-width: 860px) {
    /* Barre du haut : nom plus compact, retour à la ligne autorisé */
    .topbar-inner { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
    .marque { font-size: 1rem; }
    .contenu { margin: 16px auto; padding: 0 14px; }

    /* Menu : une seule ligne, défilable horizontalement au doigt */
    .navbar-inner { flex-wrap: nowrap; overflow-x: auto; padding: 0 10px; -webkit-overflow-scrolling: touch; }
    .navbar-inner::-webkit-scrollbar { height: 0; }
    .navbar a { flex: 0 0 auto; white-space: nowrap; padding: 12px 13px; font-size: .9rem; }

    /* Les grilles à 2/3 colonnes s'empilent (y compris celles définies en style inline) */
    .grille-stats { grid-template-columns: 1fr !important; }
}

@media (max-width: 640px) {
    .ligne-champs { grid-template-columns: 1fr; }
    .bulletin-infos, .bulletin .synthese { grid-template-columns: 1fr; }
    .entete-page h1 { font-size: 1.25rem; }
    .bandeau-etat { flex-direction: column; gap: 8px; text-align: center; }
    .bandeau-etat .col-ministere { text-align: center; }
    /* Boutons plus faciles à toucher */
    .btn { padding: 10px 15px; }
    .barre-outils { gap: 10px; }
    .barre-outils form { flex-wrap: wrap; }
    .actions-ligne { flex-wrap: wrap; }
    .formulaire, .bulletin { max-width: 100%; }
}

/* --- Impression --- */
@media print {
    .topbar, .navbar, .pied, .no-print, .form-actions { display: none !important; }
    body { background: #fff; }
    .contenu { margin: 0; max-width: 100%; }
    .bulletin { border: none; box-shadow: none; max-width: 100%; }
}
