/* ===================================================
   Évaluation & Orientation FWB — feuille de style
   =================================================== */

* { box-sizing: border-box; }

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --warn: #f59e0b;
    --warn-light: #fef3c7;
    --alert: #ef4444;
    --alert-light: #fee2e2;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.10);
    --radius: 12px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== Top bar ==================== */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.1rem; color: var(--text); }
.logo { font-size: 1.8rem; }

.user-info { display: flex; align-items: center; gap: 12px; font-weight: 500; }

/* ==================== Layout ==================== */
main {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ==================== Buttons ==================== */
.btn {
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }
.btn-block { width: 100%; padding: 14px; font-size: 1.05rem; }

/* ==================== Login ==================== */
.card-login {
    max-width: 420px;
    margin: 48px auto;
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.card-login h2 { margin: 0 0 8px; color: var(--primary); }
.card-login .subtitle { color: var(--text-muted); margin-top: 0; }
.card-login label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin: 16px 0 6px;
}
.card-login input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s;
}
.card-login input:focus {
    outline: none;
    border-color: var(--primary);
}
.hint { margin-top: 24px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.error-msg {
    background: var(--alert-light);
    color: var(--alert);
    padding: 10px 14px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ==================== Student home ==================== */
.welcome {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: white;
    padding: 32px;
    border-radius: var(--radius);
    margin-bottom: 24px;
}
.welcome h2 { margin: 0 0 4px; font-size: 1.8rem; }
.welcome p { margin: 0; opacity: 0.95; }

.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.test-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
}
.test-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.test-icon { font-size: 2.5rem; margin-bottom: 8px; }
.test-card h3 { margin: 4px 0 8px; font-size: 1.1rem; }
.test-card p { color: var(--text-muted); flex: 1; margin-top: 0; }
.test-card .btn { margin-top: 12px; }

.history-box {
    background: var(--surface);
    padding: 20px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.history-box h3 { margin: 0 0 12px; }
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-score { font-weight: 700; font-size: 1.1rem; }

/* ==================== Test view ==================== */
.test-header {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.test-header h2 { margin: 0 0 12px; color: var(--primary); }
.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    transition: width 0.3s ease;
    width: 0%;
}
.progress-text { margin: 8px 0 0; color: var(--text-muted); font-size: 0.9rem; }

.question-container {
    background: var(--surface);
    padding: 28px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.question-text {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 20px;
}
.question-context {
    background: var(--primary-light);
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-style: italic;
    border-left: 4px solid var(--primary);
}
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 1rem;
}
.choice-label:hover { border-color: var(--primary); background: var(--primary-light); }
.choice-label input[type="radio"] { accent-color: var(--primary); transform: scale(1.2); }
.choice-label.selected { border-color: var(--primary); background: var(--primary-light); }

.text-input {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}
.text-input:focus { outline: none; border-color: var(--primary); }

.test-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

/* ==================== Result ==================== */
.card-result {
    max-width: 500px;
    margin: 24px auto;
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.card-result h2 { color: var(--primary); margin-top: 0; }
.score-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    margin: 24px auto;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
}
.score-circle span { font-size: 3.5rem; line-height: 1; }
.score-circle small { font-size: 1.2rem; opacity: 0.9; margin-top: 4px; }
.score-percent { font-size: 1.3rem; font-weight: 600; }
.feedback {
    padding: 20px;
    border-radius: 8px;
    margin: 24px 0;
    font-size: 1rem;
    text-align: left;
}
.feedback.ok { background: var(--success-light); color: #065f46; border-left: 4px solid var(--success); }
.feedback.warn { background: var(--warn-light); color: #92400e; border-left: 4px solid var(--warn); }
.feedback.alert { background: var(--alert-light); color: #991b1b; border-left: 4px solid var(--alert); }
.result-actions { margin-top: 20px; }

/* ==================== Teacher dashboard ==================== */
.teacher-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.teacher-header h2 { margin: 0; color: var(--primary); }
.teacher-actions { display: flex; gap: 8px; }

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-card h4 { margin: 0 0 6px; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.stat-card p { margin: 0; font-size: 1.8rem; font-weight: 700; color: var(--text); }
.stat-card.ok p { color: var(--success); }
.stat-card.warn p { color: var(--warn); }
.stat-card.alert p { color: var(--alert); }

.legend {
    background: var(--surface);
    padding: 14px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}
.tag.ok { background: var(--success-light); color: #065f46; }
.tag.warn { background: var(--warn-light); color: #92400e; }
.tag.alert { background: var(--alert-light); color: #991b1b; }

.table-wrap {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow-x: auto;
    box-shadow: var(--shadow);
}
.results-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}
.results-table th, .results-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.results-table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.results-table tbody tr:hover { background: var(--bg); }
.score-cell {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 54px;
    text-align: center;
}
.score-cell.ok { background: var(--success-light); color: #065f46; }
.score-cell.warn { background: var(--warn-light); color: #92400e; }
.score-cell.alert { background: var(--alert-light); color: #991b1b; }
.score-cell.none { background: var(--border); color: var(--text-muted); }

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ==================== Footer ==================== */
.footer {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
    background: var(--surface);
}

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* ==================== Login : onglets ==================== */
.login-tabs {
    display: flex;
    gap: 0;
    margin: -32px -32px 20px;
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}
.login-tab {
    flex: 1;
    padding: 14px 16px;
    border: none;
    background: #f1f5f9;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    border-bottom: 3px solid transparent;
}
.login-tab:hover { background: #e2e8f0; color: var(--text); }
.login-tab.active {
    background: var(--surface);
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.login-panel { display: none; }
.login-panel.active { display: block; }

/* ==================== Teacher : lignes cliquables ==================== */
.results-table tr.clickable { cursor: pointer; }
.results-table tr.clickable:hover td:first-child { color: var(--primary); }

/* ==================== Modale ==================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.hidden { display: none; }
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
}
.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 820px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; color: var(--primary); font-size: 1.25rem; }
.modal-close {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ==================== Détails dans la modale ==================== */
.detail-global {
    margin-bottom: 20px;
    padding: 14px 18px;
    border-radius: 8px;
}
.detail-test {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.detail-test:last-child { border-bottom: none; }
.detail-test-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    gap: 12px;
    flex-wrap: wrap;
}
.detail-test-head h3 { margin: 0; font-size: 1.05rem; }

.detail-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.detail-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--bg);
    border-left: 4px solid var(--border);
}
.detail-item.ok {
    background: #f0fdf4;
    border-left-color: var(--success);
}
.detail-item.ko {
    background: #fff1f2;
    border-left-color: var(--alert);
}
.detail-item-head {
    display: flex;
    gap: 8px;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.detail-num {
    font-weight: 700;
    color: var(--primary);
    min-width: 34px;
}
.detail-icon { font-size: 0.95rem; }
.detail-question { font-weight: 500; flex: 1; }
.detail-user, .detail-correct {
    margin: 2px 0 0 42px;
    font-size: 0.92rem;
    color: var(--text);
}
.detail-correct { color: #065f46; }

/* ==================== Responsive ==================== */
@media (max-width: 640px) {
    .topbar { flex-direction: column; gap: 8px; padding: 12px; }
    .brand h1 { font-size: 0.95rem; text-align: center; }
    main { padding: 16px; }
    .welcome { padding: 20px; }
    .welcome h2 { font-size: 1.4rem; }
    .test-actions { flex-direction: column-reverse; }
    .test-actions .btn { width: 100%; }
    .score-circle { width: 140px; height: 140px; }
    .score-circle span { font-size: 2.8rem; }
    .modal { padding: 8px; }
    .modal-header, .modal-body, .modal-footer { padding-left: 14px; padding-right: 14px; }
    .detail-user, .detail-correct { margin-left: 0; }
}
