/* =========================================
   1. VARIABLES & BASE
   ========================================= */
:root {
    --sega-blue: #00a3ff;       /* Megadrive (Défaut) */
    --neon-color: #bc13fe;      /* Violet Néon */
    --sidebar-bg: #ffffff;
    --content-bg: #f4f4f4;
    --header-height: 65px;

    /* NOUVELLES COULEURS POUR LES THÈMES */
    --mca-orange: #ff8c00;      /* MakeCode Arcade */
    --fab-dark: #004488;        /* Fabrication : Bleu Foncé */
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background-color: var(--content-bg);
    color: #333;
    overflow-x: hidden;
}

/* =========================================
   2. HEADER (BANDEAU NOIR)
   ========================================= */
.header-mini {
    background: linear-gradient(180deg, #1a1a1a 0%, #000000 100%);
    height: 65px; 
    display: flex;  
    align-items: center;  
    padding: 0 20px;
    border-bottom: 3px solid var(--sega-blue);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 100;
}
.logo-mini { height: 40px; margin-right: 15px; }

/* Le titre SEGA par défaut */
.sega-blue {
    color: var(--sega-blue);
    font-family: 'Arial Black', sans-serif; 
    font-weight: 900; 
    text-transform: uppercase;
    font-size: 0.95rem;
    letter-spacing: 1px;
    margin-right: 5px;
    -webkit-font-smoothing: antialiased;
}

.neon-text {
    color: #fff;
    font-size: 1.1rem;
    text-shadow: 0 0 5px var(--neon-color), 0 0 10px var(--neon-color);
    animation: breathe 3s ease-in-out infinite alternate;
}

@keyframes breathe {
    from { opacity: 0.7; }
    to { opacity: 1; text-shadow: 0 0 10px var(--neon-color), 0 0 20px var(--neon-color); }
}

/* =========================================
   3. MISE EN PAGE
   ========================================= */
.main-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    width: 100%;
}

/* LE MENU GAUCHE */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid #ddd;
    padding: 20px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin-bottom: 15px; }
.sidebar a { 
    text-decoration: none; 
    color: #555; 
    font-weight: bold; 
    display: block;
    padding: 10px;
    border-radius: 5px;
    transition: all 0.2s;
}

/* Comportement par défaut (Megadrive) */
.sidebar a:hover { background: #f0f0f0; color: var(--sega-blue); }
.sidebar a.active { 
    color: white; 
    background: var(--sega-blue); 
}

/* LA ZONE DE DROITE (CONTENU) */
.content-area {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
    background-color: var(--content-bg);
}

/* =========================================
   4. ELEMENTS SPÉCIFIQUES COURS (Vidéo & Texte)
   ========================================= */
.course-container {
    max-width: 900px;
    margin: 0 auto;
    background: transparent;
}

/* Titre de la leçon (H1) */
.course-header h1 {
    color: var(--sega-blue); /* Par défaut */
    margin-top: 0;
    font-size: 2rem;
    border-left: 6px solid var(--sega-blue); /* Par défaut */
    padding-left: 20px;
}

/* Vidéo */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin: 30px 0;
    border-radius: 12px;
    border: 4px solid #222;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    background: black;
}
.video-wrapper iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

/* Texte explicatif */
.content-text {
    background: #ffffff;
    padding: 40px;
    border-radius: 8px;
    line-height: 1.8;
    font-size: 1.1rem;
    color: #333;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.content-text h2 {
    color: var(--sega-blue); /* Par défaut */
    margin-top: 40px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

/* Code Blocks */
pre {
    background: #1e1e1e;
    color: #00ff41;
    padding: 20px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    border: 1px solid #444;
    margin: 20px 0;
}

code {
    background: #f0f0f0;
    padding: 2px 5px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #d63384;
    font-weight: bold;
}

/* Lien de retour */
.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #666;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
}
.back-link:hover { color: var(--sega-blue); text-decoration: underline; }

/* =========================================
   5. ELEMENTS DIVERS
   ========================================= */
.cards-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.lesson-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-left: 5px solid #ccc;
}
.lesson-card.new { border-left-color: var(--sega-blue); }
.badge {
    background: var(--sega-blue);
    color: white;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 10px;
    float: right;
}
.btn-read {
    color: var(--sega-blue);
    text-decoration: none;
    font-weight: bold;
    margin-top: 10px;
    display: inline-block;
}

.tools-container {
    display: flex;
    gap: 40px;
    margin: 20px 0;
    flex-wrap: wrap;
}
.tool-logo-only {
    width: 150px; 
    height: 150px;
    object-fit: contain;
    filter: drop-shadow(5px 5px 10px rgba(0,0,0,0.3));
    transition: transform 0.3s ease;
}
.tool-logo-link:hover .tool-logo-only {
    transform: scale(1.1);
    filter: drop-shadow(0 0 15px var(--sega-blue));
}


/* =========================================
   6. GESTION DES THÈMES (OVERRIDE)
   ========================================= */

/* --- THÈME FABRICATION (Bleu Foncé & Liseré) --- */

/* A. Le Titre "SEGA" dans le bandeau -> Blanc + Liseré Bleu Foncé */
.theme-fabrication .header-mini .sega-blue {
    color: white !important;
    text-shadow: 
        -2px -2px 0 var(--fab-dark),  
         2px -2px 0 var(--fab-dark),
        -2px  2px 0 var(--fab-dark),
         2px  2px 0 var(--fab-dark);
}

/* B. Tout le reste -> Bleu Foncé SANS liseré */
.theme-fabrication .course-header h1,
.theme-fabrication .content-text h2,
.theme-fabrication .back-link:hover,
.theme-fabrication .btn-read,
.theme-fabrication .sidebar a:hover {
    color: var(--fab-dark) !important;
    border-color: var(--fab-dark); /* Pour le H1 et les bordures */
}

/* C. Backgrounds */
.theme-fabrication .sidebar a.active,
.theme-fabrication .badge {
    background: var(--fab-dark) !important;
}

/* D. Bordures spéciales */
.theme-fabrication .header-mini,
.theme-fabrication .lesson-card.new {
    border-color: var(--fab-dark) !important;
}

/* E. Correction Bug Disparition Menu */
.theme-fabrication .sidebar a.active:hover {
    color: white !important;
    background: var(--fab-dark) !important;
}
.theme-fabrication .tool-logo-link:hover .tool-logo-only {
    filter: drop-shadow(0 0 15px var(--fab-dark));
}


/* --- THÈME MAKECODE ARCADE (Orange) --- */

/* A. Tout est Orange (y compris le titre SEGA) */
.theme-makecode .sega-blue,
.theme-makecode .course-header h1,
.theme-makecode .content-text h2,
.theme-makecode .back-link:hover,
.theme-makecode .btn-read,
.theme-makecode .sidebar a:hover {
    color: var(--mca-orange) !important;
    border-color: var(--mca-orange);
    text-shadow: none; /* Pas de liseré ici */
}

/* B. Backgrounds */
.theme-makecode .sidebar a.active,
.theme-makecode .badge {
    background: var(--mca-orange) !important;
}

/* C. Bordures */
.theme-makecode .header-mini,
.theme-makecode .lesson-card.new {
    border-color: var(--mca-orange) !important;
}

/* D. Correction Bug Disparition Menu */
.theme-makecode .sidebar a.active:hover {
    color: white !important;
    background: var(--mca-orange) !important;
}
.theme-makecode .tool-logo-link:hover .tool-logo-only {
    filter: drop-shadow(0 0 15px var(--mca-orange));
}


/* =========================================
   7. MOBILE
   ========================================= */
@media (max-width: 800px) {
    .main-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
        box-sizing: border-box;
    }
    .content-area {
        padding: 15px;
    }
    .course-header h1 {
        font-size: 1.5rem;
    }
}