/* ---------------------------------------------------------------------------
 * Website AI chatbot widget.
 *
 * Everything is prefixed bzsb- and scoped under its own ids so nothing here can
 * collide with the marketing template's own styles - or with the separate
 * per-company chat widget, which uses inline styles of its own.
 *
 * z-index sits just below a bootstrap modal backdrop so the chat never covers a
 * dialog the visitor opened deliberately.
 * ------------------------------------------------------------------------- */

#bzsb-root {
  --bzsb-brand: #05a9c5;
  --bzsb-brand-dark: #048ca3;
  --bzsb-ink: #1e293b;
  --bzsb-muted: #64748b;
  --bzsb-line: #e2e8f0;
  --bzsb-surface: #ffffff;
  --bzsb-bot-bubble: #f1f5f9;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1040;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--bzsb-ink);
}

/* ------------------------------------------------------------------ bubble */

#bzsb-bubble {
  position: relative;          /* anchors the first-visit pulse ring below */
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--bzsb-brand);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(2, 56, 65, 0.28);
  transition: transform 0.18s ease, background 0.18s ease;
  padding: 0;
}
#bzsb-bubble:hover { background: var(--bzsb-brand-dark); transform: scale(1.06); }
#bzsb-bubble:focus-visible { outline: 3px solid #0b7285; outline-offset: 3px; }
#bzsb-bubble svg { width: 26px; height: 26px; display: block; }
#bzsb-bubble .bzsb-icon-close { display: none; }
#bzsb-root.bzsb-open #bzsb-bubble .bzsb-icon-chat { display: none; }
#bzsb-root.bzsb-open #bzsb-bubble .bzsb-icon-close { display: block; }

/* A single quiet nudge on the first visit, so the bubble is noticed without
 * nagging. Removed for good once the chat has been opened. */
#bzsb-bubble.bzsb-nudge::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--bzsb-brand);
  animation: bzsb-pulse 2.2s ease-out 3;
}
@keyframes bzsb-pulse {
  0%   { transform: scale(1);    opacity: 0.7; }
  100% { transform: scale(1.75); opacity: 0; }
}

/* ------------------------------------------------------------------- panel */

#bzsb-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 366px;
  height: 540px;
  max-height: calc(100vh - 120px);
  background: var(--bzsb-surface);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(2, 32, 38, 0.26);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
#bzsb-root.bzsb-open #bzsb-panel {
  display: flex;
  animation: bzsb-rise 0.18s ease-out;
}
@keyframes bzsb-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#bzsb-head {
  background: var(--bzsb-brand);
  color: #fff;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
#bzsb-head-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
#bzsb-head-avatar svg { width: 19px; height: 19px; }
#bzsb-head-text { flex: 1 1 auto; min-width: 0; }
#bzsb-head-name {
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#bzsb-head-sub { font-size: 11.5px; opacity: 0.85; }
#bzsb-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 0;
}
#bzsb-close:hover { background: rgba(255, 255, 255, 0.16); }
#bzsb-close svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- messages */

#bzsb-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  background: #fbfcfe;
}

.bzsb-row { display: flex; margin-bottom: 10px; }
.bzsb-row.bzsb-user { justify-content: flex-end; }

.bzsb-bubble-text {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.bzsb-bot .bzsb-bubble-text {
  background: var(--bzsb-bot-bubble);
  color: var(--bzsb-ink);
  border-bottom-left-radius: 4px;
}
.bzsb-user .bzsb-bubble-text {
  background: var(--bzsb-brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
#bzsb-typing .bzsb-bubble-text { display: flex; gap: 4px; align-items: center; padding: 12px; }
#bzsb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bzsb-muted);
  animation: bzsb-blink 1.2s infinite ease-in-out;
}
#bzsb-typing span:nth-child(2) { animation-delay: 0.18s; }
#bzsb-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bzsb-blink {
  0%, 80%, 100% { opacity: 0.25; }
  40%           { opacity: 1; }
}

/* ------------------------------------------------------------ suggestions */

#bzsb-suggestions {
  padding: 0 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  background: #fbfcfe;
  flex: 0 0 auto;
}
.bzsb-chip {
  background: #fff;
  border: 1px solid var(--bzsb-line);
  color: var(--bzsb-brand-dark);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.bzsb-chip:hover { border-color: var(--bzsb-brand); background: #f2fbfd; }

/* ------------------------------------------------------------------- input */

#bzsb-form {
  flex: 0 0 auto;
  border-top: 1px solid var(--bzsb-line);
  padding: 9px;
  display: flex;
  gap: 7px;
  background: #fff;
}
#bzsb-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid #d8dee7;
  border-radius: 9px;
  padding: 9px 11px;
  font: inherit;
  color: var(--bzsb-ink);
  background: #fff;
}
#bzsb-input:focus { outline: none; border-color: var(--bzsb-brand); }
#bzsb-send {
  flex: 0 0 auto;
  border: none;
  border-radius: 9px;
  background: var(--bzsb-brand);
  color: #fff;
  width: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#bzsb-send:hover:not(:disabled) { background: var(--bzsb-brand-dark); }
#bzsb-send:disabled { opacity: 0.5; cursor: default; }
#bzsb-send svg { width: 17px; height: 17px; }

#bzsb-foot {
  flex: 0 0 auto;
  text-align: center;
  font-size: 10.5px;
  color: var(--bzsb-muted);
  padding: 0 0 7px;
  background: #fff;
}

/* ------------------------------------------------------------------ phones */

@media (max-width: 520px) {
  #bzsb-root { right: 14px; bottom: 14px; }
  #bzsb-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
  /* The panel fills the screen on a phone, so the floating button would sit on
   * top of the send button. The header's close icon is the way out here. */
  #bzsb-root.bzsb-open #bzsb-bubble { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #bzsb-bubble,
  #bzsb-root.bzsb-open #bzsb-panel,
  #bzsb-bubble.bzsb-nudge::after,
  #bzsb-typing span {
    animation: none;
    transition: none;
  }
}
