/* =============================================================================
   SIMPLE TRUST · ESTILOS DEL FORMULARIO
   -----------------------------------------------------------------------------
   Índice:
     1. Variables de marca
     2. Base y contenedor
     3. Barra superior y progreso
     4. Columnas (formulario + mascota acompañante)
     5. Burbuja y mascota
     6. Campos (texto, selector, botones, tarjetas)
     7. Ayuda ("i") y errores de validación
     8. Botón principal y pantalla final
     9. Confeti
    10. Tablet
    11. Móvil  (aquí se oculta la mascota)
   ============================================================================= */

/* ---- 1. Variables de marca ------------------------------------------------ */
:root {
  --navy:   #0B2347;
  --navy2:  #06183F;
  --blue:   #0B6CFF;
  --blue2:  #143C72;
  --sky:    #38B6FF;
  --sea:    #2DE3A7;
  --ink:    #0B2347;
  --muted:  #5B6B85;
  --line:   #A9BAD2;   /* borde de campos: 2.2:1, mínimo AA para bordes de control */
  --line2:  #E4EBF5;
  --canvas: #F6FAFF;
  --tint:   #EAF3FF;
  --error:  #C4183C;
  --applegrad: linear-gradient(135deg, #0071E3, #5AC8FA);
}

/* ---- 2. Base y contenedor ------------------------------------------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; }

/* min-height (NO height:100%): así el panel se centra cuando cabe en la
   pantalla, y cuando es más alto la página hace scroll desde arriba en vez
   de recortar la cabecera. */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif;
  background: radial-gradient(90% 60% at 50% 0, #EAF3FF 0, var(--canvas) 60%);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
}

.app {
  width: 100%;
  max-width: 1080px;
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(11, 35, 71, .16);
}

/* ---- 3. Barra superior y progreso ---------------------------------------- */
.topbar {
  background: linear-gradient(90deg, var(--navy), var(--blue2));
  border-bottom: 2px solid var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 26px;
}
.wm   { font-weight: 300; font-size: 22px; }
.wm b { font-weight: 700; }
.lock {
  font-size: 12px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  padding: 5px 12px;
  color: #EAF3FF;
}

.prog { padding: 14px 26px 0; }
.prow { display: flex; justify-content: flex-start; align-items: center; gap: 11px; margin-bottom: 9px; }

.back {
  width: 27px; height: 27px; flex: 0 0 auto;
  border-radius: 50%; border: 1.5px solid var(--line); background: #fff;
  color: var(--blue); font: 800 18px/1 -apple-system, sans-serif;
  cursor: pointer; padding: 0 2px 2px 0;
  display: none; align-items: center; justify-content: center;
}
.back.show { display: flex; }

.pstep { font-size: 13px; font-weight: 800; color: var(--blue); letter-spacing: .01em; }
.pbar  { height: 6px; background: #DCE7F7; border-radius: 9px; overflow: hidden; }
.pbar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--sky));
  border-radius: 9px;
  transition: width .5s cubic-bezier(.2, .85, .25, 1);
}

/* ---- 4. Columnas ---------------------------------------------------------- */
.cols    { display: flex; gap: 26px; padding: 22px 26px 30px; align-items: flex-start; }
.formcol { flex: 1.35; min-width: 0; }
.compcol {
  flex: 1; position: sticky; top: 20px;
  display: flex; flex-direction: column; align-items: center;
  background: linear-gradient(180deg, #F4F9FF, #EAF3FF);
  border: 1px solid var(--line2); border-radius: 18px;
  padding: 22px 20px 8px; align-self: flex-start;
}

/* ---- 5. Burbuja y mascota ------------------------------------------------- */
.bub {
  position: relative; width: 100%;
  background: #fff; border: 1px solid var(--line2); border-radius: 16px;
  padding: 14px 16px; min-height: 78px;
  display: flex; align-items: center;
  font-size: 15px; line-height: 1.35; color: var(--navy);
  box-shadow: 0 8px 20px rgba(11, 35, 71, .10);
  transition: opacity .17s, background .28s, color .28s;
}
.bub:after {
  content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px;
  width: 13px; height: 13px; background: #fff;
  border-right: 1px solid var(--line2); border-bottom: 1px solid var(--line2);
  transform: rotate(45deg); transition: background .28s;
}
.bub.on { background: var(--applegrad); border-color: transparent; color: #fff; box-shadow: 0 12px 28px rgba(0, 113, 227, .32); }
.bub.on:after { background: #4FC0F5; border-color: transparent; }

.avac {
  position: relative; width: 100%; flex: 0 0 auto; min-height: 280px; margin-top: 18px;
  display: flex; align-items: flex-end; justify-content: center;
}
.avac .ava {
  position: absolute; bottom: 0; max-height: 262px; width: auto; max-width: 92%;
  opacity: 0; transition: opacity .32s ease;
  filter: drop-shadow(0 16px 24px rgba(11, 35, 71, .20));
  will-change: opacity;
}
.avac .ava.show { opacity: 1; }

/* ---- 6. Campos ------------------------------------------------------------ */
.qtitle { font-size: 25px; font-weight: 800; letter-spacing: -.01em; margin: 2px 0 20px; }
/* Al cambiar de paso el foco va al titular (ver js/formulario.js). El recuadro de
   foco se muestra SOLO a quien navega con teclado: con el mouse estorbaría. */
.qtitle:focus { outline: none; }
.qtitle:focus-visible { outline: 2px solid var(--blue); outline-offset: 5px; border-radius: 5px; }
.grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.grid .full { grid-column: 1 / -1; }
.field  { position: relative; }

.fg { position: relative; display: block; }
.fg .fl {
  position: absolute; top: -8px; left: 11px;
  background: #fff; padding: 0 5px;
  font-size: 12px; color: #56637A; font-weight: 600;   /* 4.6:1 sobre blanco (WCAG AA) */
}
.fg input, .fg select {
  width: 100%; font-size: 15px; padding: 13px 13px;
  border: 1.5px solid var(--line); border-radius: 11px;
  background: #fff; color: var(--navy); outline: 0;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
  appearance: none; -webkit-appearance: none;
}
.fg select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235B6B85' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.fg input:focus, .fg select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(11, 108, 255, .14); }

/* Pregunta con opciones (botones o tarjetas) */
.fgq { position: relative; }
.ql {
  display: block; font-size: 15px; font-weight: 700; color: var(--navy);
  margin: 0 0 10px; line-height: 1.32; padding-right: 32px;
}
.pills { display: flex; gap: 10px; }
.pill {
  flex: 1; padding: 12px; border: 1.5px solid var(--line); border-radius: 11px;
  background: #fff; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--navy); cursor: pointer; transition: .15s;
}
.pill.sel { border-color: var(--blue); background: var(--tint); color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 108, 255, .12); }

.cards { display: flex; flex-direction: column; gap: 8px; }
.card {
  text-align: left; padding: 12px 38px 12px 13px;
  border: 1.5px solid var(--line); border-radius: 11px; background: #fff;
  font: inherit; font-size: 13.5px; line-height: 1.3; color: var(--navy);
  cursor: pointer; transition: .15s; position: relative;
}
.card.sel { border-color: var(--blue); background: var(--tint); box-shadow: 0 0 0 3px rgba(11, 108, 255, .12); }
.card.sel:after {
  content: "\2713"; position: absolute; right: 13px; top: 50%;
  transform: translateY(-50%); color: var(--blue); font-weight: 800;
}

/* Campo solo lectura (se calcula solo, el usuario no lo escribe) */
.fg.ro .rov {
  width: 100%; font-size: 14px; padding: 13px;
  border: 1.5px dashed var(--line); border-radius: 11px;
  background: #F2F6FC; color: var(--muted); font-weight: 600;
}

/* Botón de acción (validar identidad, firmar…) */
.act {
  width: 100%; display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); border-radius: 11px; background: #fff;
  padding: 14px 13px; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--navy); cursor: pointer; transition: .15s; text-align: left;
}
.act.sel { border-color: var(--sea); background: #EAFBF4; color: #0B7B54; }
.act .acti {
  width: 25px; height: 25px; flex: 0 0 auto; border-radius: 50%;
  background: var(--tint); color: var(--blue);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}

/* ---- 7. Ayuda ("i") y errores -------------------------------------------- */
.info {
  position: absolute; top: -9px; right: 9px; z-index: 3;
  width: 23px; height: 23px; border-radius: 50%;
  border: 1.5px solid var(--line); background: #fff; color: var(--blue);
  font: italic 700 13px Georgia, serif; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; box-shadow: 0 2px 6px rgba(11, 35, 71, .12); transition: .15s;
}
.info:hover, .info.lit { background: var(--applegrad); color: #fff; border-color: transparent; }

/* La etiqueta flotante nunca debe meterse debajo del botón "i" (se recorta
   antes de pisarlo). Es la red de seguridad; en tablet además el campo pasa
   a ancho completo, así no hace falta recortar nada. */
.field.con-i .fl {
  max-width: calc(100% - 44px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Texto de ayuda de cada campo.
   En ESCRITORIO no se ve (lo explica la mascota en su burbuja), pero sigue
   existiendo para los lectores de pantalla: por eso se oculta con la técnica
   "solo lectores" y no con display:none, que lo borraría también para ellos. */
.hint {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@keyframes aparecer { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* Error de validación */
.err {
  margin-top: 7px; font-size: 12.5px; font-weight: 600; line-height: 1.35;
  color: var(--error); animation: aparecer .18s ease;
}
.field.mal .fg input,
.field.mal .fg select { border-color: var(--error); box-shadow: 0 0 0 3px rgba(196, 24, 60, .10); }
.field.mal .pill,
.field.mal .card,
.field.mal .act  { border-color: var(--error); }

/* ---- 8. Botón principal y pantalla final --------------------------------- */
.cta {
  margin-top: 20px; border: 0; cursor: pointer; font-family: inherit;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 16px;
  border-radius: 999px; padding: 14px 28px;
  box-shadow: 0 10px 24px rgba(11, 108, 255, .3);
  display: inline-flex; align-items: center; gap: 8px;
}
.cta:active { transform: translateY(1px); }
/* Mientras se envía, el botón queda bloqueado para no mandar la solicitud dos veces. */
.cta:disabled { opacity: .6; cursor: default; box-shadow: none; transform: none; }

.done   { text-align: center; padding: 20px 10px; }
.done h2 { font-size: 26px; margin: 6px 0; }
.done p  { color: var(--muted); margin: 0; }

/* Pie legal (exigido por normativa CMF: quién es la entidad y dónde se abre
   realmente la cuenta). No quitar sin revisar con cumplimiento. */
.legal {
  border-top: 1px solid var(--line2);
  padding: 14px 26px 18px;
  font-size: 11.5px; line-height: 1.5; color: var(--muted);
}
.legal b { color: var(--navy); font-weight: 700; }

/* ---- 9. Confeti ----------------------------------------------------------- */
canvas#confeti {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 60;
}

/* ---- 10. Tablet ----------------------------------------------------------- */
/* En pantallas medianas las columnas quedan angostas: los campos que llevan
   botón "i" pasan a ancho completo para que la etiqueta no compita con él. */
@media (min-width: 761px) and (max-width: 1023px) {
  .field.con-i { grid-column: 1 / -1; }
}

/* ---- 11. Móvil ------------------------------------------------------------ */
@media (max-width: 760px) {
  body { padding: 0; }
  .app { max-width: 100%; border: 0; border-radius: 0; box-shadow: none; min-height: 100vh; }
  .cols { flex-direction: column; gap: 0; padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }

  /* Los pares de campos se MANTIENEN lado a lado, achicados: menos scroll.
     (Pedido de Ignacio.) */
  .grid { grid-template-columns: 1fr 1fr; gap: 10px 10px; }

  .qtitle { font-size: 20px; margin: 2px 0 14px; }
  /* 16px evita que iOS haga zoom al enfocar un campo. */
  .fg input, .fg select { font-size: 16px; padding: 12px 10px; border-radius: 10px; }
  .fg .fl { font-size: 10.5px; left: 9px; }
  .ql { font-size: 14px; margin-bottom: 8px; padding-right: 26px; }
  .info { width: 21px; height: 21px; font-size: 12px; top: -8px; right: 6px; }

  /* Zona de toque mínima cómoda con el dedo. */
  .pill { padding: 11px 8px; font-size: 13px; min-height: 44px; }
  .card { min-height: 44px; }

  /* En móvil la ayuda SÍ se ve, como texto bajo el campo… */
  .hint {
    position: static; width: auto; height: auto;
    margin: 8px 0 0; padding: 9px 12px;
    overflow: visible; clip: auto; white-space: normal;
    font-size: 12.5px; line-height: 1.42; color: var(--navy);
    background: var(--tint); border: 1px solid #CFE0F6; border-radius: 10px;
    animation: aparecer .18s ease;
  }
  /* …porque en el teléfono NO se muestra la mascota
     (Ignacio: "en el teléfono molestan más que aportan").
     Al estar oculta, sus imágenes tampoco se descargan. */
  .compcol { display: none; }

  .legal { padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); }
}
