/* ============================================================================
 * Family Time · Tiempo en Familia (familytimes.com)
 * Estética unificada con la limpieza, aire y sobriedad de Instant Runners:
 * - Modo Día / Noche (data-theme="light" | "dark")
 * - Botón Día/Noche flotante arriba-izquierda + Acceso Admin discreto arriba-derecha
 * - Emblema central con globitos festivos (en lugar de fuego y corredora)
 * - Entrada directa: Tomar selfie + Código del evento
 * ============================================================================ */

:root,
:root[data-theme="light"] {
  --bg: #faf7f2;
  --bg-grad: radial-gradient(circle at 50% 0%, #fff1dc 0%, #faf7f2 54%, #f2ebe0 100%);
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #ffffff;
  --ink: #1a241f;
  --muted: #5d6862;
  --accent: #1f3a2e;
  --accent-hover: #162b22;
  --gold: #c98a36;
  --border: rgba(31, 58, 46, 0.12);
  --shadow: 0 18px 48px rgba(31, 58, 46, 0.09);
  --pill-bg: rgba(255, 255, 255, 0.92);
  --pill-border: rgba(31, 58, 46, 0.14);
  --input-bg: #ffffff;
  --ring-glow: rgba(201, 138, 54, 0.25);
  --radius: 24px;
}

:root[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-grad: radial-gradient(circle at 50% 0%, rgba(201, 138, 54, 0.16) 0%, #0b0d12 52%, #07080c 100%);
  --surface: rgba(22, 25, 34, 0.84);
  --surface-strong: #171a24;
  --ink: #f4f6f9;
  --muted: #9da6b8;
  --accent: #2e7d5b;
  --accent-hover: #38946d;
  --gold: #e6a94e;
  --border: rgba(255, 255, 255, 0.11);
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.55);
  --pill-bg: rgba(28, 31, 42, 0.88);
  --pill-border: rgba(255, 255, 255, 0.16);
  --input-bg: rgba(14, 17, 24, 0.9);
  --ring-glow: rgba(230, 169, 78, 0.34);
  --radius: 24px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-grad);
  background-color: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background 0.28s ease, color 0.22s ease;
  -webkit-font-smoothing: antialiased;
}

/* ==================== CAPA AMBIENTAL DE GLOBITOS ==================== */
#ambientStage {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.ambient-balloon {
  position: absolute;
  bottom: -120px;
  will-change: transform;
  animation: balloonRise var(--dur, 19s) linear var(--delay, 0s) infinite;
}
.ambient-balloon svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.12));
}
@keyframes balloonRise {
  0%   { transform: translate3d(0, 0, 0) rotate(-3deg); }
  25%  { transform: translate3d(var(--sway, 16px), -30vh, 0) rotate(3deg); }
  50%  { transform: translate3d(0, -60vh, 0) rotate(-2deg); }
  75%  { transform: translate3d(calc(var(--sway, 16px) * -0.8), -90vh, 0) rotate(3deg); }
  100% { transform: translate3d(0, -125vh, 0) rotate(-2deg); }
}

.ambient-particle {
  position: absolute;
  bottom: -40px;
  opacity: 0.34;
  will-change: transform;
  animation: balloonRise var(--dur, 15s) linear var(--delay, 0s) infinite;
}
.ambient-bokeh { border-radius: 50%; filter: blur(4px); opacity: 0.28; }
.ambient-sparkle { border-radius: 50%; box-shadow: 0 0 12px rgba(230, 192, 123, 0.6); opacity: 0.42; }
.ambient-leaf { border-radius: 0 70% 0 70%; opacity: 0.32; }
.ambient-confetti { border-radius: 3px; opacity: 0.38; }

/* ==================== CONTROLES FLOTANTES ESTILO INSTANT RUNNERS ==================== */
/* Día/Noche arriba-izquierda (exactamente como Instant Runners) */
.theme-toggle {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  z-index: 200;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 18px;
  transition: transform 0.15s ease;
}
.theme-toggle:active { transform: scale(0.92); }
.theme-toggle .mx-ico { display: inline-block; line-height: 1; }

/* Acceso Admin discreto arriba-derecha + idioma ES/EN */
.top-right-dock {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
}

.float-circle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  color: var(--ink);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.float-circle-btn:hover { border-color: var(--gold); }
.float-circle-btn:active { transform: scale(0.92); }
.float-circle-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ==================== CONTENEDOR PRINCIPAL CENTRADO ==================== */
.container {
  position: relative;
  z-index: 10;
  max-width: 960px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(68px + env(safe-area-inset-top)) 16px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.welcome-stage {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
}

/* Emblema central limpio con globitos (reemplaza el fuego y la corredora de Instant Runners) */
.hero-emblem {
  position: relative;
  width: 148px;
  height: 148px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: 0 0 0 10px var(--ring-glow), var(--shadow);
  display: grid;
  place-items: center;
  backdrop-filter: blur(14px);
}
.hero-balloons {
  width: 102px;
  height: 102px;
  animation: gentleBob 4.4s ease-in-out infinite;
}
@keyframes gentleBob {
  0%, 100% { transform: translateY(0px) rotate(-1.5deg); }
  50% { transform: translateY(-7px) rotate(1.5deg); }
}

.brand-heading {
  margin: 0 0 4px;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.event-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 22px;
}

/* ==================== ZONA DE ACCIÓN DIRECTA (SELFIE + CÓDIGO) ==================== */
.action-panel {
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px 18px;
  box-shadow: var(--shadow);
  text-align: left;
}

/* Botón estrella "Tomar selfie" (mismo peso visual y limpieza que Instant Runners) */
.btn-selfie {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 15px 22px;
  font-size: 15.5px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: linear-gradient(110deg, #1f3a2e, #2e6b50, #c98a36, #1f3a2e);
  background-size: 240% 240%;
  box-shadow: 0 12px 26px rgba(31, 58, 46, 0.30), inset 0 1px 1px rgba(255, 255, 255, 0.35);
  animation: selfieFlow 6.5s ease-in-out infinite;
  transition: transform 0.14s ease;
}
.btn-selfie::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 36%;
  left: -55%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.36), transparent);
  transform: skewX(-20deg);
  animation: selfieShine 4.2s ease-in-out 1.1s infinite;
  pointer-events: none;
}
.btn-selfie:active { transform: scale(0.98); }

@keyframes selfieFlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes selfieShine {
  0%, 58% { left: -55%; }
  88%, 100% { left: 130%; }
}

.divider-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.divider-or::before,
.divider-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Fila directa de Código del Evento */
.code-inline-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.code-inline-row .input {
  margin-bottom: 0;
  flex: 1;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.code-inline-row .btn {
  padding: 0 16px;
  border-radius: 14px;
  white-space: nowrap;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0 14px;
  font-size: 12px;
  line-height: 1.42;
  color: var(--muted);
  cursor: pointer;
}
.consent-row input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.privacy-foot {
  margin-top: 14px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

/* ==================== TARJETAS SECUNDARIAS Y CONTROLES ==================== */
.card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.input, .select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  font-size: 14.5px;
  color: var(--ink);
  margin-bottom: 10px;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--gold); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 14px;
  border: none;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-soft { background: var(--pill-bg); color: var(--ink); border: 1px solid var(--border); }
.btn-danger { background: rgba(220, 38, 38, 0.14); color: #ef4444; }
.btn-full { width: 100%; }

.pill-btn {
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.pill-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.camera-box {
  position: relative;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 3 / 4;
  margin: 0 auto 14px;
  border-radius: 24px;
  overflow: hidden;
  background: #101318;
  border: 2px solid var(--border);
}
.camera-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.face-oval {
  position: absolute;
  inset: 14% 18% 20% 18%;
  border: 2.5px dashed rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  pointer-events: none;
}

.webview-banner {
  background: rgba(245, 185, 66, 0.18);
  border: 1px solid rgba(245, 185, 66, 0.45);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-box {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 12px;
}
.status-err { background: rgba(220, 38, 38, 0.14); color: #dc2626; border: 1px solid rgba(220, 38, 38, 0.3); }
.status-ok { background: rgba(22, 163, 74, 0.14); color: #16a34a; border: 1px solid rgba(22, 163, 74, 0.3); }
.status-wait { background: rgba(217, 119, 6, 0.14); color: #d97706; border: 1px solid rgba(217, 119, 6, 0.3); }
:root[data-theme="dark"] .status-err { color: #fca5a5; }
:root[data-theme="dark"] .status-ok { color: #86efac; }
:root[data-theme="dark"] .status-wait { color: #fcd34d; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.media-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid transparent;
  background: rgba(128, 128, 128, 0.15);
  aspect-ratio: 1 / 1;
  cursor: pointer;
}
.media-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--ring-glow);
}
.media-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(15, 23, 20, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}
.media-actions { position: absolute; bottom: 8px; right: 8px; display: flex; gap: 6px; }
.icon-chip {
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.92);
  color: #1a241f;
  cursor: pointer;
  text-decoration: none;
}

.guest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.guest-info { display: flex; align-items: center; gap: 12px; }
.guest-thumb {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
}

.subtitle { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.hidden { display: none !important; }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 14px;
}
.stat-chip {
  padding: 10px 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  text-align: center;
}
.stat-chip strong {
  display: block;
  font-size: 17px;
  color: var(--ink);
}
.stat-chip span {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 700;
}

.admin-box {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  margin-bottom: 14px;
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.media-card.is-hidden {
  opacity: 0.48;
  border-color: rgba(220, 38, 38, 0.55);
}

/* Lightbox limpio para fotos y videos en Admin */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(8, 10, 14, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lightbox-card {
  width: 100%;
  max-width: 680px;
  max-height: 92dvh;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.lightbox-media {
  background: #090b0f;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 62dvh;
  overflow: hidden;
}
.lightbox-media img,
.lightbox-media video {
  max-width: 100%;
  max-height: 62dvh;
  object-fit: contain;
}
.lightbox-bar {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  .ambient-balloon, .ambient-particle, .hero-balloons, .btn-selfie, .btn-selfie::after {
    animation: none !important;
  }
}

@media print {
  .theme-toggle, .top-right-dock, .no-print, #ambientStage { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .print-grid { display: grid !important; grid-template-columns: repeat(2, 1fr); gap: 12mm; }
  .print-grid img { width: 100%; height: auto; border-radius: 4px; page-break-inside: avoid; }
}
