/* --- Variables & Styles Globaux --- */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --quiz-color: #8B4513;
    --html-course-color: #9370DB; /* NOUVEAU: Couleur Violette pour le cours HTML */
    --correction-color: #28a745; /* NOUVEAU: Couleur pour les boutons de Correction (vert) */
    --background-color: #f4f7f6;
    --header-bg: #ffffff;
    --text-color: #333;
    --card-bg: #ffffff;
    --shadow: 0 4px 8px rgba(0,0,0,0.1);
    --border-radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Roboto', sans-serif; background-color: var(--background-color); color: var(--text-color); line-height: 1.6; }
#app-container { max-width: 1200px; margin: 0 auto; background-color: var(--header-bg); }

/* --- En-tête --- */
header { background: var(--header-bg); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 1000; }
.activation-banner { background-color: var(--success-color); text-align: center; padding: 8px; }
.btn-activate { background-color: transparent; color: white; border: 1px solid white; font-weight: bold; width: 100%; }
.btn-activate:hover { background-color: rgba(255,255,255,0.2); }
.header-main { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; gap: 15px; cursor: pointer; }
.header-banner-img { height: 50px; border-radius: var(--border-radius); }
.logo { height: 50px; }
h1 { font-size: 1.5rem; font-weight: 500; text-align: center; flex-grow: 1; }
.discipline-nav { display: flex; overflow-x: auto; padding: 0 1rem 0.5rem 1rem; border-top: 1px solid #eee; }
.discipline-nav::-webkit-scrollbar { height: 5px; }
.discipline-nav::-webkit-scrollbar-thumb { background: #ccc; border-radius: 5px; }
.discipline-btn { display: flex; align-items: center; background: transparent; border: none; padding: 10px 15px; cursor: pointer; font-size: 0.9rem; color: var(--text-color); border-bottom: 3px solid transparent; transition: all 0.3s ease; flex-shrink: 0; }
.discipline-btn img { height: 24px; margin-right: 8px; border-radius: 50%; }
.discipline-btn.active, .discipline-btn:hover { color: var(--primary-color); border-bottom-color: var(--primary-color); }

/* --- Contenu Principal --- */
main { padding: 1.5rem; min-height: calc(100vh - 250px); }
.content-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid #ddd; }
.content-header h2 { display: flex; align-items: center; font-size: 1.8rem; }
.content-header img { height: 40px; margin-right: 15px; border-radius: 50%; }
.chapter-list { list-style: none; }
.chapter-item { background: var(--card-bg); margin-bottom: 1.5rem; border-radius: var(--border-radius); box-shadow: var(--shadow); overflow: hidden; }
.chapter-title { background-color: #e9ecef; padding: 12px 20px; font-weight: 700; font-size: 1.1rem; }
.part-list { list-style: none; }
.part-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-top: 1px solid #f0f0f0; }
.part-item:first-child { border-top: none; }
.part-actions { 
    display: flex; 
    gap: 10px; 
    flex-shrink: 0; 
    /* AJOUT: Permet d'aligner les boutons à droite et de les envelopper */
    flex-wrap: wrap-reverse; 
    justify-content: flex-end; /* Garde les éléments à droite */
}
.part-item.restricted { opacity: 0.6; cursor: pointer; }

/* --- Grille des disciplines --- */
.discipline-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; padding: 1rem; }
.discipline-card { background: var(--card-bg); border: 1px solid #e0e0e0; border-radius: var(--border-radius); box-shadow: var(--shadow); text-align: center; padding: 1.5rem 1rem; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1rem; font-weight: 500; color: var(--text-color); }
.discipline-card:hover { transform: translateY(-5px); box-shadow: 0 8px 16px rgba(0,0,0,0.15); color: var(--primary-color); }
.discipline-card img { height: 60px; width: 60px; border-radius: 50%; margin-bottom: 1rem; }

/* --- Boutons --- */
.btn { padding: 8px 15px; border: none; border-radius: 5px; cursor: pointer; font-size: 0.9rem; font-weight: 500; transition: opacity 0.3s; display: inline-flex; align-items: center; gap: 8px; justify-content: center;}
.btn:disabled { opacity: 0.5; cursor: not-allowed; background-color: #ccc !important; }

/* Bouton Course (Vidéo) - Bleu */
.btn-course { background-color: var(--primary-color); color: white; }

/* Bouton Cours HTML (Violet) */
.btn-html-course { background-color: var(--html-course-color); color: white; }

/* Bouton Enoncé (Violet - même couleur que HTML course) */
.btn-enonce { background-color: var(--html-course-color); color: white; }

/* Bouton Quiz - Marron */
.btn-quiz { background-color: var(--quiz-color); color: white; }

/* Bouton Télécharger Tout - Secondaire (Gris) */
.btn-download-all { background-color: var(--secondary-color); color: white; }

/* Bouton Correction (Gris - Non cliquable/titre) */
.btn-correction-title { 
    background-color: var(--secondary-color); 
    color: white; 
    cursor: default;
    opacity: 1 !important; /* Pour s'assurer qu'il a sa couleur normale même si le bouton est dans un set d'actions */
}

/* Bouton Correction Partie (Vert) */
.btn-correction-part {
    background-color: var(--correction-color);
    color: white;
}

.btn-secondary { background-color: var(--secondary-color); color: white; }
.btn-buy { background-color: #ffc107; color: black; width: 100%; }
.btn-buy img { height: 20px; }

/* AJOUT: Conteneur du bouton de téléchargement global */
.global-download-container { padding: 1rem; text-align: center; }
#btn-download-all-disciplines { padding: 12px 20px; font-size: 1rem; width: 100%; max-width: 450px; }

/* --- Modales --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; z-index: 2000; padding: 20px; }
.modal-content { background: white; padding: 25px; border-radius: var(--border-radius); max-width: 500px; width: 100%; position: relative; box-shadow: 0 5px 15px rgba(0,0,0,0.3); max-height: 90vh; overflow-y: auto;}
.close-btn { position: absolute; top: 10px; right: 15px; font-size: 1.8rem; cursor: pointer; color: #888; }
.modal-content h3 { margin-bottom: 15px; }
.modal-content p { margin-bottom: 15px; }
.modal-content .assistance { background-color: #f8f9fa; padding: 10px; border-radius: 5px; border: 1px solid #dee2e6; }
#activation-form { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
#activation-form input { padding: 10px; border: 1px solid #ccc; border-radius: 5px; }
#activation-feedback { margin-top: 10px; font-weight: bold; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Styles pour la progression du téléchargement multiple */
#multi-progress-container { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0; }
.discipline-progress-item { background: #f8f9fa; padding: 12px; border-radius: var(--border-radius); border: 1px solid #e9ecef; }
.discipline-progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 500; }
.progress-info-size { font-size: 0.9em; color: var(--primary-color); }
.progress-bar-container { width: 100%; background-color: #e0e0e0; border-radius: 5px; overflow: hidden; }
.progress-bar { width: 0%; height: 18px; background-color: var(--primary-color); transition: width 0.3s ease, background-color 0.3s; }
.progress-details { display: flex; justify-content: space-between; font-size: 0.85rem; color: #555; margin-top: 5px; }
.progress-current-file { font-size: 0.8rem; color: #777; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 1.2rem; margin-top: 4px; }
.total-download-info { text-align: right; margin-top: 1rem; font-weight: 500; color: var(--text-color); }

/* --- Pied de page --- */
footer { display: flex; justify-content: center; align-items: center; gap: 15px; text-align: center; padding: 1rem; background-color: #e9ecef; font-size: 0.9rem; color: #666; }
.footer-logo { height: 30px; }

/* --- Responsive Design --- */
@media (max-width: 768px) {
    h1 { font-size: 1.1rem; }
    .header-main { padding: 0.8rem 1rem; }
    .header-banner-img, .logo { height: 40px; }
    main { padding: 1rem; }
    .content-header h2 { font-size: 1.5rem; }
    .part-item { flex-direction: column; align-items: flex-start; gap: 10px; }
    .discipline-grid { gap: 1rem; }
    .discipline-card { padding: 1rem; }
    .discipline-card img { height: 50px; width: 50px; }
    .part-actions { 
        margin-top: 5px; 
        flex-direction: row; /* Pour que les boutons restent alignés horizontalement au lieu d'être empilés verticalement */
        flex-wrap: wrap-reverse; 
        justify-content: flex-start; /* Réinitialiser l'alignement sur mobile si nécessaire, mais flex-wrap fait le job */
        width: 100%; /* S'assurer qu'il prend toute la largeur pour le wrap */
    } 
}

.restricted-icon {
    font-size: 1.5rem;
    color: var(--secondary-color);
}

/* --- Partie de type Correction (obj: C) --- */
.part-item--correction {
    flex-direction: column;
    align-items: flex-start;
}

.part-title-correction {
    font-weight: 600;
    margin-bottom: 8px;
    width: 100%;
}

.part-actions--correction {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

/* Sur mobile : Énoncé en premier (pleine largeur), boutons verts en-dessous */
@media (max-width: 768px) {
    .part-actions--correction {
        flex-direction: column;
        align-items: flex-start;
    }

    .part-actions--correction .btn-enonce {
        order: -1;
        width: 100%;
    }

    .part-actions--correction .btn-correction-part {
        order: 1;
        width: 100%;
    }
}