/* --- Réinitialisation et base --- */
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: #EAEAEA;
    display: flex; flex-direction: column;
    background-color: #05080f; background-image: url('img_fond.jpg');
    background-size: cover; background-position: center; background-attachment: fixed;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: manipulation;
    user-select: none;
}

* { box-sizing: border-box; }

/* --- Bandeau et pied de page --- */
#banner {
    width: 100%; background-color: rgba(10, 20, 35, 0.75);
    backdrop-filter: blur(8px); padding: 10px 15px; flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5); text-align: left;
}
#main_title { font-size: 1.5rem; font-weight: 600; color: #FFF; margin: 0; }
#sub_title { font-size: 1rem; margin-top: 5px; color: #FFD700; margin: 0; }

#footer {
    width: 100%; height: 50px;
    background-color: rgba(10, 20, 35, 0.85); backdrop-filter: blur(5px);
    color: #AAA; display: flex; justify-content: center; align-items: center;
    font-size: 0.9rem; flex-shrink: 0; border-top: 1px solid rgba(255, 215, 0, 0.2);
    margin-top: auto;
}

/* --- Conteneur de la Simulation (Mobile First) --- */
#conteneur_simulation {
    flex: 1 0 auto; 
    display: flex;
    flex-direction: column;
    /* Optimisation des marges pour compacter l'écran mobile */
    gap: 8px;
    padding: 5px;
    width: 100%;
    min-height: 0; 
}

/* Ordre d'empilement sur Mobile */
#fenetre_oscillo { order: 1; }
#fenetre_banc { order: 2; }
#fenetre_commandes { order: 3; }

#colonne_centrale { display: contents; }

/* --- Style commun des fenêtres (Glassmorphism) --- */
.fenetre {
    background: linear-gradient(145deg, rgba(15, 32, 58, 0.85), rgba(0, 10, 30, 0.9));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-radius: 10px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4), inset 0 0 15px rgba(0, 0, 0, 0.3);
    transition: all 0.5s ease-out;
    min-height: auto; /* Libère la hauteur sur mobile ! */
}

.fenetre_titre {
    font-weight: 600; text-align: center; color: gold; flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    padding-bottom: 5px; margin: 2px 5px 5px 5px;
    font-size: 1rem;
}

/* Hiérarchie inférieure dans le panneau */
.section_titre {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 215, 0, 0.85);
    text-align: center;
    padding-bottom: 3px;
    border-bottom: 1px dashed rgba(255, 215, 0, 0.3);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Canvas Conteneurs --- */
.canvas_container {
    flex-grow: 1; margin: 0 5px 5px 5px; position: relative; overflow: hidden;
    border-radius: 6px; background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex; justify-content: center; align-items: center;
}
.canvas_container canvas { 
    position: absolute; top: 0; left: 0; 
    width: 100% !important; height: 100% !important; 
    object-fit: contain; 
}

/* Tailles fixes condensées sur Mobile */
#canvas_oscillo { min-height: 180px; height: 32vh; }
#canvas_banc { min-height: 130px; height: 22vh; }

/* --- Textes et informations --- */
.contenu_texte {
    padding: 0 5px; flex-grow: 1; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    overflow-y: auto; text-align: center;
}

.info_cadres_container { display: flex; justify-content: space-around; gap: 5px; }
.info_cadre {
    flex: 1; background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 215, 0, 0.4);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
    border-radius: 6px; padding: 5px; text-align: center;
}
.info_cadre_titre { font-size: 0.8rem; color: rgba(255, 215, 0, 0.7); margin-bottom: 4px; font-weight: 600; }

/* --- Style des contrôles --- */
.control_row { display: flex; gap: 5px; align-items: center; }
.control_element {
    background-color: rgba(0, 20, 40, 0.8); border: 1px solid gold; color: #FFF;
    border-radius: 5px; padding: 6px 10px; font-family: inherit; font-size: 0.8rem;
    font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px;
    outline: none; transition: all 0.2s ease; cursor: pointer; text-align: center; flex: 1;
}

.control_element:not(:disabled):hover { background-color: rgba(20, 40, 60, 0.9); border-color: rgba(255, 215, 0, 0.7); }
.control_element:disabled { border-color: #444; color: #666; background-color: rgba(10, 10, 10, 0.7); cursor: not-allowed; opacity: 0.6; }

/* --- Switch --- */
.switch { position: relative; display: inline-block; width: 40px; height: 20px; margin: 0 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: 20px; transition: .4s; }
.switch_slider:before { position: absolute; content: ""; height: 14px; width: 14px; 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); }

/* --- Style des Boutons Rotatifs (Knobs) --- */
.knob-container {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
}
.knob-container label { font-size: 0.7rem; color: #DDD; margin-bottom: 1px; }
.knob-value { font-family: 'Courier New', monospace; color: #FFF; font-size: 0.8rem; margin-top: 2px; font-weight: bold;}

.knob-wrapper { width: 40px; height: 40px; position: relative; margin: 4px 0; cursor: ns-resize; }
.knob-wrapper.small { width: 32px; height: 32px; }
.knob {
    width: 100%; height: 100%; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(30, 60, 100, 0.9), rgba(5, 10, 20, 0.9));
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 215, 0, 0.3);
    border: 1px solid rgba(255, 215, 0, 0.4);
    position: relative; transform: rotate(0deg); transition: transform 0.1s ease-out;
}
.knob-marker {
    position: absolute; top: 4px; left: 50%; width: 4px; height: 10px;
    background-color: gold; transform: translateX(-50%); border-radius: 2px;
}

/* =========================================================
   MEDIA QUERIES RESPONSIVE (Retour à la normale sur grand écran)
========================================================= */

/* --- VUE TABLETTE (725px - 1024px) --- */
@media (min-width: 725px) and (max-width: 1024px) {
    html, body { overflow: hidden; height: 100vh; } 
    
    #conteneur_simulation {
        flex: 1 1 0; 
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1.5fr 1fr;
        padding: 10px; gap: 15px; min-height: 0;
    }
    
    .fenetre_titre { font-size: 1.1rem; padding-bottom: 10px; margin: 5px 5px 10px 5px; }
    .section_titre { font-size: 1rem; margin-bottom: 15px; padding-bottom: 5px; }
    
    #canvas_oscillo, #canvas_banc { min-height: 250px; height: 100%; }
    
    .info_cadres_container { gap: 10px; }
    .info_cadre { padding: 10px; }
    .info_cadre_titre { font-size: 0.95rem; margin-bottom: 8px; }
    .control_row { gap: 10px; }
    .knob-wrapper.small { width: 38px; height: 38px; }
    .knob-container label { font-size: 0.8rem; margin-bottom: 2px; }
    .knob-value { font-size: 0.9rem; margin-top: 4px; }
    
    #fenetre_oscillo { grid-column: 1; grid-row: 1; display: flex; min-height: 0; order: unset; }
    #fenetre_banc { grid-column: 1; grid-row: 2; display: flex; min-height: 0; order: unset; }
    #fenetre_commandes { grid-column: 2; grid-row: 1 / 3; display: flex; min-height: 0; order: unset; }
    
    .fenetre { overflow-y: auto; height: 100%; }
}

/* --- VUE PC (> 1024px) --- */
@media (min-width: 1025px) {
    html, body { overflow: hidden; height: 100vh; } 
    
    #conteneur_simulation {
        flex: 1 1 0; 
        display: grid;
        grid-template-columns: 2.5fr 1.5fr;
        grid-template-rows: 2fr 1fr;
        padding: 15px; gap: 15px; min-height: 0;
    }
    
    .fenetre_titre { font-size: 1.1rem; padding-bottom: 10px; margin: 5px 5px 10px 5px; }
    .section_titre { font-size: 1rem; margin-bottom: 15px; padding-bottom: 5px; }
    
    #canvas_oscillo, #canvas_banc { min-height: 250px; height: 100%; }
    
    .info_cadres_container { gap: 10px; }
    .info_cadre { padding: 10px; }
    .info_cadre_titre { font-size: 0.95rem; margin-bottom: 8px; }
    .control_row { gap: 10px; }
    .knob-wrapper.small { width: 38px; height: 38px; }
    .knob-container label { font-size: 0.8rem; margin-bottom: 2px; }
    .knob-value { font-size: 0.9rem; margin-top: 4px; }
    
    #fenetre_oscillo { grid-column: 1; grid-row: 1; display: flex; min-height: 0; order: unset; }
    #fenetre_banc { grid-column: 1; grid-row: 2; display: flex; min-height: 0; order: unset; }
    #fenetre_commandes { grid-column: 2; grid-row: 1 / 3; display: flex; min-height: 0; order: unset; }
    
    .fenetre { overflow-y: auto; height: 100%; }
}