/**
 * Broker Built — AI Chatbot widget
 * Uses the theme's brand tokens (--bb-accent, --bb-font-body, --bb-radius)
 * so it matches whatever preset the site runs.
 */

.bb-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  font-family: var(--bb-font-body, "Lato", sans-serif);
}

/* ---- Floating action button ---- */
.bb-chat__fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--bb-accent, #c9a96e);
  color: #12100e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  margin-left: auto;
}
.bb-chat__fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
}
.bb-chat__fab-icon--close { display: none; }
.bb-chat[data-state="open"] .bb-chat__fab-icon--chat { display: none; }
.bb-chat[data-state="open"] .bb-chat__fab-icon--close { display: block; }

/* ---- Teaser nudge ---- */
.bb-chat__teaser {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: 240px;
  background: #1a1815;
  color: #ece7df;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 30px 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  animation: bb-teaser-in 0.28s ease both;
}
.bb-chat__teaser[hidden] { display: none; }
.bb-chat__teaser::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: #1a1815;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transform: rotate(45deg);
}
.bb-chat__teaser-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: 0;
  color: #8a8178;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.bb-chat__teaser-close:hover { color: #fff; }
@keyframes bb-teaser-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bb-chat[data-state="open"] .bb-chat__teaser { display: none; }

/* ---- Panel ---- */
.bb-chat__panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #1a1815;
  color: #ece7df;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bb-chat__panel[hidden] { display: none; }

.bb-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #12100e;
}
.bb-chat__head-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
}
.bb-chat__head-close {
  background: none;
  border: 0;
  color: #9a938a;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.bb-chat__head-close:hover { color: #fff; }

/* ---- Message log ---- */
.bb-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bb-chat__msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bb-chat__msg--bot {
  align-self: flex-start;
  background: #2a2621;
  border-bottom-left-radius: 4px;
}
.bb-chat__msg--user {
  align-self: flex-end;
  background: var(--bb-accent, #c9a96e);
  color: #12100e;
  border-bottom-right-radius: 4px;
}
.bb-chat__msg a { color: inherit; text-decoration: underline; }

.bb-chat__typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 11px 14px;
  background: #2a2621;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.bb-chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8a8178;
  animation: bb-chat-bounce 1.2s infinite ease-in-out;
}
.bb-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.bb-chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bb-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Inline lead form ---- */
.bb-chat__lead {
  align-self: stretch;
  background: #221f1b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bb-chat__lead-row { display: flex; gap: 8px; }
.bb-chat__lead input,
.bb-chat__lead textarea {
  width: 100%;
  box-sizing: border-box;
  background: #12100e;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #ece7df;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
}
.bb-chat__lead textarea { resize: vertical; min-height: 44px; }
.bb-chat__lead input:focus,
.bb-chat__lead textarea:focus {
  outline: none;
  border-color: var(--bb-accent, #c9a96e);
}
.bb-chat__lead-submit {
  background: var(--bb-accent, #c9a96e);
  color: #12100e;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.bb-chat__lead-submit:disabled { opacity: 0.5; cursor: default; }

/* ---- Conversational lead confirm ---- */
.bb-chat__confirm {
  align-self: stretch;
  background: #221f1b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 13px;
}
.bb-chat__confirm-text {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.5;
}
.bb-chat__confirm-text strong { color: #fff; }
.bb-chat__confirm-actions { display: flex; gap: 8px; }
.bb-chat__confirm-yes,
.bb-chat__confirm-no {
  flex: 1;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.bb-chat__confirm-yes { background: var(--bb-accent, #c9a96e); color: #12100e; }
.bb-chat__confirm-yes:disabled { opacity: 0.6; cursor: default; }
.bb-chat__confirm-no { background: #333029; color: #ece7df; }

/* ---- Composer ---- */
.bb-chat__compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.bb-chat__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.bb-chat__input {
  flex: 1;
  resize: none;
  max-height: 96px;
  background: #12100e;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: #ece7df;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  padding: 9px 12px;
}
.bb-chat__input:focus {
  outline: none;
  border-color: var(--bb-accent, #c9a96e);
}
.bb-chat__submit {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 0;
  background: var(--bb-accent, #c9a96e);
  color: #12100e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bb-chat__submit:disabled { opacity: 0.5; cursor: default; }

.bb-chat__fine {
  margin: 0;
  padding: 0 12px 12px;
  font-size: 10.5px;
  line-height: 1.4;
  color: #7d766c;
}

@media (max-width: 480px) {
  .bb-chat { right: 12px; bottom: 12px; }
  .bb-chat__panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 90px);
    bottom: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bb-chat__fab,
  .bb-chat__teaser,
  .bb-chat__typing span { transition: none; animation: none; }
}
