/* ============================================
   ExamBlanc BIA - HorizonBIA
   Mode clair + mode sombre
   ============================================ */

:root {
    --primary: #1a56db;
    --primary-dark: #1342a8;
    --primary-light: #e8effc;
    --accent: #f59e0b;
    --accent-light: #fef3c7;
    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --bg: #f9fafb;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
    /* Timer heights */
    --timer-h: 56px;
    --tabs-h: 58px;
}

/* --- MODE SOMBRE --- */
[data-theme="dark"] {
    --primary: #5b8def;
    --primary-dark: #3a6edb;
    --primary-light: #1e2a45;
    --accent-light: #3b2f14;
    --success-light: #132e22;
    --danger-light: #2e1212;
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-input: #252833;
    --border: #2d3041;
    --border-light: #1e2130;
    --text: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

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

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 640px; }

/* --- Header --- */
.site-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header .container { display: flex; justify-content: space-between; align-items: center; }

.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.logo-icon { font-size: 24px; }
.logo-text { font-size: 18px; font-weight: 500; letter-spacing: -0.3px; }
.logo-text strong { font-weight: 700; color: var(--primary); }

.btn-back {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: background 0.2s;
}
.btn-back:hover { background: var(--primary-light); }

/* --- Theme toggle --- */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.theme-toggle:hover { background: var(--primary-light); }
.timer-bar .theme-toggle { border-color: rgba(255,255,255,0.3); color: #e5e7eb; }
.timer-bar .theme-toggle:hover { background: rgba(255,255,255,0.1); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-xl { padding: 18px 36px; font-size: 18px; border-radius: var(--radius-lg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 32px;
    border: 1px solid var(--border);
}

/* --- Hero --- */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
    color: #fff;
    padding: 60px 0;
    text-align: center;
}
.hero h1 { font-size: 36px; font-weight: 700; margin-bottom: 12px; letter-spacing: -0.5px; }
.hero-sub { font-size: 18px; opacity: 0.9; }

/* --- Consignes --- */
.consignes { padding: 40px 0; }
.card-consignes h2 { font-size: 22px; margin-bottom: 16px; }
.consignes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 24px 0; }
.consigne-item {
    display: flex; flex-direction: column; gap: 4px; padding: 16px;
    background: var(--bg); border-radius: var(--radius); border: 1px solid var(--border);
}
.consigne-icon { font-size: 24px; }
.consigne-item strong { font-size: 14px; color: var(--text-secondary); }
.consigne-item span:last-child { font-size: 13px; color: var(--text-muted); }
.matieres-list { margin-top: 20px; }
.matieres-list h3 { font-size: 16px; margin-bottom: 8px; }
.matieres-list ol { padding-left: 24px; }
.matieres-list li { margin-bottom: 4px; font-size: 14px; color: var(--text-secondary); }

/* --- Choix d'examen --- */
.exam-choice { padding: 40px 0; text-align: center; }
.exam-choice h2 { font-size: 24px; margin-bottom: 24px; }
.exam-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; max-width: 960px; margin: 0 auto; }
.exam-card {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 32px 24px; background: var(--bg-card); border: 2px solid var(--border);
    border-radius: var(--radius-lg); text-decoration: none; color: var(--text); transition: all 0.2s;
}
.exam-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.exam-number {
    width: 48px; height: 48px; background: var(--primary); color: #fff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
}
.exam-name { font-size: 18px; font-weight: 600; }
.exam-detail { font-size: 13px; color: var(--text-muted); }
.exam-cta { font-size: 14px; color: var(--primary); font-weight: 600; margin-top: 8px; }

/* --- Disclaimer --- */
.disclaimer {
    background: var(--accent-light); padding: 16px 0; text-align: center;
    font-size: 13px; color: var(--text-secondary); border-top: 1px solid var(--border);
}

/* --- Footer --- */
.site-footer { padding: 24px 0; text-align: center; color: var(--text-muted); font-size: 13px; border-top: 1px solid var(--border); }

/* --- Formulaire --- */
.page-inscription main, .page-confirmation main { padding: 40px 0; }
.card-form h1 { font-size: 24px; margin-bottom: 4px; }
.form-subtitle { color: var(--primary); font-weight: 600; margin-bottom: 24px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.required { color: var(--danger); }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 15px; font-family: var(--font); background: var(--bg-input); color: var(--text); transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.15);
}
.toggle-libre { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.toggle-libre label { font-weight: 400; margin-bottom: 0; cursor: pointer; }
.suggestions-dropdown {
    position: absolute; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    max-height: 200px; overflow-y: auto; z-index: 50; display: none; box-shadow: var(--shadow-lg); width: 100%;
}
.etablissement-wrapper .form-group { position: relative; }
.suggestion-item { padding: 10px 14px; cursor: pointer; font-size: 14px; }
.suggestion-item:hover { background: var(--primary-light); }

/* --- Confirmation --- */
.card-confirmation { text-align: center; max-width: 560px; margin: 0 auto; }
.confirm-icon { font-size: 48px; margin-bottom: 16px; }
.confirm-details { margin: 16px 0; }
.confirm-rules { text-align: left; margin: 24px 0; padding: 20px; background: var(--bg); border-radius: var(--radius); }
.confirm-rules p { margin-bottom: 8px; font-size: 15px; }
.confirm-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.link-cancel { display: block; margin-top: 16px; color: var(--text-muted); font-size: 14px; text-decoration: none; }

/* ============================================
   QUIZ - CORRIGÉ : plus de chevauchement
   ============================================ */

.page-quiz { padding-top: calc(var(--timer-h) + var(--tabs-h) + 16px); padding-bottom: 80px; }
.page-english { padding-top: calc(var(--timer-h) + 16px); }

/* Timer bar - hauteur fixe */
.timer-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    height: var(--timer-h);
    background: #111827; color: #f3f4f6;
    padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center;
}
[data-theme="dark"] .timer-bar { background: #0a0c14; }
.timer-bar.warning { background: #b45309; color: #fff; border-bottom-color: #b45309; }
.timer-bar.warning-critical { background: var(--danger); color: #fff; border-bottom-color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.85; } }

.timer-label { font-size: 11px; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.5px; }
.timer-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-left, .timer-right { display: flex; flex-direction: column; align-items: center; gap: 0; }
.timer-center { font-weight: 500; font-size: 14px; }
.candidat-name { font-weight: 600; }
.subject-badge { background: var(--primary); color: #fff; padding: 4px 12px; border-radius: 20px; font-size: 13px; }

/* Onglets - position juste sous le timer */
.subject-tabs {
    position: fixed; top: var(--timer-h); left: 0; right: 0; z-index: 199;
    height: var(--tabs-h);
    background: var(--bg-card); border-bottom: 2px solid var(--border);
    display: flex; align-items: stretch;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}
.subject-tabs::-webkit-scrollbar { display: none; }

.tab {
    flex: 1; min-width: 0;
    padding: 6px 10px; border: none; background: none;
    font-family: var(--font); font-size: 12px; font-weight: 500;
    color: var(--text-muted); cursor: pointer;
    border-bottom: 3px solid transparent; transition: all 0.2s;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); }
.tab.partial .tab-progress { color: var(--accent); }
.tab.complete .tab-progress { color: var(--success); }
.tab-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-align: center; }
.tab-progress { font-size: 11px; font-weight: 700; }

/* Questions */
.quiz-main { max-width: 800px; margin: 0 auto; padding: 20px; }
.subject-panel { display: none; }
.subject-panel.active { display: block; }

.question-block {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px; margin-bottom: 20px; transition: border-color 0.2s;
}
.question-block.answered { border-left: 4px solid var(--success); }
.question-block.flagged { border-left: 4px solid var(--accent); }

.question-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.question-number { font-size: 13px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.5px; }
.btn-flag {
    background: none; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 4px 10px; cursor: pointer; font-size: 16px; color: var(--text-muted); transition: all 0.2s;
}
.btn-flag:hover, .btn-flag.active { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }

.question-enonce { font-size: 15px; line-height: 1.7; margin-bottom: 16px; }
.question-image { margin: 16px 0; text-align: center; }
.question-image img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); }

/* Choix */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
    display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px;
    border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: all 0.2s;
}
.choice:hover { border-color: var(--primary); background: var(--primary-light); }
.choice input { display: none; }
.choice input:checked + .choice-letter { background: var(--primary); color: #fff; border-color: var(--primary); }
.choice input:checked ~ .choice-text { font-weight: 600; }
.choice-letter {
    flex-shrink: 0; width: 28px; height: 28px; border: 2px solid var(--border); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
    color: var(--text-muted); transition: all 0.2s;
}
.choice-text { font-size: 14px; padding-top: 3px; }

/* Action bar */
.action-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
    background: var(--bg-card); border-top: 1px solid var(--border);
    padding: 12px 20px; display: flex; justify-content: space-between; align-items: center;
}
.action-stats { font-size: 14px; color: var(--text-secondary); }
.btn-finish {
    background: var(--success); color: #fff; padding: 10px 24px; border: none;
    border-radius: var(--radius); font-family: var(--font); font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-finish:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 300;
    display: flex; align-items: center; justify-content: center;
}
.modal {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 32px;
    max-width: 480px; width: 90%; text-align: center; border: 1px solid var(--border);
}
.modal h2 { margin-bottom: 16px; }
.modal-stats { margin: 16px 0; }
.modal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }

/* ============================================
   RÉSULTATS
   ============================================ */

.page-results main { padding: 40px 0; }

.results-header {
    text-align: center; padding: 40px; border-radius: var(--radius-lg); margin-bottom: 32px;
}
.results-header.admis { background: var(--success-light); border: 2px solid var(--success); }
.results-header.non-admis { background: var(--danger-light); border: 2px solid var(--danger); }
.verdict-icon { font-size: 48px; }
.results-header h1 { font-size: 32px; margin: 8px 0; }
.mention-badge {
    display: inline-block; padding: 4px 16px; background: var(--accent); color: #fff;
    border-radius: 20px; font-weight: 600; font-size: 14px;
}
.result-name { margin-top: 8px; font-size: 16px; color: var(--text-secondary); }

.card-notes { margin-bottom: 24px; }
.card-notes h2 { margin-bottom: 20px; }
.note-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.note-row.total { border-bottom: none; padding-top: 16px; font-weight: 700; }
.note-subject { flex: 1; font-size: 14px; }
.note-value { font-weight: 600; font-size: 15px; min-width: 60px; text-align: right; }
.note-value.good { color: var(--success); }
.note-value.bad { color: var(--danger); }
.note-bar { flex: 0 0 120px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.note-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.5s; }
.note-anglais { margin-top: 16px; padding-top: 16px; border-top: 2px solid var(--border); }
.results-actions { display: flex; gap: 12px; justify-content: center; margin-bottom: 40px; }

/* Correction */
.correction-section { margin-top: 40px; }
.correction-section h2 { font-size: 24px; margin-bottom: 24px; }
.correction-subject { margin-bottom: 32px; }
.correction-subject h3 { font-size: 18px; color: var(--primary); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--primary-light); }

.correction-question { margin-bottom: 16px; padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); }
.correction-question.correct { border-left: 4px solid var(--success); background: var(--success-light); }
.correction-question.wrong { border-left: 4px solid var(--danger); background: var(--danger-light); }
.correction-question.no-answer { border-left: 4px solid var(--text-muted); }

.correction-header { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.correction-icon { font-size: 18px; }
.correction-qnum { font-weight: 700; color: var(--text-muted); font-size: 13px; }
.correction-enonce { font-size: 14px; }

.correction-choices { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.correction-choice { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius); font-size: 14px; }
.correction-choice .choice-letter { width: 24px; height: 24px; font-size: 12px; }
.correction-choice.is-correct { background: var(--success-light); }
.correction-choice.is-correct .choice-letter { background: var(--success); color: #fff; border-color: var(--success); }
.correction-choice.is-wrong { background: var(--danger-light); }
.correction-choice.is-wrong .choice-letter { background: var(--danger); color: #fff; border-color: var(--danger); }
.choice-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; margin-left: auto; }
.correct-tag { background: var(--success); color: #fff; }
.wrong-tag { background: var(--danger); color: #fff; }

.correction-explanation {
    background: var(--primary-light); padding: 12px 16px;
    border-radius: var(--radius); font-size: 14px; line-height: 1.6;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .hero h1 { font-size: 26px; }
    .hero { padding: 40px 0; }
    .consignes-grid { grid-template-columns: 1fr 1fr; }
    .exam-cards { grid-template-columns: 1fr; }
    .card { padding: 20px; }

    :root { --timer-h: 48px; --tabs-h: 52px; }
    .timer-value { font-size: 18px; }
    .timer-center { display: none; }
    .timer-bar { padding: 0 12px; }

    .tab { padding: 4px 8px; font-size: 11px; }

    .question-block { padding: 16px; }
    .choice { padding: 10px 12px; }

    .note-bar { display: none; }
    .results-actions { flex-direction: column; }
    .modal-actions { flex-direction: column; }
}

@media (max-width: 480px) {
    .consignes-grid { grid-template-columns: 1fr; }
    .confirm-buttons { flex-direction: column; }
    .site-header .container { flex-wrap: wrap; gap: 8px; }
}

/* --- Print --- */
@media print {
    .site-header, .timer-bar, .subject-tabs, .action-bar, .btn, .results-actions, .theme-toggle { display: none !important; }
    .page-quiz { padding-top: 0; }
    body { background: white; color: black; }
    .card, .correction-question { break-inside: avoid; }
}
