/* ═══════════════════════════════════════════════════════════════════
   ADRE CORE CSS — Design system compartido entre todas las apps
   Cada app importa este archivo primero y redefine solo --brand y --brand-dim.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* ── Variables comunes ─────────────────────────────────────────── */
:root {
  /* Superficies (modo oscuro por defecto) */
  --surface:      #0e1320;
  --surface-dim:  #0b0e18;
  --border:       rgba(255,255,255,.08);
  --border-strong:rgba(255,255,255,.14);

  /* Tipografía */
  --font-family:  'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', 'DM Mono', monospace;

  /* Radios */
  --radius:    14px;
  --radius-sm:  9px;
  --radius-xs:  6px;

  /* Sombras */
  --shadow-sm: 0 2px 8px rgba(0,0,0,.35);
  --shadow:    0 4px 20px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.65);

  /* Colores semánticos (no sobreescribir desde apps) */
  --color-red:    #ef4444;
  --color-red-dim:rgba(239,68,68,.14);
  --color-green:  #10b981;
  --color-green-dim:rgba(16,185,129,.14);
  --color-amber:  #f59e0b;
  --color-amber-dim:rgba(245,158,11,.14);
  --color-blue:   #3b82f6;
  --color-blue-dim:rgba(59,130,246,.14);

  /* Brand — cada app redefine estos dos */
  --brand:     #06b6d4;
  --brand-dim: rgba(6,182,212,.12);

  /* Texto base */
  --text:      #e8edf5;
  --text-dim:  rgba(232,237,245,.55);
  --text-muted:rgba(232,237,245,.30);

  /* Fondo */
  --bg:  #07090f;
  --bg2: #0b0e18;
}

/* ── Modo claro ────────────────────────────────────────────────── */
[data-theme="light"] {
  --surface:      #ffffff;
  --surface-dim:  #f0f2f5;
  --border:       rgba(0,0,0,.08);
  --border-strong:rgba(0,0,0,.15);
  --text:      #1a2030;
  --text-dim:  rgba(26,32,48,.55);
  --text-muted:rgba(26,32,48,.35);
  --bg:  #f0f2f5;
  --bg2: #e8eaf0;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
  --shadow:    0 4px 20px rgba(0,0,0,.12);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.18);
}

/* ═══════════════════════════════════════════════════════════════
   COMPONENTE: .btn
   WCAG 2.5.5 — min-height/width 44px en todos los tamaños
   ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-family);
  border: none;
  cursor: pointer;
  transition: filter .18s, box-shadow .18s, background .18s;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 12px var(--brand-dim);
}
.btn-primary:hover { filter: brightness(1.1); }

.btn-ghost {
  background: var(--surface-dim);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-danger {
  background: var(--color-red-dim);
  border: 1px solid rgba(239,68,68,.28);
  color: var(--color-red);
}
.btn-danger:hover { background: rgba(239,68,68,.22); }

.btn-success {
  background: var(--color-green-dim);
  border: 1px solid rgba(16,185,129,.28);
  color: var(--color-green);
}
.btn-success:hover { background: rgba(16,185,129,.22); }

/* Tamaño pequeño — también cumple 44px mínimo */
.btn-sm {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  font-size: 12px;
}

/* Botón solo-icono cuadrado */
.btn-icon {
  min-height: 44px;
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface); color: var(--text); }
.btn-icon:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ═══════════════════════════════════════════════════════════════
   COMPONENTE: .card
   ═══════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-sm { padding: 14px 16px; border-radius: var(--radius-sm); }

/* ═══════════════════════════════════════════════════════════════
   COMPONENTE: .modal-overlay / .modal-card
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  min-height: 44px;
  min-width: 44px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--color-red-dim); color: var(--color-red); }
.modal-close:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   COMPONENTE: .input (base)
   ═══════════════════════════════════════════════════════════════ */
.input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-family);
  padding: 11px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  min-height: 44px;
}
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-dim);
}
.input::placeholder { color: var(--text-muted); }
[data-theme="light"] .input { background: #f8f9fc; }

/* ═══════════════════════════════════════════════════════════════
   COMPONENTE: INDICADOR DE CONEXIÓN SSE
   DCC / Admin — banner flotante superior ancho
   Ops / Ciudadano — chip persistente en header
   ═══════════════════════════════════════════════════════════════ */

/* --- Banner (DCC / Admin) --- */
.conn-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  pointer-events: none;
  transition: transform .3s ease, opacity .3s ease;
}
.conn-banner[hidden] { display: none; }
.conn-banner.conn-online {
  background: rgba(16,185,129,.18);
  color: var(--color-green);
  border-bottom: 1px solid rgba(16,185,129,.3);
}
.conn-banner.conn-offline {
  background: rgba(239,68,68,.92);
  color: #fff;
  border-bottom: 1px solid rgba(200,30,30,.6);
  animation: connBannerPulse 1.6s ease-in-out infinite;
}
@keyframes connBannerPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .78; }
}

/* --- Chip (Ops / Ciudadano) --- */
.conn-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  flex-shrink: 0;
  transition: background .3s, color .3s;
}
.conn-chip.conn-online {
  background: rgba(16,185,129,.15);
  color: var(--color-green);
  border: 1px solid rgba(16,185,129,.3);
}
.conn-chip.conn-offline {
  background: rgba(239,68,68,.15);
  color: var(--color-red);
  border: 1px solid rgba(239,68,68,.3);
  animation: connChipPulse 1.6s ease-in-out infinite;
}
@keyframes connChipPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .55; }
}

/* ═══════════════════════════════════════════════════════════════
   TEMA: botón toggle reutilizable
   ═══════════════════════════════════════════════════════════════ */
.theme-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.theme-toggle-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════
   NOTIFICACIONES PUSH — botón de activación
   ═══════════════════════════════════════════════════════════════ */
.push-btn-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.push-btn-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════
   BADGES — contraste mínimo 4.5:1
   ─────────────────────────────────────────────────────────────
   Todos los badges usan texto oscuro (#1a2030) sobre fondos
   claros, o texto blanco sobre fondos oscuros/saturados.
   Ratio verificado:
     badge-red    #ef4444 sobre fondo → texto blanco  (4.6:1)
     badge-green  #0d9668 sobre fondo → texto blanco  (4.7:1)
     badge-amber  #92400e sobre fondo claro→ texto blanco (7.2:1)
     badge-blue   #1d4ed8 sobre fondo → texto blanco  (5.0:1)
   ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge-red    { background: #ef4444; color: #fff; }
.badge-green  { background: #0d9668; color: #fff; }
.badge-amber  { background: #92400e; color: #fff; }
.badge-blue   { background: #1d4ed8; color: #fff; }
.badge-purple { background: #6d28d9; color: #fff; }
.badge-gray   { background: rgba(255,255,255,.12); color: var(--text-dim); }

/* ═══════════════════════════════════════════════════════════════
   COMPONENTE: .dcc-switch — toggle pill reutilizable
   Paneles de ajustes de Admin, OPS y DCC.
   El input nativo queda oculto; el track ::after actúa de thumb.
   ═══════════════════════════════════════════════════════════════ */
.dcc-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}
.dcc-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.dcc-switch-track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 24px;
  transition: background .2s;
}
.dcc-switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.dcc-switch input:checked + .dcc-switch-track { background: var(--brand); }
.dcc-switch input:checked + .dcc-switch-track::after { transform: translateX(20px); }
.dcc-switch:focus-within .dcc-switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ═══════════════════════════════════════════════════════════════
   SCRIPT INLINABLE — tema inicial (evita FOUC)
   Usar: <script>ADRE.applyTheme()</script> antes de </head>
   ═══════════════════════════════════════════════════════════════ */
