/* Clinicon Bot — Frontend Widget CSS */
:root { --cb-brand: #0a5cff; }

#co-launch, #co-chatbox {
  position: fixed;
  z-index: 2147483647;
}

#co-launch {
  bottom: 20px; right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--cb-brand);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(10,92,255,.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#co-launch:hover { transform: scale(1.08); box-shadow: 0 14px 36px rgba(0,0,0,.3); }
#co-launch img { width: 30px; height: 30px; object-fit: contain; }

#co-chatbox {
  bottom: -720px; right: 20px;
  width: 380px; height: 600px;
  background: #fff;
  border-radius: 18px;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  transition: bottom .35s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
}
#co-chatbox.open { bottom: 20px; }

/* ── Header — fixed layout so close button never shifts ── */
.co-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #f0f3f9;
  background: #fff;
  flex-shrink: 0;
  gap: 8px;
  min-width: 0;
}
.co-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}
.co-brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: contain; flex-shrink: 0; }
.co-brand strong { display: block; font-size: 14px; font-weight: 700; color: #1a2035; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.co-brand small { font-size: 11px; color: #8a9bbf; display: block; }

/* Toggle lives in column 2 — always occupies its grid cell */
.co-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; cursor: pointer;
  flex-shrink: 0;
  justify-self: end;
}
.mode-label { color: #bbc5d8; font-weight: 600; font-size: 11px; }
.mode-label.active { color: var(--cb-brand); }

.toggle-track {
  width: 36px; height: 19px;
  background: #dbe4ff;
  border-radius: 20px;
  position: relative;
  transition: background 0.2s;
}
.toggle-thumb {
  width: 15px; height: 15px;
  background: var(--cb-brand);
  border-radius: 50%;
  position: absolute; top: 2px; left: 2px;
  transition: left .25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ai .toggle-thumb { left: 19px; }

/* Close button — column 3, always present */
#co-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; border: none; background: transparent;
  color: #e53e3e; cursor: pointer; font-size: 18px; font-weight: 700;
  line-height: 1; transition: all 0.15s; flex-shrink: 0;
}
#co-close:hover { background: #fef2f2; }

#co-messages {
  flex: 1;
  padding: 16px;
  background: #f7f9fc;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* Messages stack from top, user scrolls DOWN naturally */
  gap: 0;
}
#co-messages::-webkit-scrollbar { width: 4px; }
#co-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }

#typing {
  display: none;
  padding: 8px 16px;
  background: #f7f9fc;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}
#typing.visible { display: flex !important; }
.cb-typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #aab4c8;
  animation: cb-typedot 1.2s ease-in-out infinite;
}
.cb-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes cb-typedot { 0%,60%,100%{transform:scale(1);opacity:.4} 30%{transform:scale(1.35);opacity:1} }

/* ── Bot & User messages — logo anchored to TOP of message ── */
.bot, .user { display: flex; margin-bottom: 12px; }

.bot {
  gap: 10px;
  align-items: flex-start; /* logo aligns to TOP of message row */
}
.bot > img {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
  /* Pin to top — stays there even on very long messages */
  align-self: flex-start;
  margin-top: 0;
  position: sticky;
  top: 0;
}

.user { justify-content: flex-end; }
.user .bubble { background: var(--cb-brand); color: #fff; border: none; border-radius: 14px 14px 4px 14px; }

.bubble {
  background: #fff;
  border: 1px solid #edf2fb;
  border-radius: 4px 14px 14px 14px;
  padding: 12px 14px;
  max-width: 78%;
  font-size: 13.5px;
  line-height: 1.65;
  box-shadow: 0 2px 8px rgba(10,92,255,.06);
  /* Allow bubble to grow with content */
  min-width: 0;
  word-break: break-word;
}
.bubble strong { font-size: 13.5px; font-weight: 700; display: block; margin-bottom: 4px; color: #1a2035; }
.divider { height: 1px; background: #e2e8f0; margin: 8px 0; }
.time { font-size: 10.5px; color: #bbc5d8; margin-top: 6px; display: block; }

#co-suggestions {
  padding: 10px 12px;
  display: flex; flex-wrap: wrap; gap: 7px;
  background: #fff;
  border-top: 1px solid #f0f3f9;
  flex-shrink: 0;
}
.sug {
  padding: 6px 14px;
  border-radius: 20px;
  background: #f0f4ff;
  color: var(--cb-brand);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid #dde6ff;
  transition: all 0.15s ease;
}
.sug:hover { background: var(--cb-brand); color: #fff; border-color: var(--cb-brand); transform: translateY(-1px); }
.sug.primary { background: var(--cb-brand); color: #fff; border-color: var(--cb-brand); }
.sug.primary:hover { opacity: 0.88; transform: none; }

.book-image {
  display: block;
  width: 140px; height: 190px;
  object-fit: cover;
  border-radius: 10px; /* rectangular card, NOT circle */
  margin: 8px 0 0 38px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.carousel {
  display: flex; gap: 10px;
  overflow-x: auto; overflow-y: hidden;
  margin: 10px 0 0 38px;
  height: 200px; padding-bottom: 4px;
  flex-shrink: 0;        /* never crush height in flex column */
  align-self: stretch;   /* full width */
  min-width: 0;
}
.carousel::-webkit-scrollbar { height: 3px; }
.carousel::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }
.carousel img { height: 100%; width: auto; min-width: 140px; border-radius: 10px; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,0.1); flex-shrink: 0; }

/* ── Conversation turn anchor (scroll target) ────────── */
.cb-turn-anchor {
  height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

/* ── Conversation turn separator ─────────────────────── */
.cb-turn-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  opacity: 0.35;
}
.cb-turn-sep::before,
.cb-turn-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #c8d4e8;
}

/* ── Suggestion chips — back nav variant ─────────────── */
.sug.back-nav {
  background: #f8fafc !important;
  color: #6b7280 !important;
  border-color: #e2e8f0 !important;
  font-size: 12px !important;
  padding: 5px 12px !important;
}
.sug.back-nav:hover {
  background: #f1f5f9 !important;
  color: #374151 !important;
  border-color: #cbd5e1 !important;
  transform: none !important;
}
.cta-wrap {
  padding: 4px 16px 4px 0;
  max-width: 85%;
  margin-left: 38px;
}
.cta-btn {
  display: block;
  border: 2px solid var(--cb-brand);
  color: var(--cb-brand);
  background: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: all 0.15s ease;
  letter-spacing: -0.1px;
}
.cta-btn:hover { background: var(--cb-brand); color: #fff; }

/* ── Bubble content — RTE HTML rendered inline ──────────── */
.bubble-content { font-size: 13.5px; line-height: 1.65; }
.bubble-content strong { font-weight: 700; }
.bubble-content a { color: var(--cb-brand); text-decoration: underline; }
.bubble-content ul, .bubble-content ol { padding-left: 18px; margin: 6px 0; }
.bubble-content li { margin: 2px 0; }
.bubble-content p { margin: 4px 0; }
.bubble-heading { display: block; font-size: 14px; font-weight: 700; color: #1a2035; margin-bottom: 5px; letter-spacing: -0.1px; }
.bubble-line { font-size: 13.5px; line-height: 1.7; color: #374151; font-weight: 500; margin: 2px 0; }

/* ── Contact card ── */
.contact-card {
  margin: 8px 0 4px 38px;
  background: #f7f9fc; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 12px 14px; font-size: 13px;
}
.contact-card a { color: var(--cb-brand); text-decoration: none; display: block; margin-top: 4px; }
.contact-card a:hover { text-decoration: underline; }

#co-input-wrap {
  display: none;
  padding: 10px 12px;
  border-top: 1px solid #f0f3f9;
  gap: 8px; align-items: center;
  background: #fff; flex-shrink: 0;
}
#co-input {
  flex: 1; padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: #f4f6fb;
  font-size: 13px; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
#co-input:focus { border-color: var(--cb-brand); background: #fff; box-shadow: 0 0 0 3px rgba(10,92,255,.1); }
#co-send {
  background: var(--cb-brand); color: #fff;
  border: none; border-radius: 10px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s;
}
#co-send:hover { background: #0040cc; }
#co-send svg { width: 15px; height: 15px; }

.ai #co-input-wrap { display: flex; }
.ai #co-suggestions { display: none; }

@media (max-width: 420px) {
  #co-chatbox { width: calc(100vw - 16px); right: 8px; }
}

/* ── Inline lead capture form ──────────────────────────── */
.cb-lead-form-wrap { width: 100%; margin: 8px 0; }
.cb-lead-form {
  background: #fff; border: 1.5px solid #e0e7ff;
  border-radius: 14px; padding: 18px 16px;
  box-shadow: 0 2px 12px rgba(10,92,255,.08); font-family: inherit;
}
.cb-lf-header { margin-bottom: 14px; }
.cb-lf-header strong { display: block; font-size: 15px; color: #1a1a2e; margin-bottom: 3px; }
.cb-lf-header span { font-size: 12px; color: #6b7280; }
.cb-lf-body { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.cb-lf-input {
  width: 100%; box-sizing: border-box; padding: 10px 13px;
  border: 1.5px solid #e5e7eb; border-radius: 9px;
  font-size: 13px; font-family: inherit; background: #f9fafb; color: #1a1a2e;
  outline: none; transition: border .15s, box-shadow .15s;
}
.cb-lf-input:focus { border-color: var(--cb-brand); background: #fff; box-shadow: 0 0 0 3px rgba(10,92,255,.1); }
.cb-lf-select { cursor: pointer; }
.cb-lf-error { background: #fef2f2; color: #dc2626; border-radius: 7px; padding: 7px 12px; font-size: 12px; margin-bottom: 8px; }
.cb-lf-submit {
  width: 100%; padding: 11px;
  background: var(--cb-brand); color: #fff;
  border: none; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.cb-lf-submit:hover { opacity: .92; transform: translateY(-1px); }
.cb-lf-submit:active { transform: translateY(0); }
.cb-lf-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ── Thank-you card ─────────────────────────────────────── */
.cb-lead-thankyou {
  background: #f0fdf4; border: 1.5px solid #86efac;
  border-radius: 14px; padding: 24px 18px; text-align: center; font-family: inherit;
}
.cb-lty-icon { font-size: 36px; margin-bottom: 10px; }
.cb-lead-thankyou strong { display: block; font-size: 14px; color: #15803d; margin-bottom: 6px; }
.cb-lead-thankyou p { font-size: 13px; color: #166534; margin: 0 0 16px; }
.cb-lty-back {
  display: inline-block; padding: 9px 20px;
  background: var(--cb-brand); color: #fff; border: none; border-radius: 9px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.cb-lty-back:hover { opacity: .88; }

/* ── Typing cursor (AI mode streaming) ─────────────────── */
.bubble .typing-cursor {
  display: inline-block; width: 2px; height: 1em;
  background: var(--cb-brand); margin-left: 2px;
  vertical-align: text-bottom; animation: cb-blink 0.7s step-end infinite;
}
@keyframes cb-blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── AI reply formatting ─────────────────────────────── */
.ai-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #1a2035;
  margin: 10px 0 4px;
  letter-spacing: -0.1px;
}
.ai-section-title:first-child { margin-top: 0; }
.ai-para {
  font-size: 13.5px;
  line-height: 1.7;
  color: #374151;
  font-weight: 400;
  margin: 3px 0;
}
.ai-bullet {
  font-size: 13.5px;
  line-height: 1.65;
  color: #374151;
  padding-left: 4px;
  margin: 2px 0;
}
.ai-spacer { height: 6px; }

/* ── Event Node Card ─────────────────────────────────── */
.cb-event-card { border-radius: 14px; overflow: hidden; margin: 8px 0; box-shadow: 0 4px 20px rgba(0,0,0,.22); }
.cb-event-img { width: 100%; height: 160px; object-fit: cover; display: block; }
.cb-event-body { padding: 14px 16px; }
.cb-event-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.cb-event-ends { font-size: 11px; opacity: .7; margin-bottom: 12px; }
.cb-event-ctas { display: flex; flex-direction: column; gap: 8px; }
.cb-event-btn { display: block; padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; text-decoration: none; text-align: center; cursor: pointer; }
.cb-event-btn-ghost { background: transparent !important; border: 2px solid currentColor; }

/* ── Video Embed — 16:9 ratio, full thumbnail visible ─── */
.cb-video-wrap {
  margin: 8px 0 8px 0;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: #000;
}
.cb-video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}
