/* ---- Base ---- */
* { box-sizing: border-box; }
body { margin: 0; font-family: 'DM Sans', sans-serif; background: #f0f2f5; }

/* ---- Layout ---- */
.form-card { width: 360px; max-width: 100%; background: #fff; border-radius: 12px; border: 0.5px solid #d1d5db; padding: 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }

/* Top bar: back button + step indicator (kept away from the primary CTA) */
.form-topbar { display: flex; align-items: center; gap: 6px; margin: -6px -6px 14px; padding: 0 6px 12px; border-bottom: 0.5px solid #e5e7eb; }
.back-btn { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex-shrink: 0; padding: 0; border: none; border-radius: 6px; background: none; color: #6b7280; cursor: pointer; transition: background 0.15s, color 0.15s; }
.back-btn:hover { background: #f0f2f5; color: #1a2535; }
.back-btn svg { width: 15px; height: 15px; display: block; }

.form-card-title { font-size: 17px; font-weight: 600; color: #1a2535; margin: 0 0 6px; }
.form-card-sub { font-size: 12px; color: #6b7280; margin: 0; }
.progress-bar { display: flex; gap: 4px; margin-bottom: 20px; }
.progress-step { flex: 1; height: 3px; border-radius: 99px; background: #e5e7eb; transition: background 0.3s; }
.progress-step.done   { background: #1a2535; }
.progress-step.active { background: #1a2535; opacity: 0.45; }
.section-title { font-size: 10.5px; font-weight: 700; color: #9ca3af; letter-spacing: 0.06em; text-transform: uppercase; margin: 22px 0 12px; }
.section-title:first-child { margin-top: 0; }
.divider { border: none; border-top: 1px solid #e2e4e8; margin: 26px 0 20px; }

/* ---- Form fields ---- */
.f-group { margin-bottom: 15px; }
.f-label { font-size: 11.5px; font-weight: 500; color: #6b7280; display: block; margin-bottom: 5px; }
.f-input { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 0.5px solid #d1d5db; border-radius: 6px; font-size: 13px; color: #1a2535; font-family: 'DM Sans', sans-serif; background: #fff; outline: none; transition: border-color 0.2s; }
.f-input:focus { border-color: #1a2535; }
.f-row { display: flex; gap: 10px; }
.f-row .f-group { flex: 1; min-width: 0; }
.f-note { font-size: 10px; color: #9ca3af; margin: 1px 0 4px; line-height: 1.3; }
.alerta { font-size: 10.5px; color: #d92d20; margin: 3px 0 6px; }
.d-none { display: none; }

/* ---- Phone field (intlTelInput overrides) ---- */
.phone-wrap { display: flex; }
.phone-input { flex: 1; padding: 8px 10px; border: 0.5px solid #d1d5db; border-radius: 6px; font-size: 13px; color: #1a2535; font-family: 'DM Sans', sans-serif; outline: none; min-width: 0; }
.phone-input:focus { border-color: #1a2535; }
.iti { flex: 1; width: 100%; }
.iti__flag-container { padding: 0; }
.iti__selected-flag { padding: 0 8px 0 10px; border-right: 0.5px solid #d1d5db; border-radius: 6px 0 0 6px; height: 100%; }
.iti__selected-flag .iti__arrow { border-top-color: #6b7280; }
.iti input.phone-input { width: 100%; padding-right: 10px; }
.iti--separate-dial-code .iti__selected-flag { background: transparent; }
.iti__country-list { font-size: 12px; font-family: 'DM Sans', sans-serif; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); border: 0.5px solid #d1d5db; }
.iti__country { padding: 6px 10px; }
.iti__flag { box-shadow: 0 0 1px rgba(0,0,0,0.3); }

/* ---- Calendar ---- */
.calendar-container { border: 0.5px solid #d1d5db; border-radius: 8px; padding: 10px; margin: -2px 0 10px; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.calendar-column { display: flex; align-items: center; gap: 4px; }
.calendar-column button { border: 0.5px solid #d1d5db; background: #f9fafb; border-radius: 4px; font-size: 11px; color: #1a2535; padding: 3px 7px; cursor: pointer; font-family: 'DM Sans', sans-serif; }
.calendar-column button:hover { background: #eef0f3; }
.calendar-column input { border: 0.5px solid #d1d5db; border-radius: 4px; font-size: 12px; font-family: 'DM Sans', sans-serif; padding: 3px 6px; text-align: center; background: #fff; color: #1a2535; }
.calendar-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.calendar-table th { color: #9ca3af; font-weight: 600; padding: 4px 0; text-transform: uppercase; font-size: 9.5px; letter-spacing: 0.04em; }
.calendar-table td { text-align: center; padding: 5px 0; border-radius: 6px; cursor: pointer; color: #1a2535; }
.calendar-table td:hover { background: #f0f2f5; }
.calendar-table td.selected { background: #1a2535; color: #fff; }
.calendar-table td.disabled { color: #d1d5db; cursor: default; }
.calendar-table td.disabled:hover { background: none; }

/* ---- Toggle switch (Responsable Legal) ---- */
.switch-row { display: flex; align-items: center; justify-content: flex-start; gap: 10px; margin-bottom: 4px; cursor: pointer; }
.switch-label { font-size: 13px; font-weight: 500; color: #374151; line-height: 1.3; }
.switch-track { width: 36px; height: 20px; background: #d1d5db; border-radius: 99px; position: relative; flex-shrink: 0; transition: background 0.2s; }
.switch-track.on { background: #1a2535; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.18); transition: transform 0.2s; }
.switch-track.on .switch-thumb { transform: translateX(16px); }
.rl-section { display: none; }
.rl-section.visible { display: block; animation: fadeIn 0.22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Horario cards ---- */
.horario-grid { display: flex; gap: 8px; }
.horario-card { flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0.5px solid #d1d5db; border-radius: 6px; cursor: pointer; transition: border-color 0.2s, background 0.2s; background: #fff; }
.horario-card:hover { border-color: #9ca3af; }
.horario-card.selected { border-color: #1a2535; background: #f4f5f7; }
.horario-icon { font-size: 14px; color: #6b7280; flex-shrink: 0; line-height: 1; }
.horario-name { font-size: 12px; font-weight: 600; color: #1a2535; line-height: 1.15; }
.horario-time { font-size: 10.5px; color: #6b7280; line-height: 1.15; }

/* ---- Checkbox ---- */
.check-opt { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: #374151; margin-bottom: 8px; cursor: pointer; }
.check-box { width: 14px; height: 14px; border-radius: 3px; border: 1.5px solid #d1d5db; flex-shrink: 0; margin-top: 1px; display: flex; align-items: center; justify-content: center; background: #fff; transition: all 0.2s; }
.check-box.checked { background: #1a2535; border-color: #1a2535; }
.check-mark { color: #fff; font-size: 9px; display: none; }
.check-box.checked .check-mark { display: block; }
.link-text { color: #2680FF; text-decoration: underline; }

/* ---- Buttons ---- */
.btn-primary { width: 100%; padding: 11px; background: #1a2535; color: #fff; border: none; border-radius: 7px; font-size: 13.5px; font-weight: 600; font-family: 'DM Sans', sans-serif; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; margin-top: 14px; letter-spacing: 0.04em; }
.btn-primary:hover { background: #2d3f57; }
.btn-secondary { background: none; border: none; color: #6b7280; font-size: 12px; font-family: 'DM Sans', sans-serif; cursor: pointer; padding: 6px 0; display: block; text-align: center; width: 100%; margin-top: 2px; }
.btn-secondary:hover { color: #1a2535; }

/* ---- Sticky CTA footer ----
   Keeps Continuar/Enviar always visible while the form scrolls.
   Bleeds into the card's own padding so it reaches the card edges. */
.form-footer { position: sticky; bottom: 0; z-index: 5; background: #fff; margin: 20px -24px -24px; padding: 14px 24px 24px; box-shadow: 0 -10px 14px -10px rgba(0,0,0,0.12); border-radius: 0 0 12px 12px; }
.form-footer .btn-primary { margin-top: 0; }

/* ---- Loading state ---- */
.loading-state { text-align: center; padding: 32px 4px; }
.loading-spinner { width: 36px; height: 36px; border: 3px solid #e5e7eb; border-top-color: #1a2535; border-radius: 50%; margin: 0 auto 14px; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-size: 14px; font-weight: 600; color: #1a2535; margin: 0 0 4px; }
.loading-sub { font-size: 12px; color: #6b7280; margin: 0; }

/* ---- Error state ---- */
.error-state { text-align: center; padding: 24px 4px; }
.error-icon { width: 44px; height: 44px; border-radius: 50%; background: #d92d20; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; }
.error-title { font-size: 15px; font-weight: 600; color: #1a2535; margin: 0 0 6px; }
.error-sub { font-size: 12.5px; color: #6b7280; line-height: 1.5; margin: 0 0 16px; }

/* ---- Success state ---- */
.success-state { text-align: center; padding: 24px 4px; }
.success-icon { width: 44px; height: 44px; border-radius: 50%; background: #1a2535; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; }
.success-title { font-size: 15px; font-weight: 600; color: #1a2535; margin: 0 0 6px; }
.success-sub { font-size: 12.5px; color: #6b7280; line-height: 1.5; margin: 0; }

@media (max-width: 480px) {
  body:not(.layout-horizontal) .form-card {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    padding: 20px 16px;
  }
  body:not(.layout-horizontal) .form-topbar { margin: -4px -4px 12px; }
  /* Footer sticky: los márgenes negativos deben igualar el nuevo padding */
  body:not(.layout-horizontal) .form-footer {
    margin: 18px -16px -20px;
    padding: 12px 16px 18px;
    border-radius: 0;
  }
  /* iOS hace zoom automático en inputs con fuente <16px */
  body:not(.layout-horizontal) .f-input,
  body:not(.layout-horizontal) .phone-input { font-size: 16px; padding: 10px 12px; }
  body:not(.layout-horizontal) .f-label { font-size: 12.5px; }
  body:not(.layout-horizontal) .btn-primary { padding: 13px; font-size: 15px; }
  body:not(.layout-horizontal) .calendar-container { max-width: 100%; }
  body:not(.layout-horizontal) .horario-grid { flex-direction: column; }
}

/* Pantallas muy angostas: apilar campos en par (fecha/sexo, apellidos) */
@media (max-width: 340px) {
  body:not(.layout-horizontal) .f-row { flex-direction: column; gap: 0; }
}

/* ---- Card a ancho completo del navegador, contenido centrado ---- */
.layout-horizontal .form-card { width: 100%; max-width: none; border-radius: 0; border-left: none; border-right: none; padding: 32px clamp(16px, 5vw, 64px); }
.layout-horizontal .form-topbar     { max-width: 960px; margin: -6px auto 14px; }
.layout-horizontal .form-card-title { max-width: 960px; margin: 0 auto 6px; }
.layout-horizontal .progress-bar    { max-width: 960px; margin: 0 auto 20px; }
.layout-horizontal #myForm          { max-width: 960px; margin: 0 auto; }

/* ---- Pasos en grid de 2 columnas ---- */
.layout-horizontal .form-step { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: start; }
/* Fallback por si algún script asigna display:block inline a un paso */
.layout-horizontal .form-step[style*="display: block"],
.layout-horizontal .form-step[style*="display:block"] { display: grid !important; }

/* Elementos que ocupan la fila completa dentro del grid */
.layout-horizontal .form-step > .section-title,
.layout-horizontal .form-step > .divider,
.layout-horizontal .form-step > .calendar-container,
.layout-horizontal .form-step > .check-opt,
.layout-horizontal .form-step > .alerta,
.layout-horizontal .form-step > .switch-row,
.layout-horizontal .form-step > .rl-section,
.layout-horizontal .form-step > .horario-grid,
.layout-horizontal .form-step > #grupo-section,
.layout-horizontal .form-step > .form-footer { grid-column: 1 / -1; }

.layout-horizontal .form-step > .section-title { margin-top: 6px; }
.layout-horizontal .form-step > .section-title:first-child { margin-top: 0; }

/* Sección Responsable Legal (toggle) también en 2 columnas */
.layout-horizontal .rl-section.visible { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: start; }
.layout-horizontal .rl-section > .section-title,
.layout-horizontal .rl-section > .divider { grid-column: 1 / -1; }

/* Calendario: no estirar a todo el ancho */
.layout-horizontal .form-step > .calendar-container { max-width: 400px; justify-self: start; }

/* Footer / CTA: fila completa, botón centrado */
.layout-horizontal .form-footer { margin: 20px 0 0; padding: 14px 0 4px; border-radius: 0; position: sticky; bottom: 0; background: #fff; box-shadow: 0 -10px 14px -10px rgba(0,0,0,0.10); }
.layout-horizontal .form-footer .btn-primary { max-width: 460px; margin: 0 auto; }

/* Responsive: una columna en pantallas angostas */
@media (max-width: 720px) {
  .layout-horizontal .form-card { padding: 24px 16px; }
  .layout-horizontal .form-step,
  .layout-horizontal .rl-section.visible { grid-template-columns: 1fr; }
  .layout-horizontal .form-step > .calendar-container { max-width: 100%; }
}

