/* public/css/app.css — Sin dependencias externas */

/* ── Reset mínimo ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --azul:       #1A6BFF;
  --azul-dark:  #0D47C7;
  --azul-light: #EFF5FF;
  --verde:      #22C55E;
  --verde-bg:   #DCFCE7;
  --rojo:       #EF4444;
  --rojo-bg:    #FEE2E2;
  --amber:      #F59E0B;
  --amber-bg:   #FEF3C7;

  --blanco:     #FFFFFF;
  --gris-0:     #F8FAFF;
  --gris-1:     #F1F5F9;
  --gris-2:     #E2E8F0;
  --gris-3:     #CBD5E1;
  --gris-4:     #94A3B8;
  --gris-5:     #64748B;
  --gris-6:     #475569;
  --negro:      #0F172A;

  --radio:      12px;
  --radio-lg:   18px;
  --radio-pill: 999px;

  --sombra-sm:  0 1px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --sombra-md:  0 4px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  --sombra-lg:  0 12px 40px rgba(0,0,0,0.14), 0 4px 12px rgba(0,0,0,0.08);

  font-family: system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--negro);
  background: var(--gris-0);
}

/* ── Pantallas ─────────────────────────────────────────────── */
body { min-height: 100vh; display: flex; flex-direction: column; }

.pantalla {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  background: var(--gris-0);
}
.pantalla.activa { display: flex; }

/* ── Tipografía ────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.125rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p  { color: var(--gris-5); font-size: 0.9rem; }

/* ── Botones ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radio);
  border: none;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s, box-shadow 0.18s;
  font-family: inherit;
  width: 100%;
}
.btn:active { transform: scale(0.98); }

.btn-primario {
  background: var(--azul);
  color: var(--blanco);
  box-shadow: 0 2px 8px rgba(26,107,255,0.35);
}
.btn-primario:hover { background: var(--azul-dark); }

.btn-secundario {
  background: var(--gris-1);
  color: var(--gris-6);
  border: 1px solid var(--gris-2);
}
.btn-secundario:hover { background: var(--gris-2); }

.btn-verde {
  background: var(--verde);
  color: var(--blanco);
  box-shadow: 0 2px 8px rgba(34,197,94,0.35);
}

.btn-rojo {
  background: var(--rojo);
  color: var(--blanco);
}

.btn-icono {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--blanco);
  flex-shrink: 0;
}

/* ── Campos de formulario ──────────────────────────────────── */
.campo { margin-bottom: 14px; }

.campo label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gris-5);
  margin-bottom: 5px;
}

.campo input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--gris-2);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--negro);
  background: var(--blanco);
  transition: border-color 0.18s;
  outline: none;
}
.campo input:focus { border-color: var(--azul); }
.campo input::placeholder { color: var(--gris-3); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--blanco);
  border: 1px solid var(--gris-2);
  border-radius: var(--radio);
  padding: 16px;
  box-shadow: var(--sombra-sm);
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radio-pill);
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-azul   { background: var(--azul-light);  color: var(--azul-dark); }
.badge-verde  { background: var(--verde-bg);     color: #166534; }
.badge-rojo   { background: var(--rojo-bg);      color: #991B1B; }
.badge-amber  { background: var(--amber-bg);     color: #92400E; }

/* ── Toast / notificación ──────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--negro);
  color: var(--blanco);
  padding: 10px 20px;
  border-radius: var(--radio-pill);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: var(--sombra-lg);
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}
#toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Spinner de carga ──────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: var(--blanco);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs de rol ───────────────────────────────────────────── */
.tabs-rol {
  display: flex;
  background: var(--gris-1);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 20px;
}
.tab-rol {
  flex: 1; padding: 8px 0;
  border: none; background: transparent;
  border-radius: 8px;
  font-size: 0.82rem; font-weight: 500;
  color: var(--gris-5);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.tab-rol.activo { background: var(--azul); color: var(--blanco); }

/* ────────────────────────────────────────────────────────────
   PANTALLA: LOGIN
──────────────────────────────────────────────────────────── */
#p-login {
  background: linear-gradient(155deg, var(--azul-light) 0%, var(--blanco) 45%);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--blanco);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--sombra-lg);
}

.login-logo {
  width: 56px; height: 56px;
  background: var(--azul);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

.login-titulo { text-align: center; margin-bottom: 4px; }
.login-sub    { text-align: center; font-size: 0.82rem; color: var(--gris-4); margin-bottom: 22px; }

.badge-seguro {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 0.75rem; font-weight: 500;
  color: var(--azul);
  background: var(--azul-light);
  border: 1px solid #BFDBFE;
  border-radius: var(--radio-pill);
  padding: 5px 12px;
  margin-bottom: 20px;
}

.login-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--gris-4);
  margin-top: 16px;
}
.login-footer a { color: var(--azul); text-decoration: none; font-weight: 500; }

#error-login {
  background: var(--rojo-bg);
  color: #991B1B;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  margin-bottom: 12px;
  display: none;
}

/* ────────────────────────────────────────────────────────────
   PANTALLA: INICIO (Vigilante / Residente)
──────────────────────────────────────────────────────────── */
.header-azul {
  background: var(--azul);
  color: var(--blanco);
  padding: 20px 20px 28px;
}

.header-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 12px;
}

.header-info .saludo { font-size: 0.78rem; opacity: 0.75; margin-bottom: 2px; }
.header-info .nombre { font-size: 1.15rem; font-weight: 700; }

.header-actions { display: flex; gap: 10px; }

.avatar-circle {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 700; color: var(--blanco);
}

.turno-badge {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.14);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.77rem;
  opacity: 0.9;
}

/* Stats */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 16px;
  margin-top: -20px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--blanco);
  border: 1px solid var(--gris-2);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
  box-shadow: var(--sombra-sm);
}
.stat-num   { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--negro); }
.stat-label { font-size: 0.68rem; color: var(--gris-4); margin-top: 3px; font-weight: 500; }
.stat-verde { color: var(--verde); }
.stat-rojo  { color: var(--rojo); }

/* CTA Escanear */
.cta-escanear {
  margin: 0 16px 16px;
  background: var(--azul);
  border-radius: 16px;
  padding: 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
  border: none; font-family: inherit;
  text-align: left;
  box-shadow: 0 4px 16px rgba(26,107,255,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  width: calc(100% - 32px);
}
.cta-escanear:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(26,107,255,0.4); }

.cta-icon {
  width: 46px; height: 46px;
  background: rgba(255,255,255,0.18);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cta-texto h3 { font-size: 0.95rem; color: var(--blanco); }
.cta-texto p  { font-size: 0.78rem; color: rgba(255,255,255,0.72); margin: 2px 0 0; }
.cta-flecha   { margin-left: auto; opacity: 0.6; }

/* Lista de actividad */
.seccion-titulo {
  font-size: 0.78rem; font-weight: 600;
  color: var(--gris-4);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0 16px;
  margin-bottom: 8px;
}

.actividad-lista { flex: 1; overflow-y: auto; }

.actividad-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--gris-1);
  transition: background 0.15s;
}
.actividad-item:hover { background: var(--gris-0); }

.act-icono {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.act-icono.ok   { background: var(--verde-bg); }
.act-icono.warn { background: var(--amber-bg); }
.act-icono.err  { background: var(--rojo-bg); }

.act-info  { flex: 1; min-width: 0; }
.act-info strong { font-size: 0.87rem; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-info span   { font-size: 0.73rem; color: var(--gris-4); }
.act-hora { font-size: 0.72rem; color: var(--gris-4); }

/* Barra de navegación inferior */
.nav-bottom {
  display: flex;
  background: var(--blanco);
  border-top: 1px solid var(--gris-2);
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
}

.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 6px 0;
  border: none; background: none;
  cursor: pointer; font-family: inherit; font-size: 0.65rem; font-weight: 500;
  color: var(--gris-4);
  transition: color 0.15s;
}
.nav-item.activo { color: var(--azul); }
.nav-item svg path, .nav-item svg rect,
.nav-item svg polyline, .nav-item svg circle { transition: stroke 0.15s; }

/* ────────────────────────────────────────────────────────────
   PANTALLA: ESCÁNER
──────────────────────────────────────────────────────────── */
#p-scanner {
  background: #0F172A;
  position: relative;
}

.scanner-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  position: relative; z-index: 10;
}

.scanner-titulo { color: var(--blanco); font-size: 0.95rem; font-weight: 600; }

.camara-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

#video-camara {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

.camara-overlay {
  position: absolute; inset: 0;
  background: rgba(15,23,42,0.65);
  display: flex; align-items: center; justify-content: center;
}

/* Marco QR animado */
.marco-qr {
  width: 220px; height: 220px;
  position: relative;
}

.esquina {
  position: absolute;
  width: 30px; height: 30px;
  border-color: var(--verde);
  border-style: solid;
  transition: border-color 0.3s;
}
.esquina.tl { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 5px 0 0 0; }
.esquina.tr { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 5px 0 0; }
.esquina.bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 5px; }
.esquina.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 5px 0; }

.esquina.error { border-color: var(--rojo); }

.linea-scan {
  position: absolute;
  left: 4px; right: 4px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--verde), transparent);
  animation: scanLine 2.2s ease-in-out infinite;
}
@keyframes scanLine {
  0%   { top: 8px;   opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { top: 208px; opacity: 0; }
}

.badge-app-only {
  position: absolute;
  bottom: -48px; left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.45);
  border-radius: var(--radio-pill);
  padding: 5px 14px;
  font-size: 0.72rem; font-weight: 600;
  color: var(--verde);
  display: flex; align-items: center; gap: 6px;
}

.punto-pulso {
  width: 6px; height: 6px;
  background: var(--verde);
  border-radius: 50%;
  animation: pulseDot 1.6s ease-in-out infinite;
}
@keyframes pulseDot {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: 0.4; transform: scale(0.65); }
}

.scanner-bottom {
  padding: 24px 20px env(safe-area-inset-bottom, 20px);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}

.instruccion-scan {
  color: rgba(255,255,255,0.55);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.5;
}
.instruccion-scan strong { color: var(--verde); }

.herramientas-scan {
  display: flex; align-items: center; gap: 28px;
}

.btn-herramienta {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.5); font-family: inherit;
  font-size: 0.68rem;
}

.herramienta-icono {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.btn-captura {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px solid var(--azul);
  background: rgba(26,107,255,0.2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.btn-captura:hover { background: rgba(26,107,255,0.4); }
.btn-captura-inner {
  width: 46px; height: 46px;
  background: var(--azul);
  border-radius: 50%;
}

#msg-sin-soporte {
  color: var(--amber);
  font-size: 0.82rem;
  text-align: center;
  padding: 0 24px;
  display: none;
}

/* ────────────────────────────────────────────────────────────
   PANTALLA: RESULTADO
──────────────────────────────────────────────────────────── */
#p-resultado {
  background: var(--blanco);
}

.resultado-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gris-1);
}
.resultado-header h2 { font-size: 0.95rem; }

.resultado-cuerpo {
  flex: 1; overflow-y: auto;
  padding: 0 16px 16px;
  display: flex; flex-direction: column; align-items: center;
}

.resultado-icono {
  width: 90px; height: 90px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 28px 0 14px;
  animation: popIn 0.4s cubic-bezier(.34,1.56,.64,1);
}
.resultado-icono.ok  { background: var(--verde-bg); border: 4px solid var(--verde); }
.resultado-icono.err { background: var(--rojo-bg);  border: 4px solid var(--rojo); }

@keyframes popIn {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.resultado-titulo { font-size: 1.2rem; font-weight: 700; text-align: center; }
.resultado-titulo.ok  { color: #166534; }
.resultado-titulo.err { color: #991B1B; }

.resultado-sub {
  font-size: 0.8rem; color: var(--gris-4);
  text-align: center; margin-top: 4px; margin-bottom: 20px;
}

/* Card del residente */
.card-residente {
  width: 100%;
  background: var(--azul-light);
  border: 1px solid #BFDBFE;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

.res-fila {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}

.res-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--azul);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; color: var(--blanco);
  flex-shrink: 0;
}

.res-nombre { font-size: 0.95rem; font-weight: 700; }
.res-unidad { font-size: 0.78rem; color: var(--gris-5); margin-top: 2px; }

.res-divisor { height: 1px; background: #BFDBFE; margin: 0 0 12px; }

.res-dato {
  display: flex; justify-content: space-between;
  margin-bottom: 8px; font-size: 0.8rem;
}
.res-dato-label { color: var(--gris-4); }
.res-dato-valor { font-weight: 500; color: var(--negro); }

/* Advertencia app-only */
.aviso-app {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  background: var(--amber-bg);
  border: 1px solid #FCD34D;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.78rem; font-weight: 600;
  color: #92400E;
  margin-bottom: 16px;
}

.resultado-pie {
  padding: 0 16px env(safe-area-inset-bottom, 16px);
  display: flex; flex-direction: column; gap: 8px;
}

/* ────────────────────────────────────────────────────────────
   PANTALLA: MI QR (Residente)
──────────────────────────────────────────────────────────── */
#p-mi-qr {
  background: var(--blanco);
}

.mi-qr-header {
  background: var(--azul);
  padding: 20px 16px 32px;
  color: var(--blanco);
}

.mi-qr-body {
  flex: 1;
  padding: 0 20px 20px;
  display: flex; flex-direction: column; align-items: center;
}

#canvas-qr {
  border-radius: 16px;
  border: 8px solid var(--blanco);
  box-shadow: var(--sombra-md);
  margin-top: -24px;
  max-width: 240px;
  width: 100%;
}

.qr-nombre {
  font-size: 1rem; font-weight: 700;
  margin-top: 16px;
}
.qr-unidad { font-size: 0.82rem; color: var(--gris-5); margin-top: 2px; }

.qr-aviso {
  background: var(--azul-light);
  border: 1px solid #BFDBFE;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.8rem;
  color: #1E40AF;
  text-align: center;
  line-height: 1.5;
  margin-top: 20px;
  width: 100%;
}

/* ── Utilidades ─────────────────────────────────────────────── */
.d-none    { display: none !important; }
.text-c    { text-align: center; }
.mt-8      { margin-top: 8px; }
.mt-16     { margin-top: 16px; }
.px-16     { padding-left: 16px; padding-right: 16px; }
.flex-1    { flex: 1; }
.gap-8     { gap: 8px; }
.ml-auto   { margin-left: auto; }
