/**
 * Splash — Portal de acceso WiFi Energuate
 * Misma paleta y tipografía que Home/Kiosk (Azul #003A8F, Verde #00A859)
 */
:root {
  --energuate-blue: #003A8F;
  --energuate-green: #00A859;
  --energuate-green-hover: #00c45d;
  --bg-light: #E6EEF8;
  --gray: #6B7280;
  --white: #FFFFFF;
  --radius: 14px;
  --font-title: 'Montserrat', system-ui, sans-serif;
  --font-body: 'Open Sans', system-ui, sans-serif;
  --error-bg: rgba(239, 68, 68, 0.12);
  --error-fg: #b91c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  background: var(--bg-light);
  color: #1f2937;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.splash {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}

/* Header */
.splash-header {
  background: var(--energuate-blue);
  color: var(--white);
  padding: 1.25rem 1rem;
  text-align: center;
  width: 100%;
}

/* Logo en badge blanco (el JPG tiene fondo blanco; el badge lo integra sobre el azul) */
.logo-badge {
  display: inline-block;
  background: #fff;
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  margin: 0 0 0.75rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  line-height: 0;
}

.logo-energuate {
  display: block;
  height: 38px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

.splash-header h1 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 600;
  opacity: 0.95;
}

/* Card */
.splash-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  margin: 1rem 1rem 0;
  box-shadow: 0 4px 20px rgba(0,58,143,0.08);
  border: 1px solid rgba(0,58,143,0.1);
  flex: 1;
}

.splash-card h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--energuate-blue);
}

.splash-card-title {
  font-size: 1.3rem !important;
  text-align: center;
  margin: 0 0 0.4rem !important;
}

.splash-card-sub {
  text-align: center;
  font-size: 0.88rem;
  color: #374151;
  line-height: 1.45;
  margin: 0 0 1.1rem;
}

.splash-card-sub strong { color: var(--energuate-blue); }

/* Form — ingresar clave + Conectar */
.splash-form-wrap { margin-top: 1.25rem; }

.splash-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.splash-form label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--energuate-blue);
}

.splash-input {
  width: 100%;
  padding: 0.9rem 1rem;
  font-size: 1rem;
  font-family: var(--font-body);
  border: 2px solid rgba(0, 58, 143, 0.25);
  border-radius: var(--radius);
  color: #1f2937;
  outline: none;
  transition: border-color 0.2s;
}

.splash-input::placeholder { color: var(--gray); }

.splash-input:focus {
  border-color: var(--energuate-blue);
}

.splash-input:focus-visible {
  outline: 2px solid var(--energuate-blue);
  outline-offset: 2px;
}

.splash-input--error {
  border-color: #dc2626 !important;
  background: rgba(239, 68, 68, 0.04);
}

/* Campo de clave con prefijo fijo EN- : el usuario solo escribe 4 caracteres */
.splash-code-group {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
}

.splash-code-prefix {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 0.7rem;
  font-family: var(--font-heading, var(--font-body));
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--energuate-blue);
  background: rgba(0, 58, 143, 0.06);
  border: 2px solid rgba(0, 58, 143, 0.25);
  border-radius: var(--radius);
  user-select: none;
}

.splash-input--code {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  text-transform: uppercase;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
}

.splash-input--code::placeholder {
  letter-spacing: 0.35em;
  font-weight: 400;
  color: rgba(31, 41, 55, 0.25);
}

/* Botón de escaneo QR destacado (solo Android, donde la cámara funciona en el portal) */
.splash-scan-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 0.25rem;
}

/* Separador "o escribe el código" entre escaneo y campo manual */
.splash-divider {
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
  color: var(--gray);
  font-size: 0.85rem;
}

.splash-divider::before,
.splash-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0, 58, 143, 0.15);
}

.splash-divider span {
  white-space: nowrap;
}

/* Mensajes */
.splash-msg {
  font-size: 0.9rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin: 1rem 0 0;
  display: none;
  line-height: 1.45;
}

.splash-msg.error {
  background: var(--error-bg);
  color: var(--error-fg);
  display: block;
  border: 1px solid rgba(185, 28, 28, 0.25);
}

.splash-msg.success {
  background: rgba(0, 168, 89, 0.12);
  color: #0d5c2e;
  display: block;
  border: 1px solid rgba(0, 168, 89, 0.3);
}

/* Botón modo prueba — touch-friendly */
.splash-actions {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn-splash {
  display: inline-block;
  width: 100%;
  min-height: 48px;
  padding: 0.9rem 1.25rem;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  transition: transform 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 58, 143, 0.15);
}

.btn-splash:active:not(:disabled) { transform: scale(0.98); }

.btn-splash:focus-visible { outline: 2px solid var(--energuate-blue); outline-offset: 2px; }

.btn-splash-primary {
  background: var(--energuate-green);
  color: var(--white);
  box-shadow: 0 4px 14px rgba(0, 168, 89, 0.3);
}

.btn-splash-primary:hover {
  background: var(--energuate-green-hover);
  box-shadow: 0 6px 18px rgba(0, 168, 89, 0.35);
}

.btn-splash-outline {
  background: transparent;
  color: var(--energuate-blue);
  border: 2px solid var(--energuate-blue);
}

.btn-splash-outline:hover {
  background: rgba(0, 58, 143, 0.06);
}

/* Debug */
.splash-debug {
  font-size: 0.8rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 168, 89, 0.1);
  color: #0d5c2e;
  border-radius: var(--radius);
  margin-top: 1rem;
  border: 1px solid rgba(0, 168, 89, 0.25);
  line-height: 1.45;
}

.splash-debug code { font-size: 0.85em; }

/* Footer */
.splash-footer {
  text-align: center;
  padding: 1.25rem 0.5rem;
  font-size: 0.8rem;
  color: var(--gray);
  width: 100%;
}

.splash-footer a {
  color: var(--energuate-blue);
  text-decoration: none;
  font-weight: 600;
}

.splash-footer a:hover { text-decoration: underline; }

/* Icono QR inline (SVG) */
.icon-qr {
  display: inline-block;
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: -0.15em;
}

/* --- Spinner de carga en botón Conectar --- */
@keyframes splash-spin {
  to { transform: rotate(360deg); }
}

.btn-splash--loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-splash--loading::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: splash-spin 0.7s linear infinite;
}

/* --- Hint de sesión bajo el botón --- */
.splash-session-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--gray);
  margin: 0.5rem 0 0;
}

/* --- Prevenir zoom iOS en input (font-size < 16px dispara zoom) --- */
@media (max-width: 768px) {
  .splash-input {
    font-size: 16px;
  }
}

/* --- Modal de cámara para escanear QR --- */
.qr-scan-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.qr-scan-inner {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem 1.25rem;
  width: min(90vw, 340px);
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.qr-scan-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1rem;
  color: var(--energuate-blue);
  margin: 0 0 .75rem;
}

.qr-scan-video {
  width: 100%;
  border-radius: 8px;
  background: #000;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.qr-scan-hint {
  font-size: .82rem;
  color: var(--gray);
  margin: .5rem 0 0;
}
