/* ============================================
   STRUCTURE HIÉRARCHIQUE CHAPITRES + ITEMS
   ============================================ */

.selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.selection-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Boutons de sélection */
.select-all-btn,
.unselect-all-btn,
.expand-all-btn,
.collapse-all-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

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

.select-all-btn:hover {
    background: #229954;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(39, 174, 96, 0.3);
}

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

.unselect-all-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
}

.expand-all-btn {
    background: #3498db;
    color: white;
}

.expand-all-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3);
}

.collapse-all-btn {
    background: #95a5a6;
    color: white;
}

.collapse-all-btn:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(149, 165, 166, 0.3);
}

.chapters-items-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

/* ============================================
   MENU DÉPLIANT GLOBAL (TOUS LES CHAPITRES)
   ============================================ */

.all-chapters-details {
    background: white;
    border: 2px solid #3498db;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.all-chapters-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    cursor: pointer;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    font-weight: 700;
    font-size: 1.1rem;
    color: #1976d2;
    user-select: none;
    transition: background 0.2s ease;
}

.all-chapters-summary:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
}

.all-chapters-details[open] .all-chapters-summary {
    background: linear-gradient(135deg, #90caf9 0%, #64b5f6 100%);
}

.all-chapters-summary::marker {
    color: #1976d2;
    font-size: 1.3em;
}

.chapters-count {
    background: #1976d2;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ============================================
   CHAPITRES (DETAILS)
   ============================================ */

.chapter-details {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.chapter-details:hover {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

.chapter-details[open] {
    border-color: #3498db;
}

/* Summary (en-tête du chapitre) */
.chapter-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    transition: all 0.2s ease;
    user-select: none;
}

.chapter-summary:hover {
    background: linear-gradient(135deg, #e8f4f8 0%, #f0f7fa 100%);
}

/* État fermé (par défaut) */
.chapter-details:not([open]) .chapter-summary {
    background: linear-gradient(135deg, #fafbfc 0%, #ffffff 100%);
}

/* État ouvert */
.chapter-details[open] .chapter-summary {
    background: linear-gradient(135deg, #d5e8f3 0%, #e3f2fd 100%);
    border-bottom: 2px solid #3498db;
}

/* Marker (flèche) personnalisée */
.chapter-summary::marker {
    color: #95a5a6;
    font-size: 1.2em;
}

.chapter-details[open] .chapter-summary::marker {
    color: #2980b9;
}

/* Checkbox du chapitre */
.chapter-checkbox-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #3498db;
    flex-shrink: 0;
}

/* Label du chapitre */
.chapter-label {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
    color: #2c3e50;
    cursor: pointer;
}

/* Compteur de questions du chapitre */
.question-count {
    background: #3498db;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* ============================================
   ITEMS (CONTAINER)
   ============================================ */

.items-container {
    padding: 1rem;
    background: #fafbfc;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

/* Si pas d'items */
.no-items {
    grid-column: 1 / -1;
    text-align: center;
    color: #95a5a6;
    font-style: italic;
    padding: 1rem;
}

/* ============================================
   ITEMS (CHECKBOXES)
   ============================================ */

.item-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.item-checkbox-wrapper:hover {
    border-color: #3498db;
    background: #f8fbfd;
    box-shadow: 0 1px 4px rgba(52, 152, 219, 0.1);
}

/* Checkbox de l'item */
.item-checkbox-input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #3498db;
    flex-shrink: 0;
}

/* Label de l'item */
.item-label {
    flex: 1;
    font-size: 0.9rem;
    color: #34495e;
    cursor: pointer;
    line-height: 1.3;
}

/* Compteur de questions de l'item */
.item-question-count {
    background: #e3f2fd;
    color: #1976d2;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

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

@media (max-width: 768px) {
    .selection-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .selection-actions {
        width: 100%;
    }
    
    .select-all-btn,
    .unselect-all-btn,
    .expand-all-btn,
    .collapse-all-btn {
        flex: 1;
        min-width: 100px;
    }
    
    /* Grid chapitres : 2 colonnes sur tablette */
    .chapters-items-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .items-container {
        grid-template-columns: 1fr;
    }
    
    .chapter-summary {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .chapter-label {
        font-size: 0.95rem;
    }
    
    .question-count {
        font-size: 0.8rem;
        padding: 0.2rem 0.6rem;
    }
}

@media (max-width: 480px) {
    .selection-actions {
        flex-direction: column;
    }
    
    .select-all-btn,
    .unselect-all-btn,
    .expand-all-btn,
    .collapse-all-btn {
        width: 100%;
    }
    
    /* Grid chapitres : 1 colonne sur mobile */
    .chapters-items-container {
        grid-template-columns: 1fr;
    }
    
    .chapter-checkbox-input {
        width: 18px;
        height: 18px;
    }
    
    .item-checkbox-input {
        width: 14px;
        height: 14px;
    }
    
    .item-label {
        font-size: 0.85rem;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

.chapter-details[open] .items-container {
    animation: slideDown 0.3s ease-out;
}

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

@media print {
    .chapter-details {
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
    
    .chapter-summary::marker {
        display: none;
    }
    
    .items-container {
        grid-template-columns: repeat(2, 1fr);
    }
}
