/* --- VARIABLES INTELIGENTES --- */
:root {
    --bg-body: #f1f5f9; --glass-bg: #ffffff; --glass-border: rgba(0,0,0,0.08);
    --text-main: #1e293b; --text-muted: #64748b;
    --primary: #3b82f6; --danger: #ef4444; --warning: #f59e0b; --success: #10b981;
    --card-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); --input-bg: #f8fafc;
    --header-gradient-1: rgba(186, 230, 253, 0.5); --header-gradient-2: rgba(221, 214, 254, 0.5);
    --monitor-alert-bg: #fee2e2; --monitor-alert-text: #dc2626;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #0f172a; --glass-bg: rgba(30,41,59,0.7); --glass-border: rgba(255,255,255,0.1);
        --text-main: #f8fafc; --text-muted: #94a3b8;
        --primary: #60a5fa; --danger: #f87171; --warning: #fbbf24; --success: #34d399;
        --card-shadow: 0 4px 6px -1px rgba(0,0,0,0.3); --input-bg: rgba(0,0,0,0.3);
        --header-gradient-1: rgba(59,130,246,0.15); --header-gradient-2: rgba(16,185,129,0.15);
        --monitor-alert-bg: rgba(239,68,68,0.25); --monitor-alert-text: #fecaca;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

body {
    background-color: var(--bg-body);
    background-image: radial-gradient(at 0% 0%, var(--header-gradient-1) 0px, transparent 50%), radial-gradient(at 100% 100%, var(--header-gradient-2) 0px, transparent 50%);
    background-attachment: fixed; color: var(--text-main); min-height: 100vh; transition: background 0.5s ease;
    padding: 80px 20px 20px 20px; 
}

/* LOGIN STYLES */
.login-wrapper { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index: 2000; background: var(--bg-body); }
.login-card { width: 350px; text-align: center; padding: 40px !important; }
.login-header h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 5px; }
.login-header p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 30px; letter-spacing: 1px; }
.login-form input { width: 100%; margin-bottom: 15px; background: var(--input-bg); border: 1px solid var(--glass-border); padding: 12px; border-radius: 8px; color: var(--text-main); outline: none; }
.login-form button { width: 100%; background: var(--primary); color: white; border: none; padding: 12px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.login-form button:hover { opacity: 0.9; }
.login-alert { margin-top: 15px; color: var(--danger); font-size: 0.85rem; font-weight: 600; min-height: 20px; }

.dashboard-container { width: 100%; max-width: 1200px; margin: 0 auto; }
.glass-panel { background: var(--glass-bg); box-shadow: var(--card-shadow); border: 1px solid var(--glass-border); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: 16px; padding: 20px; margin-bottom: 20px; transition: background 0.3s ease; }

header { display: flex; justify-content: space-between; align-items: center; transition: all 0.5s; }
header.critical-offline { background: var(--monitor-alert-bg) !important; border: 2px solid var(--danger); animation: alarm-pulse 2s infinite; }
.brand h1 { font-size: 1.1rem; font-weight: 800; }
.brand span { font-size: 0.8rem; color: var(--text-muted); display: block; margin-top: 4px; font-weight: 500;}

.client-selector-group { display: flex; align-items: center; gap: 10px; background: var(--input-bg); padding: 5px 15px; border-radius: 20px; border: 1px solid var(--glass-border); }
.client-selector-group label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); }
.client-selector-group select { background: transparent; border: none; font-weight: 800; color: var(--primary); font-size: 0.9rem; cursor: pointer; outline: none; }
.btn-logout-mini { background: transparent; border: 1px solid var(--glass-border); color: var(--danger); width: 35px; height: 35px; border-radius: 50%; cursor: pointer; display: flex; justify-content: center; align-items: center; margin-left: 10px; }
.btn-logout-mini:hover { background: rgba(239,68,68,0.1); }

.status-badge { font-size: 0.75rem; padding: 6px 12px; border-radius: 20px; display: flex; align-items: center; gap: 8px; font-weight: 700; text-transform: uppercase; }
.status-badge.offline { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.status-badge.online { background: rgba(16, 185, 129, 0.2); color: var(--success); }

.main-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
.monitor { text-align: center; padding: 30px 20px; transition: all 0.3s ease; }
.monitor h2 { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; font-weight: 700; }
.status-text { font-size: 2.2rem; font-weight: 900; }
.monitor.safe .status-text { color: var(--success); }
.monitor.alert { background: var(--monitor-alert-bg) !important; border-color: var(--danger); animation: alarm-pulse 1s infinite; }
.monitor.alert .status-text { color: var(--monitor-alert-text); }

/* ESTILO NUEVO DEL BOTÓN SIRENA MASTER (MODIFICADO A ESTADO NEUTRO TOTAL) */
.siren-group { display: grid; gap: 12px; margin-bottom: 12px; }
.btn-sirena-master {
    background-color: var(--input-bg); 
    color: var(--text-main);
    border: 1px solid var(--glass-border); /* Borde idéntico a los otros botones */
    border-radius: 12px;
    padding: 25px 20px;
    font-size: 24px;
    font-weight: 800;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}
.btn-sirena-master:hover { transform: translateY(-2px); border-color: var(--danger); color: var(--danger); box-shadow: 0 8px 20px rgba(239, 68, 68, 0.2); }
.btn-sirena-master:active { transform: scale(0.95); }

/* ESTADO CUANDO LA SIRENA ESTÁ SONANDO (ROJO Y PARPADEANDO) */
.btn-sirena-master.active {
    background-color: var(--danger) !important;
    color: white !important;
    border-color: var(--danger) !important;
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.6);
    animation: alarm-pulse 1s infinite;
}

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.btn-control { background: var(--input-bg); border: 1px solid var(--glass-border); color: var(--text-main); padding: 25px 10px; border-radius: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 10px; transition: all 0.2s ease; }
.btn-control:hover { border-color: var(--primary); transform: translateY(-2px); color: var(--primary); }
.btn-control i { font-size: 1.6rem; }
.btn-control span { font-weight: 700; font-size: 0.85rem; }
.btn-control.active { background: var(--danger) !important; color: white !important; border-color: var(--danger); transform: scale(0.98); box-shadow: 0 0 15px rgba(239, 68, 68, 0.4); }

.voice-panel h3, .client-info h3, .node-details h3, .logs-panel h3 { margin-bottom: 15px; font-size: 0.85rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.quick-messages { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 15px; }
.quick-messages button { background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3); color: var(--primary); padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 0.75rem; font-weight: 600; }
.quick-messages button:hover { background: var(--primary); color: white; }
.input-group, .log-input-group { display: flex; gap: 10px; }
input[type="text"] { flex-grow: 1; background: var(--input-bg); border: 1px solid var(--glass-border); color: var(--text-main); padding: 12px; border-radius: 8px; outline: none; }
.btn-send, .log-input-group button { background: var(--primary); border: none; color: white; padding: 0 20px; border-radius: 8px; cursor: pointer; }
.log-input-group button { width: 40px; padding: 0; background: var(--success); }

.client-card { display: flex; align-items: center; gap: 15px; background: var(--input-bg); padding: 15px; border-radius: 12px; }
.client-avatar { background: rgba(59, 130, 246, 0.2); color: var(--primary); width: 45px; height: 45px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1.2rem; }
.client-data h4 { font-size: 0.95rem; margin-bottom: 2px; color: var(--text-main); }
.client-data p { font-size: 0.8rem; color: var(--text-muted); }
.detail-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--glass-border); padding: 10px 0; font-size: 0.9rem; }
.logs-panel { max-height: 500px; display: flex; flex-direction: column; }
#log-list { overflow-y: auto; list-style: none; flex-grow: 1; padding-right: 5px; }
.log-item { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--glass-border); font-size: 0.85rem; align-items: center; }
.log-time { font-family: monospace; color: var(--text-muted); font-size: 0.75rem; }
.app-footer { text-align: center; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--glass-border); color: var(--text-muted); font-size: 0.8rem; }
@keyframes alarm-pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
@media (max-width: 768px) { .main-grid { grid-template-columns: 1fr; } }

/* === BARRA OPS CENTER === */
#operator-hud {
    position: fixed; top: 0; left: 0; width: 100%; height: 60px;
    background: #0f172a; 
    border-bottom: 1px solid #334155;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 25px; box-sizing: border-box; 
    z-index: 1500; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    transition: background 0.3s ease;
}

#operator-hud.alarm-state {
    background: #450a0a; 
    border-bottom: 4px solid #ef4444;
    animation: pulseBg 1s infinite alternate;
}
@keyframes pulseBg { from { box-shadow: inset 0 0 20px #7f1d1d; } to { box-shadow: inset 0 0 60px #ef4444; } }

.hud-brand { font-weight: 800; font-size: 20px; letter-spacing: -1px; color: white; font-family: sans-serif; }
.hud-brand span { color: #f59e0b; }

.client-chips { display: flex; gap: 12px; overflow-x: auto; align-items: center; }

.chip {
    padding: 5px 15px; border-radius: 50px;
    font-size: 13px; font-weight: 600; color: white; display: flex; align-items: center; gap: 8px;
    cursor: pointer; transition: 0.3s; white-space: nowrap; font-family: sans-serif;
}

.chip.online { background: #14532d; border: 1px solid #22c55e; }
.chip.online .led { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 8px #22c55e; }

.chip.offline { background: #7f1d1d; border: 1px solid #ef4444; animation: shake 0.5s; }
.chip.offline .led { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; animation: blinkFast 0.2s infinite; }

@keyframes blinkFast { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }