/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:        #080c14;
  --bg2:       #0d1220;
  --card:      rgba(255,255,255,0.04);
  --border:    rgba(255,255,255,0.08);
  --text:      #e2e8f0;
  --muted:     #64748b;
  --accent:    #00d4ff;
  --glow:      0 0 20px rgba(0,212,255,0.3);
  --radius:    16px;
  --font:      'Segoe UI', system-ui, sans-serif;
}
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Fondo animado ───────────────────────────────────────── */
.bg-canvas {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(0,212,255,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 90%, rgba(124,58,237,0.07) 0%, transparent 60%),
    var(--bg);
}
.star { position: absolute; border-radius: 50%; background: #fff; animation: twinkle var(--d,3s) infinite alternate; opacity: 0; }
@keyframes twinkle { to { opacity: var(--o,.6); } }

/* ── Layout ──────────────────────────────────────────────── */
.wrap { position: relative; z-index: 1; height: 100vh; display: flex; flex-direction: column; }

/* ── Header ──────────────────────────────────────────────── */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  background: rgba(8,12,20,0.7);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #00d4ff, #7c3aed);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 0 16px rgba(0,212,255,0.4);
}
.logo-text { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.5px; }
.logo-text span { color: var(--accent); }

.header-center { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.clock { font-size: 1.6rem; font-weight: 700; letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.fecha { font-size: 0.75rem; color: var(--muted); text-transform: capitalize; }

.header-right { display: flex; align-items: center; gap: 14px; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:.4} }
.status-label { font-size: 0.78rem; color: var(--muted); }
.btn-cfg {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.btn-cfg:hover { color: var(--accent); border-color: var(--accent); box-shadow: var(--glow); }

/* ── Layout sidebar + cuerpo ─────────────────────────────── */
.layout {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Menú lateral ────────────────────────────────────────── */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 20px 12px;
  background: rgba(8,12,20,0.6);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
  overflow-y: auto;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all .2s;
  border: 1px solid transparent;
}
.menu-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}
.menu-item.activo {
  color: var(--accent);
  background: rgba(0,212,255,0.08);
  border-color: rgba(0,212,255,0.2);
}
.menu-icono { font-size: 1.1rem; flex-shrink: 0; }
.menu-label { flex: 1; }

/* ── Cuerpo principal ────────────────────────────────────── */
.cuerpo {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-width: 0;
}

/* ── iframe módulo ───────────────────────────────────────── */
.modulo-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

@media (max-width: 600px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 6px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .menu-item { padding: 8px 12px; font-size: 0.8rem; }
  .menu-label { display: none; }
  .menu-icono { font-size: 1.3rem; }
}

/* ── Alertas ─────────────────────────────────────────────── */
.alertas {
  display: flex; gap: 10px; padding: 10px 28px; flex-wrap: wrap;
  background: rgba(8,12,20,0.5);
  border-bottom: 1px solid var(--border);
}
.alerta {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 20px; font-size: 0.78rem;
  backdrop-filter: blur(10px);
}
.alerta.warn { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.3); color: #fbbf24; }
.alerta.info { background: rgba(0,212,255,0.08); border: 1px solid rgba(0,212,255,0.2); color: var(--accent); }
.alerta-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.alerta.warn .alerta-dot { background: #f59e0b; }
.alerta.info .alerta-dot { background: var(--accent); }

/* ── Stats bar ───────────────────────────────────────────── */
.stats-bar { display: flex; gap: 12px; padding: 16px 28px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 110px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  backdrop-filter: blur(10px);
}
.stat-icon { font-size: 1.4rem; flex-shrink: 0; }
.stat-info { display: flex; flex-direction: column; }
.stat-val { font-size: 1.05rem; font-weight: 700; }
.stat-lbl { font-size: 0.7rem; color: var(--muted); margin-top: 1px; }

/* ── Módulos grid ────────────────────────────────────────── */
.seccion-titulo {
  padding: 8px 28px 4px;
  font-size: 0.7rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.5px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  padding: 12px 28px 32px;
}
.modulo-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 14px;
  backdrop-filter: blur(12px);
  transition: all .25s;
  position: relative; overflow: hidden;
}
.modulo-card::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at top left, var(--c,transparent) 0%, transparent 60%);
  opacity: 0; transition: opacity .3s;
}
.modulo-card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,0.16); }
.modulo-card:hover::before { opacity: 1; }
.modulo-card.activo { border-color: rgba(255,255,255,0.14); }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.card-icono {
  width: 48px; height: 48px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  transition: box-shadow .3s;
}
.modulo-card.activo .card-icono { box-shadow: 0 0 18px var(--c, transparent); }

.toggle {
  width: 38px; height: 22px; border-radius: 11px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  position: relative; cursor: pointer; flex-shrink: 0;
  transition: background .3s;
}
.toggle::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #64748b; transition: all .3s;
}
.toggle.on { background: rgba(16,185,129,0.3); border-color: rgba(16,185,129,0.5); }
.toggle.on::after { background: #10b981; transform: translateX(16px); box-shadow: 0 0 8px #10b981; }

.card-nombre { font-size: 0.95rem; font-weight: 600; }
.card-valor { font-size: 0.82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.card-indicator { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.activo .card-indicator { animation: pulse-dot 2s infinite; }

/* ── Pie ─────────────────────────────────────────────────── */
footer {
  margin-top: auto;
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.72rem; color: var(--muted);
  background: rgba(8,12,20,0.6);
  backdrop-filter: blur(10px);
}
.footer-logo { color: var(--accent); font-weight: 600; }

/* ── Panel modal ─────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-panel {
  width: 100%; max-width: 540px;
  background: #0d1220;
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 28px 24px 40px;
  transform: translateY(100%);
  animation: slideUp .3s forwards;
}
@keyframes slideUp { to { transform: translateY(0); } }
.modal-handle { width: 36px; height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px; margin: 0 auto 20px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-titulo { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-iframe { width: 100%; height: 340px; border: none; border-radius: 12px; background: #080c14; }

/* ── Modal apagado ───────────────────────────────────────── */
.btn-power:hover { color: #ef4444 !important; border-color: #ef4444 !important; box-shadow: 0 0 20px rgba(239,68,68,0.4) !important; }

.modal-power {
  text-align: center;
  padding: 36px 28px 40px;
  border-color: rgba(239,68,68,0.2) !important;
}
.power-icono {
  font-size: 3rem;
  margin-bottom: 16px;
  animation: dcLatido 2s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(239,68,68,0.6));
}
@keyframes dcLatido {
  0%,100% { filter: drop-shadow(0 0 8px rgba(239,68,68,0.4)); }
  50%      { filter: drop-shadow(0 0 20px rgba(239,68,68,0.9)); }
}
.power-titulo {
  font-size: 1.2rem; font-weight: 700;
  color: #ef4444; margin-bottom: 14px;
}
.power-aviso {
  font-size: 0.84rem; color: var(--muted);
  line-height: 1.6; margin-bottom: 8px;
}
.power-pregunta {
  font-size: 0.9rem; color: var(--text);
  font-weight: 600; margin-bottom: 24px;
}
.power-acciones { display: flex; gap: 12px; }
.btn-power-si {
  flex: 1; padding: 13px;
  background: #ef4444; border: none;
  border-radius: 10px; color: #fff;
  font-size: 0.95rem; font-weight: 700;
  cursor: pointer; transition: background .2s;
}
.btn-power-si:hover { background: #b91c1c; }
.btn-power-no {
  flex: 1; padding: 13px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px; color: var(--muted);
  font-size: 0.95rem; cursor: pointer;
  transition: all .2s;
}
.btn-power-no:hover { color: var(--text); background: rgba(255,255,255,0.08); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 14px 16px; }
  .header-center .clock { font-size: 1.3rem; }
  .stats-bar, .grid { padding-left: 16px; padding-right: 16px; }
  .alertas { padding: 8px 16px; }
  .seccion-titulo { padding-left: 16px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .modal-panel { border-radius: 16px 16px 0 0; padding: 20px 16px 32px; }
}
@media (min-width: 900px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-panel { border-radius: 20px; }
  .modal-handle { display: none; }
}
