/* =========================================
   Nukunu Mofiala - Styles principaux
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.nav-brand i {
    font-size: 2rem;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    background: rgba(255,255,255,0.2);
}

/* Hero */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4rem 2rem;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero-image {
    text-align: center;
    padding: 1.5rem 1rem;
    background: #f7fafc;
}
.hero-image img {
    max-width: 200px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.btn-primary {
    display: inline-block;
    background: white;
    color: #667eea;
    padding: 0.75rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.3s, box-shadow 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

/* Stats */
.stats {
    padding: 3rem 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card i {
    font-size: 2.5rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.stat-card h3 {
    font-size: 2rem;
    color: #333;
}

.stat-card p {
    color: #666;
    font-weight: 500;
}

/* Footer */
.footer {
    background: #2d3748;
    color: white;
    text-align: center;
    padding: 2rem;
}
.footer-visitors-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.fv-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
}
.fv-item i {
    font-size: 1.1rem;
    color: #667eea;
    margin-bottom: .3rem;
}
.fv-nb {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}
.fv-lb {
    font-size: .78rem;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 3rem;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #667eea;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.btn-submit {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s;
}

.btn-submit:hover {
    opacity: 0.9;
}

.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

.success-message {
    background: #c6f6d5;
    color: #22543d;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

/* Dashboard */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* ═══ Sidebar ═══ */
.sidebar {
    width: 250px;
    background: #2d3748;
    color: white;
    padding: 2rem 0 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 0 1.5rem 2rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left: 3px solid #667eea;
}

.sidebar-menu li.menu-parent>a{display:flex;align-items:center;gap:.75rem;padding:.75rem 1.5rem;color:rgba(255,255,255,0.7);text-decoration:none;transition:all .3s;cursor:pointer}
.sidebar-menu li.menu-parent>a:hover,.sidebar-menu li.menu-parent>a.active{background:rgba(255,255,255,0.1);color:#fff;border-left:3px solid #667eea}
.sidebar-menu li.menu-parent .sub-toggle{margin-left:auto;transition:transform .3s}
.sidebar-menu li.menu-parent.open .sub-toggle{transform:rotate(90deg)}
.sidebar-menu .sub-menu{list-style:none;padding:0;max-height:0;overflow:hidden;transition:max-height .3s ease}
.sidebar-menu li.menu-parent.open > .sub-menu{max-height:600px}
.sidebar-menu .sub-menu li a{display:flex;align-items:center;gap:.75rem;padding:.6rem 1.5rem .6rem 2.8rem;color:rgba(255,255,255,0.6);text-decoration:none;font-size:.9rem;transition:all .3s}
.sidebar-menu .sub-menu li a:hover,.sidebar-menu .sub-menu li a.active{background:rgba(255,255,255,0.08);color:#fff}
/* Troisième niveau */
.sidebar-menu .sub-menu .sub-menu li a{padding:.5rem 1.5rem .5rem 3.8rem;font-size:.85rem}
.sidebar-menu .sub-menu .sub-menu li.menu-parent > a{padding:.5rem 1.5rem .5rem 2.8rem;font-size:.85rem}

/* Sidebar footer */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: .85rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: #252d3d;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    color: white;
    flex-shrink: 0;
}
.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-user-name {
    color: white;
    font-weight: 600;
    font-size: .85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    color: rgba(255,255,255,0.45);
    font-size: .72rem;
}

/* Logo de l'école dans le sidebar */
.sidebar-school-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
    background: white;
    padding: 2px;
    flex-shrink: 0;
}

/* ── Styles pour l'upload de logo (schools.php) ── */

/* Zone drag & drop */
.logo-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.5rem;
    border: 2px dashed #cbd5e0;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: #f7fafc;
    text-align: center;
    color: #718096;
    position: relative;
}

.logo-upload-zone:hover,
.logo-upload-zone.dragover {
    border-color: #667eea;
    background: #ebf4ff;
    color: #667eea;
}

.logo-upload-zone i {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.logo-upload-zone small {
    font-size: 0.78rem;
    color: #a0aec0;
}

/* Cacher l'input file réel (on utilise la zone cliquable) */
.logo-upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* Aperçu du logo (actuel ou nouveau) */
.logo-preview-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.logo-preview {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: white;
    padding: 4px;
}

.logo-preview-label {
    font-size: 0.85rem;
    color: #718096;
}

#newLogoPreview {
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #f0fff4;
    border: 1px solid #c6f6d5;
    border-radius: 8px;
}

/* Miniature dans la liste des écoles */
.school-logo-thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f7fafc;
    padding: 3px;
    display: block;
}

.school-logo-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #edf2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a0aec0;
    font-size: 1.3rem;
}

.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 0 2rem 2rem;
    display: flex;
    flex-direction: column;
}

/* ── Topbar (barre du haut fixe) ────────────────────── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: #f5f7fa;
    z-index: 100;
}
.topbar-left {
    flex: 1;
}
.topbar-title {
    font-size: 1.4rem;
    color: #2d3748;
    font-weight: 700;
    margin: 0;
}
.topbar-center {
    flex: 1;
    text-align: center;
}
.topbar-school {
    font-size: .95rem;
    font-weight: 600;
    color: #4a5568;
}
.topbar-school i {
    color: #667eea;
    margin-right: .4rem;
}
.topbar-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .4rem .8rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 40px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    color: white;
    flex-shrink: 0;
}
.user-photo-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.user-photo-initial {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    color: white;
    flex-shrink: 0;
}
.user-photo-img.large, .user-photo-initial.large {
    width: 80px;
    height: 80px;
    font-size: 1.8rem;
}
.user-photo-img.small, .user-photo-initial.small {
    width: 28px;
    height: 28px;
    font-size: .75rem;
}
.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.topbar-user-name {
    font-weight: 600;
    font-size: .85rem;
    color: #2d3748;
    white-space: nowrap;
}
.topbar-user-role {
    font-size: .72rem;
    color: #718096;
}
.topbar-logout {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem 1rem;
    background: linear-gradient(135deg, #e53e3e, #c53030);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 600;
    transition: opacity .2s, transform .15s;
    box-shadow: 0 2px 8px rgba(197,48,48,.25);
}
.topbar-logout:hover {
    opacity: .9;
    transform: translateY(-1px);
}

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
}

.data-table tr:hover {
    background: #f7fafc;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-admin { background: #fed7d7; color: #c53030; }
.badge-teacher { background: #bee3f8; color: #2b6cb0; }
.badge-accountant { background: #fefcbf; color: #975a16; }
.badge-super { background: #c6f6d5; color: #22543d; }

.btn-action {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: opacity 0.3s;
}

.btn-edit { background: #bee3f8; color: #2b6cb0; }
.btn-delete { background: #fed7d7; color: #c53030; }
.btn-view { background: #e2e8f0; color: #4a5568; }

.btn-action:hover { opacity: 0.8; }

/* ── Tri des colonnes ──────────────────────────────────────────────────────── */

/* Lien dans l'en-tête de colonne triable */
.sort-th {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #4a5568;
    text-decoration: none;
    font-weight: 600;
    font-size: inherit;
    white-space: nowrap;
    padding: 0.2rem 0.1rem;
    border-radius: 4px;
    transition: color 0.2s;
}

.sort-th:hover {
    color: #667eea;
}

/* Colonne actuellement triée */
.sort-th-active {
    color: #667eea;
}

/* Icône de tri */
.sort-icon {
    font-size: 0.75rem;
    transition: color 0.2s;
}

.sort-inactive {
    color: #cbd5e0;
    opacity: 0.7;
}

.sort-active {
    color: #667eea;
}

/* Légère surbrillance de la colonne triée */
.data-table th:has(.sort-th-active) {
    background: #ebf4ff;
}

@media (max-width: 640px) {
    .navbar {
        flex-direction: column;
        gap: .75rem;
        text-align: center;
        padding: 1rem;
    }
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    .hero {
        padding: 2.5rem 1rem;
    }
    .hero h1 {
        font-size: 1.5rem;
    }
    .hero p {
        font-size: .95rem;
    }
    .stats .container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 0 1rem;
    }
    .stat-card {
        padding: 1.25rem;
    }
    .stat-card i {
        font-size: 1.8rem;
    }
    .stat-card h3 {
        font-size: 1.5rem;
    }
    .hero-image img {
        max-width: 140px;
    }
    .footer-visitors-bar {
        gap: .75rem;
    }
    .fv-item {
        min-width: 90px;
        padding: .4rem .6rem;
    }
    .fv-nb {
        font-size: 1rem;
    }
}

/* ══════════════════════════════════════════════════════
   NOUVELLES SECTIONS — Classes, Matières, Bulletins
   ══════════════════════════════════════════════════════ */

/* ── Badges nouveaux rôles ──────────────────────────── */
.badge-student    { background: #e9d8fd; color: #553c9a; }
.badge-parent     { background: #feebc8; color: #7b341e; }
.badge-toggle-on  { background: #c6f6d5; color: #22543d; }
.badge-toggle-off { background: #fed7d7; color: #c53030; }
.btn-toggle-on    { background: #c6f6d5; color: #22543d; border: none; cursor: pointer; }
.btn-toggle-off   { background: #fed7d7; color: #c53030; border: none; cursor: pointer; }

/* Statut actif/inactif */
.status-badge { display:inline-flex; align-items:center; gap:.3rem; padding:.2rem .6rem; border-radius:20px; font-size:.8rem; font-weight:600; }
.status-active   { background:#c6f6d5; color:#22543d; }
.status-inactive { background:#fed7d7; color:#c53030; }
.user-inactive td { opacity:.55; }

/* ── Onglets tab-nav ────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: .5rem;
    flex-wrap: wrap;
}
.tab-btn {
    padding: .5rem 1.1rem;
    border-radius: 8px 8px 0 0;
    text-decoration: none;
    color: #718096;
    font-weight: 500;
    font-size: .9rem;
    transition: background .2s, color .2s;
    border: 1px solid transparent;
}
.tab-btn:hover { background: #edf2f7; color: #2d3748; }
.tab-btn.active {
    background: white;
    color: #667eea;
    border-color: #e2e8f0 #e2e8f0 white;
    font-weight: 700;
}

/* ── Accordéon écoles (classes.php) ─────────────────── */
.school-accordion {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    margin-bottom: 1rem;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    cursor: pointer;
    background: #f7fafc;
    transition: background .2s;
    user-select: none;
}
.accordion-header:hover { background: #edf2f7; }
.accordion-school-info {
    display: flex;
    align-items: center;
    gap: .9rem;
}
.accordion-logo {
    width: 42px; height: 42px;
    object-fit: contain;
    border-radius: 8px;
    background: white;
    border: 1px solid #e2e8f0;
    padding: 3px;
}
.accordion-logo-placeholder {
    width: 42px; height: 42px;
    border-radius: 8px;
    background: #e2e8f0;
    display: flex; align-items: center; justify-content: center;
    color: #a0aec0; font-size: 1.2rem;
}
.accordion-school-name { font-weight: 700; font-size: 1rem; color: #2d3748; display: block; }
.accordion-count       { font-size: .8rem; color: #718096; }
.accordion-arrow {
    color: #718096;
    transition: transform .3s;
    font-size: .9rem;
}
.school-accordion.open .accordion-arrow { transform: rotate(180deg); }
.accordion-body { display: none; padding: 1.25rem; border-top: 1px solid #e2e8f0; }
.school-accordion.open .accordion-body { display: block; }

/* Grille de cartes de classes */
.classes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.class-card {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    transition: box-shadow .2s, transform .2s;
}
.class-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); transform: translateY(-2px); }
.class-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.class-name { font-weight: 700; font-size: 1rem; color: #2d3748; }
.class-actions { display: flex; gap: .3rem; }
.class-card-body { display: flex; flex-wrap: wrap; gap: .35rem; }
.class-tag {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    background: #edf2f7;
    color: #4a5568;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 500;
}
.class-card-footer {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: .25rem;
    padding-top: .5rem;
    border-top: 1px solid #e2e8f0;
    font-size: .8rem;
    color: #718096;
    flex-wrap: wrap;
}
.class-card-footer i { margin-right: .2rem; }
.class-link { margin-left: auto; color: #667eea; text-decoration: none; font-size: .8rem; }
.class-link:hover { text-decoration: underline; }

/* Boutons icône ronds (edit/delete sur class-card) */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem;
    transition: background .2s;
    padding: 0;
}
.btn-icon-edit   { color: #2b6cb0; } .btn-icon-edit:hover   { background: #bee3f8; }
.btn-icon-delete { color: #c53030; } .btn-icon-delete:hover { background: #fed7d7; }

/* ── Modal (classes.php) ────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: white;
    border-radius: 14px;
    padding: 2rem;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    animation: slideUp .25s ease;
}
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-header h3 { font-size: 1.1rem; color: #2d3748; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: #a0aec0; font-size: 1.1rem; padding: .2rem;
    border-radius: 6px; transition: background .2s;
}
.modal-close:hover { background: #fed7d7; color: #c53030; }

/* ── Matières : chips et coef ───────────────────────── */
.subjects-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    padding-top: .25rem;
}
.subject-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: #edf2f7;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .4rem .75rem;
    font-size: .88rem;
    transition: box-shadow .15s;
}
.subject-chip:hover { box-shadow: 0 2px 6px rgba(0,0,0,.1); }
.subject-chip-code {
    background: #667eea;
    color: white;
    border-radius: 4px;
    padding: .1rem .4rem;
    font-size: .75rem;
    font-weight: 700;
    font-family: monospace;
}
.subject-chip-name { font-weight: 500; color: #2d3748; }
.subject-chip-actions { display: flex; gap: .2rem; margin-left: .3rem; }
.subject-chip-actions a,
.subject-chip-actions button {
    background: none; border: none; cursor: pointer;
    color: #a0aec0; font-size: .8rem; padding: .1rem .2rem;
    border-radius: 4px; transition: color .15s;
    text-decoration: none;
}
.subject-chip-actions a:hover     { color: #2b6cb0; }
.subject-chip-actions button:hover { color: #c53030; }

.coef-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 20px;
    padding: .15rem .6rem;
    font-weight: 700;
    font-size: .85rem;
}

/* ── Templates de bulletins ─────────────────────────── */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}
.template-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s;
    position: relative;
}
.template-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.template-card-default { border-color: #667eea; }
.template-default-badge {
    position: absolute;
    top: .6rem; right: .6rem;
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: white;
    font-size: .72rem;
    font-weight: 700;
    padding: .2rem .6rem;
    border-radius: 20px;
}
.template-card-header {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1.1rem 1.25rem;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
}
.template-card-header i { font-size: 1.8rem; color: #667eea; }
.template-name   { font-weight: 700; color: #2d3748; font-size: .95rem; }
.template-school { font-size: .78rem; color: #718096; }
.template-card-body { padding: 1rem 1.25rem; flex: 1; display: flex; flex-direction: column; gap: .5rem; }
.template-info-row { font-size: .82rem; color: #718096; display: flex; gap: .75rem; flex-wrap: wrap; }
.template-info-row i { color: #667eea; }
.mention-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .25rem; }
.mention-chip {
    border: 1px solid;
    border-radius: 20px;
    padding: .15rem .55rem;
    font-size: .75rem;
    font-weight: 600;
}
.template-card-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    background: #fafafa;
}

/* Formulaire template : options toggles */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
}
.toggle-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-size: .9rem;
    color: #4a5568;
    padding: .4rem .5rem;
    border-radius: 6px;
    transition: background .15s;
}
.toggle-label:hover { background: #edf2f7; }
.toggle-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: #667eea; }
.toggle-label span i { color: #667eea; width: 14px; text-align: center; }

/* Mentions dynamiques */
.mention-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .4rem .6rem;
}
.mention-row input[type="number"] { border: 1px solid #e2e8f0; border-radius: 6px; padding: .35rem .5rem; }
.mention-row input[type="text"]   { border: 1px solid #e2e8f0; border-radius: 6px; padding: .35rem .5rem; }

/* ── Matrice permissions ────────────────────────────── */
.perm-group { margin-bottom: 2rem; }
.perm-group-title {
    font-size: 1rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.perm-group-title i { color: #667eea; }
.perm-matrix-wrap { overflow-x: auto; }
.perm-matrix { border-collapse: collapse; width: 100%; min-width: 700px; }
.perm-matrix th, .perm-matrix td { padding: .5rem .6rem; text-align: center; border: 1px solid #e2e8f0; }
.perm-matrix th { background: #f7fafc; font-size: .82rem; font-weight: 600; color: #4a5568; }
.perm-page-col  { text-align: left !important; min-width: 150px; }
.perm-page-label { text-align: left; font-size: .88rem; color: #4a5568; }
.perm-page-label i { color: #a0aec0; margin-right: .3rem; }
.perm-action-col { font-size: .72rem; color: #718096; min-width: 58px; }
.perm-role-col   { font-size: .82rem; }
.perm-cell       { background: white; }
.perm-row:hover td { background: #f0f4ff; }
.perm-check { width: 16px; height: 16px; cursor: pointer; accent-color: #667eea; }

/* ── Tableau de saisie des notes (grades.php) ─────────── */
.grades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
    min-width: 900px;
}
.grades-table th,
.grades-table td {
    border: 1px solid #e2e8f0;
    padding: .35rem .3rem;
    text-align: center;
    vertical-align: middle;
}
.grades-table thead th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
}
.grades-student-col {
    min-width: 160px;
    text-align: left;
    padding-left: .6rem;
}
.grades-group-header {
    background: #edf2f7;
    color: #2d3748;
    font-size: .85rem;
    letter-spacing: .03em;
}
.grades-subject-col {
    background: #f0f4ff;
    color: #2b6cb0;
    font-size: .78rem;
    font-weight: 700;
    min-width: 130px;
}
.grades-moy-classe-row td {
    background: #fffff0;
    font-size: .78rem;
}
.grades-moy-classe-row input {
    width: 52px;
}
.grades-student-name {
    font-weight: 600;
    color: #2d3748;
    white-space: nowrap;
    padding-left: .6rem;
}
.grades-student-row td {
    background: white;
}
.grades-student-row:nth-child(even) td {
    background: #fafafa;
}
.grade-input {
    width: 14ch;
    max-width: 140px;
    min-width: 65px;
    padding: .3rem .45rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    text-align: center;
    font-size: .82rem;
    color: #2d3748;
    transition: border-color .2s, box-shadow .2s, width .15s;
}
.grade-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102,126,234,.2);
}
.grade-input::placeholder {
    color: #cbd5e0;
}
.grade-input::-webkit-inner-spin-button,
.grade-input::-webkit-outer-spin-button {
    opacity: 1;
    height: 28px;
    width: 20px;
    cursor: pointer;
    margin: 0 0 0 2px;
}
.appr-select {
    padding: .2rem .15rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: .75rem;
    color: #4a5568;
    background: white;
    max-width: 95px;
    cursor: pointer;
}
.appr-select:focus {
    outline: none;
    border-color: #667eea;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Nukunu Mofiala
   ═══════════════════════════════════════════════════════════ */

img {
    max-width: 100%;
    height: auto;
}

.data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.dashboard-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: #4a5568;
    font-weight: 500;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1.5rem;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    transition: .2s;
    margin-top: auto;
    font-size: .85rem;
}
.sidebar-logout:hover {
    color: #fc8181;
    background: rgba(229,62,62,.15);
}

.detail-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.child-selector {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}
.child-tab {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.2rem;
    border-radius: 8px;
    text-decoration: none;
    color: #4a5568;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    font-weight: 500;
    transition: all .2s;
}
.child-tab:hover,
.child-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* ── Hamburger menu toggle ─────────────────────── */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #4a5568;
    font-size: 1.4rem;
    cursor: pointer;
    padding: .25rem;
    border-radius: 6px;
    transition: background .2s;
    flex-shrink: 0;
}
.menu-toggle:hover { background: #edf2f7; }

/* ── Résultats de recherche filtrés ─────────────── */
.search-highlight { background: #fefcbf; }

/* ── Boutons responsive ─────────────────────────── */
.btn-action, .btn-submit, .btn-primary, .topbar-logout {
    white-space: nowrap;
}
.btn-action { font-size: clamp(.75rem, 2vw, .85rem); }

/* ── Empêcher débordement des iframes/objets ────── */
iframe, object, embed { max-width: 100%; }

/* ═══ Breakpoints ═══ */

@media (max-width: 1100px) {
    .dashboard-grid-2 { gap: 1rem; }
    .classes-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 992px) and (min-width: 769px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; padding: 0 1.25rem 1.5rem; }
    .grades-table { font-size: .75rem; }
    .grade-input { width: 12ch; font-size: .75rem; min-width: 65px; }
}

@media (max-width: 768px) {
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        width: 260px;
        height: 100vh;
        z-index: 999;
        transition: left .3s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,.15);
    }
    .sidebar.active { left: 0; box-shadow: 4px 0 30px rgba(0,0,0,.3); }
    .sidebar.active::before {
        content:''; position:fixed; top:0; left:0; right:0; bottom:0;
        background:rgba(0,0,0,.4); z-index:-1;
    }
    .sidebar-footer { position: relative; bottom: auto; }

    .main-content { margin-left: 0; padding: 0 1rem 1.5rem; }

    .topbar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: .35rem;
        padding: .6rem 0;
    }
    .topbar-left { flex: 1; min-width: 0; }
    .topbar-center { flex: 0 0 100%; order: 0; text-align: left; font-size: .8rem; }
    .topbar-right { flex: none; width: auto; }
    .topbar-title { font-size: 1.1rem; }
    .topbar-user-info { display: none; }

    .dashboard-grid-2 { grid-template-columns: 1fr; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .detail-layout { grid-template-columns: 1fr; }
    .header-bar { flex-direction: column; align-items: flex-start; gap: .75rem; }
    .options-grid { grid-template-columns: 1fr; }
    .templates-grid { grid-template-columns: 1fr; }
    .classes-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }

    .card { padding: 1rem; }
    .card-header { flex-direction: column; align-items: flex-start; gap: .5rem; }

    .data-table { font-size: clamp(.7rem, 2vw, .82rem); }
    .data-table th,
    .data-table td { padding: .4rem .35rem; }

    .bulletin-wrapper { max-width: 100%; padding: .5rem; }
    .bulletin-header-left { width: 40%; }
    .bulletin-header-right { display: none; }
    .bulletin-school-info { font-size: .65rem; }
    .bulletin-title { font-size: 1rem; }
    .bulletin-subtitle { font-size: .85rem; }
    .bulletin-table { font-size: .65rem; }
    .bulletin-table th,
    .bulletin-table td { padding: .15rem .15rem; }
    .bl-col-appr { width: 14%; }
    .bl-col-matiere { width: 18%; }
    .students-bulletin-grid { grid-template-columns: 1fr; }
    .child-tab { flex: 1 1 auto; min-width: 0; font-size: .8rem; padding: .4rem .8rem; }

    .grades-table { font-size: .7rem; min-width: 0; }
    .grade-input { width: 11ch; font-size: .68rem; padding: .15rem .25rem; min-width: 60px; }
    .appr-select { max-width: 70px; font-size: .6rem; }
    .grades-student-col { min-width: 90px; font-size: .7rem; }
    .grades-student-name { font-size: .65rem; white-space: normal; }
    .grades-subject-col { min-width: 80px; font-size: .68rem; }

    .modal-box { max-width: 95%; margin: 1rem; padding: 1.25rem; }

    .subjects-chips { gap: .35rem; }
    .subject-chip { padding: .25rem .5rem; font-size: .78rem; }

    .perm-matrix { min-width: 0; font-size: .72rem; }
    .perm-matrix th,
    .perm-matrix td { padding: .3rem .25rem; }
    .perm-page-col { min-width: 100px; }

    .school-accordion .accordion-header { padding: .75rem 1rem; }
    .accordion-body { padding: .75rem; }
}

@media (max-width: 480px) {
    body { font-size: clamp(.8rem, 3vw, .9rem); }

    .sidebar { width: 240px; left: -260px; }

    .topbar-title { font-size: .95rem; }
    .topbar-logout span { display: none; }
    .topbar-user-info { display: none; }
    .topbar { gap: .25rem; padding: .4rem 0; }

    .card { padding: .75rem; border-radius: 8px; }
    .card-title { font-size: .9rem; }

    .stat-card { padding: .75rem; }
    .stat-card i { font-size: 1.5rem; }
    .stat-card h3 { font-size: 1.3rem; }

    .login-box { padding: 1.5rem; margin: 1rem; }
    .modal-box { padding: .85rem; margin: .35rem; }
    .modal-header h3 { font-size: .9rem; }
    .modal-header { margin-bottom: 1rem; }

    .btn-action { padding: .4rem .65rem; font-size: .72rem; }
    .btn-submit { padding: .6rem; font-size: .85rem; }

    .form-group { margin-bottom: .8rem; }
    .form-group input,
    .form-group select,
    .form-group textarea { padding: .55rem; font-size: .85rem; }

    .data-table th,
    .data-table td { padding: .3rem .25rem; }
    .data-table { font-size: .68rem; }

    .grade-input { width: 10ch; font-size: .6rem; padding: .1rem .2rem; min-width: 55px; }
    .appr-select { max-width: 60px; font-size: .55rem; padding: .1rem; }
    .grades-student-col { min-width: 75px; }
    .grades-student-name { font-size: .6rem; }
    .grades-subject-col { min-width: 60px; font-size: .6rem; }
    .grades-table th,
    .grades-table td { padding: .2rem .15rem; }

    .classes-grid { grid-template-columns: 1fr; }
    .class-card { padding: .75rem; }

    .hero { padding: 2rem 1rem; }
    .hero h1 { font-size: 1.3rem; }
    .hero p { font-size: .85rem; }

    .stats { padding: 1.5rem 1rem; }
    .stats .container { grid-template-columns: repeat(2, 1fr); gap: .75rem; }

    .footer { padding: 1.25rem; }
    .footer-visitors-bar { gap: .5rem; }
    .fv-item { min-width: 70px; padding: .3rem .5rem; }
    .fv-nb { font-size: .9rem; }

    .child-tab { font-size: .72rem; padding: .3rem .6rem; }

    .tab-btn { font-size: .78rem; padding: .35rem .7rem; }

    .topbar-school { font-size: .72rem; }
    .topbar-user { padding: .25rem .5rem; }

    .dashboard-grid-2 { gap: .75rem; }

    .school-logo-thumb { width: 36px; height: 36px; }
    .school-logo-placeholder { width: 36px; height: 36px; font-size: 1rem; }

    .logo-preview { width: 60px; height: 60px; }
}

@media (max-width: 360px) {
    .sidebar { width: 220px; left: -240px; }
    .grade-input { width: 9ch; font-size: .55rem; min-width: 48px; }
    .appr-select { max-width: 50px; font-size: .5rem; }
    .grades-student-col { min-width: 60px; }
    .card { padding: .5rem; }
    .btn-action { padding: .3rem .5rem; font-size: .65rem; }
    .topbar-title { font-size: .82rem; }
    .topbar-right { gap: .35rem; }
    .topbar-logout span { display: none; }
    .login-box { padding: 1rem; margin: .5rem; }
    .login-box h1 { font-size: 1rem; }
    .login-box .login-logo { width: 60px; height: 60px; }
}

@media print {
    .sidebar, .topbar, .no-print, .btn-action, .btn-submit,
    .btn-primary, form, .topbar-logout { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    .data-table { font-size: .75rem; }
    body { font-size: 11pt; }
}

/* ─── Bouton Retour en haut ─── */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary, #1F4E79);
    color: #fff;
    border: none;
    box-shadow: 0 4px 14px rgba(0,0,0,.2);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity .3s, visibility .3s, transform .3s;
    z-index: 9999;
}
#backToTop.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#backToTop:hover {
    background: #163a5c;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
