@font-face {
    font-family: "AR PL KaitiM GB";
    src: url("https://db.onlinewebfonts.com/t/157c7e79f7f057bbeacf5f113b964875.eot");
    src: url("https://db.onlinewebfonts.com/t/157c7e79f7f057bbeacf5f113b964875.eot?#iefix") format("embedded-opentype"),
    url("https://db.onlinewebfonts.com/t/157c7e79f7f057bbeacf5f113b964875.woff2") format("woff2"),
    url("https://db.onlinewebfonts.com/t/157c7e79f7f057bbeacf5f113b964875.woff") format("woff"),
    url("https://db.onlinewebfonts.com/t/157c7e79f7f057bbeacf5f113b964875.ttf") format("truetype"),
    url("https://db.onlinewebfonts.com/t/157c7e79f7f057bbeacf5f113b964875.svg#AR PL KaitiM GB") format("svg");
}

:root { 
    --accent: #438d67; 
    --bg: #f1f2f6;
    --card-bg: #ffffff;
    --text-main: #2f3542;
    --text-muted: #747d8c;
    --sidebar-bg: #2f3542;
    --sidebar-text: #ffffff;
    --border-color: #e1e3e8;
}

* { box-sizing: border-box; }

body { 
    font-family: 'Inter', "AR PL KaitiM GB", sans-serif; 
    background: var(--bg); 
    color: var(--text-main);
    margin: 0; 
    padding: 0;
    display: flex;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Application de la police sur les titres et l'interface */
h1, h2, h3, h4, .sidebar, .markdown-body {
    font-family: 'Inter', "AR PL KaitiM GB", sans-serif;
}

.layout {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease, transform 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    margin-left: -300px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.sidebar-header h2 { margin: 0; font-size: 1.2rem;}

#lesson-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

#lesson-list li {
    padding: 12px 15px;
    margin-bottom: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-weight: 500;
}

#lesson-list li:hover, #lesson-list li.active {
    background: var(--accent);
}

/* --- MAIN CONTENT --- */
.content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    position: relative;
    transition: width 0.3s ease;
}

.top-bar { margin-bottom: 20px; }

.menu-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: 0.2s;
}

.menu-btn:hover { opacity: 0.9; transform: translateY(-2px); }

.icon-btn {
    background: transparent;
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.icon-btn:hover { background: rgba(255,255,255,0.1); }

.card { 
    background: var(--card-bg); 
    padding: 50px; 
    border-radius: 20px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.05); 
    max-width: 900px;
    margin: 0 auto;
}

.hidden { display: none !important; }

/* --- EMBELLISSEMENT DU MARKDOWN --- */
.markdown-body {
    line-height: 1.8;
    color: var(--text-main);
    font-size: 1.05rem;
}

.markdown-body h1 {
    font-size: 2.5em;
    color: var(--text-main);
    margin-bottom: 30px;
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.markdown-body h2 {
    color: var(--accent);
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 1.7em;
}

.markdown-body h3 {
    margin-top: 30px;
    color: var(--text-main);
}

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-bottom-color 0.2s;
}

.markdown-body a:hover {
    border-bottom-color: var(--accent);
}

.markdown-body p {
    margin-bottom: 1.5em;
}

/* Citations stylisées */
.markdown-body blockquote {
    border-left: 5px solid var(--accent);
    margin: 1.5em 0;
    padding: 15px 20px;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(67, 141, 103, 0.05);
    border-radius: 0 8px 8px 0;
}

/* Code en ligne et blocs de code */
.markdown-body code {
    background: rgba(0,0,0,0.06);
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    color: #e15f41;
}

.markdown-body pre {
    background: #2f3542;
    color: #f1f2f6;
    padding: 20px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 2em 0;
}

.markdown-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Tableaux stylisés et condensés */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0; /* Réduit un peu la marge extérieure */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--border-color);
    font-size: 0.95rem; /* Optionnel : réduit légèrement la taille du texte pour gagner de la place */
}

.markdown-body th, .markdown-body td {
    padding: 6px 12px; /* Réduit de 12px/15px à 6px/12px */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.0;  /* Force une hauteur de ligne plus courte que le reste du texte (1.8) */
}

.markdown-body th {
    background: rgba(0,0,0,0.03);
    font-weight: 600;
}

/* Images avec légendes générées par le JS */
.custom-image-wrapper {
    margin: 2em 0;
    text-align: center;
}

.custom-image-wrapper img {
    max-width: 100%; /* Reste responsive sur petit écran */
    max-height: 500px; /* Empêche l'image de prendre tout l'écran */
    width: auto; /* Conserve les proportions */
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    display: inline-block;
}

.custom-image-wrapper figcaption {
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--text-muted);
    font-style: italic;
}

/* --- MOBILE --- */
@media (max-width: 768px) {
    .content { padding: 15px; }
    .card { padding: 25px; }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        margin-left: 0 !important;
        transform: translateX(-100%);
        box-shadow: 5px 0 25px rgba(0,0,0,0.5);
    }
    
    .sidebar.mobile-open { 
        transform: translateX(0); 
    }
    
    .markdown-body h1 { font-size: 2em; }
}

/* --- MISE EN PAGE CÔTE À CÔTE (Image + Vocabulaire) --- */
.lesson-header-layout {
    display: flex;
    align-items: flex-start;
    gap: 40px;
    margin-top: 20px;
    margin-bottom: 40px;
}

.layout-left {
    flex: 1;
    min-width: 250px;
}

.layout-right {
    flex: 1.5;
    min-width: 0; /* Indispensable pour empêcher le tableau de casser la largeur */
}

/* On écrase les marges par défaut pour un alignement parfait en haut */
.lesson-header-layout .custom-image-wrapper {
    margin: 0;
}

.lesson-header-layout h2 {
    margin-top: 0;
    margin-bottom: 15px;
}

.lesson-header-layout table {
    margin-top: 0;
}

/* Sur mobile, on remet tout l'un en dessous de l'autre */
@media (max-width: 768px) {
    .lesson-header-layout {
        flex-direction: column;
        gap: 20px;
    }
    .layout-left, .layout-right {
        width: 100%;
    }
}