/* ─── Reset y base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --azul:       #1a56db;
  --azul-oscuro:#1e3a8a;
  --rojo:       #dc2626;
  --verde:      #16a34a;
  --gris-claro: #f3f4f6;
  --gris-borde: #d1d5db;
  --texto:      #111827;
  --texto-suave:#6b7280;
  --blanco:     #ffffff;
  --sombra:     0 2px 8px rgba(0,0,0,.12);
  --radio:      12px;
  --radio-sm:   8px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #eef2ff;
  color: var(--texto);
  min-height: 100vh;
  padding-bottom: 40px;
}

/* ─── Encabezado ────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--azul-oscuro);
  color: white;
  padding: 14px 20px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
.app-header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: .5px; }
.app-header p { font-size: .75rem; opacity: .8; margin-top: 2px; }

/* ─── Barra de progreso ─────────────────────────────────────────────────────── */
.progress-bar-wrap {
  background: rgba(255,255,255,.15);
  height: 4px;
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.progress-bar-fill {
  background: #60a5fa;
  height: 100%;
  border-radius: 2px;
  transition: width .4s ease;
}

/* ─── Contenedor principal ──────────────────────────────────────────────────── */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

/* ─── Tarjeta de paso ──────────────────────────────────────────────────────── */
.paso {
  display: none;
  animation: fadeIn .3s ease;
}
.paso.activo { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tarjeta {
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 24px;
  margin-bottom: 16px;
}

.paso-titulo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--azul-oscuro);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.paso-titulo .icono { font-size: 1.5rem; }

.paso-descripcion {
  color: var(--texto-suave);
  font-size: .9rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.paso-num {
  font-size: .75rem;
  font-weight: 700;
  color: var(--texto-suave);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* ─── Secciones dentro de un paso ──────────────────────────────────────────── */
.seccion {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--gris-claro);
}
.seccion:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.seccion-titulo {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--azul);
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--azul);
}
.seccion-titulo.rojo { color: var(--rojo); border-color: var(--rojo); }

/* ─── Campos del formulario ─────────────────────────────────────────────────── */
.campo-grupo {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.campo-grupo.cols-2 { grid-template-columns: 1fr 1fr; }
.campo-grupo.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 500px) {
  .campo-grupo.cols-2,
  .campo-grupo.cols-3 { grid-template-columns: 1fr; }
}

.campo {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--texto);
}
label .opcional { font-weight: 400; color: var(--texto-suave); margin-left: 4px; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gris-borde);
  border-radius: var(--radio-sm);
  font-size: .95rem;
  color: var(--texto);
  background: var(--blanco);
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

textarea { resize: vertical; min-height: 80px; }

select {
  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 d='M6 8L0 0h12z' fill='%236b7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ─── Radio y checkbox estilizados ──────────────────────────────────────────── */
.opcion-grupo { display: flex; gap: 10px; flex-wrap: wrap; }

.opcion-btn {
  flex: 1;
  min-width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 2px solid var(--gris-borde);
  border-radius: var(--radio-sm);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: all .2s;
  user-select: none;
  background: var(--blanco);
}
.opcion-btn:hover { border-color: var(--azul); }
.opcion-btn input { display: none; }
.opcion-btn.seleccionado { border-color: var(--azul); background: #eff6ff; color: var(--azul); }
.opcion-btn.seleccionado-rojo { border-color: var(--rojo); background: #fef2f2; color: var(--rojo); }

/* ─── Circunstancias ────────────────────────────────────────────────────────── */
.circ-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.circ-tabla th {
  background: var(--gris-claro);
  padding: 8px;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  text-align: center;
  border: 1px solid var(--gris-borde);
}
.circ-tabla th.th-a { color: var(--azul); }
.circ-tabla th.th-b { color: var(--rojo); }
.circ-tabla td {
  padding: 8px;
  border: 1px solid var(--gris-borde);
  vertical-align: middle;
}
.circ-tabla tr:hover td { background: #f9fafb; }
.circ-tabla td.td-num { text-align: center; font-weight: 700; color: var(--texto-suave); width: 30px; }
.circ-tabla td.td-cb { text-align: center; width: 50px; }

.circ-check {
  width: 24px;
  height: 24px;
  border: 2px solid var(--gris-borde);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  font-size: 14px;
  font-weight: bold;
  background: var(--blanco);
}
.circ-check.a-marcado { background: var(--azul); border-color: var(--azul); color: white; }
.circ-check.b-marcado { background: var(--rojo); border-color: var(--rojo); color: white; }

/* ─── Canvas (croquis y firma) ──────────────────────────────────────────────── */
.canvas-wrap {
  border: 2px dashed var(--gris-borde);
  border-radius: var(--radio-sm);
  overflow: hidden;
  position: relative;
  background: #fafafa;
  touch-action: none;
}
.canvas-wrap canvas { display: block; width: 100%; cursor: crosshair; }
.canvas-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ─── Impacto en vehículo ───────────────────────────────────────────────────── */
.impacto-wrap {
  position: relative;
  display: inline-block;
  max-width: 280px;
  margin: 0 auto;
  display: block;
}
.impacto-wrap img { width: 100%; display: block; border-radius: var(--radio-sm); }
.impacto-wrap canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  cursor: crosshair;
}

/* ─── Fotos ─────────────────────────────────────────────────────────────────── */
.fotos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.foto-thumb {
  aspect-ratio: 4/3;
  background: var(--gris-claro);
  border-radius: var(--radio-sm);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--gris-borde);
}
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; }
.foto-thumb .btn-eliminar {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.btn-camara {
  aspect-ratio: 4/3;
  background: var(--gris-claro);
  border: 2px dashed var(--gris-borde);
  border-radius: var(--radio-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-size: .8rem;
  color: var(--texto-suave);
  transition: all .2s;
}
.btn-camara:hover { border-color: var(--azul); color: var(--azul); background: #eff6ff; }
.btn-camara .icono-camara { font-size: 1.5rem; }

/* ─── Botones de acción ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radio-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--azul); color: white; }
.btn-primario:hover:not(:disabled) { background: var(--azul-oscuro); transform: translateY(-1px); }
.btn-secundario { background: var(--gris-claro); color: var(--texto); }
.btn-secundario:hover:not(:disabled) { background: var(--gris-borde); }
.btn-peligro { background: #fee2e2; color: var(--rojo); }
.btn-peligro:hover:not(:disabled) { background: #fecaca; }
.btn-exito { background: var(--verde); color: white; }
.btn-exito:hover:not(:disabled) { background: #15803d; }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-lg { padding: 16px 32px; font-size: 1.1rem; width: 100%; }

.nav-botones {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.nav-botones .btn-primario { flex: 2; }
.nav-botones .btn-secundario { flex: 1; }

/* ─── Alertas y avisos ──────────────────────────────────────────────────────── */
.alerta {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radio-sm);
  font-size: .9rem;
  line-height: 1.5;
  margin-bottom: 16px;
}
.alerta-info { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; }
.alerta-aviso { background: #fefce8; border: 1px solid #fde047; color: #854d0e; }
.alerta-error { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alerta-exito { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }

/* ─── Pantalla de bienvenida ────────────────────────────────────────────────── */
.bienvenida {
  text-align: center;
  padding: 20px 0;
}
.bienvenida .hero-icon { font-size: 4rem; margin-bottom: 16px; }
.bienvenida h2 { font-size: 1.6rem; font-weight: 800; color: var(--azul-oscuro); margin-bottom: 12px; }
.bienvenida .subtitulo { font-size: 1rem; color: var(--texto-suave); line-height: 1.6; margin-bottom: 24px; }
.pasos-lista {
  text-align: left;
  background: var(--gris-claro);
  border-radius: var(--radio);
  padding: 16px 20px;
  margin-bottom: 24px;
  list-style: none;
}
.pasos-lista li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gris-borde);
  font-size: .9rem;
}
.pasos-lista li:last-child { border-bottom: none; }
.pasos-lista .num {
  width: 28px; height: 28px;
  background: var(--azul);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ─── Pantalla de éxito ─────────────────────────────────────────────────────── */
.pantalla-exito {
  text-align: center;
  padding: 20px;
}
.pantalla-exito .hero-icon { font-size: 4rem; margin-bottom: 16px; }
.pantalla-exito h2 { font-size: 1.5rem; font-weight: 800; color: var(--verde); margin-bottom: 12px; }
.whatsapp-enlaces {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.btn-whatsapp {
  background: #25d366;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radio-sm);
  font-size: .95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  justify-content: center;
}

/* ─── Spinner de carga ──────────────────────────────────────────────────────── */
.spinner-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: white;
}
.spinner-overlay.visible { display: flex; }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-texto { font-size: 1rem; font-weight: 600; }

/* ─── Indicador de vehículo (A / B) ────────────────────────────────────────── */
.vehiculo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 800;
  flex-shrink: 0;
}
.vehiculo-badge.a { background: #dbeafe; color: var(--azul); }
.vehiculo-badge.b { background: #fee2e2; color: var(--rojo); }

/* ─── Mismo que propietario ─────────────────────────────────────────────────── */
.toggle-conductor {
  background: var(--gris-claro);
  border-radius: var(--radio-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  cursor: pointer;
}
.toggle-conductor input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--azul);
  cursor: pointer;
}

/* ─── Totales circunstancias ────────────────────────────────────────────────── */
.circ-totales {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.circ-total-badge {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 700;
}
.circ-total-badge.a { background: #dbeafe; color: var(--azul); }
.circ-total-badge.b { background: #fee2e2; color: var(--rojo); }

/* ─── Método de envío ───────────────────────────────────────────────────────── */
.metodo-envio-grupo {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.metodo-card {
  border: 2px solid var(--gris-borde);
  border-radius: var(--radio-sm);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.metodo-card input { display: none; }
.metodo-card .icono { font-size: 1.6rem; }
.metodo-card .nombre { font-size: .85rem; font-weight: 600; }
.metodo-card:hover { border-color: var(--azul); }
.metodo-card.seleccionado { border-color: var(--azul); background: #eff6ff; }
.metodo-card.seleccionado .nombre { color: var(--azul); }

@media (max-width: 400px) {
  .metodo-envio-grupo { grid-template-columns: 1fr; }
  .fotos-grid { grid-template-columns: repeat(2, 1fr); }
}
