/* chatbot.css — AI receptionist widget. Self-contained, prefixed .cb- / #clinic-chat.
   Reuses site tokens where present, with local fallbacks so the widget never looks unstyled. */
#clinic-chat {
  --cb-accent: var(--accent, #0F8A82);
  --cb-accent-ink: #ffffff;
  --cb-ink: var(--ink, #16302B);
  --cb-muted: var(--muted, #5C6B66);
  --cb-surface: #ffffff;
  --cb-bot-bg: #F1EFE9;
  --cb-border: var(--border, #E9E4DA);
  --cb-shadow: 0 18px 50px -12px rgba(16, 48, 43, 0.30), 0 6px 16px -8px rgba(16, 48, 43, 0.20);
  position: fixed;
  right: clamp(16px, 4vw, 32px);
  bottom: clamp(16px, 4vw, 32px);
  z-index: 9999;
  font-family: var(--font-body, "Hanken Grotesk", system-ui, sans-serif);
}

/* Floating bubble */
.cb-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 22px 0 18px;
  border: none;
  border-radius: 999px;
  background: var(--cb-accent);
  color: var(--cb-accent-ink);
  font: 600 15px/1 var(--font-body, "Hanken Grotesk", sans-serif);
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 14px 34px -10px rgba(15, 138, 130, 0.55);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease;
}
.cb-bubble:hover { transform: translateY(-3px); box-shadow: 0 20px 42px -10px rgba(15, 138, 130, 0.65); }
.cb-bubble:active { transform: translateY(-1px); }
.cb-bubble svg { width: 24px; height: 24px; flex: none; }
.cb-bubble.cb-hidden { display: none; }

/* Panel */
.cb-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(374px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--cb-shadow);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cb-panel.cb-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* Header */
.cb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #0F8A82 0%, #0C6F69 100%);
  color: #fff;
}
.cb-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.16);
  flex: none;
}
.cb-avatar svg { width: 20px; height: 20px; }
.cb-htext { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.cb-hname { font-weight: 700; font-size: 15px; }
.cb-status { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.9; }
.cb-dot { width: 7px; height: 7px; border-radius: 50%; background: #7BE0A3; box-shadow: 0 0 0 0 rgba(123, 224, 163, 0.7); animation: cb-pulse 2s infinite; }
@keyframes cb-pulse { 0% { box-shadow: 0 0 0 0 rgba(123,224,163,0.6);} 70% { box-shadow: 0 0 0 6px rgba(123,224,163,0);} 100% { box-shadow: 0 0 0 0 rgba(123,224,163,0);} }
.cb-close {
  border: none; background: rgba(255,255,255,0.12); color: #fff;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px;
  display: grid; place-items: center; transition: background 0.18s ease;
}
.cb-close:hover { background: rgba(255,255,255,0.24); }

/* Messages */
.cb-list {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(120% 70% at 100% 0%, rgba(15,138,130,0.05), transparent 60%),
    var(--cb-surface);
  scrollbar-width: thin;
}
.cb-msg {
  max-width: 82%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
  border-radius: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: cb-rise 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes cb-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.cb-bot { align-self: flex-start; background: var(--cb-bot-bg); color: var(--cb-ink); border-bottom-left-radius: 5px; }
.cb-user { align-self: flex-end; background: var(--cb-accent); color: #fff; border-bottom-right-radius: 5px; }

/* Typing indicator */
.cb-typing { align-self: flex-start; display: flex; gap: 4px; padding: 13px 16px; background: var(--cb-bot-bg); border-radius: 16px; border-bottom-left-radius: 5px; }
.cb-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--cb-muted); opacity: 0.5; animation: cb-bounce 1.2s infinite; }
.cb-typing span:nth-child(2) { animation-delay: 0.18s; }
.cb-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes cb-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 0.9; } }

/* Quick-reply chips */
.cb-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 16px 10px; }
.cb-chip {
  border: 1px solid var(--cb-border);
  background: #fff;
  color: var(--cb-ink);
  font: 600 13px var(--font-body, sans-serif);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.cb-chip:hover { border-color: var(--cb-accent); color: var(--cb-accent); transform: translateY(-1px); }

/* Input */
.cb-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--cb-border);
  background: #fff;
}
.cb-input {
  flex: 1;
  border: 1px solid var(--cb-border);
  border-radius: 999px;
  padding: 11px 16px;
  font: 400 14px var(--font-body, sans-serif);
  color: var(--cb-ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.cb-input:focus { border-color: var(--cb-accent); box-shadow: 0 0 0 3px rgba(15,138,130,0.14); }
.cb-input:disabled { background: #F6F4EF; }
.cb-send {
  width: 42px; height: 42px; flex: none;
  border: none; border-radius: 50%;
  background: var(--cb-accent); color: #fff;
  cursor: pointer; display: grid; place-items: center;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}
.cb-send svg { width: 18px; height: 18px; }
.cb-send:hover:not(:disabled) { transform: scale(1.06); }
.cb-send:disabled { opacity: 0.45; cursor: default; }

.cb-disclaimer { text-align: center; font-size: 11px; color: var(--cb-muted); padding: 0 16px 10px; }

@media (max-width: 480px) {
  #clinic-chat { right: 12px; bottom: 12px; }
  .cb-panel { width: calc(100vw - 24px); height: calc(100vh - 24px); border-radius: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .cb-bubble, .cb-panel, .cb-msg, .cb-send, .cb-chip { transition: none; animation: none; }
}
