/* =====================================================================
   EduGest — Feuille de style principale
   Direction artistique : institutionnelle, sobre, inspirée des tons
   ocre/terre du Grand Nord (encre profonde + terracotta), typographie
   mixte serif/sans pour un rendu "établissement" plutôt que "SaaS".
   ===================================================================== */

:root {
    --ink: #1b2430;            /* bleu-nuit encre, quasi noir */
    --ink-soft: #2c3745;
    --paper: #f6f4ef;          /* fond papier légèrement chaud */
    --paper-white: #ffffff;
    --line: #e4ddd0;           /* lignes de séparation chaudes */
    --terracotta: #b5562f;     /* accent principal — terre cuite */
    --terracotta-dark: #8f431f;
    --ochre: #c98a2c;          /* accent secondaire — ocre */
    --forest: #2f6f52;         /* succès */
    --slate: #5b6572;          /* texte secondaire */
    --danger: #a63d3d;
    --warning: #c98a2c;
    --info: #35637a;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(27, 36, 48, 0.06);
    --shadow-md: 0 6px 20px rgba(27, 36, 48, 0.08);
    --sidebar-w: 264px;
}

* { box-sizing: border-box; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand-serif {
    font-family: Georgia, 'Times New Roman', serif;
    letter-spacing: 0.2px;
}

a { color: var(--terracotta-dark); text-decoration: none; }
a:hover { color: var(--terracotta); }
.link-muted { color: var(--slate); font-size: 0.9rem; }
.link-muted:hover { color: var(--terracotta-dark); }

/* ---------------------------------------------------------------
   Boutons & formulaires
   --------------------------------------------------------------- */
.btn-primary {
    background: var(--terracotta);
    border-color: var(--terracotta);
    font-weight: 600;
    letter-spacing: 0.2px;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--terracotta-dark);
    border-color: var(--terracotta-dark);
}
.btn-outline-secondary { border-color: var(--line); color: var(--ink-soft); }
.btn-outline-secondary:hover { background: var(--ink); border-color: var(--ink); color: #fff; }

.form-control, .form-select {
    border-color: var(--line);
    border-radius: 8px;
    padding: 0.55rem 0.8rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--terracotta);
    box-shadow: 0 0 0 0.2rem rgba(181, 86, 47, 0.12);
}
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 0.35rem; }

/* ---------------------------------------------------------------
   Page de connexion
   --------------------------------------------------------------- */
.auth-body { background: var(--ink); min-height: 100vh; }
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.auth-shell--single { grid-template-columns: 1fr; }
.auth-panel-brand {
    background: linear-gradient(160deg, var(--ink) 0%, #262f3c 60%, var(--terracotta-dark) 160%);
    color: #f1ede4;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    position: relative;
}
.auth-panel-brand::after {
    content: "";
    position: absolute; inset: 0;
    background-image: radial-gradient(circle at 80% 10%, rgba(201,138,44,0.18), transparent 45%);
    pointer-events: none;
}
.brand-mark {
    width: 56px; height: 56px;
    background: var(--terracotta);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; margin-bottom: 1.5rem;
}
.auth-panel-brand h1 { font-size: 2.2rem; margin-bottom: 0.25rem; }
.auth-panel-brand p { color: #cfc8ba; margin-bottom: 2rem; }
.auth-highlights { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.auth-highlights li { color: #e7e1d3; display: flex; align-items: center; gap: 0.6rem; }
.auth-highlights i { color: var(--ochre); }

.auth-panel-form { background: var(--paper); display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-form-inner { width: 100%; max-width: 380px; }
.auth-form-inner h2 { font-size: 1.6rem; margin-bottom: 0.25rem; }

.demo-accounts { margin-top: 2rem; border-top: 1px dashed var(--line); padding-top: 1.25rem; }
.demo-title { font-size: 0.8rem; color: var(--slate); margin-bottom: 0.6rem; }
.demo-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.demo-chip {
    border: 1px solid var(--line); background: var(--paper-white); color: var(--ink-soft);
    border-radius: 20px; padding: 0.3rem 0.8rem; font-size: 0.78rem; cursor: pointer;
}
.demo-chip:hover { border-color: var(--terracotta); color: var(--terracotta-dark); }

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-panel-brand { display: none; }
}

/* ---------------------------------------------------------------
   Layout applicatif (sidebar + topbar)
   --------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-w);
    background: var(--ink);
    color: #e7e3d9;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    transition: transform 0.25s ease;
    z-index: 1030;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 1.35rem 1.4rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .brand-mark { width: 38px; height: 38px; font-size: 1.1rem; margin: 0; }
.sidebar-brand-text { line-height: 1.15; }
.sidebar-brand-text strong { display: block; font-family: Georgia, serif; font-size: 1.05rem; color: #fff; }
.sidebar-brand-text span { font-size: 0.72rem; color: #a9a297; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0.75rem; }
.sidebar-section-title {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: #837c70; margin: 1.1rem 0.6rem 0.4rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.55rem 0.7rem; border-radius: 8px;
    color: #d8d2c5; font-size: 0.88rem; margin-bottom: 2px;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; color: #a9a297; }
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-link.active { background: var(--terracotta); color: #fff; }
.sidebar-link.active i { color: #fff; }

.sidebar-footer { padding: 1rem 1.2rem; border-top: 1px solid rgba(255,255,255,0.08); font-size: 0.75rem; color: #8a8377; }

.app-main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.app-topbar {
    background: var(--paper-white);
    border-bottom: 1px solid var(--line);
    padding: 0.85rem 1.75rem;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-family: Georgia, serif; font-size: 1.15rem; color: var(--ink); }
.topbar-title small { display: block; font-family: inherit; font-size: 0.72rem; color: var(--slate); font-weight: 400; }
.sidebar-toggle-btn { display: none; border: none; background: none; font-size: 1.3rem; color: var(--ink); }

.topbar-user { display: flex; align-items: center; gap: 0.7rem; }
.topbar-user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--terracotta); color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem;
}
.topbar-user-meta { line-height: 1.1; }
.topbar-user-meta strong { display: block; font-size: 0.85rem; }
.topbar-user-meta span { font-size: 0.72rem; color: var(--slate); }

.app-content { padding: 1.75rem; flex: 1; }

@media (max-width: 992px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-toggle-btn { display: inline-block; }
}

/* ---------------------------------------------------------------
   Composants : cartes, badges, tableaux
   --------------------------------------------------------------- */
.panel {
    background: var(--paper-white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.panel-header {
    padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.panel-header h2, .panel-header h3 { font-size: 1.05rem; margin: 0; }
.panel-body { padding: 1.4rem; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--paper-white); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.3rem; display: flex; align-items: flex-start; gap: 0.9rem;
}
.stat-card .stat-icon {
    width: 42px; height: 42px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
    background: rgba(181, 86, 47, 0.1); color: var(--terracotta-dark);
}
.stat-card.accent-ochre .stat-icon { background: rgba(201, 138, 44, 0.14); color: var(--ochre); }
.stat-card.accent-forest .stat-icon { background: rgba(47, 111, 82, 0.12); color: var(--forest); }
.stat-card.accent-info .stat-icon { background: rgba(53, 99, 122, 0.12); color: var(--info); }
.stat-card.accent-danger .stat-icon { background: rgba(166, 61, 61, 0.12); color: var(--danger); }
.stat-value { font-family: Georgia, serif; font-size: 1.55rem; line-height: 1.1; color: var(--ink); }
.stat-label { font-size: 0.78rem; color: var(--slate); margin-top: 0.15rem; }

.badge-success { background: rgba(47,111,82,0.12); color: var(--forest); font-weight: 600; }
.badge-danger  { background: rgba(166,61,61,0.12); color: var(--danger); font-weight: 600; }
.badge-warning { background: rgba(201,138,44,0.14); color: var(--ochre); font-weight: 600; }
.badge-neutral { background: rgba(91,101,114,0.12); color: var(--slate); font-weight: 600; }
.badge-success, .badge-danger, .badge-warning, .badge-neutral {
    padding: 0.3rem 0.65rem; border-radius: 20px; font-size: 0.74rem; display: inline-block;
}

table.table { margin-bottom: 0; }
.table thead th {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--slate); border-bottom: 2px solid var(--line); font-weight: 700;
    white-space: nowrap;
}
.table td { vertical-align: middle; font-size: 0.88rem; }
.table-hover tbody tr:hover { background: rgba(181, 86, 47, 0.04); }

.avatar-sm {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
    background: var(--line); display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 600; color: var(--ink-soft);
}

.nav-tabs .nav-link { color: var(--slate); border: none; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--terracotta-dark); border-bottom-color: var(--terracotta); background: none; }

.modal-content { border-radius: var(--radius); border: none; }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-footer { border-top: 1px solid var(--line); }

/* Timeline (activités récentes / historique) */
.activity-list { list-style: none; padding: 0; margin: 0; }
.activity-item { display: flex; gap: 0.8rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--paper); display: flex; align-items: center; justify-content: center; color: var(--terracotta-dark); flex-shrink: 0; }
.activity-text { font-size: 0.85rem; }
.activity-time { font-size: 0.74rem; color: var(--slate); }

/* Simple bar chart (CSS-only, aucune dépendance JS externe) */
.bar-chart { display: flex; align-items: flex-end; gap: 0.6rem; height: 160px; padding-top: 1rem; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar { width: 100%; max-width: 34px; background: var(--terracotta); border-radius: 4px 4px 0 0; transition: height 0.4s ease; }
.bar-chart .bar-label { font-size: 0.7rem; color: var(--slate); margin-top: 0.4rem; }
.bar-chart .bar-val { font-size: 0.72rem; color: var(--ink-soft); font-weight: 600; margin-bottom: 0.25rem; }

/* Fiche élève / bulletin (aperçu web avant impression PDF) */
.report-sheet {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 2rem; max-width: 900px; margin: 0 auto;
}
.report-sheet-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 1rem; margin-bottom: 1.2rem; }
.report-sheet-header h3 { margin: 0; font-size: 1.2rem; }
.report-grade-table th, .report-grade-table td { font-size: 0.85rem; }

/* Impression (bulletins, listes) */
@media print {
    .app-sidebar, .app-topbar, .no-print { display: none !important; }
    .app-main { margin-left: 0 !important; }
    body { background: #fff; }
    .panel { border: none; box-shadow: none; }
}

.text-muted-sm { font-size: 0.8rem; color: var(--slate); }
.section-title { font-family: Georgia, serif; font-size: 1.3rem; margin-bottom: 1rem; color: var(--ink); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--slate); }
.empty-state i { font-size: 2.2rem; color: var(--line); display: block; margin-bottom: 0.7rem; }
