/* ============================================================
   MathsMDE — Quiz Bac : feuille de styles
   ============================================================ */
:root {
    --bleu-fonce: #0a3d62;
    --bleu-clair: #0c4a7a;
    --vert: #1e8e5a;
    --rouge: #c0392b;
    --fond: #f4f6f9;
    /* Couleur d'accent dynamique : change selon le niveau consulté */
    --accent: #0a3d62;
    --accent-clair: #0c4a7a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--fond);
    overflow-x: hidden;
}

/* BARRE DE NAVIGATION DU SITE (lien vers les autres modules MathsMDE) */
.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: 46px;
    background: #071f38;
    color: #cfe0f0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    padding: 0 20px;
    font-size: 0.85rem;
    z-index: 1100;
}

.topbar a {
    color: #cfe0f0;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 5px;
}

.topbar a:hover { background: rgba(255,255,255,0.12); color: #fff; }

.topbar .utilisateur {
    margin-right: auto;
    font-weight: 600;
    color: #fff;
}

.topbar .role-badge {
    font-size: 0.72rem;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
}

/* MENU LATERAL RETRACTABLE */
.sidebar {
    width: 260px;
    background: var(--bleu-fonce);
    color: white;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 46px;
    padding: 20px;
    box-shadow: 4px 0 12px rgba(0,0,0,0.25);
    transform: translateX(0);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 900;
}

.sidebar.hidden { transform: translateX(-260px); }

.toggle-btn {
    position: fixed;
    left: 20px;
    top: 58px;
    background: var(--bleu-fonce);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.25);
    font-weight: 600;
    user-select: none;
}

.sidebar h2 {
    margin-top: 0;
    text-align: center;
    font-size: 1.25rem;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.logo-mathsmde { width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; }
.logo-mathsmde svg { width: 44px; height: 44px; }

.niveau-item { margin-bottom: 8px; }

.niveau-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 10px;
    color: white;
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: 6px;
    transition: background 0.2s;
    cursor: pointer;
}

.niveau-btn:hover { background: rgba(255,255,255,0.15); }
.niveau-btn.actif { background: rgba(255,255,255,0.22); border-left: 3px solid var(--accent-clair); }

.niveau-btn .chevron { transition: transform 0.2s ease; font-size: 0.8rem; }
.niveau-btn.actif .chevron { transform: rotate(90deg); }

.niveau-btn.a-venir { opacity: 0.55; cursor: default; }

.chapitre-liste {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 14px;
}

.chapitre-liste.ouvert { max-height: 500px; }

.chapitre-liste a {
    display: block;
    padding: 8px 10px;
    margin-top: 4px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.92rem;
    border-radius: 5px;
    border-left: 2px solid rgba(255,255,255,0.25);
}

.chapitre-liste a:hover { background: rgba(255,255,255,0.12); color: white; }

.compteur-sidebar {
    margin-top: 30px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-size: 0.85rem;
    opacity: 0.85;
    text-align: center;
}

.compteur-sidebar strong { display: block; font-size: 1.3rem; color: #fff; }

/* CONTENU PRINCIPAL */
.content {
    margin-left: 260px;
    margin-top: 46px;
    padding: 30px 30px 60px;
    transition: margin-left 0.3s ease;
    max-width: 1100px;
}

.content.full { margin-left: 0; }

.fil-ariane {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 6px;
}

.fil-ariane span { cursor: pointer; color: var(--accent); }
.fil-ariane span:hover { text-decoration: underline; }

h1 { color: var(--accent); margin-top: 46px; }

.sous-titre { color: #555; margin-bottom: 30px; }

/* GRILLE DES BOUTONS 3D */
.chapitre-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 25px;
    padding: 10px 0;
}

.chapitre-btn-wrap { cursor: pointer; text-align: center; }

.chapitre-btn {
    width: 180px;
    height: 180px;
    animation: pulse 2.2s ease-in-out infinite;
    transition: transform 0.15s ease, filter 0.15s ease;
}

@keyframes pulse {
    0% { filter: drop-shadow(0px 4px 8px rgba(0,0,0,0.25)); }
    50% { filter: drop-shadow(0px 8px 14px rgba(0,0,0,0.40)); }
    100% { filter: drop-shadow(0px 4px 8px rgba(0,0,0,0.25)); }
}

.chapitre-btn-wrap:hover .chapitre-btn {
    transform: translateY(-6px);
    filter: drop-shadow(0px 10px 16px rgba(0,0,0,0.45));
}

.chapitre-btn-wrap:active .chapitre-btn {
    transform: translateY(2px);
    filter: drop-shadow(0px 2px 6px rgba(0,0,0,0.25));
}

.chapitre-progress {
    margin-top: 8px;
    font-size: 0.8rem;
    color: #666;
}

.badge-vide {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.72rem;
    background: #eee;
    color: #888;
    padding: 2px 8px;
    border-radius: 10px;
}

/* QUIZ */
.quiz-card {
    background: white;
    border-radius: 14px;
    padding: 30px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    max-width: 720px;
}

.quiz-progress-bar {
    width: 100%;
    height: 8px;
    background: #e4e8ee;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 22px;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--accent-clair);
    width: 0%;
    transition: width 0.3s ease;
}

.quiz-question {
    font-size: 1.15rem;
    font-weight: 600;
    color: #222;
    margin-bottom: 20px;
    line-height: 1.5;
}

.quiz-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 13px 16px;
    margin-bottom: 12px;
    border: 2px solid #dde3ea;
    border-radius: 10px;
    background: #fafbfc;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.quiz-option:hover { border-color: var(--accent-clair); }
.quiz-option.bonne { border-color: var(--vert); background: #e9f7ef; }
.quiz-option.mauvaise { border-color: var(--rouge); background: #fbe9e7; }
.quiz-option[disabled] { cursor: default; }

.quiz-explication {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    background: #eef3f8;
    font-size: 0.95rem;
    color: #333;
    display: none;
}

.quiz-nav {
    margin-top: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-suivant, .btn-retour, .btn-recommencer {
    background: var(--accent);
    color: white;
    border: none;
    padding: 11px 22px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn-suivant:hover, .btn-retour:hover, .btn-recommencer:hover { background: var(--accent-clair); }
.btn-suivant[disabled] { opacity: 0.4; cursor: default; }

.lien-retour {
    color: var(--accent);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
}

.resultat-final {
    text-align: center;
    padding: 20px 10px;
}

.resultat-final .score {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--accent);
    margin: 10px 0;
}

.resultat-final .msg { font-size: 1.05rem; color: #444; margin-bottom: 24px; }

.resultat-final .sync-msg { font-size: 0.8rem; color: #999; margin-top: 14px; }

.vide-msg, .niveau-a-venir-msg {
    background: white;
    border-radius: 14px;
    padding: 40px;
    text-align: center;
    color: #666;
    max-width: 600px;
}

.compteur-bas {
    margin-top: 50px;
    font-size: 0.8rem;
    color: #999;
    text-align: center;
}

@media (max-width: 640px) {
    .sidebar { z-index: 950; }
    .content { margin-left: 0; padding: 90px 16px 40px; }
    .content.full { margin-left: 0; }
    .topbar { font-size: 0.75rem; gap: 10px; }
}
