/* ==========================================================
   Design maison NewTech : la feuille de style unique du site.
   Pour changer une couleur, on la change ici et nulle part ailleurs.
   ========================================================== */

:root {
    /* Couleurs du Design maison */
    --ground: #f8f7fc;
    --surface: #FFFFFF;
    --rail: #f8f7fc;
    --ink: #15102d;
    --ink-2: #575267;
    --ink-3: #69657c;
    --line: #e9e5f0;
    --line-2: #f3f0f8;
    --line-3: #e0dbe9;
    --side: #15102d;
    --side-2: #211038;
    --side-3: #211038;
    --side-text: #d9d4e8;
    --side-muted: #b9b3cc;
    --side-bright: #c4b0ff;
    --accent-dark: #5422e0;
    --accent-soft: #f5f2ff;
    --accent-line: #dcd1ff;
    --ok: #047857;
    --ok-dark: #065F46;
    --ok-soft: #E7F7F1;
    --ok-line: #BFE8D8;
    --warn: #B45309;
    --warn-dark: #9A3412;
    --warn-soft: #FDF3E3;
    --warn-line: #F3DCB4;
    --info: #6D28D9;
    --info-soft: #F1EBFE;
    --info-line: #DDD0FB;

    /* Polices et formes */
    --font: Inter, "Segoe UI", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
    --radius-sm: 10px;
    --radius-md: 13px;

    /* Anciens noms : gardés pour les pages pas encore reprises */
    --accent: #642bfa;
    --accent-hover: #5422e0;
    --accent-light: #f5f2ff;
    --accent-text: #5422e0;
    --bg-sidebar: #FFFFFF;
    --bg-sidebar-hover: #f8f7fc;
    --bg-main: #f8f7fc;
    --bg-header: #FFFFFF;
    --border: #e9e5f0;
    --text-primary: #15102d;
    --text-secondary: #575267;
    --text-muted: #69657c;
    --success: #047857;
    --success-light: #E7F7F1;
    --danger: #9A3412;
    --danger-light: #FDF3E3;
    --warning: #B45309;
    --warning-light: #FDF3E3;
    --primary: #642bfa;
    --primary-hover: #5422e0;
    --primary-light: #f5f2ff;
    --primary-container: #dcd1ff;
    --on-surface: #15102d;
    --on-surface-variant: #575267;
    --on-surface-muted: #69657c;
    --outline: #e9e5f0;
    --outline-variant: #e9e5f0;
    --surface-container-lowest: #FFFFFF;
    --surface-container-low: #f8f7fc;
    --surface-container: #f8f7fc;
    --surface-container-high: #f3f0f8;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 13.5px;
    line-height: 20px;
    background: var(--ground);
    color: var(--ink);
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── STRUCTURE DE LA PAGE ── */
.dashboard-container {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100vh;
}

.main-content { padding: 28px 32px; min-width: 0; }
.page-width { max-width: 1120px; margin: 0 auto; }

/* ── BARRE LATÉRALE ── */
.sidebar {
    background: linear-gradient(180deg, var(--side-3), var(--side));
    color: var(--side-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 16px 14px; }

.logo-badge {
    width: 30px; height: 30px; flex-shrink: 0;
    border-radius: 6px;
    background: var(--surface);
    color: var(--side);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}

.logo-name { font-size: 14.5px; font-weight: 700; color: var(--surface); }
.logo-name span { color: var(--side-bright); }
.logo-role { font-size: 11.5px; line-height: 16px; color: var(--side-muted); }

.sidebar-nav { list-style: none; padding: 8px 0; }

.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    min-height: 40px;
    padding: 0 12px;
    margin: 1px 8px;
    border-radius: var(--radius-sm);
    color: var(--side-text);
    font-size: 13px; font-weight: 500;
    text-decoration: none;
}

.sidebar-nav a i, .sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-nav a:hover { background: var(--side-2); color: var(--surface); }
.sidebar-nav a.active {
    background: var(--side-2);
    color: var(--surface);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--side-bright);
}

.sidebar-nav .nav-section {
    padding: 14px 20px 4px;
    font-size: 11.5px; line-height: 16px; font-weight: 500;
    color: var(--side-muted);
}

.sidebar-nav-wrap { flex: 1; }

.sidebar-footer {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--side-2);
}

.user-avatar {
    width: 28px; height: 28px; flex-shrink: 0;
    border-radius: 50%;
    background: var(--side-2);
    color: var(--surface);
    display: flex; align-items: center; justify-content: center;
    font-size: 11.5px; font-weight: 600;
}

.user-info-text { flex: 1; overflow: hidden; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.footer-icon-btn {
    width: 44px; height: 44px; flex-shrink: 0;
    border: none; border-radius: var(--radius-sm);
    background: transparent;
    color: var(--side-text);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.footer-icon-btn:hover { background: var(--side-2); color: var(--surface); }
.footer-icon-btn i, .footer-icon-btn svg { width: 16px; height: 16px; }

/* ── EN-TÊTE DE PAGE ── */
.page-header { margin-bottom: 20px; }
.page-title { font-size: 26px; line-height: 32px; font-weight: 600; color: var(--ink); }
.page-subtitle { margin-top: 4px; color: var(--ink-3); font-size: 13.5px; }

.page-header-row {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
    gap: 16px;
}
.gestion .page-header {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
    gap: 16px;
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.breadcrumb {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin-bottom: 12px;
    font-size: 12.5px; color: var(--ink-3);
}
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── ONGLETS ── */
.tabs { display: flex; gap: 20px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab {
    display: inline-flex; align-items: center;
    min-height: 44px; padding: 0 4px; margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--ink-2); font-weight: 500; text-decoration: none;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-dark); font-weight: 600; border-bottom-color: var(--accent); }

/* ── CARTES ── */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}
.card-title {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 16px;
    font-size: 14.5px; line-height: 20px; font-weight: 600;
    color: var(--ink);
}
.card-title i, .card-title svg { width: 16px; height: 16px; }

/* Les pages de gestion découpent leurs cartes en en-tête + corps */
.gestion .card { padding: 0; }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px;
    background: var(--rail);
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.card-header .card-title { margin-bottom: 0; }
.card-body { padding: 20px; }

/* ── LISTES : une ligne cliquable + un menu « ⋯ » ── */
.rows { padding: 0; }

.cols-livres, .cols-chapitres, .cols-paragraphes, .cols-eleves { display: grid; column-gap: 12px; align-items: center; }
.cols-livres { grid-template-columns: minmax(0, 1fr) 96px 104px 88px 24px 44px; }
.cols-chapitres { grid-template-columns: minmax(0, 1fr) 104px 88px 24px 44px; }
.cols-paragraphes { grid-template-columns: minmax(0, 1fr) 88px 24px 44px; }
.cols-eleves { grid-template-columns: minmax(0, 1fr) 130px 64px 100px 24px 44px; }

.rows-head {
    padding: 8px 12px 8px 20px;
    background: var(--rail);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 11.5px; line-height: 16px; font-weight: 500;
    color: var(--ink-3);
}

.row { position: relative; padding: 10px 12px 10px 20px; border-top: 1px solid var(--line-2); }
.row:hover { background: var(--rail); }
.row:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }

.row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-link { color: var(--ink); font-size: 14.5px; font-weight: 600; text-decoration: none; }
/* Toute la ligne devient cliquable, sans lien imbriqué */
.row-link::after { content: ""; position: absolute; inset: 0; }
.row:hover .row-link, .row:hover .row-chevron { color: var(--accent); }

.row-sub { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.row-stats { display: none; font-size: 12.5px; color: var(--ink-3); }
.row-chevron { width: 16px; height: 16px; color: var(--ink-3); }

.num {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px; font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.rows-head .num { font-family: var(--font); font-size: 11.5px; }

.row-menu { position: relative; z-index: 2; }
/* Le menu ouvert passe au-dessus des lignes suivantes */
.row-menu[open] { z-index: 10; }
.row-menu > summary {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    cursor: pointer;
    list-style: none;
}
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary:hover, .row-menu[open] > summary { background: var(--line-2); color: var(--ink); }
.row-menu > summary svg, .row-menu > summary i { width: 18px; height: 18px; }

.row-menu-list {
    position: absolute; z-index: 5; top: 46px; right: 0;
    width: 180px; padding: 4px 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 20px rgba(21, 16, 45, .12);
}
.row-menu-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-height: 44px; padding: 0 14px;
    border: none; background: transparent;
    color: var(--ink);
    font: inherit; text-align: left; text-decoration: none;
    cursor: pointer;
}
.row-menu-item:hover { background: var(--rail); color: var(--accent-dark); }
.row-menu-item i, .row-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.row-menu-item.is-danger { color: var(--warn-dark); }
.row-menu-item.is-danger:hover { background: var(--warn-soft); color: var(--warn-dark); }

/* ── BOUTONS ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13.5px; font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn i, .btn svg { width: 15px; height: 15px; }
.btn-sm { padding: 0 12px; font-size: 12.5px; }

/* L'action principale est toujours bleu nuit, jamais verte */
.btn-primary, .btn-success { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-primary:hover, .btn-success:hover { background: var(--accent); border-color: var(--accent); color: var(--surface); }

.btn-secondary, .btn-outline { background: var(--surface); border-color: var(--line-3); color: var(--ink); }
.btn-secondary:hover, .btn-outline:hover { border-color: var(--accent); color: var(--accent-dark); }

.btn-danger { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-dark); }
.btn-danger:hover { background: var(--warn-dark); border-color: var(--warn-dark); color: var(--surface); }

.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ── BADGES ── */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11.5px; line-height: 16px; font-weight: 500;
}
.badge-primary { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-dark); }
.badge-success { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-dark); }
.badge-warning, .badge-danger { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-dark); }

/* ── FORMULAIRES ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.form-hint { display: block; margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }

.form-control, .form-input, .form-select, .form-textarea {
    width: 100%; min-height: 44px; padding: 10px 12px;
    border: 1px solid var(--line-3);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--ink);
    font-family: inherit; font-size: 13.5px;
    outline: none;
}
.form-control:focus, .form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-control::placeholder, .form-input::placeholder, .form-textarea::placeholder { color: var(--ink-3); }
.form-control[disabled], .form-input[disabled], .form-select[disabled], .form-textarea[disabled] { background-color: var(--line-2); cursor: not-allowed; }
textarea.form-control, .form-textarea { min-height: 120px; resize: vertical; }
select.form-control, .form-select { cursor: pointer; }

/* ── TABLEAUX ── */
.table-container { overflow-x: auto; }
.table, .gestion table { width: 100%; border-collapse: collapse; }
.table th, .table td, .gestion th, .gestion td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line-2);
    font-size: 13.5px;
}
.table th, .gestion th {
    background: var(--rail);
    font-size: 11.5px; line-height: 16px; font-weight: 500;
    color: var(--ink-3);
}
.table tr:hover td, .gestion tr:hover td { background: var(--rail); }

/* ── MESSAGES ── */
.messages { margin-bottom: 20px; }
.alert, .message {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px; padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}
.alert-success, .message-success { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-dark); }
.alert-error, .message-error, .alert-warning, .message-warning { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-dark); }
.alert-info, .message-info { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-dark); }
.alert i, .alert svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── CHIFFRES CLÉS ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; }
.stat-value { font-family: var(--font-mono); font-size: 31px; line-height: 36px; font-weight: 500; color: var(--ink); }
.stat-label { margin-top: 4px; color: var(--ink-3); font-size: 12.5px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ── PROGRESSION ── */
.progress-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }

/* ── ÉTAT VIDE ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty-state-icon:empty { display: none; }
.empty-state-icon {
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px;
    border: 1px solid var(--line); border-radius: var(--radius-md);
}
.empty-state-icon i, .empty-state-icon svg { width: 22px; height: 22px; }
.empty-state-title { margin-bottom: 6px; font-size: 14.5px; font-weight: 600; color: var(--ink); }
.empty-state-text { max-width: 360px; margin: 0 auto; }

/* ── FICHES ET FORMULAIRES SEULS ── */
.form-card { max-width: 560px; }
.section-title { margin: 0; padding: 16px 20px 12px; }
.rows .table-container { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.progress-cell { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.progress-cell .progress-bar { flex: 1; }

/* ── PAGE DE CONNEXION ── */
.auth-layout { display: grid; grid-template-columns: minmax(280px, 2fr) 3fr; min-height: 100vh; }
.auth-side {
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 28px 32px 48px;
    background: linear-gradient(180deg, var(--side-3), var(--side));
    color: var(--side-text);
}
.auth-brand { padding: 0; }
.auth-pitch-title { font-size: 26px; line-height: 32px; font-weight: 600; color: var(--surface); }
.auth-pitch-text { max-width: 340px; margin-top: 8px; font-size: 14.5px; line-height: 22px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-subtitle { margin-bottom: 24px; }
.auth-submit { width: 100%; }

.animate-in { animation: fadeIn .2s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── PETITS ÉCRANS ── */
@media (max-width: 860px) {
    .auth-layout { grid-template-columns: minmax(0, 1fr); }
    .auth-side { gap: 32px; padding: 20px; }
    .dashboard-container { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; height: auto; }
    .main-content { padding: 20px 16px; }
}

@media (max-width: 720px) {
    .cols-livres, .cols-chapitres, .cols-paragraphes, .cols-eleves { grid-template-columns: minmax(0, 1fr) 44px; }
    .rows-head, .row .num, .row-chevron, .col-level { display: none; }
    .row-stats { display: block; }
}

/* ── SIGNATURE NEWTECH (comme newtech.institute) ── */
::selection { background: #dcd1ff; color: #15102d; }
:focus-visible { outline: 3px solid #ad93ff; outline-offset: 2px; }
h1, h2, h3, .page-title { font-weight: 800; letter-spacing: -0.03em; }
.card { box-shadow: 0 8px 21px rgba(54, 27, 98, .05); }
.btn-primary { background: #642bfa; border-color: #642bfa; color: #fff; }
.btn-primary:hover { background: #5422e0; border-color: #5422e0; color: #fff; }
/* Taille normale des icônes, là où aucune règle plus précise n'existe */
:where(svg.lucide) { width: 16px; height: 16px; }
