/* ======================================================= */
/* DESIGN SYSTEM CLEMENTE - THÈME GLOBAL POUR SIMULATEURS  */
/* ======================================================= */

/* --- Variables CSS (Thèmes Dark/Light) --- */
:root {
    --bg-main: #05080f;
    --text-main: #EAEAEA;
    --panel-bg-1: rgba(15, 32, 58, 0.85);
    --panel-bg-2: rgba(0, 10, 30, 0.9);
    --banner-bg: rgba(10, 20, 35, 0.85);
    --border-gold: rgba(255, 215, 0, 0.4);
    --title-shadow: rgba(255, 215, 0, 0.5);
    --input-bg: rgba(0, 20, 40, 0.8);
    --input-border: rgba(255, 215, 0, 0.5);
    --param-box: rgba(0, 0, 0, 0.2);
    --text-highlight: gold;
    --text-muted: #aaa;
    
    /* Couleurs de feedback */
    --color-success: #27ae60;
    --color-warning: #f39c12;
    --color-danger:  #c0392b;
    --color-info:    #3498db;
}

body.light-mode {
    --bg-main: #f0f2f5;
    --text-main: #1a252f;
    --panel-bg-1: rgba(255, 255, 255, 0.95);
    --panel-bg-2: rgba(240, 245, 250, 0.95);
    --banner-bg: rgba(255, 255, 255, 0.95);
    --border-gold: #2980b9;
    --title-shadow: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
    --input-border: #bdc3c7;
    --param-box: rgba(0, 0, 0, 0.05);
    --text-highlight: #2980b9;
    --text-muted: #666;
}

/* --- Base & Typographie --- */
html { font-size: clamp(13px, 1.2vw + 0.1rem, 16px); }
body {
    margin: 0; padding: 0; width: 100%; min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main); display: flex; flex-direction: column;
    background-color: var(--bg-main);
    background-size: cover; background-position: center; background-attachment: fixed;
    overflow-x: hidden; touch-action: manipulation; user-select: none;
    transition: background-color 0.3s, color 0.3s;
}
* { box-sizing: border-box; }

/* Pour l'écriture des vecteurs (ex: v fléché) */
.vec { position: relative; display: inline-block; font-style: italic; padding-top: 0.3em; padding-right: 0.1em; }
.vec::after { content: '→'; position: absolute; top: -0.5em; left: 45%; transform: translateX(-50%); font-style: normal; font-size: 0.85em; line-height: 1; font-weight: normal; }


/* ======================================= */
/* BANDEAU & PIED DE PAGE                  */
/* ======================================= */

#banner {
    width: 100%; min-height: 80px; background-color: var(--banner-bg);
    backdrop-filter: blur(8px); padding: 10px 15px; flex-shrink: 0;
    border-bottom: 1px solid var(--border-gold);
    display: flex; flex-direction: row; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 10px; position: relative; z-index: 50;
    transition: background-color 0.3s;
}
.banner-left { display: flex; flex-direction: column; flex: 1 1 auto; }
#main_title { font-size: clamp(1.1rem, 2vw, 1.4rem); font-weight: 600; color: var(--text-main); text-shadow: 0 0 5px var(--title-shadow); margin: 0; }
#sub_title { font-size: clamp(0.85rem, 1.5vw, 0.95rem); margin-top: 2px; color: var(--border-gold); text-shadow: 0 0 5px var(--title-shadow); }

/* --- Boutons "Se tester", "Libre", "Chrono" --- */
.modes-container { 
    display: flex; gap: 5px; background: rgba(0,0,0,0.4); padding: 4px; 
    border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); 
    justify-content: center; flex: 0 1 auto; white-space: nowrap; 
}
.mode-btn { 
    -webkit-appearance: none; -moz-appearance: none; appearance: none; 
    background: transparent; border: 1px solid transparent; color: #aaa; 
    padding: 6px 12px; border-radius: 5px; font-weight: bold; 
    font-size: clamp(0.8rem, 1.5vw, 0.9rem); cursor: pointer; transition: all 0.3s ease; 
}
.mode-btn:hover:not(:disabled) { color: #fff; background: rgba(255,255,255,0.1); }
.mode-btn.active { background: var(--color-info); color: #fff; border-color: #2980b9; box-shadow: 0 0 10px rgba(52, 152, 219, 0.5); }
.mode-btn:disabled, .mode-btn.locked { 
    cursor: not-allowed !important; 
    opacity: 0.45 !important; 
    filter: grayscale(0.8) !important; 
    pointer-events: none !important; 
    background: rgba(30, 45, 65, 0.6) !important; 
    border: 1px solid rgba(255, 255, 255, 0.15) !important; 
    color: #888 !important; 
    box-shadow: none !important; 
}

/* Menus déroulants du header */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; top: 110%; left: 50%; transform: translateX(-50%); background: rgba(10,20,40,0.95); border: 1px solid var(--border-gold); border-radius: 8px; flex-direction: column; z-index: 1000; box-shadow: 0 4px 15px rgba(0,0,0,0.6); min-width: 180px; overflow: hidden; }
.dropdown-menu.show { display: flex; }
.dropdown-item { background: transparent; color: #FFF; padding: 10px 15px; border: none; font-size: 0.9rem; text-align: left; cursor: pointer; transition: background 0.2s; border-bottom: 1px solid rgba(255,255,255,0.1); }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: rgba(52, 152, 219, 0.4); }

.banner-right { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; justify-content: flex-end; }
#score_display { font-size: clamp(1rem, 2vw, 1.3rem); font-weight: bold; color: #64ff96; background: rgba(0, 0, 0, 0.5); padding: 6px 12px; border-radius: 6px; border: 1px solid rgba(100, 255, 150, 0.3); white-space: nowrap; }

.banner-link {
    font-size: 0.85rem;
    font-weight: bold;
    color: gold;
    text-decoration: none;
    background: rgba(255, 215, 0, 0.15);
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 215, 0, 0.4);
    transition: all 0.25s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.banner-link:hover {
    background: rgba(255, 215, 0, 0.3);
    border-color: gold;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#footer { width: 100%; height: 50px; background-color: var(--banner-bg); backdrop-filter: blur(5px); color: var(--text-muted); display: flex; justify-content: center; align-items: center; font-size: 0.9rem; flex-shrink: 0; border-top: 1px solid var(--border-gold); transition: background-color 0.3s; }


/* ======================================= */
/* VUES & FENÊTRES COMMUNES                */
/* ======================================= */

.fenetre, .fenetre-contenu { 
    background: var(--panel-bg-1); border: 1px solid var(--border-gold); 
    border-radius: 10px; box-shadow: 0 5px 20px rgba(0,0,0,0.4), inset 0 0 15px rgba(0, 0, 0, 0.3); 
    display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; 
    padding: 15px; transition: background 0.3s, border-color 0.3s; 
}
.fenetre_titre { font-weight: 600; text-align: center; color: var(--text-highlight); flex-shrink: 0; border-bottom: 1px solid var(--border-gold); padding-bottom: 10px; margin-bottom: 10px; font-size: 1.2rem; }
.fenetre_titre_wrapper { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-gold); margin-bottom: 10px; padding-bottom: 10px; flex-shrink: 0; }
.fenetre_titre_wrapper .fenetre_titre { border: none; margin: 0; padding: 0; flex-grow: 1; text-align: left; }

.canvas_container { position: relative; flex-grow: 1; min-height: 150px; display: flex; justify-content: center; touch-action: none; overflow: hidden; }


/* ======================================= */
/* BOUTONS ET CONTRÔLES (FORMULAIRES)      */
/* ======================================= */

.control_row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.input_group { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.input_group label { font-size: .95rem; color: var(--text-highlight); text-align: left; font-weight: 500; }

.control_element { 
    -webkit-appearance: none; appearance: none; background-color: var(--input-bg); 
    border: 1px solid var(--input-border); color: var(--text-main); border-radius: 5px; 
    padding: 0.6em 0.8em; font-family: inherit; font-size: 0.9rem; font-weight: 500; 
    outline: none; transition: all 0.2s ease; text-align: center; cursor: pointer; 
}
.control_element:hover:not(:disabled) { background-color: rgba(0,40,80,.9); border-color: gold; box-shadow: 0 0 8px rgba(255,215,0,0.4); }
.control_element:disabled { border-color: #444; color: #666; background-color: rgba(10,10,10,.7); cursor: not-allowed; }

select.control_element { appearance: auto; cursor: pointer; }
input[type="number"].control_element { font-family: 'Courier New', Courier, monospace; font-weight: bold; color: gold; }

.step-button { font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }

.reset-button { 
    background-color: var(--color-danger); border: 1px solid #c0392b; 
    padding: 0.5rem 1rem !important; font-size: 0.8rem !important;
    flex-grow: 0; flex-shrink: 0; white-space: nowrap; color: white !important; 
}
.reset-button:hover { background-color: #c0392b; border-color: #a02113; }

/* --- Boutons d'Action Premium --- */
.premium-btn {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.9), rgba(41, 128, 185, 0.9));
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 10px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.3);
    color: #fff; font-weight: bold; text-transform: uppercase; letter-spacing: 1px;
    border-radius: 8px; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    transition: all 0.2s ease;
}
.premium-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(65, 170, 240, 0.9), rgba(52, 152, 219, 0.9));
    box-shadow: 0 6px 15px rgba(52, 152, 219, 0.6), inset 0 1px 1px #fff;
    border-color: gold;
}
.premium-btn:active:not(:disabled) {
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
.premium-btn.danger {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.9), rgba(192, 57, 43, 0.9));
}
.premium-btn.danger:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(245, 90, 75, 0.9), rgba(231, 76, 60, 0.9));
    box-shadow: 0 6px 15px rgba(231, 76, 60, 0.6), inset 0 1px 1px #fff;
}
.premium-btn.success {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.9), rgba(39, 174, 96, 0.9));
}
.premium-btn.success:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(60, 220, 130, 0.9), rgba(46, 204, 113, 0.9));
    box-shadow: 0 6px 15px rgba(46, 204, 113, 0.6), inset 0 1px 1px #fff;
}

/* --- Groupe de boutons attachés (ex: << Jouer >>) --- */
.btn-group { display: flex; align-items: stretch; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.btn-group .control_element { border-radius: 0; box-shadow: inset 0 1px 1px rgba(255,255,255,0.2); border-right: 1px solid rgba(0,0,0,0.3); margin: 0; }
.btn-group .control_element:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.btn-group .control_element:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-right: none; }
.btn-group .control_element:hover:not(:disabled) { z-index: 2; border-color: gold; }

/* --- Sliders "Whouaouh" avec Halo --- */
input[type=range].control_slider.halo-slider {
    -webkit-appearance: none; appearance: none;
    height: 8px; background: rgba(0, 0, 0, 0.4);
    border-radius: 5px; outline: none; transition: background 0.3s;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.6), 0 1px 1px rgba(255,255,255,0.1);
}
input[type=range].control_slider.halo-slider:hover { background: rgba(255, 215, 0, 0.2); }
input[type=range].control_slider.halo-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; border-radius: 50%;
    background: gold; cursor: pointer; transition: all 0.2s ease;
    box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.6), inset 0 0 5px rgba(255, 255, 255, 0.8);
    border: 2px solid #fff; margin-top: -6px; /* alignement vertical webkit */
}
input[type=range].control_slider.halo-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2); box-shadow: 0 0 15px 5px rgba(255, 215, 0, 0.8), inset 0 0 5px #fff;
}
input[type=range].control_slider.halo-slider::-webkit-slider-runnable-track { width: 100%; height: 8px; cursor: pointer; border-radius: 5px; }
input[type=range].control_slider.halo-slider::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff;
    background: gold; cursor: pointer; transition: all 0.2s ease;
    box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.6), inset 0 0 5px rgba(255, 255, 255, 0.8);
}
input[type=range].control_slider.halo-slider::-moz-range-thumb:hover {
    transform: scale(1.2); box-shadow: 0 0 15px 5px rgba(255, 215, 0, 0.8), inset 0 0 5px #fff;
}
input[type=range].control_slider.halo-slider::-moz-range-track { width: 100%; height: 8px; cursor: pointer; border-radius: 5px; }

/* Layout englobant plusieurs contrôles (Paramétrages) */
.controls-main-container { display: flex; flex-wrap: wrap; gap: 15px; flex-grow: 1; align-items: stretch; }
.control-main-group { flex: 1; min-width: 250px; display: flex; flex-direction: column; gap: 10px; background-color: var(--param-box); padding: 15px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.05); }
.main-group-title { font-size: 1.1rem; color: var(--text-highlight); text-align: center; margin: 0 0 10px 0; border-bottom: 1px solid var(--border-gold); padding-bottom: 8px; font-weight: 600; }

/* Modales d'information centrales */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(3px); }
.modal-content { background-color: var(--panel-bg-1); margin: 10% auto; padding: 25px; border: 1px solid var(--border-gold); border-radius: 12px; width: 90%; max-width: 600px; color: var(--text-main); box-shadow: 0 10px 30px rgba(0,0,0,0.8); position: relative; line-height: 1.5; }
.close-btn { color: var(--text-muted); position: absolute; right: 20px; top: 15px; font-size: 28px; font-weight: bold; cursor: pointer; line-height: 1; transition: color 0.2s; }
.close-btn:hover { color: var(--color-danger); }
.modal-title { color: var(--text-highlight); font-size: 1.3rem; border-bottom: 1px solid var(--border-gold); padding-bottom: 10px; margin-top: 0; margin-right: 30px; }


/* ======================================= */
/* INTERRUPTEURS ANIMÉS (Switches Photon)  */
/* ======================================= */

.switch { position: relative; display: inline-block; width: 44px; height: 24px; vertical-align: middle; margin-right: 5px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch_slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #555; border-radius: 24px; transition: .4s; }
.switch_slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; border-radius: 50%; transition: .4s; }
input:checked+.switch_slider { background-color: gold; }
input:checked+.switch_slider:before { transform: translateX(20px); }

/* Déclinaisons de couleurs pour les vecteurs du Mode Libre */
.switch.switch-vit input:checked+.switch_slider { background-color: #2ecc71; }
.switch.switch-acc input:checked+.switch_slider { background-color: #f39c12; }
.switch.switch-frc input:checked+.switch_slider { background-color: #e74c3c; }
.switch.switch-res input:checked+.switch_slider { background-color: #9b59b6; }

/* Switch avec étiquette OuI/NON (Bicolor-switch) */
.switch.bicolor-switch { width: 70px; height: 28px; }
.switch.bicolor-switch .switch_slider {
    background-color: var(--color-danger); /* Rouge par défaut (NON) */
    border-radius: 28px; display: flex; align-items: center;
}
.switch.bicolor-switch .switch_slider::before {
    position: absolute; content: "NON"; height: 22px; width: 22px;
    left: 4px; bottom: 3px; background-color: white; border-radius: 50%;
    color: var(--color-danger); font-size: 0.6rem; font-weight: bold;
    display: flex; justify-content: center; align-items: center; line-height: 1;
}
.switch.bicolor-switch input:checked + .switch_slider { background-color: var(--color-success); }
.switch.bicolor-switch input:checked + .switch_slider:before { transform: translateX(42px); content: "OUI"; color: var(--color-success); }
.switch-row { justify-content: space-between; align-items: center; padding: 5px 0; }
.switch_label { font-weight: 600; color: var(--text-main) !important; font-size: 0.95rem !important; text-align: left !important;}


/* ======================================= */
/* ANIMATIONS & EFFET WOW                 */
/* ======================================= */

@keyframes successFlash {
    0% { background-color: rgba(46, 204, 113, 0.4); box-shadow: 0 0 15px rgba(46, 204, 113, 0.8); border-color: #2ecc71; }
    100% { background-color: transparent; box-shadow: none; border-color: transparent; }
}
.success-flash { animation: successFlash 0.8s ease-out; border: 1px solid transparent; border-radius: 5px; }

.wow-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(5, 8, 15, 0.95); display: flex; justify-content: center; align-items: center; 
    z-index: 9999; opacity: 0; pointer-events: none; transition: opacity 0.5s ease; backdrop-filter: blur(5px); 
}
.wow-overlay.show { opacity: 1; pointer-events: auto; }
#wow_content { 
    text-align: center; transform: scale(0.8); transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    background: linear-gradient(145deg, rgba(20, 40, 70, 0.9), rgba(10, 20, 40, 0.95)); padding: 40px; 
    border-radius: 20px; border: 2px solid rgba(255,215,0,0.3); box-shadow: 0 10px 40px rgba(0,0,0,0.8); max-width: 90%; 
}
.wow-overlay.show #wow_content { transform: scale(1); }
.wow-title { font-size: 3rem; margin-bottom: 10px; }
.wow-subtitle { font-size: 1.2rem; color: #EAEAEA; margin-bottom: 30px; line-height: 1.5; }
.wow-btn { 
    -webkit-appearance: none; appearance: none; padding: 12px 25px; font-size: 1.2rem; font-weight: bold; 
    border: none; border-radius: 8px; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 4px 10px rgba(0,0,0,0.3); 
}
.wow-btn:hover { transform: scale(1.05); }

/* Animation pour un bouton en attente/focus */
@keyframes pulse-yellow { from { box-shadow: 0 0 5px -2px gold; } to { box-shadow: 0 0 12px 2px gold; } }
@keyframes pulse-red { from { box-shadow: 0 0 5px -2px #FF4136; } to { box-shadow: 0 0 12px 2px #FF4136; } }
.waiting-for-input { border-color: gold !important; animation: pulse-yellow 1s infinite alternate !important; }
.button-warning { border-color: #FF4136 !important; color: #FF4136 !important; animation: pulse-red 1s infinite alternate !important; }

/* ======================================= */
/* JAUGE ET BARRE DE CHRONOMÈTRE GAMIFIÉE  */
/* ======================================= */

#chrono_bar_container {
    display: none;
    position: relative;
    width: calc(100% - 24px);
    max-width: 1200px;
    height: 36px;
    margin: 8px auto 4px auto;
    background: rgba(10, 22, 42, 0.9);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.15);
}

#chrono_bar_fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    transition: width 0.1s linear;
}
#chrono_bar_fill.fill-timeattack {
    background: linear-gradient(90deg, rgba(243, 156, 18, 0.85), rgba(46, 204, 113, 0.85));
}
#chrono_bar_fill.fill-speedrun {
    background: linear-gradient(90deg, rgba(52, 152, 219, 0.85), rgba(155, 89, 182, 0.85));
}
#chrono_bar_fill.fill-survival {
    background: linear-gradient(90deg, rgba(231, 76, 60, 0.85), rgba(243, 156, 18, 0.85));
}

#chrono_bar_content {
    position: relative;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 14px;
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
    letter-spacing: 0.5px;
}

#chrono_bar_timer, #chrono_bar_score {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
