/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 50%, #1a365d 100%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px 0;
    color: white;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Panel de contrôle */
.control-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #e0e0e0;
}

.control-panel .container {
    display: flex;
    gap: 30px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.scenario-selector, .thermostat, .heating-selector, .floor-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.scenario-selector label, .thermostat label, .heating-selector label {
    font-weight: 600;
    color: #555;
}

.scenario-selector select, .heating-selector select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    transition: border-color 0.3s;
}

.scenario-selector select:focus, .heating-selector select:focus {
    outline: none;
    border-color: #667eea;
}

.heating-selector select {
    min-width: 180px;
}

.thermostat input[type="range"] {
    width: 120px;
    margin: 0 5px;
}

.thermostat #temp-display {
    font-weight: bold;
    color: #667eea;
    min-width: 50px;
    margin-left: 10px;
}

/* Boutons flèches de température */
.temp-arrow-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #667eea;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin: 0 2px;
}

.temp-arrow-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.05);
}

.temp-arrow-btn:active {
    transform: scale(0.95);
}

.temp-arrow-btn .arrow {
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}

.temp-arrow-btn.temp-up:hover {
    background: #e74c3c;
    border-color: #e74c3c;
}

.temp-arrow-btn.temp-down:hover {
    background: #3498db;
    border-color: #3498db;
}

/* Sélecteur d'étage */
.floor-btn {
    padding: 10px 20px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    margin: 0 5px;
}

.floor-btn.active, .floor-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Contenu principal */
.main-content {
    padding: 30px 0;
}

.simulation-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    align-items: start;
}

/* Plans d'étage */
.floor-plans {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.floor-plan {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.floor-plan.active {
    display: block;
    opacity: 1;
}

.floor-plan h3 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
    font-size: 1.3rem;
}

/* SVG Plans - Échelle agrandie */
.house-plan {
    width: 100%;
    height: auto;
    max-width: 1000px; /* Augmenté de 800px à 1000px */
    margin: 0 auto;
    display: block;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: #fafafa;
}

/* Labels des pièces - repositionnés en bas à droite */
.room-label {
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: bold;
    fill: #333;
    text-anchor: end; /* Alignement à droite */
}

.temp-text {
    font-weight: bold;
    fill: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.equipment-label {
    font-family: Arial, sans-serif;
    font-weight: bold;
    fill: #333;
}

/* Tuyauterie */
.pipe {
    transition: stroke 0.3s ease;
    cursor: pointer;
}

.pipe.hot {
    stroke: #ff4444;
    filter: drop-shadow(0 0 4px rgba(255, 68, 68, 0.5));
}

.pipe.cold {
    stroke: #4444ff;
}

.main-pipe {
    stroke-width: 10px; /* Augmenté pour la nouvelle échelle */
}

/* Vannes - animations supprimées */
.valve {
    cursor: pointer;
    stroke: #333;
    stroke-width: 2;
    user-select: none;
}

.valve[data-state="open"] {
    fill: #4CAF50;
}

.valve[data-state="closed"] {
    fill: #f44336;
}

.valve:hover {
    filter: brightness(1.2);
}

/* Radiateurs */
.radiator {
    cursor: pointer;
    transition: fill 0.3s ease;
}

.radiator.heating {
    fill: #e74c3c;
    filter: drop-shadow(0 0 3px rgba(231, 76, 60, 0.6));
}

.radiator.idle {
    fill: #666;
}

/* Chaudières */
.boiler {
    cursor: pointer;
    transition: all 0.3s ease;
}

.boiler:hover {
    filter: brightness(1.2) drop-shadow(0 0 8px rgba(231, 76, 60, 0.6));
}

.boiler:hover .equipment-label {
    fill: #667eea;
    font-weight: bold;
}

.boiler-status {
    transition: fill 0.3s ease;
}

.boiler.all-closed .boiler-status {
    fill: #f44336; /* Rouge quand toutes les vannes sont fermées */
}

.boiler.all-open .boiler-status {
    fill: #4CAF50; /* Vert quand toutes les vannes sont ouvertes */
}

.boiler.mixed .boiler-status {
    fill: #ff9800; /* Orange quand c'est mixte */
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Info Panel */
.info-panel {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.info-panel h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.info-panel p {
    margin-bottom: 15px;
    line-height: 1.6;
}

/* Type de chauffage */
.heating-type-section {
    margin: 15px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.heating-type-section .stat-item {
    margin-bottom: 0;
}

.heating-type-section .stat-value {
    font-size: 14px;
    color: #e74c3c;
}

/* Section informations puissance */
.power-info {
    margin-top: 15px;
    padding: 12px;
    background: #f0f8ff;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.power-info h4 {
    color: #3498db;
    margin-bottom: 8px;
    font-size: 1rem;
}

.power-info ul {
    margin: 0;
    padding-left: 16px;
}

.power-info li {
    margin-bottom: 4px;
    font-size: 13px;
    color: #555;
}

/* Statistiques */
.stats-section {
    margin: 20px 0;
    padding: 15px 0;
    border-top: 1px solid #e0e0e0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 5px 0;
}

.stat-label {
    font-weight: 500;
    color: #555;
}

.stat-value {
    font-weight: bold;
    color: #667eea;
}

/* Jauge d'efficacité */
.efficiency-section {
    margin-top: 20px;
    padding: 15px 0;
    border-top: 1px solid #e0e0e0;
}

.efficiency-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #555;
}

.meter {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.meter-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
    position: relative;
}

.meter-fill.excellent {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.meter-fill.good {
    background: linear-gradient(90deg, #f39c12, #e67e22);
}

.meter-fill.average {
    background: linear-gradient(90deg, #e67e22, #d35400);
}

.meter-fill.poor {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

#efficiency-value {
    font-weight: bold;
    color: #667eea;
    font-size: 1.1rem;
}

/* Lexique */
.lexique {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.lexique h4 {
    margin-bottom: 15px;
    color: #667eea;
    font-size: 1.1rem;
}

.lexique-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.lexique-item:hover {
    background: #f8f9fa;
}

.lexique-icon {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    flex-shrink: 0;
}

.lexique-icon.chaudiere { background: #e74c3c; }
.lexique-icon.vanne { background: #4CAF50; }
.lexique-icon.radiateur { background: #666; }
.lexique-icon.tuyau { background: #4444ff; }
.lexique-icon.thermostat { background: #f39c12; }
.lexique-icon.isolation { background: #95a5a6; }

.lexique-item span {
    font-size: 14px;
    color: #555;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    margin: 20px;
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s;
}

.close:hover {
    color: #667eea;
}

.help-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.help-content h3 {
    color: #667eea;
    margin: 20px 0 10px 0;
    font-size: 1.2rem;
}

.help-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.help-content li {
    margin-bottom: 8px;
}

/* Bouton d'aide */
.help-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 1500;
}

.help-button:hover {
    background: #5a67d8;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    transform: translateX(-50%);
}

.tooltip.hidden {
    display: none;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* Indicateurs de température animés */
.temp-arrow {
    pointer-events: none;
    z-index: 100;
}

.temp-arrow circle {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.temp-arrow text {
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Animation de pulsation pour les flèches */
@keyframes temp-arrow-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.temp-arrow.pulsing {
    animation: temp-arrow-pulse 1s infinite ease-in-out;
}

/* Messages temporaires */
.temp-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 3000;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
}

.temp-message.success {
    background: #27ae60;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.temp-message.error {
    background: #e74c3c;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.temp-message.warning {
    background: #f39c12;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .simulation-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .control-panel .container {
        flex-direction: column;
        gap: 15px;
    }
    
    .house-plan {
        max-width: 100%;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .sidebar {
        order: -1;
    }
}

@media (max-width: 480px) {
    .floor-plans {
        padding: 15px;
    }
    
    .info-panel, .lexique {
        padding: 15px;
    }
    
    .help-button {
        width: 50px;
        height: 50px;
        font-size: 20px;
        bottom: 20px;
        right: 20px;
    }
}
