/* ==========================================================================
   BabySage chat widget — fully scoped under #babysage-widget so it can never
   clash with existing site styles. Stacks ABOVE the floating WhatsApp button.
   ========================================================================== */

#babysage-widget {
  --bs-dark: #2B1810;
  --bs-gold: #B8862C;
  --bs-cream: #F5EFE6;
  --bs-shadow: 0 18px 50px rgba(43, 24, 16, 0.28);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#babysage-widget *,
#babysage-widget *::before,
#babysage-widget *::after { box-sizing: border-box; }

/* --- Floating launcher (sits above the WhatsApp float) --- */
#babysage-widget .bs-launcher {
  position: fixed;
  right: 20px;
  bottom: 88px;            /* clears the 56px WhatsApp button + gap */
  z-index: 101;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border: none;
  border-radius: 999px;
  background: var(--bs-dark);
  box-shadow: var(--bs-shadow);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  animation: bs-bob 3.2s ease-in-out infinite;
}
#babysage-widget .bs-launcher:hover { transform: translateY(-2px); }
#babysage-widget .bs-launcher img {
  width: 46px; height: 46px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bs-cream);
  border: 2px solid var(--bs-gold);
}
#babysage-widget .bs-launcher .bs-launcher-label {
  color: var(--bs-cream);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  padding-right: 4px;
}
#babysage-widget .bs-launcher.bs-hidden { display: none; }

@keyframes bs-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

/* --- Chat panel --- */
#babysage-widget .bs-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100001;
  width: 374px;
  max-width: calc(100vw - 32px);
  height: 70vh;
  max-height: 580px;
  background: var(--bs-cream);
  border-radius: 18px;
  box-shadow: var(--bs-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.98);
  transition: opacity .2s ease, transform .2s ease;
}
#babysage-widget .bs-panel.bs-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Expanded / full-screen state */
#babysage-widget .bs-panel.bs-expanded {
  width: min(780px, 96vw);
  height: 92vh;
  max-height: none;
}

/* Header */
#babysage-widget .bs-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bs-dark);
  color: var(--bs-cream);
}
#babysage-widget .bs-header img {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bs-gold);
  background: var(--bs-cream);
}
#babysage-widget .bs-header .bs-titlewrap { flex: 1; min-width: 0; }
#babysage-widget .bs-header .bs-title { font-weight: 700; font-size: 15px; line-height: 1.1; }
#babysage-widget .bs-header .bs-sub { font-size: 11.5px; opacity: .8; }
#babysage-widget .bs-header .bs-expand,
#babysage-widget .bs-header .bs-close {
  background: transparent;
  border: none;
  color: var(--bs-cream);
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#babysage-widget .bs-header .bs-expand { width: 34px; height: 34px; }
#babysage-widget .bs-header .bs-close { width: 34px; height: 34px; font-size: 24px; }
#babysage-widget .bs-header .bs-expand:hover,
#babysage-widget .bs-header .bs-close:hover { background: rgba(255,255,255,.14); }

/* Messages */
#babysage-widget .bs-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#babysage-widget .bs-msg {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
#babysage-widget .bs-msg.bs-bot {
  align-self: flex-start;
  background: #fff;
  color: var(--bs-dark);
  border: 1px solid #eaddc9;
  border-bottom-left-radius: 4px;
}
#babysage-widget .bs-msg.bs-user {
  align-self: flex-end;
  background: var(--bs-dark);
  color: var(--bs-cream);
  border-bottom-right-radius: 4px;
}

/* Product cards */
#babysage-widget .bs-products { align-self: flex-start; width: 100%; display: flex; flex-direction: column; gap: 8px; }
#babysage-widget .bs-product {
  display: flex;
  gap: 10px;
  background: #fff;
  border: 1px solid #eaddc9;
  border-radius: 12px;
  padding: 8px;
  align-items: center;
}
#babysage-widget .bs-product img {
  width: 56px; height: 56px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--bs-cream);
  flex: none;
}
#babysage-widget .bs-product .bs-p-info { flex: 1; min-width: 0; }
#babysage-widget .bs-product .bs-p-name {
  font-size: 13px; font-weight: 700; color: var(--bs-dark);
  line-height: 1.25; margin-bottom: 2px;
}
#babysage-widget .bs-product .bs-p-price { font-size: 13px; color: var(--bs-gold); font-weight: 700; }
#babysage-widget .bs-product .bs-p-was { color: #a99; text-decoration: line-through; font-weight: 500; margin-left: 5px; font-size: 12px; }
#babysage-widget .bs-product .bs-p-oos { font-size: 11px; color: #b06; font-weight: 600; }
#babysage-widget .bs-product .bs-p-actions { display: flex; flex-direction: column; gap: 5px; flex: none; }
#babysage-widget .bs-product .bs-p-actions a,
#babysage-widget .bs-product .bs-p-actions button {
  font-size: 12px; font-weight: 700; text-align: center;
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
  text-decoration: none; border: none; white-space: nowrap;
}
#babysage-widget .bs-p-cart { background: var(--bs-gold); color: #fff; }
#babysage-widget .bs-p-view { background: var(--bs-cream); color: var(--bs-dark); border: 1px solid #e0d0b8 !important; }
#babysage-widget .bs-p-actions form { margin: 0; }

/* Typing indicator */
#babysage-widget .bs-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; }
#babysage-widget .bs-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--bs-gold);
  animation: bs-blink 1.2s infinite both;
}
#babysage-widget .bs-typing span:nth-child(2) { animation-delay: .2s; }
#babysage-widget .bs-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bs-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Starter chips */
#babysage-widget .bs-starters { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 14px 6px; }
#babysage-widget .bs-chip {
  background: #fff;
  border: 1px solid var(--bs-gold);
  color: var(--bs-dark);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease;
}
#babysage-widget .bs-chip:hover { background: var(--bs-cream); }
#babysage-widget .bs-chip.bs-chip-human { background: var(--bs-dark); color: var(--bs-cream); border-color: var(--bs-dark); }

/* Predicted follow-up suggestions (after each bot reply) */
#babysage-widget .bs-suggestions {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}
#babysage-widget .bs-suggest {
  background: var(--bs-cream);
  border: 1px dashed var(--bs-gold);
  color: var(--bs-dark);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease;
}
#babysage-widget .bs-suggest:hover { background: #fff; }

/* Input */
#babysage-widget .bs-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eaddc9;
  background: #fff;
}
#babysage-widget .bs-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid #e0d0b8;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  max-height: 90px;
  line-height: 1.4;
  color: var(--bs-dark);
  background: var(--bs-cream);
}
#babysage-widget .bs-input textarea:focus { outline: 2px solid var(--bs-gold); outline-offset: 0; }
#babysage-widget .bs-send {
  flex: none;
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--bs-gold);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#babysage-widget .bs-send:disabled { opacity: .5; cursor: default; }
#babysage-widget .bs-footnote { font-size: 10px; color: #a3927c; text-align: center; padding: 0 12px 8px; background: #fff; }

/* Mobile */
@media (max-width: 640px) {
  #babysage-widget .bs-launcher { bottom: 150px; right: 14px; padding: 5px 14px 5px 5px; }
  #babysage-widget .bs-launcher img { width: 42px; height: 42px; }
  #babysage-widget .bs-panel {
    right: 8px; left: 8px; bottom: 8px;
    width: auto; max-width: none;
    height: 82vh;
    height: 82dvh;            /* respects mobile browser chrome / keyboard */
    max-height: none;
  }
  /* Expanded on phones = true full-screen */
  #babysage-widget .bs-panel.bs-expanded {
    right: 0; left: 0; bottom: 0; top: 0;
    width: auto;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
  #babysage-widget .bs-msg { max-width: 90%; }
  #babysage-widget .bs-input textarea { font-size: 16px; }   /* stops iOS zoom-on-focus */
}

@media (prefers-reduced-motion: reduce) {
  #babysage-widget .bs-launcher { animation: none; }
  #babysage-widget .bs-panel { transition: none; }
}
