/* Estilo "app del vecino" para el panel de la Central.
   Se carga DESPUÉS de style.css: redefine la paleta y pisa los componentes
   para que panel y app compartan identidad (slate oscuro, tarjetas
   redondeadas, cajitas de icono con borde, chips y pastillas). */

:root {
  --bg: #020617;
  --bg-panel: #0f172a;
  --bg-card: #0b1220;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #e11d48;
  --on-primary: #ffffff;
  --rojo: #fb7185;
  --celeste: #60a5fa;
  --ambar: #fbbf24;
  --verde: #34d399;
  --radius: 14px;
  --radius-lg: 20px;
  --font-mono: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html.tema-claro {
  --bg: #f1f5f9;
  --bg-panel: #ffffff;
  --bg-card: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #e11d48;
  --on-primary: #ffffff;
  --rojo: #e11d48;
  --celeste: #2563eb;
  --ambar: #b45309;
  --verde: #059669;
}

/* ===== Controles generales: esquinas redondeadas ===== */
.content input, .content select, .content textarea,
.modal-body input, .modal-body select, .modal-body textarea,
.config-card input, .form-comunicado input, .form-comunicado textarea,
.filtros-historial select, .filtros-historial input,
.usuarios-header input, .paginado-selector select, .checkboxes-tipo {
  border-radius: 12px !important;
  border-color: var(--border-strong);
}
.content button, .modal-body button, .btn-paginado, .btn-ver-mapa,
.tabla-historial .acciones button {
  border-radius: 12px !important;
}
.filtros-historial button, .usuarios-header button, #btn-nuevo-operador,
.modal-body button[type="submit"], .config-card form button[type="submit"],
.form-comunicado button[type="submit"], .btn-notificar {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}
.content input:focus, .content select:focus, .content textarea:focus,
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.btn-atender-seleccionadas, .alerta-card button.btn-atender { color: #022c22; }

.tabla-wrap, .filtros-historial, .config-card, .form-comunicado,
.modal-box, #mapa-historial {
  border-radius: var(--radius-lg);
}
.tabla-historial th, .stat-barra-titulo, .stat-grupo-titulo, .domotica-titulo {
  text-transform: none;
  letter-spacing: 0;
  font-family: inherit;
}
.tabla-historial th { font-size: 12px; }
.modal-box { border-color: var(--border-strong); }
.modal-overlay { background: rgba(0, 0, 0, 0.75); }
.pill { font-weight: 700; }

/* ===== Login ===== */
.pantalla-login { background: var(--bg); }
.radar-ring, .radar-sweep { display: none; }
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  box-shadow: none;
}
.login-card h1 { font-weight: 800; }
.login-logo { filter: none; }
.login-sub {
  color: var(--rojo);
  text-transform: none;
  letter-spacing: 0.3px;
  font-family: inherit;
  font-size: 13px;
}
.login-card label {
  text-transform: none;
  letter-spacing: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.login-card input { border-radius: 14px; border-color: var(--border-strong); }
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-card button {
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  text-transform: none;
  letter-spacing: 0;
  font-size: 15px;
  box-shadow: none;
}
.login-card button:hover { box-shadow: none; }

/* ===== Layout: riel lateral con iconos + barra superior ===== */
.app { background-image: none; }

.sidebar {
  width: 88px;
  border-top: none;
  box-shadow: none;
  background: var(--bg);
}
.sidebar-brand { justify-content: center; padding: 14px 0; border-bottom: none; }
.sidebar-brand .marca-icono-img { width: 34px; height: 34px; }

.sidebar-nav { padding: 6px; gap: 4px; align-items: stretch; }
.nav-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 2px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}
.nav-btn svg { display: block; }
.nav-btn:hover:not(:disabled) { background: var(--bg-panel); color: var(--text); }
.nav-btn.activo {
  background: rgba(225, 29, 72, 0.12);
  color: var(--primary);
  font-weight: 800;
}
html.tema-claro .nav-btn.activo { background: rgba(225, 29, 72, 0.1); }
.nav-badge {
  position: absolute;
  top: 4px;
  right: 14px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.content { flex: 1; min-height: 0; overflow: auto; padding: 18px 20px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.tb-titulo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; }
.tb-escudo { color: var(--primary); display: flex; }
.tb-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  background: #022c22;
  border: 1px solid rgba(5, 150, 105, 0.55);
  color: #6ee7b7;
}
.tb-pill b { width: 6px; height: 6px; border-radius: 50%; background: #34d399; }
.tb-pill-off { background: #451a03; border-color: rgba(217, 119, 6, 0.55); color: #fcd34d; }
.tb-pill-off b { background: #fbbf24; }
html.tema-claro .tb-pill { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
html.tema-claro .tb-pill-off { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.tb-sp { flex: 1; }
.tb-user { text-align: right; }
.tb-user .sidebar-usuario { margin: 0; font-size: 12px; color: var(--text-muted); }
.tb-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.tb-btn:hover { color: var(--text); border-color: var(--text-muted); }
.tb-btn-salir { color: var(--rojo); }
.tb-btn-salir:hover { border-color: var(--rojo); color: var(--rojo); }

.general-wrap { height: 100%; }

/* ===== Tarjetas de conteo (como los botones de emergencia de la app) ===== */
.stat-barra { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 20px;
  box-shadow: none;
  background: var(--bg-panel);
}
.stat-card:hover { transform: none; box-shadow: none; }
.stat-ico {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
}
.stat-card-valor { font-family: inherit; font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-card-label { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; margin-top: 2px; }

.stat-card.tipo-ROBO { background: #c81e3a; border-color: rgba(248, 113, 113, 0.6); }
.stat-card.tipo-EMERGENCIA_MEDICA { background: #1d5fd0; border-color: rgba(56, 189, 248, 0.6); }
.stat-card.tipo-MOVIMIENTO_SOSPECHOSO { background: #c67a0a; border-color: rgba(252, 211, 77, 0.6); }
.stat-card.tipo-ROBO .stat-card-valor, .stat-card.tipo-EMERGENCIA_MEDICA .stat-card-valor,
.stat-card.tipo-MOVIMIENTO_SOSPECHOSO .stat-card-valor { color: #fff; }
.stat-card.tipo-ROBO .stat-card-label, .stat-card.tipo-EMERGENCIA_MEDICA .stat-card-label,
.stat-card.tipo-MOVIMIENTO_SOSPECHOSO .stat-card-label { color: rgba(255, 255, 255, 0.88); }

.stat-total-card { border-color: var(--border-strong); }
.stat-total-card .stat-ico, .stat-verde-card .stat-ico, .stat-ambar-card .stat-ico {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-muted);
}
.stat-total-card .stat-card-valor { color: var(--text); }
.stat-total-card .stat-card-label, .stat-verde-card .stat-card-label, .stat-ambar-card .stat-card-label { color: var(--text-muted); }
.stat-verde-card { border-color: rgba(16, 185, 129, 0.4); }
.stat-verde-card .stat-card-valor { color: var(--verde); }
.stat-ambar-card { border-color: rgba(245, 158, 11, 0.4); }
.stat-ambar-card .stat-card-valor { color: var(--ambar); }

/* ===== General: mapa y lista de alertas ===== */
#mapa { border: 1px solid var(--border); border-radius: var(--radius-lg); }
.panel-alertas {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: none;
}
.panel-alertas h3 {
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
  font-size: 15px;
  font-weight: 800;
}
.badge-conteo { background: var(--primary); color: #fff; font-family: inherit; font-weight: 800; }
.lista-alertas { padding: 12px; gap: 10px; }

.alerta-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
}
.alerta-card:hover { border-color: var(--border-strong); }
.alerta-card:not(.atendida) { border-color: rgba(244, 63, 94, 0.55); background: rgba(76, 5, 25, 0.22); }
html.tema-claro .alerta-card:not(.atendida) { background: #fff1f2; }
.alerta-card.tipo-EMERGENCIA_MEDICA:not(.atendida) { border-color: rgba(59, 130, 246, 0.55); background: rgba(23, 37, 84, 0.3); }
.alerta-card.tipo-MOVIMIENTO_SOSPECHOSO:not(.atendida) { border-color: rgba(245, 158, 11, 0.55); background: rgba(69, 26, 3, 0.3); }
html.tema-claro .alerta-card.tipo-EMERGENCIA_MEDICA:not(.atendida) { background: #eff6ff; }
html.tema-claro .alerta-card.tipo-MOVIMIENTO_SOSPECHOSO:not(.atendida) { background: #fffbeb; }
.alerta-card.atendida { opacity: 0.7; border-color: var(--border); }

.ac-top { display: flex; align-items: flex-start; gap: 10px; }
.ac-ico {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(69, 10, 10, 0.8);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.5);
}
.tipo-EMERGENCIA_MEDICA .ac-ico { background: rgba(23, 37, 84, 0.8); color: #60a5fa; border-color: rgba(59, 130, 246, 0.5); }
.tipo-MOVIMIENTO_SOSPECHOSO .ac-ico { background: rgba(69, 26, 3, 0.8); color: #fbbf24; border-color: rgba(245, 158, 11, 0.5); }
html.tema-claro .ac-ico { background: #fee2e2; }
html.tema-claro .tipo-EMERGENCIA_MEDICA .ac-ico { background: #dbeafe; }
html.tema-claro .tipo-MOVIMIENTO_SOSPECHOSO .ac-ico { background: #fef3c7; }
.ac-tit { flex: 1; min-width: 0; }
.ac-tit b { display: block; font-size: 13px; font-weight: 800; }
.ac-tit small { color: var(--text-muted); font-size: 11px; }
.ac-badge {
  border-radius: 99px;
  padding: 2px 9px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  background: #4c0519;
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.4);
}
html.tema-claro .ac-badge { background: #ffe4e6; color: #be123c; }
.alerta-card.atendida .ac-badge {
  background: #022c22;
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}
html.tema-claro .alerta-card.atendida .ac-badge { background: #d1fae5; color: #047857; }
.alerta-card .check-seleccion { position: static; transform: none; margin: 8px 0 0 2px; flex: none; }
.ac-dir {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text);
}
.ac-dir span:last-child { color: var(--text-muted); white-space: nowrap; }
.ac-nota { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 8px; }
.alerta-card button.btn-atender { border-radius: 12px; padding: 8px; margin-top: 10px; }
.vacio { color: var(--text-muted); }

/* ===== Aviso de alerta entrante ===== */
.alerta-popup-overlay { background: rgba(0, 0, 0, 0.85); }
.alerta-popup-caja {
  border: 2px solid var(--primary);
  border-radius: 26px;
  padding: 22px;
  background: var(--bg-panel);
}
.alerta-popup-titulo { font-size: 13px; letter-spacing: 2px; color: var(--rojo); }
.alerta-popup-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
}
.alerta-popup-card::before { content: none; }
.alerta-popup-tipo { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.ap-ico {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(69, 10, 10, 0.8);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.5);
}
.tipo-EMERGENCIA_MEDICA .ap-ico { background: rgba(23, 37, 84, 0.8); color: #60a5fa; border-color: rgba(59, 130, 246, 0.5); }
.tipo-MOVIMIENTO_SOSPECHOSO .ap-ico { background: rgba(69, 26, 3, 0.8); color: #fbbf24; border-color: rgba(245, 158, 11, 0.5); }
.alerta-popup-card.tipo-ROBO { border-color: rgba(244, 63, 94, 0.55); }
.alerta-popup-card.tipo-EMERGENCIA_MEDICA { border-color: rgba(59, 130, 246, 0.55); }
.alerta-popup-card.tipo-MOVIMIENTO_SOSPECHOSO { border-color: rgba(245, 158, 11, 0.55); }
.alerta-popup-nombre { font-size: 19px; font-weight: 800; }
.alerta-popup-datos div { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.alerta-popup-acciones button, .alerta-popup-cerrar {
  border-radius: 14px;
  border: 2px solid var(--border-strong);
  background: var(--border);
  color: var(--text);
  font-weight: 700;
  padding: 11px;
}
.alerta-popup-acciones .btn-atender { background: #10b981; border-color: #10b981; color: #022c22; }

/* ===== Avisos: chips de destinatarios en ámbar, como la app ===== */
.chip-grupo { background: var(--bg); border-color: var(--border-strong); }
.chip-grupo.activo { background: #f59e0b; border-color: #f59e0b; color: #020617; }

.toast { border-radius: 16px; background: var(--bg-panel); }

/* ===== Dialogo.js — reemplaza prompt()/confirm()/alert() del navegador ===== */
.dialogo-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0, 0, 0, 0.75);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.dialogo-caja {
  width: 100%; max-width: 420px;
  background: var(--bg-panel); border: 1px solid var(--border-strong); border-radius: 20px;
  padding: 20px;
}
.dialogo-cuerpo h3 { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; }
.dialogo-cuerpo p { margin: 0 0 14px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.dialogo-cuerpo input, .dialogo-cuerpo textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 10px 12px; color: var(--text); font-size: 13px; font-family: inherit; margin-bottom: 16px; resize: vertical;
}
.dialogo-cuerpo input:focus, .dialogo-cuerpo textarea:focus { outline: none; border-color: var(--primary); }
.dialogo-acciones { display: flex; gap: 10px; justify-content: flex-end; }
.dialogo-acciones button { border-radius: 12px; padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; border: 1px solid var(--border-strong); }
.dialogo-cancelar { background: transparent; color: var(--text-muted); }
.dialogo-cancelar:hover { color: var(--text); }
.dialogo-ok { background: var(--primary); border-color: var(--primary); color: #fff; }
.dialogo-peligro { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.dialogo-cuerpo.dialogo-error h3 { color: var(--rojo); }
.dialogo-cuerpo.dialogo-ok h3 { color: var(--verde); }

/* ===== Historial: tipo con icono + pill de estado con icono ===== */
.pill { display: inline-flex; align-items: center; gap: 5px; }
.tipo-cell { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
.tipo-ico { display: inline-flex; color: var(--rojo); }
.tipo-cell.tipo-EMERGENCIA_MEDICA .tipo-ico { color: var(--celeste); }
.tipo-cell.tipo-MOVIMIENTO_SOSPECHOSO .tipo-ico { color: var(--ambar); }
.modal-header h3 { display: flex; align-items: center; gap: 8px; }
.ficha-medica { display: flex; align-items: flex-start; gap: 6px; }
.domotica-vacio, .domotica-titulo, .domotica-item { display: flex; align-items: center; gap: 6px; }
.gps-aprox { display: flex; align-items: center; gap: 6px; }
.btn-notificar, .btn-ver-mapa { display: inline-flex; align-items: center; gap: 7px; justify-content: center; }
