/* ============================================================
   forms.css — Componentes de formulario reutilizables por las
   pantallas 2 a 5 (Datos, Documentación, Turno, Pago).
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-4);
  box-shadow: var(--shadow-md);
}
.card + .card {
  margin-top: var(--sp-3);
}
.card__title {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Datos personales | Dirección lado a lado, misma altura (se apilan en móvil). */
.datos-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  align-items: stretch;
}
.datos-cols .card {
  display: flex;
  flex-direction: column;
}
/* Los campos ocupan el alto disponible, repartidos parejos → cards simétricas. */
.datos-cols .card > .grid {
  flex: 1;
  align-content: space-between;
}
.datos-cols + .card {
  margin-top: var(--sp-3);
}
@media (max-width: 780px) {
  .datos-cols {
    grid-template-columns: 1fr;
  }
}
.card__title .num {
  width: 26px;
  height: 26px;
  border-radius: var(--r-pill);
  background: var(--brand);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px var(--brand-glow);
}

.form-page {
  max-width: 840px;
  margin-inline: auto;
}
.form-page--narrow {
  max-width: 640px;
}
.form-page .section-title {
  margin-bottom: var(--sp-3);
}
.form-page .step-nav {
  margin-top: var(--sp-4);
}

/* --- Grilla de campos --- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2) var(--sp-3);
}
.grid .col-2 {
  grid-column: span 2;
}
@media (max-width: 560px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .grid .col-2 {
    grid-column: span 1;
  }
}

/* --- Campo --- */
.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.field > label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-2);
}
.input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
  transition: border-color var(--t), box-shadow var(--t);
}
.input::placeholder {
  color: var(--ink-3);
}
.input:hover {
  border-color: var(--ink-3);
}
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-tint);
  outline: none;
}
.field.has-error .input {
  border-color: var(--danger);
}
/* Campo validado OK: borde verde + ✓ dentro del input. */
.field__control {
  position: relative;
}
.field__check {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%) scale(0.6);
  color: var(--ok);
  font-weight: 800;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t), transform var(--t);
}
.field.is-valid .field__check {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
.field.is-valid .input {
  border-color: var(--ok);
  padding-right: 30px;
}
.field__error {
  font-size: var(--fs-xs);
  color: var(--danger);
  font-weight: 600;
  min-height: 1em;
}
/* Sugerencia de typo en el email. */
.email-sugerencia {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
}
.email-sugerencia:empty {
  display: none;
}
.email-sugerencia .link-btn {
  font-size: var(--fs-xs);
  padding: 0;
}

/* --- Radio cards (turno, abono) --- */
.radio-cards {
  display: grid;
  gap: var(--sp-3);
}
.radio-cards--2 {
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 560px) {
  .radio-cards--2 {
    grid-template-columns: 1fr;
  }
}
.radio-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t);
  text-align: left;
  background: var(--surface);
}
.radio-card:hover {
  border-color: var(--line-strong);
}
.radio-card.is-selected {
  border-color: var(--brand);
  background: var(--brand-tint);
}
.radio-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  background: var(--bg);
  display: grid;
  place-items: center;
  color: var(--brand);
  flex-shrink: 0;
}
.radio-card.is-selected .radio-card__icon {
  background: var(--surface);
}
.radio-card__body {
  flex: 1;
}
.radio-card__title {
  font-weight: 700;
}
.radio-card__sub {
  font-size: var(--fs-sm);
  color: var(--ink-3);
}

/* --- Zona de carga de archivos --- */
.uploads-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.up-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: var(--sp-2);
}
.upload {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: all var(--t);
  min-height: 120px;
}
.upload:hover {
  border-color: var(--brand);
  background: var(--brand-tint);
}
/* Estado mientras se arrastra una imagen encima. */
.upload.is-dragover {
  border-color: var(--brand);
  background: var(--brand-tint);
  transform: scale(1.01);
  box-shadow: var(--shadow-md);
}
.upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.upload__icon {
  color: var(--ink-3);
}
.upload__text {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-weight: 600;
}
.upload__hint {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.upload.has-file {
  border-style: solid;
  border-color: var(--ok);
  background: var(--ok-tint);
}
.upload.has-file .upload__text {
  color: var(--ok);
}
/* Con imagen cargada, la flechita ya no aporta: la ocultamos para compactar. */
.upload.has-file .upload__icon {
  display: none;
}
.upload__preview {
  width: 100%;
  height: 110px; /* altura fija → todas las cajas quedan parejas y alineadas */
  object-fit: contain;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  margin-top: var(--sp-2);
  background: #fff;
  cursor: zoom-in;
}
/* Estado de lectura del OCR: spinner + texto en línea. */
.upload__estado {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}
.upload__estado .spinner {
  display: none;
}
.upload.is-reading .upload__estado .spinner {
  display: inline-block;
}
.upload.is-reading .upload__text {
  color: var(--brand);
}

/* --- Combo de lecturas del OCR (flechita + menú dentro del campo) --- */
.ocr-combo {
  position: relative;
  display: block;
}
/* En los campos del OCR no se muestra el ✓ (se usa la flechita). */
.field--ocr .field__check {
  display: none;
}
.ocr-combo.has-alt .input {
  padding-right: 40px; /* deja lugar para la flechita pegada a la derecha */
}
/* Flechita: segmento a toda la altura pegado al borde derecho del input,
   como el botón de un select nativo. */
.ocr-combo__caret {
  display: none;
  position: absolute;
  top: 2px;
  bottom: 2px;
  right: 2px;
  width: 34px;
  place-items: center;
  color: var(--brand);
  font-size: 16px;
  line-height: 1;
  background: var(--surface-2);
  border: none;
  border-left: 1px solid var(--line-strong);
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  transition: color var(--t), background var(--t);
}
.ocr-combo.has-alt .ocr-combo__caret {
  display: grid;
}
.ocr-combo__caret:hover {
  color: #fff;
  background: var(--brand);
}
.ocr-combo__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  max-height: 180px;
  overflow-y: auto;
}
.ocr-combo__menu.is-open {
  display: block;
}
.ocr-combo__opt {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  padding: 6px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.ocr-combo__opt:hover {
  background: var(--brand-tint);
  color: var(--brand);
}

/* Imagen ampliada (lightbox) al tocar una miniatura de documentación. */
.lightbox-img {
  display: block;
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: var(--r-sm);
  background: #fff;
}

/* Encabezados de sección dentro del pop-up de documentación. */
.modal__seccion {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin: var(--sp-4) 0 var(--sp-2);
}

/* --- Aviso de la ventana de pago del turno --- */
.aviso-turno {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  background: var(--brand-tint);
  border: 1px solid var(--brand-glow);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  color: var(--brand-ink, var(--ink));
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.aviso-turno__ic {
  display: inline-flex;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--brand);
}
.aviso-turno__ic svg {
  width: 18px;
  height: 18px;
}
.aviso-turno b {
  font-weight: 700;
}

/* --- Resumen de cotizacion (pago) --- */
.summary {
  position: sticky;
  top: calc(var(--header-h) + var(--sp-4));
}
.summary__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px dashed var(--line);
  font-size: var(--fs-sm);
}
.summary__row span:first-child {
  color: var(--ink-2);
}
.summary__row b {
  font-weight: 700;
}
.summary__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 2px solid var(--line);
}
.summary__total .lbl {
  font-weight: 700;
}
.summary__total .amt {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.02em;
}

.pay-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp-5);
  align-items: start;
}
@media (max-width: 860px) {
  .pay-layout {
    grid-template-columns: 1fr;
  }
}

/* --- Grilla de horarios (turno sucursal) --- */
.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.slot {
  padding: var(--sp-3);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: var(--fs-sm);
  text-align: center;
  transition: all var(--t);
}
.slot:hover {
  border-color: var(--brand);
}
.slot.is-selected {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* --- Sello de bonificacion --- */
.bonif {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ok);
  background: var(--ok-tint);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-pill);
}

/* --- Spinner de carga en selects del catálogo --- */
.select-wrap {
  position: relative;
}
.select-spinner {
  position: absolute;
  right: 12px;
  top: 50%;
  margin-top: -9px; /* centra sin usar transform: no choca con el rotate del giro */
  display: none;
  pointer-events: none;
}
.select-wrap.is-loading select {
  appearance: none;
  -webkit-appearance: none;
  color: var(--ink-3);
}
.select-wrap.is-loading .select-spinner {
  display: block;
}

/* --- Términos y condiciones --- */
.terms {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  cursor: pointer;
}
.terms input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  flex-shrink: 0;
}

/* --- Loader inline --- */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--brand-tint);
  border-top-color: var(--brand);
  border-radius: var(--r-pill);
  animation: spin 0.7s linear infinite;
}
.spinner--light {
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-7);
  color: var(--ink-3);
}

/* Fila "Instalacion" del resumen (paso de Pago).
   Cuando el abono la bonifica, el costo se muestra tachado: se ve cuanto vale
   y que no se cobra. Si se cobra (auto con abono mensual) va como el resto. */
.summary__row .tachado {
  text-decoration: line-through;
  color: var(--ink-3);
  font-weight: 600;
}
/* La fila arranca oculta hasta que el back informa el costo de instalacion. */
.summary__row.is-oculta {
  display: none;
}
