/* ==========================================================================
   ABI CHATBOT — self-contained widget styles.
   Namespaced under .abi-chatbot-* / #abi-chatbot-* only. Does not read or
   override any class from the host site's own stylesheet, and uses a
   configurable font stack (see fontFamily in abi-chatbot.js) so it renders
   consistently even on a client site that hasn't loaded the same fonts as
   abi-visualization.com.
   ========================================================================== */

#abi-chatbot-root,
#abi-chatbot-root * {
  box-sizing: border-box;
}
#abi-chatbot-root {
  font-size: 16px;
  line-height: 1.5;
}
#abi-chatbot-root button {
  font-family: inherit;
  cursor: pointer;
}
#abi-chatbot-root a { text-decoration: none; }

body.abi-chatbot-no-scroll { overflow: hidden; }

.abi-chatbot-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#abi-chatbot-root :focus-visible {
  outline: 2px solid #12B5C2;
  outline-offset: 2px;
}

/* ---------- Bubble ---------- */
.abi-chatbot-bubble {
  position: fixed;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #0F262C;
  color: #fff;
  border: none;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(15, 38, 44, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.abi-chatbot-bubble:hover { transform: scale(1.06); box-shadow: 0 12px 28px rgba(15, 38, 44, 0.4); }

/* ---------- Mobile teaser pill ---------- */
.abi-chatbot-teaser {
  position: fixed;
  z-index: 9998;
  max-width: 220px;
}
.abi-chatbot-teaser-btn {
  background: #fff;
  color: #0F262C;
  border: 1px solid #E4E9EA;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  box-shadow: 0 8px 24px rgba(15, 38, 44, 0.18);
}

/* ---------- Overlay ---------- */
.abi-chatbot-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 38, 44, 0.55);
  z-index: 9997;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.abi-chatbot-overlay.is-open { opacity: 1; visibility: visible; pointer-events: auto; }

/* ---------- Panel ---------- */
.abi-chatbot-panel {
  position: fixed;
  z-index: 9999;
  right: 24px;
  bottom: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #0F262C;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}
.abi-chatbot-panel.is-open { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }

.abi-chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #14313A;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
.abi-chatbot-title {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}
.abi-chatbot-logo {
  display: block;
  max-height: 28px;
  max-width: 70%;
  width: auto;
  object-fit: contain;
}
.abi-chatbot-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.75);
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.abi-chatbot-close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* THE single scrollable area in the panel — messages, options, the
   capture form and every closing/error state all live in here. There is
   no second scroll region anywhere in the panel. */
.abi-chatbot-transcript {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.abi-chatbot-step-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.abi-chatbot-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9375rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.abi-chatbot-msg--bot {
  align-self: flex-start;
  background: #17323A;
  color: #fff;
  border-bottom-left-radius: 4px;
}
.abi-chatbot-msg--user {
  align-self: flex-end;
  background: #12B5C2;
  color: #0F262C;
  font-weight: 600;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.abi-chatbot-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px;
  width: fit-content;
}
.abi-chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  animation: abi-chatbot-bounce 1.2s infinite ease-in-out;
}
.abi-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.abi-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes abi-chatbot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .abi-chatbot-typing span { animation: none; }
}

/* ---------- Controls (options / text input / capture form) ----------
   Rendered as regular children of the transcript, not a separate area. */
.abi-chatbot-controls { display: flex; flex-direction: column; }

.abi-chatbot-back-btn {
  display: inline-block;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 4px 0;
  margin-bottom: 8px;
  transition: color 0.15s ease;
}
.abi-chatbot-back-btn:hover { color: #fff; }

.abi-chatbot-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.abi-chatbot-option-btn {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.abi-chatbot-option-btn:hover,
.abi-chatbot-option-btn:active {
  background: #FDB91B;
  border-color: #FDB91B;
  color: #0F262C;
}

.abi-chatbot-text-row {
  display: flex;
  gap: 8px;
}
.abi-chatbot-text-input {
  flex: 1;
  min-width: 0;
  background: #17323A;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 12px 14px;
  color: #fff;
  font-size: 0.9375rem;
}
.abi-chatbot-text-input::placeholder { color: rgba(255, 255, 255, 0.4); }
.abi-chatbot-send-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: #12B5C2;
  color: #0F262C;
  border: none;
  border-radius: 10px;
}
.abi-chatbot-send-btn:hover { background: #FDB91B; }

/* ---------- Fase 2: entrada de texto libre ----------
   Va debajo de los botones. Es texto legible, no un gris escondido: si
   no se ve, la Fase 2 no existe. Aun así se lee como enlace y no como
   botón, para que pulsar una opción siga siendo la vía obvia. */
.abi-chatbot-ask-ai-link {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 6px 0;
  background: none;
  border: none;
  text-align: left;
  color: #12B5C2;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.15s ease;
}
.abi-chatbot-ask-ai-link:hover,
.abi-chatbot-ask-ai-link:focus-visible {
  color: #FDB91B;
}
.abi-chatbot-ask-ai-row {
  margin-top: 10px;
}

/* ---------- Capture form ----------
   Rendered as a bot-message bubble in the thread — same max-width and
   corner treatment as .abi-chatbot-msg--bot, so it reads as "one more
   message" rather than a separate panel section. */
.abi-chatbot-form-bubble {
  align-self: flex-start;
  max-width: 82%;
  background: #17323A;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 14px;
}
.abi-chatbot-capture-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.abi-chatbot-field { display: flex; flex-direction: column; gap: 4px; }
.abi-chatbot-field label { font-size: 0.8125rem; font-weight: 600; color: rgba(255, 255, 255, 0.75); }
.abi-chatbot-field input {
  /* Darker than the bubble bg so fields stay visibly distinct inside it */
  background: #0F262C;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 12px 14px;
  color: #fff;
  font-size: 0.9375rem;
  min-height: 44px;
}
.abi-chatbot-field input::placeholder { color: rgba(255, 255, 255, 0.4); }
.abi-chatbot-error { font-size: 0.75rem; color: #FDB91B; min-height: 1em; }

/* Aclaración bajo un campo. Más apagada que el error, para que no
   compita con él cuando los dos estén visibles. */
.abi-chatbot-hint {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 2px;
}

/* Honeypot — visually hidden off-screen (not display:none, which some bots skip) */
.abi-chatbot-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.abi-chatbot-submit-btn {
  background: #FDB91B;
  color: #0F262C;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 0.9375rem;
  min-height: 44px;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
.abi-chatbot-submit-btn:hover { background: #F8C244; }
.abi-chatbot-submit-btn:disabled { opacity: 0.7; cursor: not-allowed; }

.abi-chatbot-capture-whatsapp { margin-top: 10px; }

/* ---------- WhatsApp CTA (capture / confirmation / error / returning) ----------
   Already dark text on green (not the white-on-green brand exception) —
   passes contrast on its own, no change needed there. */
.abi-chatbot-whatsapp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #92C04E;
  color: #0F262C;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 0.9375rem;
  min-height: 44px;
}
.abi-chatbot-whatsapp-btn:hover { background: #A3C86C; }

/* ---------- Powered by ---------- */
.abi-chatbot-poweredby {
  display: block;
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  padding: 8px 12px 12px;
  flex-shrink: 0;
  transition: color 0.15s ease;
}
a.abi-chatbot-poweredby:hover { color: #12B5C2; }
.abi-chatbot-poweredby--static { cursor: default; }

/* ---------- Mobile: fullscreen panel ---------- */
@media (max-width: 640px) {
  .abi-chatbot-panel {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .abi-chatbot-bubble { width: 56px; height: 56px; }
}
