/* --- POLICE ET VARIABLES DE COULEUR --- */
:root {
    /* Thème Clair (doux) */
    --bg-color: #E6EBF5;
    --card-bg: #E6EBF5;
    --primary-text: #333d52;
    --secondary-text: #828a9b;
    --accent-color: #8E99FE;
    --accent-hover: #7784f6;
    --shadow-light: #FFFFFF;
    --shadow-dark: #c8cede;
    --icon-color: #5c677d;
    --green: #50d890;
    --red: #ff7b7b;
    --yellow: #feca57;
    --blue: #82aaff;
    --theme-color-meta: #E6EBF5;
}

body.light-theme { /* Le thème clair est maintenant le défaut */
}

/* Thème Sombre (doux) */
body:not(.light-theme) {
    --bg-color: #2C2F48;
    --card-bg: #2C2F48;
    --primary-text: #E0E7FF;
    --secondary-text: #8188B3;
    --accent-color: #7A5AF8;
    --accent-hover: #9175ff;
    --shadow-light: #383c5e;
    --shadow-dark: #202232;
    --icon-color: #A6B0D9;
    --green: #48d789;
    --red: #ff7070;
    --yellow: #ffd050;
    --blue: #7abcff;
    --theme-color-meta: #2C2F48;
}

/* --- STYLE DE BASE --- */
html { -webkit-tap-highlight-color: transparent; }
body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--primary-text);
    margin: 0;
    padding: 0 15px;
    transition: background-color 0.3s ease, color 0.3s ease;
}
.container { max-width: 500px; margin: 0 auto; padding-bottom: 80px; }
h1, h2, p { margin: 0; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; color: var(--secondary-text); margin-bottom: 20px; font-weight: 600; text-align: center; }

/* --- VOILE DE SÉCURITÉ (Style adouci) --- */
#security-overlay {
    background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(10px);
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 1; transition: opacity 0.5s ease;
}
#security-overlay.hidden { opacity: 0; pointer-events: none; }
.login-box {
    background: var(--bg-color); padding: 30px; border-radius: 20px; text-align: center;
    width: 90%; max-width: 320px;
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
}
#password-input {
    width: 100%; padding: 12px; font-size: 16px; border-radius: 10px; text-align: center; margin-bottom: 20px; box-sizing: border-box;
    border: none; background: var(--bg-color); color: var(--primary-text);
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}
#login-button {
    width: 100%; padding: 12px; font-size: 16px; font-weight: bold; border-radius: 10px; border: none;
    background-color: var(--accent-color); color: #fff; cursor: pointer; transition: background-color 0.2s ease;
}
#login-button:hover { background-color: var(--accent-hover); }
.error-message { color: var(--red) !important; min-height: 20px; font-size: 14px; }
#security-overlay.shake .login-box { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } }

/* --- HEADER --- */
header { display: flex; justify-content: space-between; align-items: center; padding: 25px 0; }
.header-title p { color: var(--secondary-text); font-size: 14px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.theme-toggle-btn {
    background: var(--card-bg); border: none; cursor: pointer; width: 44px; height: 44px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: var(--icon-color);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    transition: all 0.2s ease;
}
.theme-toggle-btn:active {
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    transform: scale(0.95);
}
.theme-toggle-btn svg { width: 22px; height: 22px; }
.header-timer-status {
    display: flex; align-items: center; gap: 5px; background: var(--card-bg);
    padding: 8px 12px; border-radius: 20px; font-size: 14px; font-weight: 600;
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    color: var(--accent-color);
}
.header-timer-status svg { width: 16px; height: 16px; }

/* --- AVIS DE STABILISATION --- */
.stabilization-notice {
    background-color: var(--card-bg);
    border-radius: 15px;
    padding: 12px 15px;
    margin-bottom: 25px;
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    display: none; /* Important: Contrôlé par JavaScript */
}

.stabilization-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--secondary-text);
    margin-bottom: 8px;
}

.stabilization-text svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.stabilization-progress {
    width: 100%;
    height: 6px;
    background-color: var(--bg-color);
    border-radius: 3px;
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
    overflow: hidden;
}

.stabilization-bar {
    height: 100%;
    width: 100%;
    border-radius: 3px;
    background: repeating-linear-gradient(
        45deg,
        var(--accent-color),
        var(--accent-color) 10px,
        var(--accent-hover) 10px,
        var(--accent-hover) 20px
    );
    background-size: 200% 200%;
    animation: progress-animation 2s linear infinite;
}

@keyframes progress-animation {
    0% { background-position: 0% 50%; }
    100% { background-position: -100% 50%; }
}

/* --- SECTION GÉNÉRIQUE "CARD" --- */
.card {
    background-color: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
}

/* --- SECTION ENVIRONNEMENT --- */
.environment-compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}
.env-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    background: var(--card-bg);
    padding: 12px;
    border-radius: 15px;
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}
.stat-icon { 
    font-size: 24px; 
    flex-shrink: 0;
    line-height: 1;
}
.stat-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.3;
    flex-grow: 1;
}
.stat-value { 
    font-size: 18px; 
    font-weight: 700; 
}
.stat-label { 
    font-size: 12px; 
    color: var(--secondary-text);
}

.daily-message {
    text-align: center;
    font-style: italic;
    color: var(--secondary-text);
    margin: -10px auto 25px; /* On réduit l'espace au-dessus et on en ajoute en dessous */
    font-size: 14px;
    max-width: 85%; /* Pour éviter que le texte ne touche les bords sur mobile */
    min-height: 1.2em; /* Empêche le saut de mise en page au chargement */
}


/* --- Statuts des capteurs --- */
#tempStatus, #humidityStatus, #co2Status {
    font-size: 11px;
    font-weight: 600;
    white-space: normal;
    color: var(--secondary-text);
    margin-top: 4px;
}
.temp-status.cold, .humidity-status.humid { color: var(--blue) !important; }
.temp-status.ideal, .humidity-status.ideal, .co2-status.ideal { color: var(--green) !important; }
.temp-status.warm, .humidity-status.dry, .co2-status.acceptable { color: var(--yellow) !important; }
.temp-status.hot, .co2-status.problematic { color: var(--red) !important; }
.co2-status.urgent { color: var(--red) !important; font-weight: 700; }

/* --- CENTRE DE CONTRÔLE --- */
.control-center .separator { height: 1px; background: var(--shadow-dark); margin: 20px 0; border: none; }
.power-and-brightness { display: flex; align-items: center; gap: 20px; }
.btn-power {
    width: 80px; height: 80px; border-radius: 50%; border: none;
    background: var(--card-bg); color: var(--icon-color);
    box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
    cursor: pointer; transition: all 0.2s ease; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.btn-power:active {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    transform: scale(0.95);
}
.btn-power.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light), inset 2px 2px 4px rgba(255,255,255,0.2), inset -2px -2px 4px rgba(0,0,0,0.2);
}
.power-text-js-target {
    display: none;
}
.slider-group { flex-grow: 1; }
.slider-group label { font-size: 14px; font-weight: 600; color: var(--secondary-text); margin-bottom: 15px; display: block; text-align: center; }
.slider-wrapper { display: flex; align-items: center; gap: 10px; }
.slider-wrapper span { color: var(--icon-color); }
.slider-value { text-align: center; font-size: 12px; margin-top: 8px; color: var(--secondary-text); }
input[type="range"] {
    -webkit-appearance: none; width: 100%; height: 10px;
    background: var(--bg-color); outline: none; border-radius: 10px;
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 22px; height: 22px; background: white; border-radius: 50%;
    cursor: pointer; border: 4px solid var(--accent-color);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.color-controls { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.color-picker-wrapper { text-align: center; }
.color-picker-wrapper label { font-size: 14px; font-weight: 600; color: var(--secondary-text); margin-bottom: 10px; display: block; }
input[type="color"] {
    -webkit-appearance: none; width: 50px; height: 50px; border: none; padding: 0;
    border-radius: 50%; cursor: pointer; background-color: transparent;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 5px solid var(--card-bg); border-radius: 50%; }

.white-slider { flex-grow: 1; }

/* --- SECTION AMBIANCES & ONGLETS --- */
.moods-section h2 { 
    margin-bottom: 20px;
}
.tabs { display: flex; justify-content: center; gap: 10px; margin-bottom: 20px; }
.tab-btn {
    padding: 8px 16px; border-radius: 15px; border: none;
    background: var(--card-bg); color: var(--secondary-text); font-weight: 600; font-size: 14px;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    transition: all 0.2s ease;
}
.tab-btn.active {
    background: var(--accent-color);
    color: white;
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.2), inset -2px -2px 4px rgba(255,255,255,0.2);
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.effects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 15px; }
.effect-btn {
    background: var(--card-bg); color: var(--primary-text);
    border: none; border-radius: 15px; padding: 12px 5px;
    font-size: 12px; cursor: pointer; transition: all 0.2s ease;
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 5px;
}
.effect-btn:active {
    transform: scale(0.95);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}
.effect-btn.active {
    color: white;
    background-color: var(--accent-color);
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.2), inset -2px -2px 4px rgba(255,255,255,0.2);
}
.effect-icon { font-size: 24px; line-height: 1; }
.effect-name { font-weight: 600; }

/* --- NOUVELLE SECTION : AMBIANCES SONORES --- */
.sound-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}
.sound-btn {
    padding: 12px 10px;
    border-radius: 12px;
    border: none;
    background: var(--card-bg);
    color: var(--secondary-text);
    font-weight: 600;
    font-size: 14px;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    transition: all 0.2s ease;
    cursor: pointer;
}
.sound-btn.active {
    background: var(--accent-color);
    color: white;
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.2), inset -2px -2px 4px rgba(255,255,255,0.2);
}
.sound-btn:active {
    transform: scale(0.95);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

/* --- MINUTEUR --- */
.timer-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.timer-btn {
    flex-grow: 1; padding: 10px; border-radius: 12px; border: none;
    background: var(--card-bg); color: var(--secondary-text); font-weight: 600;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    transition: all 0.2s ease;
}
.timer-btn.active {
    background: var(--accent-color); color: white;
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.2), inset -2px -2px 4px rgba(255,255,255,0.2);
}
.timer-btn:active {
    transform: scale(0.95);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

/* --- FOOTER & STATUS --- */
.status-footer { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--secondary-text); margin-top: 20px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background-color: #888; transition: background-color 0.3s; }
.status-dot.connected { background-color: var(--green); }
.status-dot.error { background-color: var(--red); }
footer { text-align: center; padding: 20px; font-size: 12px; color: var(--secondary-text); opacity: 0.7; }
