/* styles.css — Formularios públicos GR2 · formularios.grupor2.com
 * Mobile-first. Paleta coherente con los PDF GR2. Sin CDN externos.
 *
 * Base copiada de firma/assets/styles.css (2026-07-05). El bloque
 * "MODO EDICIÓN" al final agrega los controles de captura (inputs,
 * select, toggle Sí/No, foto, aviso legal). Todo lo anterior es idéntico
 * a la firma para mantener la misma identidad visual. */

:root {
  --navy: #0c2340;
  --navy-suave: #1a3a5c;
  --teal: #0891b2;
  --teal-claro: #e0f4f8;
  --gris-texto: #2b3440;
  --gris-medio: #5b6673;
  --gris-suave: #8a949e;
  --borde: #dde2e8;
  --borde-suave: #eaedf1;
  --fondo: #f6f7f9;
  --blanco: #ffffff;
  --verde: #15803d;
  --verde-fondo: #e7f6ec;
  --rojo: #b42318;
  --rojo-fondo: #fdecea;
  --ambar-fondo: #fff4e5;
  --ambar-texto: #92400e;
  --radio: 12px;
  --radio-sm: 8px;
  --sombra: 0 1px 3px rgba(12, 35, 64, .08), 0 1px 2px rgba(12, 35, 64, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fondo);
  color: var(--gris-texto);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

/* ── Cabecera / logo ─────────────────────────────────────────── */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
}
.top img.logo {
  height: 40px;
  width: auto;
  display: block;
}
.top .marca {
  font-weight: 700;
  color: var(--navy);
  letter-spacing: .3px;
  font-size: 1.05rem;
}

/* ── Tarjetas ────────────────────────────────────────────────── */
.card {
  background: var(--blanco);
  border: 1px solid var(--borde-suave);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 20px;
  margin-top: 16px;
}

/* ── Cabecera del documento ──────────────────────────────────── */
.doc-cabecera h1 {
  font-size: 1.25rem;
  color: var(--navy);
  margin: 0 0 2px;
  line-height: 1.25;
}
.doc-cabecera .codigo {
  color: var(--gris-medio);
  font-size: .85rem;
  font-weight: 500;
}
.doc-cabecera .solicitado {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--teal-claro);
  border-left: 3px solid var(--teal);
  border-radius: var(--radio-sm);
  font-size: .92rem;
  color: var(--navy-suave);
}
.doc-cabecera .solicitado strong { color: var(--navy); }

/* ── Documento (campos) ──────────────────────────────────────── */
.doc-titulo {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--gris-suave);
  font-weight: 700;
  margin: 4px 0 12px;
}

.campo {
  padding: 10px 0;
  border-bottom: 1px solid var(--borde-suave);
}
.campo:last-child { border-bottom: none; }

.campo-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}
.campo-etiqueta {
  font-size: .78rem;
  font-weight: 600;
  color: var(--gris-medio);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.campo-badge {
  font-size: .68rem;
  font-weight: 700;
  color: var(--teal);
  background: var(--teal-claro);
  border: 1px solid var(--teal);
  border-radius: 999px;
  padding: 1px 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.campo-valor {
  font-size: 1rem;
  color: var(--gris-texto);
  word-break: break-word;
}
.campo-valor.campo-vacio { color: var(--gris-suave); }
.campo-valor.campo-multilinea { white-space: pre-wrap; }

/* Campo del propio firmante: resaltado teal */
.campo.campo-mio {
  background: var(--teal-claro);
  border: 1px solid var(--teal);
  border-radius: var(--radio-sm);
  padding: 10px 12px;
  margin: 6px 0;
}

/* Firma dentro del documento */
.campo-firma {
  display: inline-block;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .9rem;
}
.campo-firma.firmado { color: var(--verde); background: var(--verde-fondo); }
.campo-firma.pendiente { color: var(--ambar-texto); background: var(--ambar-fondo); }

/* Tabla */
.campo-tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.campo-tabla {
  border-collapse: collapse;
  width: 100%;
  font-size: .88rem;
  margin-top: 4px;
}
.campo-tabla th, .campo-tabla td {
  border: 1px solid var(--borde);
  padding: 6px 9px;
  text-align: left;
}
.campo-tabla th {
  background: var(--fondo);
  color: var(--navy-suave);
  font-weight: 600;
  white-space: nowrap;
}

/* Foto */
.campo-foto {
  max-width: 140px;
  max-height: 140px;
  border-radius: var(--radio-sm);
  border: 1px solid var(--borde);
  margin-top: 4px;
  object-fit: cover;
}

.doc-vacio, .doc-vacio { color: var(--gris-suave); font-style: italic; }

/* ── Bloque de firma ─────────────────────────────────────────── */
.firma-bloque { margin-top: 4px; }

.campo-doc { margin-bottom: 18px; }
.campo-doc label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gris-medio);
  margin-bottom: 6px;
}
.campo-doc input[type="text"],
.campo-doc input[type="tel"] {
  width: 100%;
  font-size: 1.05rem;
  padding: 12px 14px;
  border: 1px solid var(--borde);
  border-radius: var(--radio-sm);
  background: var(--blanco);
  color: var(--gris-texto);
}
.campo-doc input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, .15);
}

.firma-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.firma-label span {
  font-size: .85rem;
  font-weight: 600;
  color: var(--gris-medio);
}
.btn-limpiar {
  background: none;
  border: none;
  color: var(--teal);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}
.btn-limpiar:active { opacity: .6; }

.canvas-caja {
  position: relative;
  border: 2px dashed var(--borde);
  border-radius: var(--radio-sm);
  background: var(--blanco);
  overflow: hidden;
}
#canvasFirma {
  display: block;
  width: 100%;
  height: 200px;
  touch-action: none;
  cursor: crosshair;
}
.canvas-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gris-suave);
  font-size: .9rem;
  pointer-events: none;
  transition: opacity .2s;
}
.canvas-caja.con-trazos .canvas-hint { opacity: 0; }
.canvas-linea {
  position: absolute;
  left: 12px; right: 12px; bottom: 34px;
  border-bottom: 1px solid var(--borde);
  pointer-events: none;
}

/* ── Aceptación electrónica ──────────────────────────────────── */
.aceptacion {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 18px 0;
  padding: 12px 14px;
  background: var(--fondo);
  border: 1px solid var(--borde-suave);
  border-radius: var(--radio-sm);
  cursor: pointer;
}
.aceptacion input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  flex-shrink: 0;
  accent-color: var(--teal);
}
.aceptacion .texto {
  font-size: .9rem;
  color: var(--gris-texto);
}

/* ── Botones ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 15px 20px;
  border: none;
  border-radius: var(--radio-sm);
  cursor: pointer;
  background: var(--navy);
  color: #fff;
  transition: background .15s, opacity .15s;
}
.btn:active { background: var(--navy-suave); }
.btn:disabled {
  background: #c3cad3;
  color: #eef1f4;
  cursor: not-allowed;
}
.btn-secundario {
  background: transparent;
  color: var(--teal);
  border: 1px solid var(--teal);
}
.btn-secundario:active { background: var(--teal-claro); }

/* ── Banner de error reintentable (dentro de la vista de firma) ─ */
.banner-error {
  display: none;
  margin: 14px 0;
  padding: 12px 14px;
  background: var(--rojo-fondo);
  border: 1px solid #f3c6c1;
  border-left: 3px solid var(--rojo);
  border-radius: var(--radio-sm);
  color: var(--rojo);
  font-size: .92rem;
}
.banner-error.visible { display: block; }

/* ── Estados de pantalla completa ────────────────────────────── */
.estado-centro {
  text-align: center;
  padding: 40px 20px;
}
.estado-centro .icono {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 12px;
}
.estado-centro h2 {
  color: var(--navy);
  font-size: 1.3rem;
  margin: 0 0 8px;
}
.estado-centro p {
  color: var(--gris-medio);
  margin: 0 auto;
  max-width: 380px;
}
.estado-centro .btn { margin-top: 20px; max-width: 280px; }

/* Spinner */
.spinner {
  width: 42px; height: 42px;
  border: 4px solid var(--borde);
  border-top-color: var(--teal);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: girar .8s linear infinite;
}
.spinner-sm {
  width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: girar .8s linear infinite;
  display: inline-block;
}
@keyframes girar { to { transform: rotate(360deg); } }

.icono-exito { color: var(--verde); }
.icono-error { color: var(--rojo); }

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 16px;
  font-size: .78rem;
  color: var(--gris-suave);
  line-height: 1.4;
}

/* ── Utilidades de visibilidad de estados ────────────────────── */
.oculto { display: none !important; }

@media (min-width: 560px) {
  .wrap { padding: 24px 24px 56px; }
  .card { padding: 26px; }
}

/* ══════════════════════════════════════════════════════════════
   MODO EDICIÓN — controles de captura (formularios públicos)
   Estas clases NO existen en firma/. Las pinta campos-renderer.js
   en modo 'edicion'. La estética hereda las variables de arriba.
   ══════════════════════════════════════════════════════════════ */

/* Campo editable: contenedor de un control con su etiqueta y ayuda */
.ce {
  padding: 14px 0;
  border-bottom: 1px solid var(--borde-suave);
}
.ce:last-child { border-bottom: none; }

.ce-label {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  color: var(--gris-texto);
  margin-bottom: 7px;
}
.ce-req {
  color: var(--rojo);
  margin-left: 3px;
  font-weight: 700;
}
.ce-ayuda {
  font-size: .82rem;
  color: var(--gris-suave);
  margin: 6px 0 0;
}

/* Inputs de texto / número / textarea / date / time / select */
.ce-input,
.ce-textarea,
.ce-select {
  width: 100%;
  font-size: 1.05rem;
  padding: 12px 14px;
  border: 1px solid var(--borde);
  border-radius: var(--radio-sm);
  background: var(--blanco);
  color: var(--gris-texto);
  font-family: inherit;
}
.ce-textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
.ce-input:focus,
.ce-textarea:focus,
.ce-select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, .15);
}
.ce-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235b6673' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

/* Campo bloqueado (datoPuesto prellenado por el servidor) */
.ce-input:disabled,
.ce-bloqueado {
  background: var(--fondo);
  color: var(--gris-medio);
  cursor: not-allowed;
}

/* Toggle Sí/No (segmentado) */
.ce-sino {
  display: flex;
  gap: 8px;
}
.ce-sino .ce-opt {
  flex: 1;
  position: relative;
}
.ce-sino .ce-opt input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}
.ce-sino .ce-opt span {
  display: block;
  text-align: center;
  padding: 12px 8px;
  border: 1px solid var(--borde);
  border-radius: var(--radio-sm);
  font-weight: 600;
  color: var(--gris-medio);
  background: var(--blanco);
  transition: all .12s;
}
.ce-sino .ce-opt input:checked + span {
  border-color: var(--teal);
  color: var(--navy);
  background: var(--teal-claro);
  box-shadow: 0 0 0 2px rgba(8, 145, 178, .2) inset;
}
.ce-sino .ce-opt input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(8, 145, 178, .25);
}

/* Consentimiento: checkbox de autorización expresa (reusa .aceptacion) */
.ce-consent { margin-top: 4px; }

/* Aviso legal (campo tipo 'informacion') */
.ce-aviso {
  padding: 14px 16px;
  background: var(--ambar-fondo);
  border: 1px solid #f2d9a8;
  border-left: 3px solid var(--ambar-texto);
  border-radius: var(--radio-sm);
  font-size: .88rem;
  color: var(--ambar-texto);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.ce-aviso strong { color: var(--ambar-texto); }

/* Foto: botón de captura + preview */
.ce-foto-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ce-foto-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1px solid var(--teal);
  border-radius: var(--radio-sm);
  background: var(--teal-claro);
  color: var(--navy);
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
}
.ce-foto-btn:active { opacity: .7; }
.ce-foto-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.ce-foto-preview {
  position: relative;
  display: none;
}
.ce-foto-preview.visible { display: inline-block; }
.ce-foto-preview img {
  max-width: 120px;
  max-height: 120px;
  border-radius: var(--radio-sm);
  border: 1px solid var(--borde);
  object-fit: cover;
  display: block;
}
.ce-foto-quitar {
  position: absolute;
  top: -8px; right: -8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--rojo);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--sombra);
}
.ce-foto-cargando {
  font-size: .85rem;
  color: var(--gris-medio);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Nota para tipos no soportados en esta versión (p.ej. firma) */
.ce-no-soportado {
  font-size: .85rem;
  color: var(--gris-suave);
  font-style: italic;
}

/* Honeypot: fuera de la vista para humanos, visible para bots */
.hp-campo {
  position: absolute !important;
  left: -9999px !important;
  top: auto;
  width: 1px; height: 1px;
  overflow: hidden;
}
