/* ============================================================================
   DIAGNÓSTICO EXTERNO — solo GUI / diseño / dimensiones
   Se carga únicamente en las páginas de diagnostico_ext (registro,
   cuestionario y resultado). No afecta al landing ni al diagnóstico interno.
   ============================================================================ */

/* --- Utilidades que usan las plantillas y no existían ---------------------- */
.text-destructive { color: var(--destructive); }
.text-sm { font-size: 16px; line-height: 1.5; }

/* El tema base no define box-sizing: con content-box los width:100% de
   inputs y contenedores con padding se desbordan y se solapan. */
.diagnostic-layout,
.diagnostic-layout *,
.diagnostic-layout *::before,
.diagnostic-layout *::after,
.question-layout,
.question-layout *,
.question-layout *::before,
.question-layout *::after {
  box-sizing: border-box;
}

/* Errores de formulario / alertas */
.diagnostic-layout [role="alert"],
.question-layout [role="alert"] {
  display: block;
  margin: 0 0 18px;
  padding: 11px 14px;
  border: 1px solid color-mix(in oklch, var(--destructive) 35%, transparent);
  border-radius: 6px;
  background: color-mix(in oklch, var(--destructive) 8%, white);
  color: var(--destructive);
  font-size: 16px;
  line-height: 1.5;
}

/* ============================================================================
   PASO 01 · REGISTRO EMPRESARIAL
   ============================================================================ */
.diagnostic-layout {
  max-width: 1200px;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 0;
  align-items: start;
  padding: clamp(40px, 5.5vw, 64px) 5.5% clamp(56px, 7vw, 84px);
}

.diagnostic-intro {
  padding: 6px clamp(28px, 4vw, 54px) 0 0;
}

.diagnostic-intro > p:not(.eyebrow) {
  max-width: 42ch;
}

.company-form-section {
  padding-left: clamp(28px, 4vw, 54px);
  min-width: 0;
}

.company-form-section h2 {
  line-height: 1.25;
  margin-bottom: 0;
}

.form-subtitle {
  margin: 10px 0 32px;
}

/* Rejilla de campos */
.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 26px;
  align-items: start;
}

.form-field {
  gap: 7px;
  min-width: 0;
}

.form-field > span {
  font-size: 15px;
  line-height: 1.4;
}

.form-field input,
.form-field select {
  height: 44px;
  border-radius: 5px;
  font-size: 17px;
}

/* El correo ocupa toda la fila y no debe desbordar */
.form-grid > div[style*="grid-column"] {
  min-width: 0;
}

/* Autorizaciones */
.consents {
  margin-top: 36px;
  padding-top: 28px;
}

.consents h3 {
  margin-bottom: 2px;
}

.consent-row {
  gap: 14px;
  margin-top: 24px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.consent-row:hover {
  background: var(--muted);
}

.consent-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.consent-row > div {
  min-width: 0;
}

.consent-row strong {
  display: block;
  font-size: 16px;
  line-height: 1.4;
}

.consent-row p {
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.7;
}

/* Acciones */
.form-actions {
  align-items: center;
  gap: 16px;
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.form-actions > span {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
}

.form-actions .btn {
  flex: 0 0 auto;
  min-height: 44px;
  white-space: nowrap;
}

/* ============================================================================
   PASO 02 · CUESTIONARIO
   ============================================================================ */
.question-layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: clamp(36px, 5vw, 58px) 5.5% clamp(56px, 7vw, 78px);
}

.question-top {
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--border);
}

.question-top h1 {
  font-size: clamp(30px, 3vw, 36px);
  line-height: 1.2;
  margin: 12px 0 10px;
}

.question-counter {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 14px;
  white-space: nowrap;
}

/* Bloque de cada pregunta */
.question-block {
  margin-top: 28px;
  padding: clamp(22px, 2.8vw, 32px) clamp(22px, 3vw, 34px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

.question-meta {
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.question-meta > span:last-child {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  letter-spacing: 0;
  white-space: nowrap;
}

.question-block h2 {
  margin: 14px 0 24px;
  font-size: clamp(22px, 2vw, 25px);
  font-weight: 500;
  line-height: 1.45;
  color: var(--foreground);
}

/* Respuestas */
.answer-list {
  gap: 14px;
}

.answer-option {
  display: flex;
  align-items: center;
  gap: 15px;
  position: relative;
  min-height: 0;
  height: auto;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  box-shadow: none;
  text-align: left;
  white-space: normal;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.answer-option:hover {
  background: var(--muted);
}

/* Oculta el radio nativo: se usa el círculo .answer-radio */
.answer-option input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.answer-radio {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--input);
  border-radius: 50%;
  background: var(--background);
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.answer-radio::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  transition: background-color 0.15s ease;
}

/* Estado seleccionado (CSS puro, sin JS) */
.answer-option:has(input[type="radio"]:checked) {
  border-color: var(--primary);
  background: var(--accent);
}
.answer-option:has(input[type="radio"]:checked) .answer-radio {
  border-color: var(--primary);
  background: var(--primary);
}
.answer-option:has(input[type="radio"]:checked) .answer-radio::after {
  background: var(--primary-foreground);
}

/* Estado foco por teclado */
.answer-option:has(input[type="radio"]:focus-visible) {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Compatibilidad con la clase .answer-selected existente */
.answer-option.answer-selected {
  border-color: var(--primary);
  background: var(--accent);
}

.answer-option > span:last-child {
  min-width: 0;
}

.answer-option strong {
  font-size: 17px;
  line-height: 1.35;
}

.answer-option small {
  margin-top: 3px;
  font-size: 15px;
  line-height: 1.5;
}

/* Acción final */
.question-actions {
  justify-content: center;
  margin-top: 38px;
}

.question-actions .btn {
  min-width: 250px;
  max-width: 100%;
  padding: 0 26px;
  white-space: normal;
  text-align: center;
}

/* ============================================================================
   ENCUESTA · CUESTIONARIO IZQUIERDA + GRÁFICO EN VIVO DERECHA
   ============================================================================ */
.question-layout--encuesta {
  max-width: 1240px;
}

.survey-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  gap: 38px;
  align-items: start;
  margin-top: 26px;
}

.survey-form {
  min-width: 0;
}

/* El panel de puntajes acompaña al visitante mientras responde */
.score-panel--live {
  position: sticky;
  top: 24px;
  border-radius: 8px;
}

/* Banner de éxito (mensajes Django) */
.ok-banner {
  display: block;
  margin: 0 0 18px;
  padding: 11px 14px;
  border: 1px solid color-mix(in oklch, var(--primary) 35%, transparent);
  border-radius: 6px;
  background: color-mix(in oklch, var(--primary) 10%, white);
  color: var(--foreground);
  font-size: 16px;
  line-height: 1.5;
}

/* Botones finales: PDF a la izquierda, WhatsApp a la derecha */
.final-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.final-actions .btn {
  min-height: 46px;
  padding: 0 24px;
  white-space: normal;
  text-align: center;
}

.btn-whatsapp {
  background: #25d366;
  border-color: #25d366;
  color: #063d1d;
}
.btn-whatsapp:hover {
  background: #1fb959;
}

@media (max-width: 960px) {
  .survey-grid {
    grid-template-columns: 1fr;
    gap: 26px;
  }
  .score-panel--live {
    position: static;
  }
}

@media (max-width: 700px) {
  .final-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .final-actions .btn {
    width: 100%;
  }
}

/* ============================================================================
   PREGUNTAS R0 / R1 · GRÁFICAS EN VIVO · INFORME DE RESULTADOS
   ============================================================================ */
.question-ayuda {
  margin: -8px 0 14px;
  font-size: 15px;
  color: var(--muted-foreground);
  line-height: 1.6;
}

/* --- Gráficas en vivo (columna derecha) --- */
.live-global {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 14px 0 22px;
}
.live-global strong {
  font-size: 38px;
  font-weight: 600;
  font-family: var(--font-display);
  line-height: 1;
}
.live-global > span {
  font-size: 16px;
  color: var(--muted-foreground);
}
.live-barras {
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.live-fila {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 40px;
  gap: 8px;
  align-items: center;
  font-size: 15px;
}
.live-nombre {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted-foreground);
}
.live-track {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: var(--secondary);
  overflow: hidden;
}
.live-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--chart-neutral);
  transition: width 0.3s ease, background-color 0.3s ease;
}
.live-pct {
  text-align: right;
  font-family: var(--font-display);
  font-weight: 600;
}

/* --- Chips de rango --- */
.rango-chip {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.rango-Inicial { background: #c0563f; }
.rango-En-desarrollo { background: #d9a441; }
.rango-Avanzado { background: #75755a; }

/* --- Informe de resultados (niveles 1-4) --- */
.informe {
  margin-top: 42px;
  border-top: 1px solid var(--border);
  padding-top: 38px;
}
.resultados {
  margin-top: 34px;
}
.informe-bloque {
  margin-bottom: 42px;
}
.informe .eyebrow {
  color: var(--primary);
  margin-bottom: 12px;
}
.resultado-global {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 8px 0 24px;
}
.resultado-global strong {
  font-size: 44px;
  font-weight: 600;
  font-family: var(--font-display);
  line-height: 1;
}
.resultado-global > span {
  font-size: 17px;
  color: var(--muted-foreground);
}
.barras-componentes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 780px;
}
.barra-fila {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 160px;
  gap: 10px;
  align-items: center;
  font-size: 16px;
}
.barra-nombre {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.barra-track {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: var(--secondary);
  overflow: hidden;
}
.barra-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}
.barra-pct {
  font-size: 15px;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.barra-nota {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted-foreground);
}
.parrafo {
  font-size: 17px;
  line-height: 1.85;
  color: var(--muted-foreground);
  margin: 0 0 16px;
  max-width: 880px;
}
.parrafo.pie {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  font-size: 15px;
}

.final-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
}

@media (max-width: 700px) {
  .live-fila {
    grid-template-columns: minmax(0, 1fr) 70px 36px;
  }
  .barra-fila {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 120px;
  }
  .final-nav {
    flex-direction: column;
  }
  .final-nav .btn {
    width: 100%;
  }
  .resultado-global strong {
    font-size: 36px;
  }
}

/* ============================================================================
   RESULTADO · PANEL DE PUNTAJES
   ============================================================================ */
.score-panel {
  /* El inline style fija max-width:720px y márgenes; se refuerza el resto */
  box-sizing: border-box;
  padding: clamp(22px, 3vw, 30px);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.score-title {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.score-panel h3 {
  font-size: clamp(23px, 2.2vw, 26px);
  line-height: 1.4;
  margin-top: 14px;
}

.score-chart {
  gap: clamp(12px, 2vw, 22px);
  margin-top: 28px;
  align-items: end;
}

.score-column {
  min-width: 0;
  align-items: center;
}

.score-column > strong {
  margin-bottom: 10px;
  font-size: 26px;
  line-height: 1;
}

.bar-track {
  width: 100%;
  max-width: 54px;
  height: 190px;
  border-radius: 3px 3px 0 0;
}

.score-bar {
  border-radius: 3px 3px 0 0;
}

/* Etiqueta de dimensión: misma altura para las tres columnas */
.score-column > span {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 3em;
  margin-top: 0;
  padding-top: 12px;
  font-size: 14px;
  line-height: 1.3;
  text-align: center;
}

.score-disclaimer {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.7;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 960px) {
  .diagnostic-layout {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 34px 6% 52px;
  }
  .diagnostic-intro {
    padding: 0;
  }
  .diagnostic-intro > p:not(.eyebrow) {
    max-width: none;
  }
  .company-form-section {
    padding: 28px 0 0;
    border: 0;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .form-actions > span {
    order: 2;
    text-align: center;
  }
  .form-actions .btn {
    order: 1;
    width: 100%;
  }

  .question-top {
    flex-direction: column;
    gap: 14px;
  }
  .question-top h1 {
    font-size: 30px;
  }
  .question-block {
    margin-top: 16px;
    padding: 18px 16px;
  }
  .question-block h2 {
    font-size: 22px;
  }
  .answer-option {
    gap: 11px;
    padding: 12px 14px;
  }
  .question-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .score-chart {
    gap: 12px;
  }
  .bar-track {
    height: 150px;
  }
  .score-column > strong {
    font-size: 23px;
  }
}

/* ============================================================================
   PANTALLA 2 · CONDICIONES, DATOS Y AUTORIZACIÓN
   ============================================================================ */
.diag-form-layout {
  max-width: 960px;
  margin: 0 auto;
  padding: 46px 5.5% 72px;
}
.diag-form-layout h1 {
  font-size: 34px;
  font-weight: 500;
  line-height: 1.2;
  margin: 12px 0 22px;
}
.diag-form-layout h2 {
  font-size: 26px;
  font-weight: 500;
  line-height: 1.25;
  margin: 0 0 6px;
}
.diag-sub {
  font-size: 11px;
  color: var(--muted-foreground);
  margin: 0 0 20px;
}

.condiciones-aviso,
.autorizacion-aviso {
  border: 1px solid var(--border);
  background: var(--muted);
  border-radius: 8px;
  padding: 15px 18px;
  margin-bottom: 16px;
}
.condiciones-aviso p,
.autorizacion-aviso p {
  margin: 0;
  font-size: 12px;
  line-height: 1.75;
  color: var(--foreground);
}
.autorizacion-aviso a {
  color: var(--primary);
  text-decoration: underline;
}
.link-condiciones {
  background: none;
  border: 0;
  padding: 0;
  margin-left: 4px;
  color: var(--primary);
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
}

.check-linea {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.6;
  margin: 10px 0;
  cursor: pointer;
}
.check-linea input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.check-linea i,
.diag-field label i {
  font-style: normal;
  color: var(--primary);
}
.check-linea em {
  font-style: normal;
  color: var(--muted-foreground);
}

.diag-sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 34px 0 28px;
}

.diag-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}
.diag-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.diag-field label {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}
.diag-field input,
.diag-field select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--input);
  border-radius: 4px;
  background: var(--background);
  color: var(--foreground);
  font-size: 13px;
  outline: none;
}
.diag-field input:focus,
.diag-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--primary) 12%, transparent);
}

.autorizacion-titulo {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin: 0 0 10px;
}

.diag-actions {
  margin-top: 26px;
}
.diag-actions .btn {
  min-height: 48px;
  padding: 0 26px;
}
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Ventana emergente de condiciones completas */
dialog.modal-condiciones {
  width: min(720px, 92vw);
  max-height: 82vh;
  overflow: auto;
  padding: 26px 28px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
}
dialog.modal-condiciones::backdrop {
  background: rgba(22, 22, 22, 0.45);
}
dialog.modal-condiciones h2 {
  font-size: 22px;
  margin: 0 0 14px;
}
dialog.modal-condiciones p {
  font-size: 12px;
  line-height: 1.8;
  margin: 0 0 12px;
}
.modal-acciones {
  margin-top: 18px;
}

@media (max-width: 760px) {
  .diag-grid { grid-template-columns: 1fr; }
}

/* ============================================================================
   CIERRE DEL RESULTADO · WHATSAPP
   ============================================================================ */
.cierre {
  margin-top: 46px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.cierre-texto {
  max-width: 820px;
  margin: 0 auto 28px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--foreground);
}
.btn-whatsapp--principal {
  display: flex;
  width: min(100%, 560px);
  min-height: 54px;
  margin: 0 auto;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  white-space: normal;
}
.final-nav {
  margin-top: 26px;
}
.final-nav .btn {
  background: var(--secondary);
  border-color: var(--border);
  color: var(--foreground);
}
.final-nav .btn:hover {
  background: color-mix(in oklch, var(--secondary) 88%, var(--border));
}

/* El tema no define box-sizing: con content-box los inputs/selects con
   width:100% + padding se desbordan y se solapan entre columnas. */
.diag-form-layout,
.diag-form-layout *,
.diag-form-layout *::before,
.diag-form-layout *::after,
dialog.modal-condiciones,
dialog.modal-condiciones * {
  box-sizing: border-box;
}

/* ── Ajuste 1: subir 2px la letra de la página de resultados ── */
.resultados .parrafo        { font-size: 19px; }     /* ya está en 17px */
.resultados .cierre-texto   { font-size: 17px; }     /* ya está en 15px */
.resultados .informe .eyebrow { font-size: 13px; }   /* heredaba 10-11px */
.resultados .barra-pct      { font-size: 16px; }     /* ya está en 15px */

/* ── Ajuste 2: botones al ancho exacto del texto ── */

/* El texto de referencia mide 820px; los botones deben alinearse a ese ancho */
.cierre-texto {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

/* WhatsApp ocupa todo el ancho del texto (antes era min(100%, 560px)) */
.btn-whatsapp--principal {
  width: 100%;
  max-width: 820px;
}

/* Volver + Inicio: dos botones simétricos que suman 820px */
.final-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}
.final-nav .btn {
  width: 100%;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* En móviles los dos botones se apilan */
@media (max-width: 480px) {
  .final-nav { grid-template-columns: 1fr; }
}
