/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    /* Couleurs */
    --bg-gradient-1: #0f2027;
    --bg-gradient-2: #203a43;
    --bg-gradient-3: #2c5364;
    --primary-green: #00b09b;
    --accent-blue: #96c93d;
    --danger: #e74c3c;
    
    /* UI & Verre */
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-main: #ecf0f1;
    --text-muted: #bdc3c7;
    
    /* Dimensions */
    --sidebar-width: 280px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background: linear-gradient(-45deg, var(--bg-gradient-1), var(--bg-gradient-2), var(--bg-gradient-3), #1a4a5a);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

h1, h2 { font-weight: 300; letter-spacing: 1px; }
h2 { color: var(--primary-green); margin-top: 0; }
a { text-decoration: none; color: inherit; }

/* =========================================
   2. LAYOUT & STRUCTURE
   ========================================= */
main {
    flex: 1;
    padding: 3rem;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Gestion des Vues (SPA) */
.view-section {
    display: none;
    width: 100%;
    height: 100%;
    padding: 2rem;
    overflow-y: auto;
    animation: fadeIn 0.5s ease-out;
}
.view-section.active { display: block; }

/* Vue Accueil Spécifique (Centrage) */
#view-home.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
    overflow: hidden;
}

/* Sidebar */
aside {
    width: var(--sidebar-width);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem;
    display: none; /* Caché par défaut */
    flex-direction: column;
    gap: 2rem;
    box-shadow: 5px 0 15px rgba(0,0,0,0.3);
}
aside.active { display: flex; }

.brand {
    font-size: 1.5rem;
    font-weight: bold;
    background: linear-gradient(to right, var(--primary-green), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* =========================================
   3. COMPOSANTS UI
   ========================================= */
/* Glassmorphism Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    animation: slideIn 0.6s ease-out;
}

.hero-card {
    max-width: 1000px;
    text-align: center;
    background: rgba(15, 32, 39, 0.7);
    backdrop-filter: blur(20px);
    z-index: 10;
}

/* Boutons */
button {
    padding: 1rem;
    border: 1px solid var(--primary-green);
    background: rgba(0, 176, 155, 0.1);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}
button:hover {
    background: var(--primary-green);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 176, 155, 0.4);
}
.cta-btn {
    background: linear-gradient(90deg, var(--primary-green), var(--accent-blue));
    padding: 1.2rem 3rem;
    font-weight: bold;
    border: none;
}

/* Jauges & Métriques */
.metric-container { margin-bottom: 1.5rem; }
.metric-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255,255,255,0.7);
    margin-bottom: 0.5rem;
}
.progress-track {
    background: rgba(0, 0, 0, 0.5);
    height: 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}
/* Variantes Jauges */
.progress-fill.tech { background: linear-gradient(90deg, #3498db, #9b59b6); box-shadow: 0 0 15px rgba(52, 152, 219, 0.6); }
.progress-fill.safe { background: linear-gradient(90deg, #2ecc71, #27ae60); box-shadow: 0 0 10px rgba(46, 204, 113, 0.4); }
.progress-fill.warning { background: linear-gradient(90deg, #f1c40f, #e67e22); box-shadow: 0 0 15px rgba(230, 126, 34, 0.6); }
.progress-fill.critical { background: linear-gradient(90deg, #e74c3c, #c0392b); animation: pulse-critical 1s infinite alternate; }

/* Modale */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-content {
    background: linear-gradient(135deg, #1e2a33, #0f2027);
    border: 2px solid var(--primary-green);
    padding: 2.5rem;
    border-radius: 20px;
    max-width: 500px;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.active .modal-content { transform: scale(1); }
.impact-row {
    display: flex; justify-content: center; gap: 1.5rem;
    background: rgba(0,0,0,0.3); padding: 10px; border-radius: 10px;
    margin: 1.5rem 0; font-family: monospace; font-size: 1.1rem; font-weight: bold;
}

/* =========================================
   4. MODULES SPÉCIFIQUES
   ========================================= */

/* --- MENU ACCUEIL --- */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}
.menu-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    padding: 2rem;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s;
}
.menu-item:hover {
    background: rgba(0, 176, 155, 0.2);
    transform: translateY(-10px);
    border-color: var(--primary-green);
}
.menu-item .icon { font-size: 3rem; margin-bottom: 1rem; }

/* --- JEU (MISSION) --- */
.scenario-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: center;
}
.visual-column {
    position: relative;
    height: 400px;
    background-color: rgba(0,0,0,0.2);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.visual-column img {
    width: 100%; height: 100%; object-fit: cover;
    opacity: 0; animation: fadeInImg 0.5s ease forwards;
}
.ceo-request {
    font-style: italic;
    border-left: 4px solid var(--accent-blue);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: #fff;
    font-size: 1.1rem;
}

/* --- COURS (LESSONS) --- */
#lesson-container { width: 90%; max-width: 1200px; margin: 0 auto; padding-bottom: 5rem; }
.chapter-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem; margin-top: 2rem;
}
.chapter-card {
    cursor: pointer; transition: all 0.3s ease;
    border-left: 5px solid transparent; padding: 2rem;
    position: relative; overflow: hidden;
}
.chapter-card:hover { transform: translateY(-5px); border-left-color: var(--primary-green); }
.chapter-number {
    font-size: 4rem; position: absolute; top: -10px; right: 10px;
    color: rgba(255, 255, 255, 0.05); font-weight: bold;
}

/* Lecteur Markdown */
.lesson-header { text-align: center; margin-bottom: 4rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.lesson-header h1 { font-size: 3rem; color: var(--primary-green); }
.subsection { margin-bottom: 5rem; }
.subsection-visual {
    width: 100%; height: 250px;
    border-radius: 16px; overflow: hidden; margin-bottom: 2rem;
    border: 1px solid rgba(255,255,255,0.1);
}
.subsection-visual img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.subsection-text h3 {
    font-size: 2rem; margin-bottom: 1.5rem; color: #fff;
    border-left: 5px solid var(--primary-green); padding-left: 1rem;
}
.md-content { font-size: 1.2rem; line-height: 1.8; color: #e0e0e0; max-width: 900px; margin: 0 auto; }
.md-content p, .md-content ul { margin-bottom: 1.5rem; }
.md-content li::marker { color: var(--primary-green); }
.md-content strong { color: white; font-weight: 700; }

/* --- RESSOURCES (REF) --- */
.ref-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem; max-width: 1200px; margin: 0 auto;
}
.ref-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.ref-icon { font-size: 2rem; }
.ref-link-item {
    display: block; background: rgba(255,255,255,0.05); padding: 1rem;
    border-radius: 8px; transition: transform 0.2s, background 0.2s;
    border-left: 3px solid transparent;
}
.ref-link-item:hover { background: rgba(255,255,255,0.1); transform: translateX(5px); border-left-color: var(--primary-green); }

/* --- CHATBOT --- */
#chatbot-widget {
    position: fixed; bottom: 20px; right: 20px; width: 350px;
    background: #1e2a33; border: 1px solid var(--primary-green); border-radius: 15px;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); z-index: 1000;
    transform: translateY(110%); transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#chatbot-widget.active { transform: translateY(0); }
.chat-header { background: var(--primary-green); padding: 10px 15px; font-weight: bold; display: flex; justify-content: space-between; cursor: pointer; }
#chat-toggle {
    position: fixed; bottom: 20px; right: 20px; width: 60px; height: 60px;
    border-radius: 50%; background: var(--primary-green); border: none;
    box-shadow: 0 0 20px var(--primary-green); cursor: pointer; font-size: 24px;
    z-index: 1001; transition: transform 0.2s;
}
#chat-toggle:hover { transform: scale(1.1); }
.chat-body { height: 300px; padding: 10px; overflow-y: auto; }
.chat-input-area { display: flex; border-top: 1px solid #333; }
.chat-input-area input { flex: 1; background: #111; border: none; padding: 10px; color: white; outline: none; }
.msg { margin-bottom: 8px; padding: 8px; border-radius: 8px; max-width: 80%; }
.msg.user { background: var(--accent-blue); align-self: flex-end; color: #111; margin-left: auto; }
.msg.bot { background: #34495e; color: #ddd; }

/* =========================================
   5. ANIMATIONS & BACKGROUNDS
   ========================================= */
@keyframes gradientBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInImg { to { opacity: 1; } }
@keyframes pulse-critical { 0% { box-shadow: 0 0 15px rgba(231, 76, 60, 0.5); } 100% { box-shadow: 0 0 30px rgba(231, 76, 60, 1); } }

/* Zen Mode (Lucioles & Vagues) */
.nature-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 1; overflow: hidden;
    background: radial-gradient(circle at bottom center, #1b3a4b 0%, transparent 70%);
}
.firefly {
    position: absolute; bottom: -5%; width: 6px; height: 6px;
    background-color: var(--primary-green); border-radius: 50%;
    opacity: 0; filter: blur(2px);
    box-shadow: 0 0 10px var(--primary-green), 0 0 20px var(--accent-blue);
    animation: riseAndShine 15s infinite ease-in-out;
}
@keyframes riseAndShine {
    0% { opacity: 0; transform: translateY(0) translateX(0) scale(0.5); }
    20% { opacity: 0.6; }
    50% { opacity: 0.8; transform: translateY(-40vh) translateX(20px) scale(1); }
    80% { opacity: 0.3; }
    100% { opacity: 0; transform: translateY(-90vh) translateX(-20px) scale(0.5); }
}
/* Délais aléatoires Lucioles */
.firefly:nth-child(1) { left: 10%; animation-duration: 25s; animation-delay: 0s; }
.firefly:nth-child(2) { left: 20%; animation-duration: 35s; animation-delay: 5s; background: var(--accent-blue); }
.firefly:nth-child(3) { left: 35%; animation-duration: 28s; animation-delay: 2s; }
.firefly:nth-child(4) { left: 50%; animation-duration: 40s; animation-delay: 10s; }
.firefly:nth-child(5) { left: 65%; animation-duration: 32s; animation-delay: 1s; background: #f1c40f; }
.firefly:nth-child(6) { left: 80%; animation-duration: 22s; animation-delay: 7s; }
.firefly:nth-child(7) { left: 90%; animation-duration: 38s; animation-delay: 12s; }
.firefly:nth-child(8) { left: 15%; animation-duration: 45s; animation-delay: 18s; }
.firefly:nth-child(9) { left: 55%; animation-duration: 29s; animation-delay: 15s; background: var(--accent-blue); }

.wave {
    position: absolute; bottom: -20px; left: 0; width: 200%; height: 120px;
    background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1440 320" xmlns="http://www.w3.org/2000/svg"><path fill="%2300b09b" fill-opacity="0.05" d="M0,224L48,213.3C96,203,192,181,288,181.3C384,181,480,203,576,224C672,245,768,267,864,261.3C960,256,1056,224,1152,197.3C1248,171,1344,149,1392,138.7L1440,128L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"></path></svg>');
    background-size: 50% 100%; animation: waveMove 60s linear infinite; z-index: 0; opacity: 0.6;
}
@keyframes waveMove { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

/* =========================================
   6. RESPONSIVE (MOBILE)
   ========================================= */
@media (max-width: 900px) {
    body { flex-direction: column; overflow-y: auto; height: auto; }
    main { padding: 1rem !important; width: 100%; height: auto; overflow: visible; }
    h1 { font-size: 1.8rem; } h2 { font-size: 1.5rem; } p { font-size: 1rem; }

/* Sidebar Mobile (Version Verticale & Propre) */
    aside.active {
        position: relative;
        width: 100%;
        height: auto;
        
        /* C'est ici que ça change : on empile verticalement */
        display: flex;
        flex-direction: column; 
        
        background: rgba(15, 32, 39, 0.95); /* Fond opaque pour bien lire */
        padding: 1rem;
        gap: 0.8rem;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.2);
        z-index: 1000;
    }

    aside .brand {
        width: 100%;
        text-align: left;
        margin-bottom: 0.5rem;
        font-size: 1rem;
    }

    aside .metric-container {
        width: 100%; /* Prend toute la largeur */
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
    }

    /* Ajustements pour gagner de la place */
    aside .metric-label { font-size: 0.8rem; margin-bottom: 2px; }
    aside .progress-track { height: 8px; }

    aside button {
        width: 100%;
        padding: 0.5rem;
        margin-top: 0.5rem;
        font-size: 0.9rem;
        background: rgba(255,255,255,0.1);
    }

    /* Layouts Mobile */
    .menu-grid, .scenario-grid, .chapter-grid, .ref-grid { grid-template-columns: 1fr; }
    #view-home.active { justify-content: flex-start; padding-top: 4rem; }
    .scenario-grid { display: flex; flex-direction: column; gap: 1rem; }
    .visual-column { height: 200px; width: 100%; }
    .subsection { flex-direction: column; gap: 1.5rem; margin-bottom: 3rem; }
    .subsection-visual { width: 100%; height: 200px; order: -1; position: static; }
    #lesson-container { width: 100%; padding: 0 0.5rem 5rem 0.5rem; }
    .lesson-header h1 { font-size: 2rem; }
    .modal-content { width: 95%; padding: 1.5rem; margin: auto; }
    #chatbot-widget { width: 100%; right: 0; bottom: 0; border-radius: 15px 15px 0 0; }
    #chat-toggle { bottom: 10px; right: 10px; width: 50px; height: 50px; }
}