/*
 * Novo CX — Enrolamiento (demo).
 *
 * Mismo lenguaje visual que el backoffice productivo de Novo CX: azul Novo
 * Nordisk #001965 sobre fondo #F6F7FB, tipografía Quicksand, cards blancas muy
 * redondeadas con sombra flotante. Los tokens salen de
 * `apps/backoffice/tailwind.config.ts` — replicados a mano, sin Tailwind ni
 * build: esta demo es HTML plano servido por el mismo proceso del agente.
 *
 * ES UNA DEMO SEPARADA. No comparte código, ni base, ni deploy con la
 * plataforma productiva.
 */
:root {
  /* Azul Novo */
  --brand-50:  #EEF1FC;
  --brand-100: #DCE3F9;
  --brand-200: #ADBCEF;
  --brand-300: #6B82DC;
  --brand-400: #2B47C5;
  --brand-500: #001965;
  --brand-600: #001450;

  /* Neutros */
  --ink-50:  #F6F7FB;
  --ink-100: #EDEFF5;
  --ink-200: #DEE2EC;
  --ink-300: #BCC2D2;
  --ink-400: #8C93A8;
  --ink-500: #5D6478;
  --ink-600: #3E4456;
  --ink-700: #2A2F3E;
  --ink-800: #1A1D28;
  --ink-900: #0F1119;

  /* Semáforo */
  --ok:   #16A37A;
  --warn: #F5A91F;
  --err:  #E5325B;

  /* Alias que usa el resto de la hoja */
  --bg: var(--ink-50);
  --bg-2: var(--ink-50);
  --surface: #ffffff;
  --surface-2: var(--ink-50);
  --line: var(--ink-100);
  --text: var(--ink-800);
  --text-dim: var(--ink-500);
  --text-faint: var(--ink-400);
  --novo: var(--brand-500);
  --novo-light: var(--brand-400);
  --accent: var(--brand-400);

  --radius: 1rem;
  --shadow-soft: 0 0 0 1px rgb(7 13 34 / 0.05), 0 1px 2px rgb(7 13 34 / 0.06), 0 2px 5px -2px rgb(7 13 34 / 0.07);
  --shadow-card: 0 0 0 1px rgb(7 13 34 / 0.08), 0 1px 3px rgb(7 13 34 / 0.12), 0 6px 14px -2px rgb(7 13 34 / 0.15), 0 16px 32px -8px rgb(7 13 34 / 0.18);
  --shadow-sidebar: 2px 0 16px -6px rgb(7 13 34 / 0.10);

  --font: "Quicksand", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}
body { display: flex; overflow: hidden; }

h1, h2, h3 { margin: 0; }
a { color: inherit; text-decoration: none; }
.meta { font-size: 11.5px; color: var(--text-faint); font-weight: 500; }
.empty { font-size: 12.5px; color: var(--text-faint); margin: 0; line-height: 1.55; }

/* ───────────────────────────── sidebar ───────────────────────────── */
.sidebar {
  width: 240px; flex: 0 0 240px;
  display: flex; flex-direction: column;
  background: #fff; border-right: 1px solid var(--ink-100);
  box-shadow: var(--shadow-sidebar);
  z-index: 2;
}
.sb-brand { display: block; padding: 20px; }
.sb-brand img { width: 128px; height: auto; display: block; }
.sb-brand-name { display: block; margin-top: 12px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--brand-500); }
.sb-brand-sub { display: block; font-size: 11px; font-weight: 500; color: var(--ink-400); }

.sb-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; }
.sb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 600; color: var(--ink-600);
  transition: background .15s ease, color .15s ease;
}
.sb-item svg { flex: 0 0 auto; color: var(--ink-400); transition: color .15s ease; }
.sb-item:hover { background: var(--ink-50); color: var(--brand-500); }
.sb-item:hover svg { color: var(--brand-400); }
.sb-item.activo { background: var(--brand-50); color: var(--brand-500); }
.sb-item.activo svg { color: var(--brand-500); }
.sb-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sb-foot { border-top: 1px solid var(--ink-100); padding: 14px 20px; }
.sb-linea { display: flex; align-items: center; gap: 10px; }
.dot-ok { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.dot-ok.off { background: var(--ink-300); }
.sb-linea-num { font-size: 12.5px; font-weight: 700; color: var(--ink-700); }
.sb-linea-sub { font-size: 11px; color: var(--ink-400); font-weight: 500; }

/* ───────────────────────────── main ───────────────────────────── */
.main { flex: 1; min-width: 0; overflow-y: auto; }
.main::-webkit-scrollbar { width: 8px; }
.main::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 4px; }

.vista { display: none; padding: 28px 32px 32px; min-height: 100%; flex-direction: column; }
.vista.activa { display: flex; }

.vhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.vhead h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--brand-500); }
.vhead .sub { margin: 6px 0 0; font-size: 13px; color: var(--ink-500); max-width: 62ch; line-height: 1.5; }
.vhead-right { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

.btn-ghost {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 999px;
  background: #fff; color: var(--ink-600); border: 1px solid var(--ink-200);
  box-shadow: var(--shadow-soft);
  transition: color .15s ease, border-color .15s ease;
}
.btn-ghost:hover { color: var(--brand-500); border-color: var(--brand-200); }

.card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 15px; font-weight: 700; color: var(--ink-900); }

.badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 8px; border-radius: 999px;
  background: var(--brand-50); color: var(--brand-500);
}
.badge.wa { background: rgb(22 163 122 / .12); color: var(--ok); }
.badge.sim { background: var(--ink-100); color: var(--ink-500); }
.badge.listo { background: rgb(22 163 122 / .12); color: var(--ok); }

/* ─────────────────────── vista Conversaciones ─────────────────────── */
.conv-layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 300px minmax(340px, 1fr) minmax(340px, 420px);
  gap: 18px; align-items: stretch;
}
@media (max-width: 1400px) { .conv-layout { grid-template-columns: 270px 1fr; } .conv-panel-card { grid-column: 1 / -1; } }
@media (max-width: 980px)  { .conv-layout { grid-template-columns: 1fr; } }

.conv-lista-card, .conv-chat-card, .conv-panel-card { min-height: 0; max-height: calc(100vh - 150px); }
.conv-lista { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -8px; display: flex; flex-direction: column; gap: 2px; }
.conv-lista::-webkit-scrollbar, .conv-panel-card::-webkit-scrollbar { width: 6px; }
.conv-lista::-webkit-scrollbar-thumb, .conv-panel-card::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 3px; }

.conv-item {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px; border-radius: 12px; cursor: pointer;
  transition: background .15s ease;
}
.conv-item:hover { background: var(--ink-50); }
.conv-item.activa { background: var(--brand-50); }
.conv-item .fila { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-item .nom { font-size: 13.5px; font-weight: 700; color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .hora { font-size: 10.5px; color: var(--ink-400); flex: 0 0 auto; }
.conv-item .prev { font-size: 12px; color: var(--ink-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4; }
.conv-item .tags { display: flex; gap: 6px; align-items: center; margin-top: 2px; }

.conv-chat-card .wa-chat.leer {
  flex: 1; min-height: 0; border-radius: 12px;
  padding: 14px 10px;
}

/* ─────────────────────── vista Simulador ─────────────────────── */
.sim-layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(320px, 420px) minmax(360px, 1fr);
  gap: 22px; align-items: stretch;
}
@media (max-width: 1000px) { .sim-layout { grid-template-columns: 1fr; } }

/* ─────────────────────── vista Base de conocimiento ─────────────────────── */
.kb-layout { display: flex; flex-direction: column; gap: 18px; }
.kb-card h2 { font-size: 15px; font-weight: 700; color: var(--ink-900); }
.kb-card .panel-sub { margin: 4px 0 0; }
.kb-texto {
  font-size: 13px; line-height: 1.65; color: var(--ink-700);
  white-space: pre-wrap; word-break: break-word;
  background: var(--ink-50); border-radius: 12px; padding: 16px 18px;
  max-height: 520px; overflow-y: auto;
}
.kb-texto::-webkit-scrollbar { width: 6px; }
.kb-texto::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 3px; }
.kb-texto b { color: var(--brand-500); }
.kb-texto h4 { margin: 18px 0 6px; font-size: 13px; color: var(--brand-500); }
.kb-texto h4:first-child { margin-top: 0; }
.kb-tools { display: flex; flex-direction: column; gap: 8px; }
.kb-tool { border-radius: 12px; background: var(--ink-50); padding: 12px 14px; }
.kb-tool .n { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--brand-400); }
.kb-tool .d { margin-top: 4px; font-size: 12.5px; color: var(--ink-600); line-height: 1.5; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.kb-dato { background: var(--ink-50); border-radius: 12px; padding: 10px 12px; }
.kb-dato .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-400); }
.kb-dato .v { margin-top: 3px; font-size: 13px; font-weight: 600; color: var(--ink-800); word-break: break-word; }

/* ───────────────────────────── phone ───────────────────────────── */
.phone-col { display: flex; flex-direction: column; align-items: center; gap: 12px; height: 100%; min-height: 0; }
.phone {
  position: relative;
  width: 100%; max-width: 400px; height: 100%; min-height: 520px;
  background: #0b0f14;
  border: 10px solid #0b0f14;
  border-radius: 40px;
  box-shadow: 0 0 0 2px #333c47, 0 24px 60px rgba(0,0,0,.45);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.phone-notch {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 130px; height: 24px; background: #0b0f14; border-radius: 0 0 16px 16px; z-index: 5;
}
.phone-hint { font-size: 11.5px; color: var(--text-faint); text-align: center; max-width: 380px; line-height: 1.5; }

.wa { display: flex; flex-direction: column; height: 100%; background: #efeae2; border-radius: 30px; overflow: hidden; }

.wa-header {
  display: flex; align-items: center; gap: 10px;
  background: #f0f2f5; color: #3b4a54;
  padding: 30px 10px 10px 8px;
  border-bottom: 1px solid #d6dade;
}
.wa-back { background: none; border: 0; color: #54656f; padding: 0 2px; cursor: default; display: flex; }
.wa-avatar { flex: 0 0 auto; border-radius: 50%; overflow: hidden; width: 40px; height: 40px; }
.wa-who { flex: 1; min-width: 0; }
.wa-name { font-size: 14.5px; font-weight: 600; color: #111b21; }
.wa-status { font-size: 11.5px; color: #667781; }
.wa-status.typing { color: #00a884; }
.wa-actions { display: flex; gap: 14px; color: #54656f; }

.wa-chat {
  flex: 1; overflow-y: auto; padding: 12px 8px 8px;
  background-color: #efeae2;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,.022) 0 2px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,.022) 0 2px, transparent 2px),
    radial-gradient(circle at 45% 85%, rgba(0,0,0,.02) 0 3px, transparent 3px);
  background-size: 90px 90px, 130px 130px, 160px 160px;
}
.wa-chat::-webkit-scrollbar { width: 6px; }
.wa-chat::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 3px; }

.wa-daychip, .wa-notice {
  margin: 4px auto 10px; width: fit-content; max-width: 88%;
  background: #ffffffcc; color: #54656f;
  font-size: 11px; padding: 5px 12px; border-radius: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,.06); text-align: center;
}
.wa-notice { background: #fdf4c8dd; color: #6b5b17; line-height: 1.45; }

/* La burbuja se ajusta al texto (como WhatsApp): `fit-content` con un tope. */
.msg {
  position: relative;
  width: fit-content; max-width: 80%;
  margin: 3px 6px;
  padding: 6px 9px 6px; border-radius: 8px;
  font-size: 14.2px; line-height: 1.45; color: #111b21;
  box-shadow: 0 1px .5px rgba(11,20,26,.13);
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
.msg.in  { background: #fff; border-top-left-radius: 0; margin-right: auto; }
.msg.out { background: #d9fdd3; border-top-right-radius: 0; margin-left: auto; }

.msg .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Hueco reservado en la última línea para que la hora nunca pise el texto.
   Si no entra, el navegador lo baja de línea y la burbuja crece sola. */
.msg .txt::after {
  content: ""; display: inline-block; width: 68px; height: 1px; vertical-align: bottom;
}
.msg.out .txt::after { width: 88px; }

.msg .t {
  position: absolute; right: 9px; bottom: 5px;
  font-size: 10.5px; color: #667781;
  display: flex; align-items: center; gap: 2px; white-space: nowrap;
  pointer-events: none;
}
.msg .tick { color: #53bdeb; }
.msg a { color: #027eb5; text-decoration: underline; }
.msg.out a { color: #056162; }

/* El indicador de "escribiendo" no lleva hora ni ancho mínimo. */
.msg.typing-bubble { padding: 8px 12px; }

.typing { display: inline-flex; gap: 3px; padding: 4px 2px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: #9aa6ad;
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity:.35; transform: translateY(0);} 30% { opacity:1; transform: translateY(-2px);} }

.wa-compose { display: flex; align-items: center; gap: 7px; padding: 8px 8px 14px; background: #f0f2f5; }
.wa-input {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 20px; padding: 8px 12px; color: #54656f;
}
.wa-input input {
  flex: 1; border: 0; outline: 0; font: inherit; font-size: 14px; color: #111b21; background: transparent;
}
.wa-send {
  width: 40px; height: 40px; flex: 0 0 auto; border: 0; border-radius: 50%;
  background: #00a884; color: #fff; display: grid; place-items: center; cursor: pointer;
}
.wa-send:disabled { opacity: .5; cursor: default; }

/* ───────────────────────────── panel ───────────────────────────── */
.panel { height: 100%; min-height: 0; overflow-y: auto; }
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 4px; }

.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel h2, .conv-panel-card h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink-900); }
.panel-sub { margin: 4px 0 0; font-size: 12px; color: var(--text-dim); }

.progress-ring {
  flex: 0 0 auto; width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--brand-400) calc(var(--p, 0) * 1%), var(--ink-100) 0);
  position: relative;
}
.progress-ring::after {
  content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface);
}
.progress-ring span { position: relative; z-index: 1; font-size: 12px; font-weight: 700; }

.progress-bar { height: 5px; background: var(--ink-100); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--brand-300), var(--brand-500)); transition: width .35s ease; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--ink-200); color: var(--ink-500); background: #fff;
}
.chip.on { color: var(--brand-500); border-color: transparent; background: var(--brand-50); }
.chip.done { color: var(--ok); border-color: transparent; background: rgb(22 163 122 / .12); }

.sections { display: flex; flex-direction: column; gap: 12px; }
.section { border-radius: 12px; overflow: hidden; background: var(--ink-50); }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 13px; background: var(--ink-100);
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim);
}
.section-head .count { font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-faint); }
.rows { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: baseline;
  padding: 8px 12px; border-top: 1px solid var(--line); font-size: 13px;
  transition: background .3s ease;
}
.row:first-child { border-top: 0; }
.row.flash { background: var(--brand-100); }
.row .k { color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.row .k .req { color: var(--err); font-size: 10px; }
.row .v { font-weight: 600; text-align: right; word-break: break-word; max-width: 260px; }
.row .v.empty { color: var(--text-faint); font-weight: 400; font-style: italic; }
.row .v.invalido { color: var(--err); font-weight: 500; }
.row .v.no_verificado { color: var(--warn); }
.row .err { grid-column: 1 / -1; font-size: 11.5px; color: var(--err); line-height: 1.4; margin-top: 2px; }
.row .note { grid-column: 1 / -1; font-size: 11px; color: var(--text-faint); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: 0 0 auto; }
.dot.confirmado { background: var(--ok); }
.dot.invalido { background: var(--err); }
.dot.no_verificado { background: var(--warn); }

/* ───────────────────────────── traza ───────────────────────────── */
.trace { margin-top: auto; }
.trace-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.trace h3 { margin: 0; font-size: 13px; font-weight: 700; }
.trace-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.trace-list::-webkit-scrollbar { width: 6px; }
.trace-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.empty { font-size: 12px; color: var(--text-faint); margin: 0; line-height: 1.5; }

.call { border-radius: 10px; background: var(--ink-50); overflow: hidden; }
.call summary {
  cursor: pointer; list-style: none; padding: 7px 10px;
  display: flex; align-items: center; gap: 8px; font-size: 12px;
}
.call summary::-webkit-details-marker { display: none; }
.call .name { font-family: var(--mono); font-size: 11.5px; font-weight: 700; color: var(--brand-400); }
.call .sum { color: var(--text-dim); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call .time { color: var(--text-faint); font-size: 10.5px; }
.call pre {
  margin: 0; padding: 8px 10px; border-top: 1px solid var(--ink-200);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.5;
  color: var(--ink-600); background: #fff; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.call.ok .name { color: var(--ok); }
.call.warn .name { color: var(--warn); }

.done-banner {
  background: rgb(22 163 122 / .12); color: var(--ink-700);
  border-radius: 12px; padding: 11px 13px; font-size: 12.5px; line-height: 1.5;
  margin: 6px;
}
.done-banner b { color: var(--ok); }

/* ─────────────────────── catálogos del Programa ─────────────────────── */
.catalogos { display: flex; flex-direction: column; gap: 10px; }
.cat-head h3 { margin: 0 0 2px; font-size: 13px; font-weight: 700; }
.cat-head .panel-sub { margin: 0; }

.cat-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-tab {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 7px 14px; border-radius: 999px;
  background: #fff; color: var(--ink-500); border: 1px solid var(--ink-200);
}
.cat-tab:hover { color: var(--text); }
.cat-tab.activo { color: var(--brand-500); border-color: transparent; background: var(--brand-50); }

.cat-search { display: flex; align-items: center; gap: 10px; }
.cat-search input {
  flex: 1; font: inherit; font-size: 13px; color: var(--ink-800);
  background: #fff; border: 1px solid var(--ink-200);
  border-radius: 12px; padding: 9px 13px; outline: none;
}
.cat-search input:focus { border-color: var(--brand-400); box-shadow: 0 0 0 3px rgb(43 71 197 / 0.18); }

.cat-list {
  display: flex; flex-direction: column;
  border-radius: 12px; overflow: hidden; background: var(--ink-50);
  max-height: calc(100vh - 340px); min-height: 240px; overflow-y: auto;
}
.cat-list::-webkit-scrollbar { width: 6px; }
.cat-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.cat-item {
  padding: 7px 12px; border-top: 1px solid var(--line);
  font-size: 12.5px; display: flex; flex-direction: column; gap: 2px;
}
.cat-item:first-child { border-top: 0; }
.cat-item { border-top-color: var(--ink-200); }
.cat-item .n { font-weight: 600; }
.cat-item .d { font-size: 11px; color: var(--text-faint); line-height: 1.45; }
.cat-mas { align-self: center; }
