/* ==================== CSS RESET & BASE ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563EB;
    --primary-dark: #1E40AF;
    --accent: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --border: #E2E8F0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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);
    --radius: 12px;
    --radius-sm: 8px;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ==================== SCREENS ==================== */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 24px;
    width: 100%;
}

/* ==================== START SCREEN ==================== */
.logo {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

/* ==================== FORM ==================== */
.form {
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group:last-of-type {
    margin-bottom: 32px;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

input[type="text"],
input[type="email"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input::placeholder {
    color: var(--text-secondary);
}

/* ==================== FILE UPLOAD ==================== */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.file-upload:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.02);
}

.file-upload.dragover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.file-upload svg {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.file-upload span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.file-name {
    color: var(--primary) !important;
    font-weight: 500 !important;
    margin-top: 4px;
}

.hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #DC2626;
}

.btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.125rem;
}

/* ==================== INFO BOX ==================== */
.info-box {
    display: flex;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.info-item svg {
    color: var(--primary);
}

/* ==================== QUIZ SCREEN ==================== */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left,
.header-right {
    flex: 1;
}

.header-right {
    text-align: right;
}

.candidate-name {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.timer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1.25rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary);
}

.timer.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    animation: pulse 1s ease-in-out infinite;
}

.timer.critical {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.question-counter {
    font-weight: 600;
    color: var(--text-primary);
}

.quiz-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.question-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    width: 100%;
    max-width: 600px;
}

.question-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.question-badge.programmation { background: #2563EB; }
.question-badge.web { background: #7C3AED; }
.question-badge.algo { background: #7C3AED; }
.question-badge.ia { background: #059669; }

.question-text {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 24px;
}

/* ==================== OPTIONS ==================== */
.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.option:hover:not(.selected):not(.disabled) {
    border-color: var(--primary);
    transform: translateX(4px);
}

.option.selected {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.option-radio {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.option.selected .option-radio {
    border-color: var(--primary);
    background: var(--primary);
}

.option.selected .option-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.option-letter {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.option.selected .option-letter {
    background: var(--primary);
    color: white;
}

.option-text {
    flex: 1;
    font-size: 1rem;
    line-height: 1.4;
}

/* ==================== PROGRESS BAR ==================== */
.quiz-footer {
    padding: 16px 24px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.progress-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.progress-segment {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.progress-segment.answered {
    background: var(--accent);
}

.progress-segment.current {
    background: var(--primary);
}

.answered-count {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.answered-count span {
    font-weight: 700;
    color: var(--primary);
}

/* ==================== RESULTS SCREEN ==================== */
.results-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px;
}

.results-header {
    text-align: center;
    margin-bottom: 40px;
}

.results-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 50%;
    margin-bottom: 24px;
}

.results-icon svg {
    color: var(--accent);
}

.results-wrapper.timeout .results-icon {
    background: rgba(245, 158, 11, 0.1);
}

.results-wrapper.timeout .results-icon svg {
    color: var(--warning);
}

#results-title {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.results-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.results-score {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 32px;
}

#score-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.score-total {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.results-details {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-bottom: 40px;
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.result-value {
    font-size: 1.25rem;
    font-weight: 600;
}

/* ==================== DETAILED ANSWERS ==================== */
.results-review {
    margin-bottom: 40px;
}

.results-review h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    text-align: center;
}

.answer-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--border);
}

.answer-card.correct {
    border-left-color: var(--accent);
    background: rgba(16, 185, 129, 0.03);
}

.answer-card.incorrect {
    border-left-color: var(--danger);
    background: rgba(239, 68, 68, 0.03);
}

.answer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.answer-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
}

.answer-card.correct .answer-number {
    background: var(--accent);
    color: white;
}

.answer-card.incorrect .answer-number {
    background: var(--danger);
    color: white;
}

.answer-badge {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-secondary);
}

.answer-status {
    margin-left: auto;
    font-weight: 600;
    font-size: 0.875rem;
}

.answer-card.correct .answer-status {
    color: var(--accent);
}

.answer-card.incorrect .answer-status {
    color: var(--danger);
}

.answer-question {
    font-weight: 500;
    margin-bottom: 12px;
    white-space: pre-line;
}

.answer-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.answer-label {
    font-weight: 600;
    min-width: 100px;
}

.answer-your {
    color: var(--danger);
}

.answer-correct {
    color: var(--accent);
}

.answer-explanation {
    margin-top: 12px;
    padding: 12px;
    background: rgba(37, 99, 235, 0.05);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.answer-explanation strong {
    color: var(--primary);
}

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.modal-content h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions .btn {
    flex: 1;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 640px) {
    .container {
        padding: 24px 16px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .info-box {
        gap: 16px;
    }

    .quiz-header {
        padding: 12px 16px;
    }

    .timer {
        padding: 6px 12px;
        font-size: 1rem;
    }

    .question-card {
        padding: 24px;
    }

    .question-text {
        font-size: 1.125rem;
    }

    .option {
        padding: 12px;
    }

    .results-details {
        gap: 24px;
    }
}
