/* Chat comercial con Bela (compartido por todas las páginas del sitio).
   Réplica para HTML estático del chat de Bela en el producto (volabela-web):
   burbujas de .bela-agente__msg, pills de vb-assistant-quick-replies (Brand25/200/800),
   indicador de escritura y composer. Tokens propios --vbc-* con valores del design system
   (volabela-fundamentos) y su versión oscura, igual que el resto del sitio. */
.vbc {
  --vbc-bg: #FFFFFF;
  --vbc-app: #F8F7FB;
  --vbc-fg: #181D27;
  --vbc-muted: #717680;
  --vbc-line: #E9EAEB;
  --vbc-line-strong: #D5D7DA;
  --vbc-bot: #F5F5F5;
  --vbc-brand: #7F56D9;
  --vbc-brand-strong: #6941C6;
  --vbc-on-brand: #FFFFFF;
  --vbc-pill-bg: #FCFAFF;
  --vbc-pill-bg-hover: #F9F5FF;
  --vbc-pill-line: #E9D7FE;
  --vbc-pill-line-hover: #D6BBFB;
  --vbc-pill-fg: #53389E;
  --vbc-focus: #F4EBFF;
  --vbc-err: #B42318;
  --vbc-err-bg: #FEF3F2;
  --vbc-ok: #027A48;
  --vbc-ok-bg: #ECFDF3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .vbc {
    --vbc-bg: #19132A; --vbc-app: #120D20; --vbc-fg: #F1EEFA; --vbc-muted: #ADA6C2;
    --vbc-line: #2E2546; --vbc-line-strong: #3B3058; --vbc-bot: #241B3A;
    --vbc-brand: #A68AF6; --vbc-brand-strong: #BBA4F8; --vbc-on-brand: #160F26;
    --vbc-pill-bg: #221839; --vbc-pill-bg-hover: #2C2048; --vbc-pill-line: #4A3B74; --vbc-pill-line-hover: #6B57A8; --vbc-pill-fg: #D2C4FC;
    --vbc-focus: #2C2048; --vbc-err: #FDA29B; --vbc-err-bg: #34120F; --vbc-ok: #6CE9A6; --vbc-ok-bg: #0B2A1D;
  }
}
:root[data-theme="dark"] .vbc {
  --vbc-bg: #19132A; --vbc-app: #120D20; --vbc-fg: #F1EEFA; --vbc-muted: #ADA6C2;
  --vbc-line: #2E2546; --vbc-line-strong: #3B3058; --vbc-bot: #241B3A;
  --vbc-brand: #A68AF6; --vbc-brand-strong: #BBA4F8; --vbc-on-brand: #160F26;
  --vbc-pill-bg: #221839; --vbc-pill-bg-hover: #2C2048; --vbc-pill-line: #4A3B74; --vbc-pill-line-hover: #6B57A8; --vbc-pill-fg: #D2C4FC;
  --vbc-focus: #2C2048; --vbc-err: #FDA29B; --vbc-err-bg: #34120F; --vbc-ok: #6CE9A6; --vbc-ok-bg: #0B2A1D;
}

/* Ventana: panel flotante abajo a la derecha (como el panel de Bela en el producto);
   pantalla completa en el celular. */
.vbc {
  position: fixed;
  inset: auto 24px 24px auto;
  width: min(420px, calc(100vw - 32px));
  height: min(680px, calc(100dvh - 48px));
  max-height: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--vbc-line);
  border-radius: 20px;
  background: var(--vbc-bg);
  color: var(--vbc-fg);
  box-shadow: 0 24px 64px -16px rgba(26, 21, 48, .45);
  font: 400 14px/1.5 var(--f-body, "Inter", "Segoe UI", system-ui, sans-serif);
  overflow: hidden;
}
.vbc[open] { display: flex; flex-direction: column; animation: vbc-in .2s ease-out; }
.vbc::backdrop { background: rgba(16, 11, 28, .35); }
@keyframes vbc-in { from { opacity: 0; transform: translateY(16px); } }
@media (prefers-reduced-motion: reduce) { .vbc[open] { animation: none; } }
@media (max-width: 719px) {
  .vbc {
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-width: none;
    border: 0;
    border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Cabecera */
.vbc-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--vbc-line); }
.vbc-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--vbc-brand); display: grid; place-items: center; }
.vbc-avatar img { width: 18px; height: 18px; }
.vbc-title { min-width: 0; flex: 1; }
.vbc-title h2 { margin: 0; font: 600 15px/1.2 var(--f-display, "Poppins", system-ui, sans-serif); }
.vbc-title p { margin: 2px 0 0; color: var(--vbc-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vbc-icon-btn { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--vbc-muted); cursor: pointer; display: grid; place-items: center; }
.vbc-icon-btn:hover { color: var(--vbc-fg); border-color: var(--vbc-line); }
.vbc-icon-btn:focus-visible { outline: 2px solid var(--vbc-brand); outline-offset: 2px; }
.vbc-icon-btn svg { width: 18px; height: 18px; }

/* Hilo */
.vbc-thread { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--vbc-bg); }
.vbc-msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; line-height: 1.5; word-break: break-word; }
.vbc-msg--user { align-self: flex-end; background: var(--vbc-brand); color: var(--vbc-on-brand); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.vbc-msg--bela { align-self: flex-start; background: var(--vbc-bot); border-bottom-left-radius: 4px; }
.vbc-msg--bela p { margin: 0 0 8px; }
.vbc-msg--bela ul { margin: 0 0 8px; padding-left: 18px; }
.vbc-msg--bela li { margin: 0 0 4px; }
.vbc-msg--bela > :last-child { margin-bottom: 0; }
.vbc-msg--bela strong { font-weight: 600; }
.vbc-msg--error { align-self: flex-start; background: var(--vbc-err-bg); color: var(--vbc-err); border-bottom-left-radius: 4px; }
.vbc-msg--error a { color: inherit; font-weight: 600; }

.vbc-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--vbc-bot); border-radius: 14px; border-bottom-left-radius: 4px; }
.vbc-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--vbc-muted); animation: vbc-typing 1s infinite ease-in-out; }
.vbc-typing span:nth-child(2) { animation-delay: .15s; }
.vbc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes vbc-typing { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .vbc-typing span { animation: none; } }

/* Respuestas rápidas (mismo patrón que vb-assistant-quick-replies) */
.vbc-quick { align-self: flex-start; max-width: 100%; display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 4px; padding: 0; list-style: none; }
.vbc-pill {
  max-width: 100%; min-height: 32px; padding: 6px 12px;
  border: 1px solid var(--vbc-pill-line); border-radius: 999px;
  background: var(--vbc-pill-bg); color: var(--vbc-pill-fg);
  font-family: inherit; font-size: 14px; font-weight: 500; line-height: 1.25; text-align: left; overflow-wrap: anywhere; cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.vbc-pill:hover:not(:disabled) { border-color: var(--vbc-pill-line-hover); background: var(--vbc-pill-bg-hover); }
.vbc-pill:focus-visible { outline: 2px solid var(--vbc-brand); outline-offset: 2px; }
.vbc-pill:disabled { opacity: .55; cursor: default; }
@media (pointer: coarse) { .vbc-pill { min-height: 44px; } }
/* Selección múltiple: la pill marcada se rellena y muestra una palomita */
.vbc-pill .vbc-check { display: none; width: 14px; height: 14px; }
.vbc-pill[aria-pressed="true"] { background: var(--vbc-brand); border-color: var(--vbc-brand); color: var(--vbc-on-brand); }
.vbc-pill[aria-pressed="true"] .vbc-check { display: block; }
.vbc-pill[aria-pressed="true"]:hover:not(:disabled) { background: var(--vbc-brand-strong); border-color: var(--vbc-brand-strong); }
.vbc-multi { align-self: stretch; display: grid; gap: 8px; }
.vbc-multi-hint { margin: 0; color: var(--vbc-muted); font-size: 12px; }
.vbc-multi-send { justify-self: start; }

/* Botón principal (mismo estilo que el resto del sitio) */
.vbc-btn { min-height: 40px; padding: 8px 16px; border-radius: 999px; border: 0; background: var(--vbc-brand); color: var(--vbc-on-brand); font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.vbc-btn:hover:not(:disabled) { background: var(--vbc-brand-strong); }
.vbc-btn:disabled { opacity: .5; cursor: default; }
.vbc-btn:focus-visible { outline: 2px solid var(--vbc-brand); outline-offset: 2px; }
.vbc-btn--ghost { background: transparent; color: var(--vbc-fg); border: 1px solid var(--vbc-line-strong); }
.vbc-btn--ghost:hover:not(:disabled) { background: var(--vbc-app); }
.vbc-btn svg { width: 18px; height: 18px; }

/* Tarjeta de contacto */
.vbc-card { align-self: stretch; border: 1px solid var(--vbc-line); border-radius: 16px; background: var(--vbc-app); padding: 14px; display: grid; gap: 10px; }
.vbc-card h3 { margin: 0; font: 600 15px/1.3 var(--f-display, "Poppins", system-ui, sans-serif); }
.vbc-card p { margin: 0; color: var(--vbc-muted); font-size: 13px; }
.vbc-field { display: grid; gap: 4px; min-width: 0; }
.vbc-field label { font-weight: 600; font-size: 13px; }
.vbc-field input { min-height: 40px; padding: 8px 12px; border: 1px solid var(--vbc-line-strong); border-radius: 10px; background: var(--vbc-bg); color: var(--vbc-fg); font: inherit; font-size: 16px; width: 100%; box-sizing: border-box; }
.vbc-field input:focus { outline: none; border-color: var(--vbc-brand); box-shadow: 0 0 0 3px var(--vbc-focus); }
.vbc-field .vbc-err { display: none; color: var(--vbc-err); font-size: 12px; }
.vbc-field.bad input { border-color: var(--vbc-err); }
.vbc-field.bad .vbc-err { display: block; }
.vbc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .vbc-row { grid-template-columns: 1fr; } }
.vbc-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.vbc-trampa { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.vbc-card a { color: var(--vbc-brand); }

/* Composer */
.vbc-composer { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--vbc-line); background: var(--vbc-bg); }
.vbc-input { flex: 1 1 auto; min-height: 40px; max-height: 120px; padding: 9px 12px; border: 1px solid var(--vbc-line-strong); border-radius: 12px; background: var(--vbc-bg); color: var(--vbc-fg); font: inherit; font-size: 16px; line-height: 1.35; resize: none; overflow-y: hidden; box-sizing: border-box; }
.vbc-input:focus { outline: none; border-color: var(--vbc-brand); box-shadow: 0 0 0 3px var(--vbc-focus); }
.vbc-send { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--vbc-brand); color: var(--vbc-on-brand); cursor: pointer; display: grid; place-items: center; }
.vbc-send svg { width: 18px; height: 18px; }
.vbc-send:disabled { background: var(--vbc-line); color: var(--vbc-muted); cursor: default; }
.vbc-send:focus-visible { outline: 2px solid var(--vbc-brand); outline-offset: 2px; }
.vbc-foot { flex: none; margin: 0; padding: 0 12px 10px; color: var(--vbc-muted); font-size: 11.5px; text-align: center; background: var(--vbc-bg); }
.vbc-foot a { color: inherit; }
.vbc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Vista previa en la sección #analisis de cada página: chips que abren el chat */
.scanner .quick button[data-bela-chat]:hover { border-color: var(--ui-brand, #7F56D9); color: var(--ui-brand, #7F56D9); }
.scanner .scan-or { margin: 4px 0 0; color: var(--ui-muted, #717680); font-size: 12.5px; }
.scanner .scan-or a { color: var(--ui-brand, #7F56D9); font-weight: 600; }
