* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, sans-serif; }
html { background-color: #f4f7f6; transition: background-color 0.3s; } /* Correction du bug de fond */
body { background-color: #f4f7f6; color: #2c3e50; transition: background-color 0.3s, color 0.3s; min-height: 100vh; }
.hidden { display: none !important; }

/* LAYOUT & AUTH */
.app-layout { display: flex; align-items: center; justify-content: center; gap: 40px; max-width: 1200px; margin: 40px auto; padding: 0 20px; min-height: 80vh; flex-wrap: wrap; }
/* Remplacement du white par #fcfcfc (blanc doux) pour éviter l'éblouissement */
.simulator-section { flex: 2; min-width: 300px; background: #fcfcfc; padding: 40px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.04); transition: background-color 0.3s; }
.auth-section { flex: 1; min-width: 300px; }
.auth-card { background: #fcfcfc; padding: 40px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.04); text-align: center; transition: background-color 0.3s; }

h1, h2, h3, h4 { margin-bottom: 10px; font-weight: 600; }
.subtitle { color: #7f8c8d; margin-bottom: 20px; }

/* ANIMATION ALERTE SALAIRE */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(230, 41, 34, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(230, 41, 34, 0); }
    100% { box-shadow: 0 0 0 0 rgba(230, 41, 34, 0); }
}

/* FORMULAIRES */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.form-group { text-align: left; margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; color: #34495e; }
input, select { width: 100%; padding: 12px; border: 1px solid #dcdde1; border-radius: 8px; font-size: 15px; outline: none; background: #fdfbfb; transition: border-color 0.2s, background-color 0.3s; }
input:focus, select:focus { border-color: #27ae60; background: #fcfcfc; }

/* BOUTONS */
.btn-calculer, .btn-login { background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%); color: white; border: none; padding: 12px; border-radius: 8px; width: 100%; cursor: pointer; font-weight: bold; font-size: 15px; transition: opacity 0.2s; box-shadow: 0 4px 10px rgba(46, 204, 113, 0.2); }
.btn-calculer:hover, .btn-login:hover { opacity: 0.9; }
.btn-craquage { background: linear-gradient(135deg, #e62922 0%, #f11b13 100%); color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: bold; box-shadow: 0 4px 10px rgba(230, 41, 34, 0.2); }
.btn-outline { background: transparent; border: 1px solid #bdc3c7; padding: 8px 15px; border-radius: 6px; cursor: pointer; font-weight: bold; transition: background 0.2s; }
.btn-outline:hover { background: rgba(0,0,0,0.03); }
.btn-icon { background: transparent; border: 1px solid #bdc3c7; padding: 4px 8px; border-radius: 5px; cursor: pointer; font-size: 14px; transition: 0.2s; }
.btn-edit { color: #f39c12; border-color: #f39c12; margin-right: 5px; }
.btn-delete { color: #e74c3c; border-color: #e74c3c; }
.btn-event { color: #9b59b6; border-color: #9b59b6; margin-right: 5px; }

/* CONTAINER & MENUS */
.app-container { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar adaptative (Bleu/Gris doux en mode clair) */
.sidebar { width: 260px; background-color: #e8eef2; border-right: 1px solid #d1d8dd; display: flex; flex-direction: column; transition: background-color 0.3s; }
.sidebar .logo { padding: 25px; font-size: 20px; font-weight: bold; color: #27ae60; border-bottom: 1px solid #d1d8dd; transition: color 0.3s; }
.side-menu { display: flex; flex-direction: column; padding: 20px 0; flex-grow: 1; }
.side-menu a { color: #576574; text-decoration: none; padding: 15px 25px; font-size: 15px; font-weight: 500; transition: 0.2s; cursor: pointer; }
.side-menu a:hover, .side-menu a.active { background-color: #d1d8dd; color: #2c3e50; border-left: 4px solid #2ecc71; }

.main-content { flex: 1; overflow-y: auto; background-color: #f4f7f6; transition: background-color 0.3s; }
.page-section { display: none; animation: fadeIn 0.3s; }
.page-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* TOPBAR & MÉTÉO */
.topbar { background: #fcfcfc; padding: 15px 40px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 10px rgba(0,0,0,0.02); position: sticky; top: 0; z-index: 10; transition: background-color 0.3s; }
.meteo-box { font-size: 15px; font-weight: bold; padding: 8px 15px; border-radius: 20px; background: #fdfbfb; border: 1px solid #eee; display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.02); transition: background-color 0.3s; }
.user-profile-btn { display: inline-flex; align-items: center; gap: 10px; background: #f8fafc; padding: 8px 15px; border-radius: 20px; cursor: pointer; border: 1px solid #e2e8f0; transition: 0.2s; }
.user-profile-btn:hover { background: #e2e8f0; }
.user-name { font-weight: 600; font-size: 14px; color: #2c3e50; }

.dashboard-area { padding: 30px 40px; max-width: 1100px; margin: 0 auto; }
.action-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; background: #fcfcfc; padding: 20px; border-radius: 12px; flex-wrap: wrap; gap: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.02); transition: background-color 0.3s; }

/* JAUGES (PROGRESS BARS) */
.progress-bg { width: 100%; height: 10px; background: #ecf0f1; border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease-out; }

/* DASHBOARDS & CARDS */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 25px; }
.kpi-card { background: #fcfcfc; padding: 20px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); border-left: 5px solid #3498db; transition: background-color 0.3s; }
.kpi-card.warning { border-left-color: #e74c3c; }
.kpi-card h3 { font-size: 24px; margin-top: 5px; color: #2c3e50; }
.dashboard-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 25px; 
    align-items: stretch; /* Oblige les colonnes à avoir la même hauteur */
}

.profile-grid {
    align-items: start;
}

.dashboard-card { 
    background: #fcfcfc; 
    padding: 25px; 
    border-radius: 14px; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.03); 
    margin-bottom: 20px; 
    transition: background-color 0.3s; 
    display: flex; 
    flex-direction: column; 
    
}

/* BADGES & ASTUCES */
.badges-card { background: linear-gradient(135deg, #fcfcfc 0%, #f4f7f6 100%); border: 1px solid #eee; }
.badges-container { display: flex; gap: 15px; overflow-x: auto; padding-bottom: 10px; }
.badge-item { display: flex; flex-direction: column; align-items: center; text-align: center; width: 85px; opacity: 0.4; filter: grayscale(100%); transition: 0.3s; cursor: help; }
.badge-item.unlocked { opacity: 1; filter: none; transform: none; }
.badge-icon { font-size: 24px; background: #fcfcfc; padding: 8px; border-radius: 50%; box-shadow: 0 4px 10px rgba(0,0,0,0.05); margin-bottom: 8px; border: 1px solid #f1f2f6; }
.badge-name { font-size: 11px; font-weight: 600; color:#34495e; }

.astuce-filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.btn-filter { padding: 6px 14px; border-radius: 20px; border: 1px solid #bdc3c7; background: transparent; cursor: pointer; font-weight: 600; font-size: 13px; color: #7f8c8d; transition: 0.2s; }
.btn-filter.active { background: #3498db; color: white; border-color: #3498db; }
.astuces-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.astuce-card ul { margin-left: 20px; margin-top: 10px; line-height: 1.5; font-size:14px; color:#555; }
.astuce-card li { margin-bottom: 8px; }

/* PAGE INFOS & AIDES */
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 15px; }
.help-card { background: #f8fafc; border: 1px solid #e2e8f0; padding: 20px; border-radius: 10px; text-align: left; transition: background-color 0.3s; }
.help-card h4 { margin-bottom: 12px; color: #1e2b3c; font-weight: bold; }
.help-card p { font-size: 14px; color: #34495e; line-height: 1.5; margin-bottom: 8px; }
.help-card ul { margin-left: 20px; line-height: 1.6; font-size: 14px; color: #34495e; }
.help-card li { margin-bottom: 6px; }

/* LISTES & ÉLÉMENTS DIVERS */
.quick-add-box { background: #f8fafc; padding: 15px; border-radius: 10px; margin-bottom: 15px; border: 1px solid #e2e8f0; transition: background-color 0.3s; }
.simulator-box { background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%); border-color: #eee; }
.result-box { padding: 15px; background: #e8f5e9; border-left: 5px solid #27ae60; border-radius: 8px; color: #2c3e50; }
.transaction-list { 
    list-style: none; 
    margin-top: 10px; 
    max-height: 380px; /* Taille rallongée pour voir plus d'historique */
    overflow-y: auto; 
    padding-right: 5px; 
    flex-grow: 1; /* Permet à la liste de s'étirer pour combler le vide */
}
.transaction-list::-webkit-scrollbar { width: 5px; }
.transaction-list::-webkit-scrollbar-thumb { background: #bdc3c7; border-radius: 5px; }
.transaction-list li { padding: 10px 0; border-bottom: 1px solid #f1f2f6; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.trans-date { font-size: 12px; color: #7f8c8d; width: 75px; }
.trans-motif { flex-grow: 1; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.trans-montant { font-weight: bold; margin-right: 15px; font-size: 15px; }
.trans-badge { padding: 3px 8px; border-radius: 12px; font-size: 10px; font-weight: bold; margin-right: 10px; color: white; text-transform: uppercase; }

.badge-courante { background-color: #3498db; }
.badge-confort { background-color: #f39c12; }
.badge-imprevu { background-color: #e62922; }
.badge-entree { background-color: #2ecc71; }
.status-icon { font-size: 12px; }

/* OVERLAY MODALES (Pop-ups élégantes) */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: #fcfcfc; padding: 30px; border-radius: 16px; width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,0.1); animation: fadeIn 0.3s; transition: background-color 0.3s; }

/* === MODE SOMBRE CONTRÔLABLE === */
html.dark-theme { background-color: #121212; } /* Correction du bug de fond */
body.dark-theme, body.dark-theme .main-content { background-color: #121212; color: #e0e0e0; }

body.dark-theme .sidebar { background-color: #1a252f; border-right: none; }
body.dark-theme .sidebar .logo { color: #2ecc71; border-bottom: 1px solid #2c3e50; }
body.dark-theme .side-menu a { color: #bdc3c7; }
body.dark-theme .side-menu a:hover, body.dark-theme .side-menu a.active { background-color: #2c3e50; color: white; border-left: 4px solid #2ecc71; }

body.dark-theme .simulator-section, body.dark-theme .auth-card, body.dark-theme .topbar, body.dark-theme .action-header, body.dark-theme .kpi-card, body.dark-theme .dashboard-card, body.dark-theme .modal-content { background-color: #1e1e1e; border: 1px solid #2c2c2c; box-shadow: none; }

body.dark-theme h1, body.dark-theme h2, body.dark-theme h3, body.dark-theme h4, body.dark-theme .kpi-card h3, body.dark-theme .user-name { color: #f5f6fa; }
body.dark-theme .form-group label { color: #dcdde1; }

body.dark-theme input, body.dark-theme select { background-color: #2c2c2c; color: white; border-color: #444; }
body.dark-theme input:focus, body.dark-theme select:focus { background-color: #2c2c2c; border-color: #2ecc71; }

body.dark-theme .meteo-box { background: #252525; border-color: #333; color: white; }
body.dark-theme .user-profile-btn { background: #252525; border-color: #333; }
body.dark-theme .user-profile-btn:hover { background: #333; }

body.dark-theme .badges-card { background: linear-gradient(135deg, #1e1e1e 0%, #252525 100%); border: 1px solid #333; }
body.dark-theme .badge-icon { background: #2c2c2c; border: 1px solid #444; }
body.dark-theme .badge-name { color: #dcdde1; }

body.dark-theme .quick-add-box, body.dark-theme .simulator-box { background: #252525; border-color: #333; }
body.dark-theme .result-box { background-color: #1a2b22; color: #e0e0e0; border-left-color: #2ecc71; }

body.dark-theme .help-card { background: #252525; border-color: #333; }
body.dark-theme .help-card h4 { color: #f5f6fa; }
body.dark-theme .help-card p, body.dark-theme .help-card ul, body.dark-theme .help-card li { color: #dcdde1; }

body.dark-theme .transaction-list li { border-bottom-color: #333; }
body.dark-theme .astuce-card ul { color: #dcdde1; }
body.dark-theme .progress-bg { background: #333; }
body.dark-theme .btn-outline { color: #dcdde1; border-color: #dcdde1; }

/* ==========================================
   UI CHATBOT FLOTTANT
   ========================================== */
.chatbot-fab {
    position: fixed; bottom: 30px; right: 30px;
    background: #3498db; color: white;
    border: none; border-radius: 50px;
    padding: 15px 25px; font-size: 16px; font-weight: bold;
    cursor: pointer; box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
    z-index: 1000; transition: transform 0.2s, background 0.3s;
}
.chatbot-fab:hover { transform: scale(1.05); background: #2980b9; }

.chatbot-container {
    position: fixed; bottom: 90px; right: 30px;
    width: 350px; height: 450px;
    background: #fcfcfc; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex; flex-direction: column;
    z-index: 1001; overflow: hidden;
    animation: fadeIn 0.3s; transition: background-color 0.3s;
}

.chatbot-header {
    background: #3498db; color: white; padding: 15px;
    display: flex; justify-content: space-between; align-items: center;
}

.chatbot-messages {
    flex: 1; padding: 15px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
    background: #f4f7f6;
}

.chat-bubble {
    max-width: 80%; padding: 10px 15px; border-radius: 15px;
    font-size: 14px; line-height: 1.4;
}
.chat-bot { background: white; border: 1px solid #e2e8f0; align-self: flex-start; color: #2c3e50; border-bottom-left-radius: 2px;}
.chat-user { background: #3498db; color: white; align-self: flex-end; border-bottom-right-radius: 2px;}

.chat-btn-suggest {
    background: transparent; border: 1px solid #3498db;
    color: #3498db; padding: 6px 12px; border-radius: 20px;
    font-size: 12px; cursor: pointer; text-align: left;
    transition: 0.2s; margin-top: 5px;
}
.chat-btn-suggest:hover { background: #3498db; color: white; }

.chatbot-input {
    padding: 10px; background: white; border-top: 1px solid #eee;
    display: flex; gap: 8px;
}
.chatbot-input input {
    flex: 1; padding: 10px; border: 1px solid #ddd;
    border-radius: 8px; font-size: 14px; outline: none;
}

/* Mode sombre du Chatbot */
body.dark-theme .chatbot-container { background: #1e1e1e; border: 1px solid #333; }
body.dark-theme .chatbot-messages { background: #121212; }
body.dark-theme .chat-bot { background: #2c2c2c; border-color: #444; color: #e0e0e0; }
body.dark-theme .chatbot-input { background: #1e1e1e; border-top-color: #333; }
body.dark-theme .chatbot-input input { background: #2c2c2c; color: white; border-color: #444; }

/* ==========================================
   BOÎTES SPÉCIALES (MOIS OFFERT)
   ========================================== */
.resiliation-box {
    margin-bottom: 20px; padding: 10px; border-radius: 8px; 
    border: 1px solid #eee; display: flex; align-items: center; gap: 10px;
    background: #fdfbfb;
}
body.dark-theme .resiliation-box {
    background: #2c2c2c; border-color: #444;
}