:root {
    --primary-color: #2c3e50;
    --secondary-color: #e74c3c;
    --bg-color: #f8f9fa;
    --sidebar-bg: #ffffff;
    --text-color: #333333;
    --border-color: #e2e8f0;
    --hover-color: #ecf0f1;
}

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

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.app-container { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 300px; /* Un peu plus large pour l'indentation */
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 1.5em;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
}

#lesson-list { list-style: none; }

/* Niveau 1 : HSK */
.hsk-level {
    color: var(--secondary-color);
    font-size: 1.1em;
    margin: 10px 0 5px 0;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
    display: flex;
    align-items: center;
    font-weight: bold;
}
.hsk-level:hover { background-color: var(--hover-color); }
.hsk-level::before { content: '▶'; font-size: 0.7em; margin-right: 8px; transition: transform 0.3s ease; }
.hsk-level.open::before { transform: rotate(90deg); }

.lesson-group {
    list-style: none;
    padding-left: 20px;
    display: none;
}
.lesson-group.open { display: block; }

/* Niveau 2 : Leçon */
.lesson-item { margin-bottom: 4px; }
.lesson-title {
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    font-weight: 500;
    color: var(--primary-color);
    user-select: none;
}
.lesson-title:hover { background-color: var(--hover-color); }
.lesson-title::before { content: '▶'; font-size: 0.6em; margin-right: 6px; color: #95a5a6; transition: transform 0.3s ease; }
.lesson-title.open::before { transform: rotate(90deg); }

/* Niveau 3 : Catégories (Dialogues, Vocabulaire, Grammaire) */
.category-group {
    list-style: none;
    padding-left: 28px;
    display: none;
    margin-top: 2px;
    margin-bottom: 8px;
}
.category-group.open { display: block; }

.category-group a {
    text-decoration: none;
    color: #555;
    display: block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.9em;
    margin-bottom: 2px;
    border-left: 2px solid transparent;
}
.category-group a:hover, .category-group a.active {
    background-color: #f1f5f9;
    color: var(--primary-color);
    border-left: 2px solid var(--secondary-color);
    font-weight: bold;
}

/* Main Content */
.main-content {
    margin-left: 300px;
    padding: 40px;
    flex: 1;
    max-width: 1000px;
}

/* Typographie & Contenu */
.chinois { font-size: 1.4em; font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif; color: var(--primary-color); }
.pinyin { color: #666; font-size: 0.9em; font-style: italic; }

section { background: white; padding: 25px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); margin-bottom: 30px; }
h1 { color: var(--primary-color); margin-bottom: 30px; font-size: 2.2em; border-bottom: 3px solid var(--secondary-color); padding-bottom: 10px; }
h2.section-title { color: var(--secondary-color); margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
h3 { margin: 15px 0; color: var(--primary-color); }

table { width: 100%; border-collapse: collapse; margin-top: 15px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border-color); }
th { background-color: #f1f5f9; font-weight: 600; position: sticky; top: 0; }
tr:hover { background-color: #f8fafc; }

.dialogue-line { display: flex; margin-bottom: 15px; padding: 10px; background: #f8fafc; border-radius: 6px; }
.personnage { font-weight: bold; min-width: 50px; color: var(--secondary-color); }
.texte-content { flex: 1; }

.grammar-point { margin-bottom: 30px; }
.grammar-sub { background: #f8fafc; padding: 15px; border-left: 4px solid var(--secondary-color); margin: 15px 0; }
.structure { font-weight: bold; color: var(--primary-color); font-size: 1.1em; }
.example { margin-top: 10px; padding-left: 15px; border-left: 2px solid #cbd5e1; }

/* Bouton Outils Sidebar */
.tools-section { margin-bottom: 15px; }
#btn-export-vocab {
    width: 100%;
    background-color: #f1f5f9;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    text-align: left;
    transition: background-color 0.2s;
}
#btn-export-vocab:hover { background-color: #e2e8f0; }
.nav-divider { border: none; border-top: 2px solid var(--border-color); margin: 15px 0 20px 0; }

/* Bouton Audio */
.play-btn {
    cursor: pointer;
    font-size: 0.9em;
    margin-left: 8px;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.1s;
    user-select: none;
    display: inline-block;
}
.play-btn:hover { opacity: 1; transform: scale(1.2); }
.play-btn:active { transform: scale(0.9); }

/* Interface d'Export Vocabulaire */
.export-ui {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.export-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.export-controls select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    min-width: 200px;
}
.btn-generate, .btn-copy {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.btn-generate:hover, .btn-copy:hover { background-color: #c0392b; }
.btn-copy { background-color: var(--primary-color); margin-top: 10px; }
.btn-copy:hover { background-color: #1a252f; }
#export-result {
    width: 100%;
    height: 300px;
    padding: 15px;
    font-family: monospace;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
    white-space: pre;
}

/* --- Mode Révélation (Flashcard) --- */
.revealable {
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
    border-radius: 4px;
    padding: 5px;
}

.revealable:hover {
    background-color: #f1f5f9; /* Léger fond gris au survol pour montrer que c'est cliquable */
}

/* On masque le pinyin et la traduction par défaut */
.revealable .pinyin,
.revealable .traduction {
    display: none;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #cbd5e1;
}

/* Classe ajoutée par le JavaScript lors du clic */
.revealable.revealed .pinyin,
.revealable.revealed .traduction {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Petit indicateur visuel */
.revealable:not(.revealed)::after {
    content: '👁️';
    font-size: 0.75em;
    color: #94a3b8;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none; /* Pour ne pas gêner le clic */
}

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