:root {
    --primary:       #1a3a5c;
    --primary-hover: #234d7a;
    --accent:        #0d6efd;
    --accent-hover:  #0b5ed7;
    --success:       #198754;
    --danger:        #dc3545;
    --warning:       #e07b00;
    --bg:            #f0f4f8;
    --card-bg:       #ffffff;
    --text:          #212529;
    --text-muted:    #6c757d;
    --border:        #dee2e6;
    --nav-height:    54px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: Arial, sans-serif;
    background: var(--bg);
    margin: 0;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Bandeau navigation ─────────────────────────────────────────────────── */
.top-bar {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    overflow: hidden;
}

.top-left {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
}

.app-name {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-right: 14px;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-link {
    color: rgba(255,255,255,0.82);
    text-decoration: none;
    font-size: 13px;
    padding: 5px 9px;
    border-radius: 4px;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.nav-link:hover { background: rgba(255,255,255,0.14); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.18); color: #fff; font-weight: 600; }

.top-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 10px;
}

.user-badge {
    font-size: 13px;
    color: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-pill {
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.role-admin   { background: #fbbf24; color: #78350f; }
.role-teacher { background: #34d399; color: #064e3b; }
.role-student { background: #60a5fa; color: #1e3a8a; }

.nav-btn {
    background: rgba(255,255,255,0.15);
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    padding: 5px 11px;
    border-radius: 4px;
    white-space: nowrap;
    transition: background 0.15s;
}
.nav-btn:hover { background: rgba(255,255,255,0.25); }

.logout-btn {
    background: var(--danger);
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    padding: 5px 11px;
    border-radius: 4px;
    white-space: nowrap;
}
.logout-btn:hover { background: #b02a37; }

/* ── Contenu principal ───────────────────────────────────────────────────── */
.main-content {
    padding-top: calc(var(--nav-height) + 24px);
    padding-bottom: 40px;
    flex: 1;
}

.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 20px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

/* ── Cartes ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    padding: 22px 24px;
    margin-bottom: 20px;
}
.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 16px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Grille 2 colonnes ───────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Formulaires ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 5px;
    color: #374151;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: #f9fafb;
    color: var(--text);
    font-family: inherit;
}
.form-group textarea { min-height: 120px; resize: vertical; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
    background: #fff;
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ── Boutons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    transition: background 0.15s, opacity 0.15s;
}
.btn-primary   { background: var(--accent);   color: #fff; }
.btn-primary:hover   { background: var(--accent-hover); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover   { background: #146c43; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover    { background: #b02a37; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5c636a; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* ── Tableaux ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 6px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 500px; }
.data-table th {
    background: #f8fafc;
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    color: #374151;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f9fafb; }

/* ── Alertes ─────────────────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #d1e7dd; color: #0a3622; border: 1px solid #a3cfbb; }
.alert-error   { background: #f8d7da; color: #58151c; border: 1px solid #f1aeb5; }
.alert-warning { background: #fff3cd; color: #664d03; border: 1px solid #ffe69c; }
.alert-info    { background: #cff4fc; color: #055160; border: 1px solid #9eeaf9; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-yellow { background: #fef9c3; color: #713f12; }

/* ── Page de connexion ───────────────────────────────────────────────────── */
body.login-page {
    background: linear-gradient(135deg, #1a3a5c 0%, #1e56a0 50%, #2563eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    padding: 40px;
    width: 400px;
    max-width: 95%;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0 0 4px 0;
    letter-spacing: -0.5px;
}
.login-logo p { color: var(--text-muted); font-size: 13px; margin: 0; }
.login-box h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 22px 0; color: var(--text); }
.login-submit { width: 100%; padding: 11px; font-size: 15px; border-radius: 8px; margin-top: 8px; }
.login-footer { text-align: center; margin-top: 16px; font-size: 12px; color: var(--text-muted); }

/* ── Carte devoir ────────────────────────────────────────────────────────── */
.devoir-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 10px;
    background: #fff;
    transition: box-shadow 0.15s;
}
.devoir-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.09); }
.devoir-title { font-weight: 700; font-size: 15px; color: var(--primary); margin-bottom: 5px; }
.devoir-meta  { font-size: 12px; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; }
.devoir-content { font-size: 14px; margin-top: 10px; line-height: 1.6; white-space: pre-wrap; }

/* ── Carte annonce ───────────────────────────────────────────────────────── */
.annonce-item {
    border-left: 4px solid var(--accent);
    padding: 14px 18px;
    margin-bottom: 12px;
    background: #fff;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.annonce-title   { font-weight: 700; font-size: 15px; margin-bottom: 7px; color: var(--text); }
.annonce-content { font-size: 14px; color: var(--text); line-height: 1.65; white-space: pre-wrap; }
.annonce-meta    { font-size: 12px; color: var(--text-muted); margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }

/* ── État vide ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state p { font-size: 0.95rem; margin: 0; }

/* ── Filtres ─────────────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 18px;
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar label { font-size: 12px; }
.filter-bar input,
.filter-bar select { min-width: 150px; font-size: 13px; padding: 7px 10px; }

/* ── Statistiques (home) ─────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    border-top: 3px solid var(--accent);
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Welcome banner ──────────────────────────────────────────────────────── */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, #1e56a0 100%);
    color: #fff;
    border-radius: 10px;
    padding: 22px 28px;
    margin-bottom: 20px;
}
.welcome-banner h2 { margin: 0 0 6px 0; font-size: 1.3rem; }
.welcome-banner p  { margin: 0; opacity: 0.85; font-size: 14px; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .container { padding: 0 12px; }
    .top-left .nav-link:not(:first-of-type) { display: none; }
    .user-badge { max-width: 130px; }
}
