/* CSS Global - Thème Blanc et Moderne (V3) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&display=swap');

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --accent-color: #8b5cf6;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --error-color: #ef4444;
    
    /* Couleurs des Fiches (Thèmes) */
    --fiche-math: #f3e8ff;
    --fiche-physique: #e0f2fe;
    --fiche-sin: #dcfce7;
    --fiche-itec: #fef08a;
    --fiche-tronc: #ffedd5;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.8;
}

/* Header & Navigation */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 2.5rem 1rem;
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-weight: 700;
    font-size: 2.8rem;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.15rem;
    opacity: 0.9;
}

nav {
    background-color: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav ul {
    display: flex;
    justify-content: center;
    list-style: none;
    flex-wrap: wrap;
}

nav a {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

nav a:hover, nav a.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: #f1f5f9;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Sections des matières */
.subject-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 3rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.subject-card h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 2.2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Système d'onglets (Tabs) */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s;
    border-bottom: 4px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

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

/* Fiches & Cours */
h3 {
    margin-top: 3rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

h4 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-main);
    font-size: 1.3rem;
}

p, ul, ol {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
}

ul, ol {
    padding-left: 2rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Design des Formules dans le cours */
.formula-card {
    background-color: #f1f5f9;
    border-left: 6px solid var(--primary-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.formula-card strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.formula-card code {
    font-family: 'Fira Code', monospace;
    font-size: 1.2rem;
    color: #0f172a;
    display: block;
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    margin-top: 0.5rem;
}

/* Boîtes d'Exemples */
.example-box {
    background-color: #f0fdf4;
    border-left: 6px solid #22c55e;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.example-box::before {
    content: "💡 Exemple détaillé :";
    display: block;
    font-weight: 700;
    color: #166534;
    margin-bottom: 0.75rem;
    font-size: 1.15rem;
}

/* Schémas Mermaid */
.schema-container {
    background-color: white;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 2.5rem;
    margin: 2.5rem 0;
    text-align: center;
    overflow-x: auto;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.schema-caption {
    text-align: center;
    font-style: italic;
    color: var(--text-muted);
    margin-top: 1rem;
    font-size: 1rem;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

th, td {
    border: 1px solid var(--border-color);
    padding: 1rem;
    text-align: left;
}

th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: var(--text-main);
    font-size: 1.1rem;
}

/* ========================================= */
/* DESIGN PREMIUM DES FICHES (V4 - UTLIME)   */
/* ========================================= */

.fiche-premium-container {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background: white;
    /* On enlève le padding de la subject-card s'il y en a un pour ce container, 
       car on veut gérer l'espace avec le header premium */
}

/* En-tête de la fiche */
.fiche-premium-header {
    border-radius: 12px;
    padding: 2.5rem;
    margin-bottom: 2.5rem;
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.fiche-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.fiche-premium-header h2 {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: white;
    border: none;
    padding: 0;
}

.fiche-premium-header p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin: 0;
}

/* Grille principale (2 colonnes) */
.fiche-premium-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
}

/* Cartes de sections */
.fiche-section {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    overflow: hidden;
    margin-bottom: 2rem;
    page-break-inside: avoid;
}

.fiche-section-title {
    padding: 1rem 1.5rem;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.fiche-section-content {
    padding: 1.5rem;
}

/* Sous-titres à l'intérieur des cartes */
.fiche-subsection-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    display: block;
}

.fiche-section-content > .fiche-subsection-title:first-child {
    margin-top: 0;
}

.fiche-text {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Boîtes de formules */
.fiche-box-light {
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    text-align: center;
}

.fiche-box-dark {
    background-color: #0f172a;
    color: white;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    text-align: center;
}

.fiche-box-tinted {
    background-color: #fdf2f8; /* Ex: rose pastel */
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

/* Grilles internes pour mettre des boîtes côte à côte */
.fiche-split-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.fiche-split-2 .fiche-box-light,
.fiche-split-2 .fiche-box-tinted {
    margin-bottom: 0;
}

/* Typographie spécifique dans les boîtes */
.box-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
}

.fiche-box-dark .box-label {
    color: #94a3b8;
}

.box-formula {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0.5rem 0;
}

/* Thèmes de Couleurs pour les Fiches Premium */
/* ITEC (Orange/Rouge) */
.theme-itec .fiche-premium-header { background: linear-gradient(135deg, #f97316, #ea580c); }
.theme-itec .fiche-section-title { background: #ea580c; }
.theme-itec .fiche-subsection-title { color: #ea580c; }
.theme-itec .fiche-box-tinted { background: #ffedd5; } /* Orange très clair */

/* SIN (Vert) */
.theme-sin .fiche-premium-header { background: linear-gradient(135deg, #22c55e, #16a34a); }
.theme-sin .fiche-section-title { background: #16a34a; }
.theme-sin .fiche-subsection-title { color: #16a34a; }
.theme-sin .fiche-box-tinted { background: #dcfce7; }

/* Tronc Commun (Jaune/Moutarde) */
.theme-tronc .fiche-premium-header { background: linear-gradient(135deg, #eab308, #ca8a04); }
.theme-tronc .fiche-section-title { background: #ca8a04; }
.theme-tronc .fiche-subsection-title { color: #ca8a04; }
.theme-tronc .fiche-box-tinted { background: #fef08a; }

/* Physique (Bleu) */
.theme-physique .fiche-premium-header { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.theme-physique .fiche-section-title { background: #0284c7; }
.theme-physique .fiche-subsection-title { color: #0284c7; }
.theme-physique .fiche-box-tinted { background: #e0f2fe; }

/* Maths (Violet) */
.theme-math .fiche-premium-header { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.theme-math .fiche-section-title { background: #7c3aed; }
.theme-math .fiche-subsection-title { color: #7c3aed; }
.theme-math .fiche-box-tinted { background: #f3e8ff; }


/* ========================================= */
/* MEDIA PRINT - POUR IMPRIMER LA FICHE A4 */
/* ========================================= */
@media print {
    /* Cacher tout ce qui n'est pas la fiche */
    header, nav, .tabs, button, .quiz-container, #cours, #exercices {
        display: none !important;
    }

    body {
        background-color: white;
        color: black;
    }

    .container {
        margin: 0;
        padding: 0;
        max-width: 100%;
    }

    .subject-card {
        box-shadow: none;
        padding: 0;
        margin: 0;
        border: none;
    }

    /* On force l'affichage de l'onglet fiche à l'impression */
    #fiche {
        display: block !important;
    }

    /* Forcer l'impression des couleurs de fond et gradients */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .fiche-premium-layout {
        display: grid;
        grid-template-columns: 1fr 1fr; /* Maintient les 2 colonnes */
        gap: 1.5rem;
    }

    /* On évite les coupures de sections au milieu d'une page */
    .fiche-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* ========================================= */
/* RESPONSIVE DESIGN (MOBILE & TABLETTE)     */
/* ========================================= */

@media (max-width: 900px) {
    .fiche-premium-layout {
        grid-template-columns: 1fr;
    }
    .fiche-split-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Header et Navigation */
    header {
        padding: 1.5rem 1rem;
    }
    header h1 {
        font-size: 2rem;
    }
    header p {
        font-size: 1rem;
    }
    
    nav ul {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px; /* Pour la barre de scroll */
    }
    nav a {
        white-space: nowrap;
        padding: 0.75rem 1rem;
        border-bottom: 3px solid transparent;
        border-left: none;
    }
    nav a.active {
        border-bottom-color: var(--primary-color);
        border-left-color: transparent;
    }
    
    /* Container et Cartes */
    .container {
        margin: 1rem auto;
    }
    .subject-card, .quiz-app, .fiche-premium-header {
        padding: 1.5rem;
        border-radius: 8px;
    }
    .subject-card h2, .fiche-premium-header h2 {
        font-size: 1.6rem;
    }
    
    /* Onglets (Tabs) */
    .tabs {
        flex-direction: column;
        gap: 0.5rem;
        border-bottom: none;
    }
    .tab-btn {
        width: 100%;
        background-color: #f1f5f9;
        border-radius: 8px;
        margin-bottom: 0;
        border-bottom: none;
        border-left: 4px solid transparent;
        padding: 0.75rem 1rem;
    }
    .tab-btn.active {
        border-bottom: none;
        border-left-color: var(--primary-color);
        background-color: #e2e8f0;
    }
    
    /* Typographie Fiche / Cours */
    h3 {
        font-size: 1.3rem;
    }
    h4 {
        font-size: 1.15rem;
    }
    p, ul, ol, .fiche-text, .quiz-question-text {
        font-size: 1rem;
    }
    
    /* Formules */
    .formula-card, .example-box {
        padding: 1rem;
    }
    .box-formula {
        font-size: 1.1rem;
    }
    
    /* Quiz */
    .quiz-option-btn {
        padding: 1rem;
        font-size: 0.95rem;
    }
    .quiz-option-btn .opt-letter {
        width: 25px;
        height: 25px;
        font-size: 0.85rem;
        margin-right: 0.75rem;
    }
    .quiz-header {
        margin-bottom: 1rem;
    }
    .quiz-start-screen h3, .quiz-score-screen h3 {
        font-size: 1.5rem;
    }
    .score-circle {
        width: 120px;
        height: 120px;
    }
    .score-number {
        font-size: 2.5rem;
    }
}

/* ========================================= */
/* SYSTEME DE QUIZ INTERACTIF (V5)           */
/* ========================================= */

.quiz-app {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    padding: 2.5rem;
    margin-top: 2rem;
    border: 1px solid var(--border-color);
}

.quiz-start-screen, .quiz-score-screen {
    text-align: center;
    padding: 3rem 1rem;
}

.quiz-start-screen h3, .quiz-score-screen h3 {
    font-size: 2rem;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.quiz-primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    margin-top: 1.5rem;
    display: inline-block;
}

.quiz-primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.quiz-primary-btn:active {
    transform: translateY(0);
}

.quiz-header {
    margin-bottom: 2rem;
}

.quiz-progress-text {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-align: right;
}

.quiz-progress-bar {
    width: 100%;
    height: 10px;
    background-color: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transition: width 0.4s ease;
    border-radius: 10px;
}

.quiz-question-container {
    animation: fadeIn 0.4s ease;
}

.quiz-question-text {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.quiz-options-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.quiz-option-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    background-color: white;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.quiz-option-btn:hover:not(.disabled) {
    border-color: var(--primary-color);
    background-color: #f8fafc;
}

.quiz-option-btn .opt-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background-color: #f1f5f9;
    color: var(--text-muted);
    border-radius: 50%;
    font-weight: 700;
    margin-right: 1rem;
    flex-shrink: 0;
}

.quiz-option-btn:hover:not(.disabled) .opt-letter {
    background-color: var(--primary-color);
    color: white;
}

.quiz-option-btn .opt-text {
    flex-grow: 1;
}

/* États après réponse */
.quiz-option-btn.disabled {
    cursor: default;
    opacity: 0.7;
}

.quiz-option-btn.correct {
    background-color: #ecfdf5;
    border-color: #10b981;
    color: #065f46;
    opacity: 1;
}

.quiz-option-btn.correct .opt-letter {
    background-color: #10b981;
    color: white;
}

.quiz-option-btn.wrong {
    background-color: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
    opacity: 1;
}

.quiz-option-btn.wrong .opt-letter {
    background-color: #ef4444;
    color: white;
}

.quiz-feedback {
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.4s ease;
}

.quiz-feedback.success {
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.quiz-feedback.error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.quiz-feedback strong {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.hidden {
    display: none !important;
}

/* Score Circle */
.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 2rem auto;
    background: #f8fafc;
    border: 8px solid var(--border-color);
}

.score-number {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
}

.score-total {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.score-excellent {
    border-color: #10b981;
    color: #059669;
}

.score-good {
    border-color: #f59e0b;
    color: #d97706;
}

.score-bad {
    border-color: #ef4444;
    color: #dc2626;
}

.score-message {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: var(--text-muted);
}

