/* bhambo · asistente IA — widget flotante + embebido. Paleta de marca; accesible; respeta reduced-motion. */
.bh-chat, .bh-chat * { box-sizing: border-box; }
.bh-chat {
  --ink: #16191B; --ink2: #20302a; --bone: #F7F5F1; --bone2: #EAF7EF; --amber: #0B6E37; --moss: #12A150;
  --muted: #5C6569; --line: rgba(22,25,27,.12);
  font-family: 'Manrope', system-ui, sans-serif;
}

/* ---------- lanzador flotante ---------- */
.bh-chat-launcher {
  position: fixed; right: clamp(14px, 3vw, 28px); bottom: clamp(14px, 3vw, 28px); z-index: 9998;
  display: inline-flex; align-items: center; gap: .55rem; padding: .7rem .95rem .7rem .75rem;
  /* fondo oscuro + aro claro: contrasta sobre los tres fondos del sitio (oscuro, hueso y ámbar) */
  background: var(--ink); color: var(--bone); border: 2px solid rgba(241,237,228,.9); border-radius: 999px; cursor: pointer;
  font: 600 .95rem/1 'IBM Plex Sans', sans-serif;
  box-shadow: 0 0 0 4px rgba(15,23,20,.18), 0 14px 32px rgba(15,23,20,.4), 0 2px 6px rgba(15,23,20,.3);
  transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s;
}
.bh-chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 0 0 4px rgba(15,23,20,.18), 0 20px 44px rgba(15,23,20,.46), 0 2px 6px rgba(15,23,20,.3); }
.bh-chat-launcher:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.bh-chat-launcher svg { width: 26px; height: 26px; display: block; }
.bh-chat-launcher .bh-chat-led { animation: bh-chat-led 3.6s ease-in-out infinite; }
.bh-chat-launcher[aria-expanded="true"] { transform: scale(.9); opacity: 0; pointer-events: none; }
@keyframes bh-chat-led { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.bh-chat-launcher-label { white-space: nowrap; }
@media (max-width: 520px) { .bh-chat-launcher-label { display: none; } .bh-chat-launcher { padding: .8rem; } }

/* ---------- panel flotante ---------- */
.bh-chat-panel {
  position: fixed; right: clamp(14px, 3vw, 28px); bottom: clamp(14px, 3vw, 28px); z-index: 9999;
  width: min(380px, calc(100vw - 28px)); height: min(560px, calc(100vh - 90px));
  display: flex; flex-direction: column; background: var(--bone); border-radius: 16px; overflow: hidden;
  box-shadow: 0 30px 70px rgba(15,23,20,.4), 0 4px 12px rgba(15,23,20,.25);
  transform-origin: bottom right; transform: translateY(12px) scale(.96); opacity: 0; pointer-events: none;
  transition: transform .28s cubic-bezier(.2,.9,.25,1), opacity .22s;
}
.bh-chat-panel.is-open { transform: none; opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .bh-chat-panel, .bh-chat-launcher { transition: opacity .15s; transform: none; } .bh-chat-launcher .bh-chat-led { animation: none; } }

/* ---------- caja embebida (Contacto) ---------- */
.bh-chat-embed { display: flex; flex-direction: column; height: min(560px, 70vh); background: var(--bone);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 20px 50px rgba(15,23,20,.12); }

/* ---------- cabecera ---------- */
.bh-chat-head { display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; background: var(--ink); color: var(--bone); }
.bh-chat-head .bh-chat-avatar { width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--ink2); display: grid; place-items: center; }
.bh-chat-head .bh-chat-avatar svg { width: 22px; height: 22px; }
.bh-chat-head b { font: 600 1rem/1.2 'Fraunces', Georgia, serif; }
.bh-chat-head .bh-chat-sub { font-size: .72rem; color: #A9B8B0; letter-spacing: .02em; }
.bh-chat-head .bh-chat-x { margin-left: auto; background: none; border: none; color: #A9B8B0; cursor: pointer; padding: .3rem; border-radius: 6px; line-height: 0; }
.bh-chat-head .bh-chat-x:hover { color: var(--bone); background: rgba(255,255,255,.08); }
.bh-chat-head .bh-chat-x:focus-visible { outline: 2px solid var(--amber); }

/* ---------- mensajes ---------- */
.bh-chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; scroll-behavior: smooth; }
.bh-chat-msg { max-width: 85%; padding: .6rem .8rem; border-radius: 14px; font-size: .92rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.bh-chat-msg.user { align-self: flex-end; background: var(--ink); color: var(--bone); border-bottom-right-radius: 4px; }
.bh-chat-msg.bot { align-self: flex-start; background: #fff; color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bh-chat-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: .7rem .8rem; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.bh-chat-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--moss); opacity: .5; animation: bh-chat-dot 1.1s infinite; }
.bh-chat-typing i:nth-child(2) { animation-delay: .18s; } .bh-chat-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes bh-chat-dot { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- sugerencias rápidas ---------- */
.bh-chat-chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .4rem; }
.bh-chat-chip { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: .35rem .7rem; font-size: .8rem; cursor: pointer; transition: background .15s, border-color .15s; }
.bh-chat-chip:hover { background: var(--bone2); border-color: var(--moss); }

/* ---------- entrada ---------- */
.bh-chat-form { display: flex; align-items: flex-end; gap: .5rem; padding: .7rem; border-top: 1px solid var(--line); background: var(--bone); }
.bh-chat-form textarea { flex: 1; resize: none; max-height: 120px; min-height: 42px; padding: .6rem .7rem; border: 1px solid #CFC6B4; border-radius: 10px;
  font: inherit; font-size: .92rem; color: var(--ink); background: #FBF9F4; }
.bh-chat-form textarea:focus { outline: 2px solid rgba(63,122,100,.25); border-color: var(--moss); }
.bh-chat-send { flex: none; width: 42px; height: 42px; border: none; border-radius: 10px; background: var(--ink); color: var(--bone); cursor: pointer; display: grid; place-items: center; transition: background .2s, transform .15s; }
.bh-chat-send:hover { background: #1f2f29; } .bh-chat-send:active { transform: scale(.94); }
.bh-chat-send:disabled { opacity: .4; cursor: default; }
.bh-chat-send:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.bh-chat-foot { padding: 0 1rem .6rem; font-size: .68rem; color: var(--muted); text-align: center; }
.bh-chat-foot a { color: var(--moss); }
.bh-chat-send svg, .bh-chat-x svg { width: 20px; height: 20px; }
/* la flecha "subir" de Astra a la izquierda para no chocar con el lanzador del chat (abajo dcha.) */
#ast-scroll-top { left: clamp(14px, 3vw, 28px) !important; right: auto !important; }
/* formato de las respuestas (Markdown seguro) */
.bh-chat-msg p { margin: 0 0 .5rem; } .bh-chat-msg p:last-child { margin-bottom: 0; }
.bh-chat-msg strong { font-weight: 700; }
.bh-chat-msg em { font-style: italic; }
.bh-chat-msg ul, .bh-chat-msg ol { margin: .35rem 0 .5rem; padding-left: 1.25rem; }
.bh-chat-msg ul { list-style: disc; } .bh-chat-msg ol { list-style: decimal; }
.bh-chat-msg li { margin: .2rem 0; padding-left: .1rem; }
.bh-chat-msg li::marker { color: var(--moss); }
.bh-chat-msg a { color: var(--moss); text-decoration: underline; }
