:root {
  --color-bg: #FAFAF7;
  --color-surface: #FFFFFF;
  --color-surface-soft: #F3F4F6;
  --color-text: #111827;
  --color-text-muted: #6B7280;
  --color-primary: #2563EB;
  --color-primary-hover: #1D4ED8;
  --color-accent: #10B981;
  --color-warning: #F59E0B;
  --color-error: #EF4444;
  --color-border: #E5E7EB;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
  --shadow-soft: 0 10px 30px rgba(17, 24, 39, 0.08);
  --shadow-card: 0 4px 20px rgba(17, 24, 39, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

h1 { font-size: 42px; line-height: 1.1; letter-spacing: -0.04em; font-weight: 750; }
h2 { font-size: 28px; line-height: 1.2; letter-spacing: -0.03em; font-weight: 700; }
h3 { font-size: 20px; line-height: 1.3; letter-spacing: -0.02em; font-weight: 650; }
p  { font-size: 16px; line-height: 1.6; color: var(--color-text-muted); }

a { color: var(--color-primary); }

/* ---------- Botones ---------- */
.button-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.button-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}
.button-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.button-secondary {
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 14px 26px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.button-secondary:hover { border-color: #c9ccd1; }

/* ---------- Inputs ---------- */
.input, textarea.input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-size: 16px;
  background: #fff;
  color: var(--color-text);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}
.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
textarea.input { resize: vertical; min-height: 130px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.logo-login { height: 48px; width: auto; display: block; }
.login-card h2 { margin: 18px 0 6px; }
.login-card p { margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.alerta {
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ---------- Layout app ---------- */
.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo-img { height: 30px; width: auto; display: block; }
.topbar-marca { display: flex; align-items: center; gap: 10px; }
.topbar-sufijo {
  font-weight: 700; font-size: 15px; color: var(--color-text-muted);
  border-left: 1px solid var(--color-border); padding-left: 10px;
}
.topbar .salir { font-size: 14px; color: var(--color-text-muted); text-decoration: none; }
.topbar .salir:hover { color: var(--color-text); }

.banner-prueba {
  background: rgba(245, 158, 11, 0.12);
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  color: #92400e;
  font-size: 13px;
  padding: 10px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.banner-prueba .banner-acciones { display: flex; align-items: center; gap: 14px; }
.banner-prueba button {
  background: var(--color-warning);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.banner-prueba a { color: #92400e; font-weight: 600; }
.banner-prueba select {
  font: inherit;
  font-size: 13px;
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 999px;
  padding: 5px 12px;
  background: #fff;
  color: var(--color-text);
  max-width: 230px;
  cursor: pointer;
}

.progress {
  background: var(--color-surface);
  padding: 14px 28px 18px;
  border-bottom: 1px solid var(--color-border);
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}
.progress-track {
  height: 8px;
  background: var(--color-surface-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
  width: 0;
  transition: width 0.35s ease;
}

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 28px 64px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 36px;
  align-items: start;
}
.aside h2 { margin-bottom: 12px; }
.aside .bloque-chip {
  display: inline-block;
  background: rgba(37, 99, 235, 0.08);
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.aside .ayuda {
  margin-top: 18px;
  background: var(--color-surface-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--color-text-muted);
}

/* ---------- Tarjeta de pregunta ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  box-shadow: var(--shadow-card);
  padding: 32px;
  animation: entrada 0.36s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.aside { animation: entrada 0.36s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.card .pregunta-num { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.card h3 { margin: 6px 0 4px; font-size: 24px; line-height: 1.25; }
.card .pregunta-ayuda { margin-bottom: 22px; font-size: 15px; }

/* ---------- Comparativa de emails (texto plano vs HTML) ---------- */
.comparativa {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 0 0 24px;
}
.email-demo {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
}
.email-tag {
  display: block;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  background: var(--color-surface-soft);
  color: var(--color-text-muted);
}
.email-tag-pro { background: rgba(37, 99, 235, 0.1); color: var(--color-primary); }
.email-plano-cuerpo {
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  color: #4b5563;
  padding: 14px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.email-html-cab {
  padding: 16px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  text-align: center;
}
.email-html-cab img { height: 24px; width: auto; }
.email-html-main { padding: 16px; }
.email-html-main h4 {
  font-size: 16px;
  color: var(--color-text);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.email-html-main p { font-size: 13px; color: var(--color-text); margin-bottom: 12px; }
.email-html-box {
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  color: var(--color-text);
  margin-bottom: 14px;
}
.email-html-btn {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
}
.email-html-pie {
  padding: 12px 16px;
  background: var(--color-text);
  color: #fff;
  font-size: 11px;
  text-align: center;
}
@media (max-width: 600px) {
  .comparativa { grid-template-columns: 1fr; }
}

.opciones { display: flex; flex-direction: column; gap: 12px; }
.option-card {
  border: 1px solid var(--color-border);
  border-radius: 18px;
  padding: 16px 18px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease,
              background 0.18s ease, transform 0.12s ease;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  animation: opcion-entra 0.34s ease backwards;
}
.option-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.option-card:active { transform: scale(0.992); }
.option-card.selected {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.06);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.opciones .option-card:nth-child(1) { animation-delay: 0.02s; }
.opciones .option-card:nth-child(2) { animation-delay: 0.05s; }
.opciones .option-card:nth-child(3) { animation-delay: 0.08s; }
.opciones .option-card:nth-child(4) { animation-delay: 0.11s; }
.opciones .option-card:nth-child(5) { animation-delay: 0.14s; }
.opciones .option-card:nth-child(6) { animation-delay: 0.17s; }
.opciones .option-card:nth-child(7) { animation-delay: 0.20s; }
.opciones .option-card:nth-child(n+8) { animation-delay: 0.22s; }
.option-mark {
  flex: 0 0 22px;
  height: 22px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.option-card.multi .option-mark { border-radius: 7px; }
.option-card.selected .option-mark {
  border-color: var(--color-primary);
  background: var(--color-primary);
}
.option-card.selected .option-mark::after {
  content: "";
  width: 8px; height: 8px;
  background: #fff;
  border-radius: inherit;
  animation: marca-in 0.26s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.option-texto .et { font-weight: 600; font-size: 15px; }
.option-texto .desc { font-size: 14px; color: var(--color-text-muted); margin-top: 2px; }

.campo-extra { margin-top: 18px; }
.campo-extra label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.otro-texto { margin-top: 10px; }

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
}
.guardado {
  font-size: 13px;
  color: var(--color-accent);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.guardado.visible { opacity: 1; }
.aviso-validacion { color: var(--color-error); font-size: 14px; margin-top: 12px; display: none; }
.aviso-validacion.visible { display: block; }

/* ---------- Pantallas completas ---------- */
.pantalla {
  max-width: 640px;
  margin: 0 auto;
  padding: 64px 28px;
  text-align: center;
}
.pantalla h1 { margin-bottom: 14px; }
.pantalla p { margin-bottom: 28px; }
.pantalla .acciones { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Resumen ---------- */
.resumen-grid { display: grid; gap: 10px; margin: 24px 0; text-align: left; }
.resumen-fila {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--color-surface-soft);
  border-radius: var(--radius-md);
}
.resumen-fila .clave { font-weight: 600; font-size: 14px; }
.resumen-fila .valor { font-size: 14px; color: var(--color-text-muted); text-align: right; }
.resumen-detalle { text-align: left; margin-top: 20px; }
.resumen-detalle .item {
  border-bottom: 1px solid var(--color-border);
  padding: 12px 0;
}
.resumen-detalle .item:last-child { border-bottom: none; }
.resumen-detalle .preg { font-size: 14px; font-weight: 600; }
.resumen-detalle .resp { font-size: 14px; color: var(--color-text-muted); margin-top: 2px; }
.resumen-detalle .editar {
  font-size: 13px; background: none; border: none; color: var(--color-primary);
  cursor: pointer; padding: 0; margin-top: 4px;
}

/* ---------- Admin ---------- */
.admin-wrap { max-width: 960px; margin: 0 auto; padding: 36px 28px 64px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.estado-badge {
  display: inline-block; font-size: 13px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
}
.estado-badge.enviado { background: rgba(16,185,129,0.12); color: #047857; }
.estado-badge.en_progreso { background: rgba(245,158,11,0.14); color: #b45309; }
.admin-bloque { margin-top: 26px; }
.admin-bloque h3 { margin-bottom: 10px; }
.admin-item { padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.admin-item .preg { font-size: 14px; font-weight: 600; }
.admin-item .resp { font-size: 14px; color: var(--color-text-muted); margin-top: 3px; }
.admin-item.sin .resp { color: #c2c5cb; font-style: italic; }

.spinner { text-align: center; padding: 60px; color: var(--color-text-muted); }

/* ---------- Animaciones ---------- */
@keyframes entrada {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes opcion-entra {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes marca-in {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
.pantalla { animation: entrada 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.resumen-fila { animation: opcion-entra 0.32s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 22px; padding: 24px 18px 56px; }
  .aside { order: -1; }
}
@media (max-width: 768px) {
  h1 { font-size: 32px; }
  h2 { font-size: 24px; }
  .card { padding: 22px; border-radius: 20px; }
  .card h3 { font-size: 20px; }
  .topbar, .progress { padding-left: 18px; padding-right: 18px; }
  .nav-row { flex-direction: column-reverse; }
  .nav-row button { width: 100%; }
}

@media print {
  .topbar .salir, .admin-head button { display: none; }
}
