/* 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 .28s cubic-bezier(0.34, 1.56, 0.64, 1), width .22s ease, height .22s ease, border-radius .22s ease, right .22s ease;
  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 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-fullscreen {
  width: 30px !important; height: 30px !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
  border-radius: 8px !important; border: none !important;
  background-color: var(--cb-brand) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M3 8V5a2 2 0 0 1 2-2h3M16 3h3a2 2 0 0 1 2 2v3M21 16v3a2 2 0 0 1-2 2h-3M8 21H5a2 2 0 0 1-2-2v-3' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: center center !important;
  background-size: 14px 14px !important;
  cursor: pointer !important;
  transition: opacity 0.18s !important;
  flex-shrink: 0 !important;
  font-size: 0 !important;     /* hide any text/svg injected by JS */
  color: transparent !important;
}
#co-fullscreen:hover { opacity: 0.82 !important; }
/* When fullscreen active — show compress icon */
#co-chatbox.fullscreen #co-fullscreen {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0 2-2h3M3 16h3a2 2 0 0 0 2 2v3' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") !important;
}

#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;
  position: relative;
}
#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 moved to fullscreen section below */
.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; max-width: 220px; border-radius: 10px; object-fit: contain; object-position: center; background: #f0f2f7; box-shadow: 0 2px 8px rgba(0,0,0,0.1); flex-shrink: 0; }
/* Carousel taller + wider in fullscreen */
#co-chatbox.fullscreen .carousel { height: 280px; margin-left: 54px; }
#co-chatbox.fullscreen .carousel img { min-width: 200px; max-width: 340px; }

/* ── 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: 6px 0 4px 38px;
  max-width: calc(100% - 38px);
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--cb-brand);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: all 0.18s ease;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 14px rgba(10,92,255,0.28);
  white-space: nowrap;
}
.cta-btn::after {
  content: '→';
  font-size: 13px;
  transition: transform 0.18s;
}
.cta-btn:hover {
  background: #0040cc;
  box-shadow: 0 6px 20px rgba(10,92,255,0.38);
  transform: translateY(-1px);
  color: #fff;
}
.cta-btn:hover::after { transform: translateX(3px); }
.cta-btn:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(10,92,255,0.22); }

/* ── 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: #0B5CFF; border: none;
  border-radius: 10px; padding: 12px 14px; font-size: 13px;
  color: #fff;
}
.contact-card a { color: #fff; text-decoration: none; display: block; margin-top: 4px; opacity: 0.92; }
.contact-card a:hover { opacity: 1; 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; }
  #co-fullscreen { display: none !important; }
}

/* ── 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 24px rgba(0,0,0,.28);
  cursor: pointer;
  /* bg_color and color set inline by JS from admin settings */
}
.cb-event-img {
  width: 100%; height: 200px;
  object-fit: cover; object-position: center top;
  display: block; transition: transform .3s ease;
  cursor: zoom-in;
}
.cb-event-card:hover .cb-event-img { transform: scale(1.02); }
.cb-event-body {
  padding: 14px 16px 16px;
  /* inherits bg and text color from inline style on .cb-event-card */
}
.cb-event-title {
  font-size: 14px; font-weight: 700;
  margin-bottom: 5px; line-height: 1.35;
  /* color inherited from card */
}
.cb-event-ends { font-size: 11px; opacity: .75; margin-bottom: 12px; }
.cb-event-ctas { display: flex; flex-direction: column; gap: 8px; }
.cb-event-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 16px; border-radius: 50px;
  font-weight: 700; font-size: 13px;
  text-decoration: none; text-align: center; cursor: pointer;
  transition: opacity .15s, transform .15s;
  /* Primary: background=text_color, color=bg_color (inverted) — set inline by JS */
}
.cb-event-btn:hover { opacity: .85; transform: translateY(-1px); }
.cb-event-btn-ghost {
  background: transparent !important;
  border: 2px solid currentColor;
  /* color=text_color set inline by JS */
}
/* Fullscreen: event card wider */
#co-chatbox.fullscreen .cb-event-card { max-width: 480px; }

/* ── 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;
}

/* ── Fullscreen mode ─────────────────────────────────── */
#co-chatbox.fullscreen {
  bottom: 16px !important;
  right: auto !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: min(calc(100vw - 32px), 980px) !important;
  height: calc(100dvh - 32px) !important;
  height: calc(100vh - 32px) !important;
  border-radius: 20px !important;
  max-width: min(calc(100vw - 32px), 980px) !important;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55) !important;
}
/* Messages area in fullscreen */
#co-chatbox.fullscreen #co-messages { max-width: 100%; }
#co-chatbox.fullscreen .bubble { max-width: 56%; }

/* ── Single image — full width ───────────────────────── */
.book-image {
  display: block;
  width: calc(100% - 38px);
  height: auto;
  max-height: 300px;
  object-fit: contain;
  object-position: center top;
  border-radius: 10px;
  margin: 8px 0 4px 38px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
  cursor: zoom-in;
  background: #f0f2f7;
}
/* In fullscreen the chat is much wider — cap image width for readability */
#co-chatbox.fullscreen .book-image {
  max-width: 480px;
  max-height: 360px;
}

/* ── Lightbox ────────────────────────────────────────── */
.cb-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  background: rgba(0,0,0,0);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.25s;
  cursor: zoom-out;
}
.cb-lightbox-overlay.cb-lb-visible { background: rgba(0,0,0,0.88); }
.cb-lightbox-img {
  max-width: 92vw; max-height: 88vh;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  object-fit: contain;
  opacity: 0; transform: scale(0.92);
  transition: opacity 0.25s, transform 0.25s;
  cursor: default;
}
.cb-lb-visible .cb-lightbox-img { opacity: 1; transform: scale(1); }
.cb-lightbox-close {
  position: absolute; top: 16px; right: 20px;
  background: rgba(255,255,255,0.15);
  border: none; color: #fff; font-size: 20px;
  width: 38px; height: 38px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.cb-lightbox-close:hover { background: rgba(255,255,255,0.28); }

/* ── Carousel scroll hint ────────────────────────────── */
.carousel img { cursor: zoom-in; }

/* ── Popup bubble ────────────────────────────────────── */
.co-popup-bubble {
  position: fixed;
  bottom: 90px; right: 16px;
  max-width: 220px;
  background: var(--cb-brand);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 12px 36px 12px 16px;
  font-size: 13.5px; font-weight: 500; line-height: 1.45;
  box-shadow: 0 8px 28px rgba(10,92,255,.32);
  z-index: 2147483640;
  animation: cb-popup-in .4s cubic-bezier(0.34,1.56,0.64,1) both;
  cursor: pointer;
}
.co-popup-bubble p { margin: 0; }
.co-popup-close {
  position: absolute; top: 6px; right: 8px;
  background: rgba(255,255,255,.2); border: none; color: #fff;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 11px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background .15s;
}
.co-popup-close:hover { background: rgba(255,255,255,.38); }
@keyframes cb-popup-in {
  from { opacity: 0; transform: translateY(12px) scale(.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* Popup also hides co-launch label when chat is open */

/* ── Chat background image ───────────────────────────────
   Centred watermark between header and suggestions bar.
   Fixed inside chatbox — NEVER scrolls with messages.
   Normal:     260×260px centred (no border-radius — square/natural shape)
   Fullscreen: 520×520px centred
   ─────────────────────────────────────────────────────── */

/* Wrapper: fills the content area below header, above input */
.co-bg-image {
  position: absolute;
  top: 56px;           /* below co-header */
  bottom: 58px;        /* above suggestions + input area */
  left: 0;
  right: 0;
  z-index: 0;          /* below flex content which has no z-index */
  pointer-events: none;
  /* Image is set inline via style="background-image:url(...)" */
  /* Centre at fixed 260×260 — no stretch, no crop, natural shape */
  background-size: 260px 260px;
  background-repeat: no-repeat;
  background-position: center center;
  /* Opacity via CSS custom property so it only affects this element */
  /* opacity set via inline style from PHP */
}

/* Fullscreen: 2× size */
#co-chatbox.fullscreen .co-bg-image {
  bottom: 64px;
  background-size: 520px 520px;
}

/* Content layers naturally sit above the absolute-positioned bg watermark */
/* No explicit z-index needed — position:relative is enough */
#co-messages, #typing, #co-suggestions, #co-input-wrap, .co-header {
  position: relative;
}
