/* BuzyBuddy widget. Colours come from Settings > Branding via CSS variables set in widget.js;
   the values below are the default palette (sky, cream, orange, maroon). */
.bb-root {
  --bb-primary: #990033;
  --bb-on-primary: #FFF0A5;
  --bb-on-user: #ffffff;
  --bb-accent: #FFA500;
  --bb-on-accent: #990033;
  --bb-bubble: #FFF0A5;
  --bb-on-bubble: #2B0A16;
  --bb-bg: #BFDFFF;
  --bb-bg-soft: color-mix(in srgb, var(--bb-bg) 28%, #ffffff);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1a1a1a;
}
.bb-root.bb-site-font { font-family: inherit; }
.bb-root.bb-left { right: auto; left: 20px; }
.bb-root *, .bb-root *::before, .bb-root *::after { box-sizing: border-box; }
.bb-root [hidden] { display: none !important; }

.bb-launcher {
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--bb-accent);
  color: var(--bb-on-accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  margin-left: auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  transition: transform .18s ease, box-shadow .18s ease;
}
.bb-left .bb-launcher { margin-left: 0; }
.bb-launcher:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, .3); }
.bb-launcher svg { width: 28px; height: 28px; fill: currentColor; }
.bb-root.is-open .bb-launcher { display: none; }

.bb-panel {
  width: 370px;
  height: min(600px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  background: var(--bb-bg-soft);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
  animation: bb-in .2s ease-out;
}
@keyframes bb-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.bb-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 14px 16px 18px;
  background: var(--bb-primary);
  color: var(--bb-on-primary);
  border-bottom: 5px solid var(--bb-accent);
}
.bb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bb-bubble);
  color: var(--bb-on-bubble);
  font-weight: 800;
  font-size: 18px;
  flex: none;
}
.bb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bb-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.bb-name { font-size: 17px; line-height: 1.2; }
.bb-tagline { font-size: 13px; opacity: .85; }
.bb-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.bb-close:hover { background: rgba(255, 255, 255, .15); }
.bb-new { display: grid; place-items: center; margin-right: -8px; flex: none; }
.bb-new svg { width: 20px; height: 20px; fill: currentColor; }
.bb-new:disabled { opacity: .5; cursor: wait; }

.bb-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(180deg, var(--bb-bg) 0, var(--bb-bg-soft) 140px);
}
.bb-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bb-msg-bot { align-self: flex-start; background: var(--bb-bubble); color: var(--bb-on-bubble); border-bottom-left-radius: 4px; }
.bb-msg-agent { align-self: flex-start; background: #fff; border: 2px solid var(--bb-accent); border-bottom-left-radius: 4px; }
.bb-msg-user { align-self: flex-end; background: var(--bb-primary); color: var(--bb-on-user); border-bottom-right-radius: 4px; }
.bb-msg-who { display: block; font-size: 12px; font-weight: 700; margin-bottom: 2px; }

.bb-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 10px 13px;
  border: 2px solid var(--bb-accent);
  border-radius: 12px;
  background: #fff;
}
.bb-confirm span { flex: 1 1 auto; font-weight: 700; }
.bb-confirm button { min-height: 36px; padding: 0 14px; border: 2px solid transparent; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; }
.bb-confirm-yes { background: var(--bb-primary); color: var(--bb-on-user); }
.bb-confirm .bb-confirm-no { background: transparent; border-color: var(--bb-bg); color: inherit; }

.bb-typing { display: flex; gap: 4px; padding: 13px 14px; }
.bb-typing span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .35; animation: bb-dot 1s infinite; }
.bb-typing span:nth-child(2) { animation-delay: .15s; }
.bb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bb-dot { 50% { opacity: 1; transform: translateY(-3px); } }

.bb-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid var(--bb-bg);
}
.bb-input {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border: 2px solid var(--bb-bg);
  border-radius: 12px;
  font: inherit;
  color: inherit;
  background: #fff;
}
.bb-input:focus { outline: none; border-color: var(--bb-primary); }
.bb-send {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--bb-accent);
  color: var(--bb-on-accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.bb-send svg { width: 20px; height: 20px; fill: currentColor; }
.bb-mic {
  width: 44px;
  height: 44px;
  border: 2px solid var(--bb-bg);
  border-radius: 12px;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.bb-mic svg { width: 20px; height: 20px; fill: currentColor; }
.bb-mic:hover { border-color: var(--bb-primary); }
.bb-mic.is-listening { background: var(--bb-primary); border-color: var(--bb-primary); color: var(--bb-on-user); animation: bb-pulse 1.2s ease-in-out infinite; }
@keyframes bb-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--bb-primary) 25%, transparent); } }
.bb-send:disabled { opacity: .5; cursor: wait; }

.bb-root button:focus-visible { outline: 3px solid var(--bb-primary); outline-offset: 2px; }
.bb-head button:focus-visible { outline-color: var(--bb-on-primary); }

@media (max-width: 480px) {
  .bb-root { right: 12px; bottom: 12px; }
  .bb-root.bb-left { left: 12px; right: auto; }
  .bb-root.is-open { inset: 0; }
  .bb-root.is-open .bb-panel { width: 100%; height: 100%; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bb-panel, .bb-typing span, .bb-launcher, .bb-mic.is-listening { animation: none; transition: none; }
}

/* Admin live preview: same markup, not floating. */
.bb-root.bb-preview { position: static; z-index: auto; }
.bb-root.bb-preview .bb-panel { height: 440px; animation: none; }
