/* ============================================
   VARIABLES & RESET
   ============================================ */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --flashcard-color: #667eea;     /* Accent violet */
    --success-color: #27ae60;        /* Vert succès */
    --danger-color: #e74c3c;         /* Rouge danger */
    --error-color: #ef4444;
    --text-color: #2c3e50;
    --bg-light: #f8f9fa;
    --border-color: #e1e8ed;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* ============================================
   CONTAINER PRINCIPAL
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgb(127, 171, 238);
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* ============================================
   HEADER & TITRE
   ============================================ */
header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--primary-color);
}

h1 {
    color: var(--primary-color);
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1.2em;
}
.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: rgb(56, 11, 11);
    text-decoration: none;
    font-weight: bold;
    background: rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 25px;
    transition: all 0.3s;
}
/* ============================================
   FORMULAIRE IDENTITÉ (POUR IMPRESSION)
   ============================================ */
.identity-form {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 10px;
}

.identity-form > div {
    flex: 1;
}

.identity-form label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--text-color);
}

.identity-form input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1em;
}

/* ============================================
   SÉLECTION DES CHAPITRES ET ITEMS
   ============================================ */

/* Anciennes règles .notions-section supprimées - structure changée */

.chapters-wrapper h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

/* ============================================
   SÉLECTION CHAPITRES & ITEMS (modèle flashcards)
   ============================================ */

/* Masquer anciennes sections HTML statiques */
.chapter-selection,
#chapter-selection,
.chapters-section {
    display: none !important;
}

/* Section principale (IDENTIQUE flashcards) */
.selection-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.section-title {
    font-size: 1.3em;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

/* Boutons Tout/Aucun */
.selection-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.selection-actions button {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
    font-weight: 600;
}

.select-all-btn {
    background: #27ae60;
    color: white;
}

.select-all-btn:hover {
    background: #229954;
    transform: translateY(-2px);
}

.unselect-all-btn {
    background: #e74c3c;
    color: white;
}

.unselect-all-btn:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

/* Grille chapitres */
.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.chapter-checkbox {
    background: #ecf0f1;
    padding: 15px;
    border-radius: 10px;
    transition: all 0.3s;
    cursor: pointer;
}

.chapter-checkbox:hover {
    background: #dfe6e9;
    transform: translateX(5px);
}

.chapter-checkbox input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.chapter-checkbox label {
    cursor: pointer;
    font-weight: 500;
}

/* Bouton toggle items */
.toggle-items-btn {
    display: block;
    width: 100%;
    margin: 20px 0;
    padding: 10px;
    background: #e9ecef;
    color: #495057;
    border: 2px dashed #ced4da;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s;
}

.toggle-items-btn:hover {
    background: #dee2e6;
    border-color: #adb5bd;
}

/* Section items pliable (ANIMATION IDENTIQUE flashcards) */
.items-section {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.items-section.expanded {
    max-height: none;  /* Pas de limite */
    overflow-y: auto;  /* Scroll si nécessaire */
    padding-top: 20px;
}

/* Grille items */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.item-checkbox {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: all 0.2s;
    cursor: pointer;
}

.item-checkbox:hover {
    background: #e9ecef;
}

.item-checkbox input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.item-checkbox label {
    cursor: pointer;
    font-size: 0.9em;
}

/* Badge compteur exercices */
.exercise-count {
    color: #667eea;
    font-weight: bold;
    font-size: 0.85em;
}

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.chapter-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.chapter-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.chapter-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
}

.chapter-item label {
    cursor: pointer;
    flex: 1;
    font-size: 0.95em;
}

.chapter-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.chapter-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.3s ease;
}

.chapter-info {
    text-align: center;
    padding: 12px;
    background: white;
    border-radius: 5px;
    color: var(--primary-color);
    font-weight: bold;
}

#available-questions {
    color: var(--secondary-color);
    font-size: 1.2em;
}

/* ============================================
   CONTRÔLES
   ============================================ */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: end;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 10px;
}

.controls > * {
    flex: 1;
    min-width: 150px;
}

.controls label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
}

.controls input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1em;
}

/* ============================================
   BOUTONS
   ============================================ */
.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* ============================================
   SCORE
   ============================================ */
.score-container {
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 10px;
    color: white;
    text-align: center;
}

.score-display h3 {
    font-size: 2em;
    margin-bottom: 10px;
}

.score-percentage {
    font-size: 3em;
    font-weight: bold;
}

/* ============================================
   QUESTIONS - MODE NAVIGATION FIX8
   ============================================ */
.questions-container {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

/* AFFICHAGE UNE PAR UNE (mode normal FIX8) */
.question-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    padding: 40px;
    background: white;
    border: 3px solid var(--border-color);
    border-radius: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    min-height: 300px;
}

.question-item:hover {
    box-shadow: 0 15px 50px rgba(0,0,0,0.15);
}

.question-number {
    display: none; /* Masqué en mode une par une, remplacé par le badge de progrès */
}

.question-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
    text-align: center;
}

.question-text {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-color);
    line-height: 1.5;
    max-width: 800px;
}

.answer-input {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.answer-input input {
    width: 100%;
    padding: 20px;
    border: 3px solid var(--border-color);
    border-radius: 8px;
    font-size: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.answer-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* AFFICHAGE LISTE (mode correction) */
.questions-container.correction-mode .question-item {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 20px;
    align-items: start;
    padding: 20px;
    min-height: auto;
}

.questions-container.correction-mode .question-number {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    padding-top: 5px;
}

.questions-container.correction-mode .question-content {
    text-align: left;
    align-items: flex-start;
    gap: 15px;
}

.questions-container.correction-mode .question-text {
    font-size: 1.1em;
    font-weight: normal;
    text-align: left;
}

.questions-container.correction-mode .answer-input {
    max-width: 100%;
}

.questions-container.correction-mode .answer-input input {
    padding: 12px;
    font-size: 1em;
    text-align: left;
}

/* ============================================
   BOUTONS D'AIDE À LA SAISIE MATHÉMATIQUE
   ============================================ */
.math-buttons {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.math-btn {
    padding: 8px 14px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    font-weight: 500;
}

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

/* ============================================
   CORRECTION
   ============================================ */
.correction {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.95em;
}

.correction.correct {
    background: #d4edda;
    border-left: 4px solid var(--success-color);
}

.correction.incorrect {
    background: #f8d7da;
    border-left: 4px solid var(--error-color);
}

.correction-header {
    font-weight: bold;
    margin-bottom: 8px;
}

.correction-details {
    margin-top: 8px;
}

.correct-answer {
    color: var(--success-color);
    font-weight: bold;
}

.user-answer {
    color: var(--error-color);
    font-weight: bold;
}

/* Bordures colorées après correction */
.answer-input input.correct-input {
    border-color: var(--success-color) !important;
    background: #f0fdf4;
}

.answer-input input.incorrect-input {
    border-color: var(--error-color) !important;
    background: #fef2f2;
}

/* ============================================
   IMPRESSION
   ============================================ */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        padding: 20px;
    }
    
    .controls, .btn, header {
        display: none;
    }
    
    .question-item {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid #ddd;
        margin-bottom: 15px;
        padding: 15px;
        box-shadow: none;
    }
    
    .questions-container.correction-mode .question-item {
        display: grid;
        grid-template-columns: 50px 1fr;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .question-item {
        padding: 25px;
        min-height: 250px;
    }
    
    .question-text {
        font-size: 20px;
    }
    
    .answer-input input {
        padding: 15px;
        font-size: 18px;
    }
    
    .questions-container.correction-mode .question-item {
        grid-template-columns: 50px 1fr;
        padding: 15px;
    }
    
    .math-buttons {
        gap: 3px;
    }
    
    .math-btn {
        padding: 6px 10px;
        font-size: 0.9em;
    }
}

/* ============================================
   MODES FLASH & GAMING (conservés de v3.15)
   ============================================ */
.flash-mode, .gaming-mode {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 25px;
    border-radius: 16px;
    margin: 20px 0;
    box-shadow: 0 8px 32px rgba(240, 147, 251, 0.4);
}

.flash-mode h3, .gaming-mode h3 {
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4em;
}

.flash-mode h3 span:first-child,
.gaming-mode h3 span:first-child {
    font-size: 32px;
}

.timer-container {
    margin: 20px 0;
    text-align: center;
}

.timer-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}

.timer-fill {
    height: 100%;
    background: white;
    transition: width 0.1s linear;
}

.timer-text {
    font-size: 48px;
    font-weight: bold;
    margin: 15px 0;
}

/* Mode défi */
.defi-mode {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    margin: 25px 0;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.defi-mode:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.5);
}

.defi-mode h3 {
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4em;
}

.defi-mode h3 span:first-child {
    font-size: 32px;
    animation: pulse 2s ease-in-out infinite;
}

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

.defi-mode p {
    margin: 12px 0;
    font-size: 1em;
    opacity: 0.95;
    line-height: 1.6;
}

.defi-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.defi-buttons button {
    flex: 1;
    min-width: 150px;
    background: white;
    color: #667eea;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.defi-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}

#defiStreak {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    text-align: center;
    backdrop-filter: blur(10px);
}

#defiStreak > div:first-child {
    font-size: 0.9em;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#defiStreak > div:nth-child(2) {
    font-size: 48px;
    font-weight: bold;
    margin: 10px 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Double zone score */
.score-container {
    margin: 25px 0;
    padding: 0;
    border-radius: 16px;
    background: transparent;
    position: relative;
}

.score-display {
    padding: 25px;
    border-radius: 16px;
    color: white;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    margin-bottom: 15px;
}

.score-display .score {
    font-size: 36px !important;
    font-weight: bold !important;
    margin: 15px 0 !important;
}

#scoreContainerTop {
    position: sticky;
    top: 20px;
    z-index: 100;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Récapitulatif défi */
.defi-recap-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 30px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.defi-victory {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%);
    border-radius: 16px;
    color: white;
    margin-bottom: 30px;
}

.trophy-icon {
    font-size: 80px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.defi-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: #ecf0f1;
    border-radius: 12px;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #2c3e50;
}

/* Mobile responsive modes */
@media (max-width: 768px) {
    .defi-buttons {
        flex-direction: column;
    }
    
    .defi-buttons button {
        width: 100%;
        min-width: 0;
    }
    
    .defi-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}
.btn-revision { background: linear-gradient(135deg, #8e44ad, #6c3483); color: white; }

