/* ── Thrive Outside Chatbot Widget ─────────────────────────────────────────── */

:root {
  --cb-forest:   #1E3A1E;
  --cb-moss:     #3D5C2E;
  --cb-sage:     #7B9E72;
  --cb-cream:    #F5EFE0;
  --cb-sand:     #E8DCC8;
  --cb-charcoal: #2C2A25;
  --cb-amber:    #C07A28;
  --cb-white:    #FFFFFF;
  --cb-radius:   14px;
  --cb-shadow:   0 8px 40px rgba(30,58,30,.22), 0 2px 8px rgba(0,0,0,.12);
}

/* ── Toggle Button ─────────────────────────────────────────────────────────── */
#cb-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cb-forest);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(30,58,30,.35);
  transition: transform .2s ease, background .2s ease;
  outline: none;
}
#cb-toggle:hover  { background: var(--cb-moss); transform: scale(1.06); }
#cb-toggle:active { transform: scale(.96); }
#cb-toggle svg    { width: 26px; height: 26px; color: var(--cb-cream); }

/* Unread badge */
#cb-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  background: var(--cb-amber);
  border-radius: 50%;
  border: 2px solid var(--cb-white);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Work Sans', sans-serif;
  color: var(--cb-white);
}
#cb-badge.visible { display: flex; }

/* ── Chat Window ───────────────────────────────────────────────────────────── */
#cb-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 9999;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--cb-cream);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Work Sans', sans-serif;
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .22s cubic-bezier(.34,1.4,.64,1);
}
#cb-window.cb-hidden {
  opacity: 0;
  transform: scale(.88) translateY(16px);
  pointer-events: none;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
#cb-header {
  background: var(--cb-forest);
  color: var(--cb-cream);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#cb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cb-moss);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#cb-avatar svg { width: 20px; height: 20px; color: var(--cb-cream); }
#cb-header-text { flex: 1; min-width: 0; }
#cb-header-name {
  font-weight: 600;
  font-size: .9375rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#cb-header-status {
  font-size: .75rem;
  opacity: .65;
  display: flex;
  align-items: center;
  gap: 5px;
}
#cb-header-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6fcf6f;
}
#cb-close {
  background: none;
  border: none;
  color: var(--cb-cream);
  opacity: .65;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: opacity .15s;
}
#cb-close:hover { opacity: 1; }
#cb-close svg { width: 18px; height: 18px; }

/* ── Messages ──────────────────────────────────────────────────────────────── */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#cb-messages::-webkit-scrollbar { width: 4px; }
#cb-messages::-webkit-scrollbar-track { background: transparent; }
#cb-messages::-webkit-scrollbar-thumb { background: rgba(30,58,30,.18); border-radius: 4px; }

.cb-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: cb-pop .18s ease;
}
@keyframes cb-pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cb-msg--bot  { align-self: flex-start; }
.cb-msg--user { align-self: flex-end; }

.cb-bubble {
  padding: 10px 13px;
  border-radius: 12px;
  font-size: .9rem;
  line-height: 1.55;
  color: var(--cb-charcoal);
  word-break: break-word;
}
.cb-msg--bot  .cb-bubble {
  background: var(--cb-white);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.cb-msg--user .cb-bubble {
  background: var(--cb-forest);
  color: var(--cb-cream);
  border-bottom-right-radius: 4px;
}

.cb-bubble a {
  color: var(--cb-amber);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cb-msg--user .cb-bubble a { color: var(--cb-sand); }

.cb-bubble strong { font-weight: 600; }
.cb-bubble ul { margin: 6px 0 0 0; padding-left: 18px; }
.cb-bubble li { margin-bottom: 3px; }

/* Typing indicator */
.cb-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--cb-white);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.cb-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-sage);
  animation: cb-bounce .9s infinite ease-in-out;
}
.cb-typing span:nth-child(2) { animation-delay: .15s; }
.cb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cb-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* ── Quick Replies ─────────────────────────────────────────────────────────── */
#cb-chips {
  padding: 6px 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.cb-chip {
  padding: 6px 12px;
  border-radius: 100px;
  border: 1.5px solid rgba(30,58,30,.25);
  background: transparent;
  font-family: 'Work Sans', sans-serif;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--cb-charcoal);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.cb-chip:hover {
  background: var(--cb-forest);
  border-color: var(--cb-forest);
  color: var(--cb-cream);
}

/* ── Input Area ────────────────────────────────────────────────────────────── */
#cb-footer {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(30,58,30,.1);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: var(--cb-cream);
}
#cb-input {
  flex: 1;
  border: 1.5px solid rgba(30,58,30,.2);
  border-radius: 100px;
  padding: 9px 14px;
  font-family: 'Work Sans', sans-serif;
  font-size: .9rem;
  color: var(--cb-charcoal);
  background: var(--cb-white);
  outline: none;
  transition: border-color .15s;
}
#cb-input:focus { border-color: var(--cb-sage); }
#cb-input::placeholder { color: rgba(44,42,37,.38); }

#cb-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--cb-forest);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .12s;
}
#cb-send:hover  { background: var(--cb-moss); }
#cb-send:active { transform: scale(.92); }
#cb-send svg    { width: 16px; height: 16px; color: var(--cb-cream); }

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #cb-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 72vh;
    max-height: 72vh;
    border-radius: var(--cb-radius) var(--cb-radius) 0 0;
  }
  #cb-toggle { bottom: 20px; right: 20px; }
}
