/* ============================================
   Deutsch Quiz - Feuille de style principale
   Layout : flexbox/grid (pas de table HTML)
   ============================================ */

/* --- Reset minimal --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Container --- */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* --- Header --- */
.site-header {
    background: #2b4c7e;
    color: white;
    padding: 0.8rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.logo {
    color: white;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav a:hover {
    color: white;
}

.nav-user {
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
}

/* --- Main content --- */
.main-content {
    flex: 1;
    padding: 2rem 1rem;
}

/* --- Flash messages --- */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.flash-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* --- Auth forms --- */
.auth-container {
    max-width: 420px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.auth-container h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #2b4c7e;
}

.auth-container p {
    color: #666;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.form-auth {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-group label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #444;
}

.form-group input {
    padding: 0.6rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #5ba4e6;
    box-shadow: 0 0 0 3px rgba(91,164,230,0.15);
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s;
}

.btn-primary {
    background: #2b4c7e;
    color: white;
    margin-top: 1rem;
}

.btn-primary:hover {
    background: #1a3a5c;
}

.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.5);
    color: white;
}

.btn-outline:hover {
    background: rgba(255,255,255,0.1);
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #666;
}

.auth-link a {
    color: #3b7dd8;
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* --- Footer --- */
.site-footer {
    background: #2b4c7e;
    color: rgba(255,255,255,0.7);
    text-align: center;
    padding: 1rem 0;
    font-size: 0.8rem;
    margin-top: auto;
}

/* --- Quiz container --- */
.quiz-container {
    max-width: 700px;
    margin: 0 auto;
}

.quiz-container h1 {
    color: #2b4c7e;
    margin-bottom: 0.5rem;
}

.quiz-container > p {
    color: #666;
    margin-bottom: 2rem;
}

/* --- Level selection grid --- */
.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.level-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.2rem;
    border-radius: 8px;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
}

.level-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.level-a { background: #e8f5e9; border-color: #a5d6a7; }
.level-b { background: #fff3e0; border-color: #ffcc80; }
.level-c { background: #fce4ec; border-color: #f48fb1; }

.level-tag {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.level-name {
    font-size: 0.85rem;
    color: #555;
    margin-top: 0.3rem;
}

.level-desc {
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.2rem;
}

.all-levels {
    text-align: center;
    margin-top: 1rem;
}

/* --- Progress bar --- */
.quiz-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #3b7dd8;
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.85rem;
    color: #555;
    white-space: nowrap;
}

.progress-level {
    background: #2b4c7e;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* --- Question card --- */
.question-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.question-card form {
    display: flex;
    flex-direction: column;
}

.question-text {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.options-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.option-label {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.option-label:hover {
    border-color: #3b7dd8;
    background: #f0f7ff;
}

.option-label input[type="radio"] {
    accent-color: #3b7dd8;
}

.option-text {
    font-size: 0.95rem;
}

/* --- Result page --- */
.result-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.score-big {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2b4c7e;
}

.score-percent {
    font-size: 1.2rem;
    color: #666;
    margin-left: 0.5rem;
}

.result-level {
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

.level-badge {
    display: inline-block;
    background: #2b4c7e;
    color: white;
    padding: 0.2rem 0.8rem;
    border-radius: 6px;
    font-size: 1.3rem;
}

.result-date {
    color: #888;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* --- Results list --- */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0 2rem;
}

.result-item {
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid;
}

.result-correct {
    background: #f1f8e9;
    border-color: #66bb6a;
}

.result-wrong {
    background: #fef2f2;
    border-color: #ef5350;
}

.result-item-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.result-num {
    background: #eee;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.result-level-tag {
    font-size: 0.75rem;
    background: #e0e0e0;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 600;
}

.result-icon {
    margin-left: auto;
    font-size: 1.2rem;
    font-weight: 700;
}

.result-correct .result-icon { color: #2e7d32; }
.result-wrong .result-icon { color: #c62828; }

.result-question {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.result-answers {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.answer-option {
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
}

.answer-correct {
    background: #c8e6c9;
    font-weight: 600;
}

.answer-wrong {
    background: #ffcdd2;
    text-decoration: line-through;
}

/* --- Result actions --- */
.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.btn-large {
    padding: 0.8rem 2rem;
    font-size: 1rem;
}

.btn-outline-dark {
    background: transparent;
    border: 2px solid #333;
    color: #333;
}

.btn-outline-dark:hover {
    background: #333;
    color: white;
}

/* --- History --- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.history-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: box-shadow 0.15s;
}

.history-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.history-date {
    font-size: 0.85rem;
    color: #666;
    min-width: 140px;
}

.history-score {
    font-weight: 700;
    font-size: 1.1rem;
}

.history-percent {
    color: #888;
    font-size: 0.85rem;
}

.history-level {
    margin-left: auto;
}

.empty-state {
    text-align: center;
    color: #888;
    padding: 3rem 0;
    font-size: 1.1rem;
}

.empty-state a {
    color: #3b7dd8;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .header-inner {
        flex-direction: column;
        text-align: center;
    }
    .auth-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    .level-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .history-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .history-level {
        margin-left: 0;
    }
    .result-actions {
        flex-direction: column;
    }
}
