/* ============================================================
   Brand Assistant — floating chat widget
   Design: "bestie texting you back" — a night-plum panel, a hot
   coral/lime duo for accents, and a chunky rounded display face
   for the header so it reads like a person, not a support ticket.
   All colors are CSS variables — override them on .ba-root from
   your theme if you want to match your brand.
   ============================================================ */

.ba-root {
  --ba-bg: #1c1030;
  --ba-bg-soft: #241640;
  --ba-panel: #150b26;
  --ba-coral: #ff5c8a;
  --ba-lime: #d4ff4f;
  --ba-text: #f6f1ff;
  --ba-text-dim: #b9aed4;
  --ba-bubble-user: #ff5c8a;
  --ba-bubble-bot: #2c1c4a;
  --ba-radius: 20px;
  --ba-font-display: "Space Grotesk", "Poppins", system-ui, sans-serif;
  --ba-font-body: "Inter", system-ui, -apple-system, sans-serif;

  position: fixed;
  z-index: 999999;
  right: 22px;
  bottom: 22px;
  font-family: var(--ba-font-body);
  color: var(--ba-text);
}

.ba-root * {
  box-sizing: border-box;
}

/* ---------- Launcher bubble ---------- */
.ba-launcher {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--ba-coral), #a24bff);
  box-shadow: 0 8px 24px rgba(255, 92, 138, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.2s ease;
}

.ba-launcher:hover {
  transform: scale(1.06);
}

.ba-launcher::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--ba-coral);
  opacity: 0.5;
  animation: ba-pulse 2.4s ease-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .ba-launcher::before {
    animation: none;
  }
}

@keyframes ba-pulse {
  0% {
    transform: scale(0.85);
    opacity: 0.55;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

.ba-launcher svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
}

.ba-launcher .ba-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ba-lime);
  border: 2px solid var(--ba-panel);
}

/* ---------- Panel ---------- */
.ba-panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--ba-panel);
  border-radius: var(--ba-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.ba-root.ba-open .ba-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Header ---------- */
.ba-header {
  background: linear-gradient(120deg, var(--ba-bg-soft), var(--ba-bg));
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ba-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ba-lime), var(--ba-coral));
  flex-shrink: 0;
}

.ba-header-text {
  flex: 1;
  min-width: 0;
}

.ba-title {
  font-family: var(--ba-font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ba-subtitle {
  font-size: 12px;
  color: var(--ba-text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ba-subtitle::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ba-lime);
  display: inline-block;
}

.ba-close {
  background: none;
  border: none;
  color: var(--ba-text-dim);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
}

.ba-close:hover {
  color: var(--ba-text);
}

/* ---------- Messages ---------- */
.ba-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--ba-bg);
}

.ba-messages::-webkit-scrollbar {
  width: 6px;
}

.ba-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
}

.ba-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  animation: ba-rise 0.16s ease-out;
}

@keyframes ba-rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ba-msg-bot {
  align-self: flex-start;
  background: var(--ba-bubble-bot);
  border-bottom-left-radius: 4px;
  color: var(--ba-text);
}

/* Markdown engine adjustments to strip whitespace spacing gaps */
.ba-msg-bot ul, 
.ba-msg-bot li, 
.ba-msg-bot pre, 
.ba-msg-bot code, 
.ba-msg-bot h1, 
.ba-msg-bot h2, 
.ba-msg-bot h3 {
  white-space: normal !important;
}

.ba-msg-bot ul {
  margin: 4px 0 !important;
  padding-left: 18px !important;
  list-style-type: disc !important;
}

.ba-msg-bot li {
  margin: 2px 0 !important;
  padding: 0 !important;
  line-height: 1.4 !important;
}

.ba-msg-user {
  align-self: flex-end;
  background: var(--ba-bubble-user);
  border-bottom-right-radius: 4px;
  color: #1c0a15;
  font-weight: 500;
}

/* ---------- Typing indicator ---------- */
.ba-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 12px 14px;
  background: var(--ba-bubble-bot);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.ba-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  animation: ba-bounce 1.1s infinite ease-in-out;
}

.ba-typing span:nth-child(1) {
  background: var(--ba-coral);
  animation-delay: 0s;
}
.ba-typing span:nth-child(2) {
  background: var(--ba-lime);
  animation-delay: 0.15s;
}
.ba-typing span:nth-child(3) {
  background: #a24bff;
  animation-delay: 0.3s;
}

@keyframes ba-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.ba-status-text {
  font-size: 11px;
  color: var(--ba-text-dim);
  align-self: flex-start;
  padding-left: 4px;
  margin-top: -4px;
}

/* ---------- Input row ---------- */
.ba-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--ba-panel);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ba-input {
  flex: 1;
  resize: none;
  max-height: 90px;
  min-height: 20px;
  background: var(--ba-bg-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 13px;
  color: var(--ba-text);
  font-family: var(--ba-font-body);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
}

.ba-input:focus {
  border-color: var(--ba-coral);
}

.ba-input::placeholder {
  color: var(--ba-text-dim);
}

.ba-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--ba-coral), #a24bff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.ba-send:hover {
  transform: scale(1.05);
}

.ba-send:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.ba-send svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .ba-root {
    right: 12px;
    bottom: 12px;
  }
  .ba-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    bottom: 78px;
  }
}
