/* ============================================
   QUIZ 5ᵉ - STYLES ADDITIONNELS v2.1
   Avec gestion de la section rétractable
   ============================================ */

/* ============================================
   SECTION RÉTRACTABLE - NOUVEAUX STYLES
   ============================================ */

/* Header cliquable */
.selection-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    position: relative;
}

.selection-header:hover {
    background-color: #f0f4ff;
}

.selection-header:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Icône de toggle (flèche) */
.toggle-icon {
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.3s ease;
    font-size: 0.85em;
    color: #667eea;
}

/* Rotation de la flèche quand ouvert */
.selection-section:not(.collapsed) .toggle-icon {
    transform: rotate(90deg);
}

/* Contenu rétractable */
.selection-content {
    max-height: 2000px; /* Ajuster selon le contenu */
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease, margin-top 0.3s ease;
    opacity: 1;
    margin-top: 15px;
}

/* État fermé */
.selection-section.collapsed .selection-content {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none; /* Empêche les interactions quand fermé */
}

/* Accessibilité : focus clavier visible */
.selection-header:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 3px;
    border-radius: 8px;
}

/* Empêcher la propagation du clic sur les boutons d'action */
.selection-actions {
    pointer-events: auto;
    z-index: 10;
    position: relative;
}

.selection-actions button {
    pointer-events: auto;
}

/* Animation de la section */
.selection-section {
    transition: all 0.3s ease;
}

/* ============================================
   STYLES EXISTANTS DU QUIZ (CONSERVÉS)
   ============================================ */

/* Sélection des modes */
.mode-selection {
    margin: 30px 0;
    padding: 25px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.mode-selection h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.3em;
}

.mode-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: #3498db;
}

.mode-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.mode-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.mode-title {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 5px;
}

.mode-desc {
    font-size: 0.85em;
    opacity: 0.8;
}

.mode-btn.active .mode-desc {
    opacity: 1;
}

/* Configuration du quiz */
.quiz-config {
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.config-item label {
    font-weight: 500;
    color: #555;
}

.config-item input[type="number"] {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1em;
}

/* Zone du quiz */
#quiz-zone {
    margin: 20px 0;
}

.progress-bar {
    position: relative;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

/* Chronomètre */
.timer-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 20px;
    animation: pulse 1s infinite;
}

.timer-display.timer-warning {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    animation: shake 0.5s infinite;
}

.timer-icon {
    font-size: 1.5em;
}

.timer-value {
    font-size: 1.8em;
    font-weight: 700;
}

.timer-label {
    font-size: 0.9em;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Score défi */
.defi-score {
    display: flex;
    gap: 30px;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 12px;
    margin-bottom: 20px;
}

.defi-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
}

.defi-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.defi-value {
    font-size: 2em;
    font-weight: 700;
}

/* Carte question */
.question-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.question-number {
    display: inline-block;
    padding: 6px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 15px;
}

.question-text {
    font-size: 1.3em;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 25px;
    line-height: 1.6;
}

.answers-grid {
    display: grid;
    gap: 12px;
}

.answer-option {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.answer-option:hover {
    background: #e8f4f8;
    border-color: #3498db;
}

.answer-option.selected {
    background: #e3f2fd;
    border-color: #2196f3;
}

.answer-option.correct {
    background: #d4edda !important;
    border-color: #28a745 !important;
    animation: correctPulse 0.5s ease;
}

.answer-option.incorrect {
    background: #f8d7da !important;
    border-color: #dc3545 !important;
    animation: shake 0.5s ease;
}

.answer-option.correct-answer {
    background: #d4edda !important;
    border-color: #28a745 !important;
}

.answer-option input[type="radio"] {
    margin-right: 15px;
    cursor: pointer;
}

.answer-option label {
    flex: 1;
    cursor: pointer;
    font-size: 1.05em;
}

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

/* Navigation quiz */
.quiz-navigation {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* Résultats */
.results-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.results-container h2 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
}

.score-summary {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.score-main {
    font-size: 3em;
    font-weight: 700;
    margin-bottom: 10px;
}

.score-value {
    color: white;
}

.score-total {
    font-size: 0.6em;
    opacity: 0.9;
}

.score-percentage {
    font-size: 1.5em;
    font-weight: 600;
}

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

.score-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
}

.score-detail.correct {
    background: #d4edda;
    border-color: #28a745;
}

.score-detail.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
}

.score-detail.time {
    background: #e3f2fd;
    border-color: #2196f3;
}

.detail-icon {
    font-size: 2em;
    margin-bottom: 10px;
}

.detail-label {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.detail-value {
    font-size: 1.8em;
    font-weight: 700;
    color: #2c3e50;
}

.congrats-message {
    text-align: center;
    font-size: 1.3em;
    font-weight: 600;
    padding: 20px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 10px;
    margin-bottom: 30px;
}

/* Revue des questions */
.questions-review {
    margin-top: 40px;
}

.questions-review h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.question-review {
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
}

.question-review.review-correct {
    background: #f0f9f4;
    border-color: #28a745;
}

.question-review.review-incorrect {
    background: #fef5f5;
    border-color: #dc3545;
}

.review-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 600;
}

.review-number {
    color: #666;
}

.review-status {
    color: #28a745;
}

.review-incorrect .review-status {
    color: #dc3545;
}

.review-question {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #2c3e50;
}

.review-answer,
.review-correct-answer {
    padding: 10px;
    background: rgba(0,0,0,0.03);
    border-radius: 6px;
    margin-bottom: 10px;
}

.review-correct-answer {
    background: rgba(40, 167, 69, 0.1);
}

.results-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

/* Mode défi interface */
.defi-mode {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    margin: 20px 0;
}

.defi-mode h3 {
    font-size: 1.8em;
    margin-bottom: 15px;
}

.defi-mode p {
    font-size: 1.1em;
    line-height: 1.8;
    margin-bottom: 25px;
}

/* Sélection items */
.items-chapter-group {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.items-chapter-group h4 {
    margin: 0 0 15px 0;
    color: #667eea;
    font-size: 1.1em;
}

.item-checkbox {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.item-checkbox:hover {
    background: #f0f4ff;
    border-color: #667eea;
}

.item-checkbox input {
    margin-right: 10px;
}

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

.info-text {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 15px;
    font-style: italic;
}

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

@media (max-width: 768px) {
    .mode-buttons {
        grid-template-columns: 1fr;
    }
    
    .quiz-config {
        flex-direction: column;
        align-items: stretch;
    }
    
    .score-main {
        font-size: 2em;
    }
    
    .question-text {
        font-size: 1.1em;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    /* Section rétractable sur mobile */
    .selection-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .selection-actions {
        width: 100%;
        justify-content: space-between;
    }
}

/* ============================================
   IMPRESSION
   ============================================ */

@media print {
    .no-print {
        display: none !important;
    }
    
    .question-card,
    .results-container {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    /* Forcer l'ouverture en mode impression */
    .selection-section.collapsed .selection-content {
        max-height: none !important;
        opacity: 1 !important;
    }
}
