:root {
    --bg-main: #F8F9FA;
    --bg-card: #FFFFFF;
    --text-primary: #343A40;
    --text-secondary: #6C757D;
    
    --color-ok: #D4EDDA;
    --color-ok-text: #155724;
    --color-risk: #FFF3CD;
    --color-risk-text: #856404;
    --color-danger: #F8D7DA;
    --color-danger-text: #721C24;
    
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Banner superior */
.banner {
    background-color: var(--text-primary);
    color: white;
    padding: 10px 20px;
    font-weight: bold;
    z-index: 1000;
    position: sticky;
    top: 0;
}

.banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.warning-text {
    background-color: #E63946;
    padding: 4px 12px;
    border-radius: 4px;
    animation: pulse 2s infinite;
}

.hidden { display: none; }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Layout Principal */
.dashboard-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    flex-grow: 1;
}

/* Sidebar */
.sidebar {
    background: white;
    border-right: 1px solid #DEE2E6;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

.sidebar h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.scrollable-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 5px;
}

.log-item {
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    border-left: 4px solid #CCC;
    background: #F1F3F5;
}

.log-item.repeated {
    border-left-color: var(--color-danger-text);
}

.badge-repeated {
    display: inline-block;
    background: var(--color-danger-text);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 5px;
}

/* Chat */
.chat-section {
    border-top: 1px solid #EEE;
    padding-top: 20px;
    height: 300px;
    display: flex;
    flex-direction: column;
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    max-width: 90%;
}

.msg.operator { background: #E9ECEF; align-self: flex-start; }

.chat-input-area {
    display: flex;
    gap: 8px;
}

.chat-input-area input {
    flex: 1;
    padding: 8px;
    border: 1px solid #DEE2E6;
    border-radius: 6px;
}

.chat-input-area button {
    padding: 8px 15px;
    background: var(--text-primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* Panel Central */
.main-panel {
    padding: 40px;
    overflow-y: auto;
}

.panel-header {
    margin-bottom: 30px;
}

.panel-header h1 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.boiler-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

/* Tarjeta de Caldera */
.boiler-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: var(--transition);
    border: 2px solid transparent;
}

.boiler-card h3 {
    margin-bottom: 20px;
    font-size: 1.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-badge {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: bold;
}

/* Estados */
.state-well { background-color: var(--color-ok); border-color: #C3E6CB; color: var(--color-ok-text); }
.state-risk { background-color: var(--color-risk); border-color: #FFEEBA; color: var(--color-risk-text); }
.state-danger { background-color: var(--color-danger); border-color: #F5C6CB; color: var(--color-danger-text); }

/* Indicadores */
.indicators {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.indicator {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon {
    width: 24px;
    height: 24px;
    opacity: 0.7;
}

.ind-info {
    flex: 1;
}

.ind-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: bold;
}

.ind-value {
    font-size: 1.2rem;
    font-weight: bold;
}

.alert-value { color: var(--color-danger-text); }

/* Gráficos */
.charts-grid {
    margin-top: 40px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.chart-box {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.chart-box.full-width {
    grid-column: span 2;
}

.chart-box h2 {
    margin-bottom: 15px;
    font-size: 1rem;
    color: var(--text-secondary);
}

canvas {
    width: 100% !important;
    max-height: 300px;
}

/* Notificaciones */
.notification-area {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
}

.notif {
    background: #721C24;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease-out;
    font-weight: bold;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* Controles de Caldera */
.boiler-controls {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.btn-off {
    background: #343A40;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.state-off {
    opacity: 0.5;
    background: #E9ECEF !important;
    border-color: #DEE2E6 !important;
    color: #6C757D !important;
}

/* Predicción */
.prediction-box {
    margin-top: 10px;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    background: #f8f9fa;
    border-left: 3px solid #6c757d;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.btn-download {
    background: #28a745;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
}

.notif {
    background: #25D366; /* WhatsApp Green */
    border-left: 5px solid #075E54;
    color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    min-width: 250px;
    position: relative;
}

.notif::before {
    content: '⚠️ ALERTA ';
    font-size: 0.7rem;
    display: block;
    margin-bottom: 5px;
    opacity: 0.8;
}
