/* =========================================================================
   Chat widget (answers as Dr. Milu) -- built by assets/js/chatbot.js.
   Uses only tokens.css vars. Launcher sits above the appointment FAB
   (.appt-fab: right 22 / bottom 22 / 52px tall).
   ========================================================================= */
.cb-launcher {
  position: fixed; right: 22px; bottom: 88px; z-index: 910;
  width: 54px; height: 54px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  background: var(--teal); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-hover); transition: transform 0.2s, background 0.2s;
}
.cb-launcher svg { width: 26px; height: 26px; }
.cb-launcher:hover { transform: scale(1.06); background: var(--navy); }
.cb-launcher:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.cb-launcher[aria-expanded="true"] { display: none; }

/* little green "online" dot, shared by launcher and header avatar */
.cb-dot {
  position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; border-radius: 50%;
  background: #34c759; border: 2px solid var(--white);
}

.cb-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 1100;
  width: 380px; max-width: calc(100vw - 24px);
  height: 560px; max-height: calc(100dvh - 44px);
  display: none; flex-direction: column; overflow: hidden;
  background: var(--white); border-radius: var(--card-radius);
  box-shadow: 0 20px 60px rgba(18, 52, 107, 0.28);
}
.cb-panel.open { display: flex; animation: cb-in 0.22s ease-out; }
@keyframes cb-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.cb-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--navy); color: var(--white);
}
.cb-avatar { position: relative; width: 40px; height: 40px; flex-shrink: 0; }
.cb-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; border: 2px solid rgba(255, 255, 255, 0.85); box-sizing: border-box; }
.cb-head-title { flex: 1; min-width: 0; font-weight: 700; font-size: 1rem; line-height: 1.3; }
.cb-close {
  background: transparent; border: none; color: var(--white); cursor: pointer;
  font-size: 1.5rem; line-height: 1; padding: 4px 8px; border-radius: 8px;
}
.cb-close:hover { background: rgba(255, 255, 255, 0.15); }

.cb-body {
  flex: 1; overflow-y: auto; padding: 14px; background: var(--mint);
  display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain;
}
.cb-msg {
  max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 0.93rem;
  line-height: 1.55; word-wrap: break-word; overflow-wrap: anywhere;
  animation: cb-pop 0.18s ease-out;
}
@keyframes cb-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cb-msg a { color: inherit; text-decoration: underline; }
.cb-msg ul { margin: 4px 0; padding-left: 18px; }
.cb-msg--bot { align-self: flex-start; background: var(--white); color: var(--slate); border-bottom-left-radius: 4px; box-shadow: var(--shadow-soft); }
.cb-msg--user { align-self: flex-end; background: var(--navy); color: var(--white); border-bottom-right-radius: 4px; }
.cb-msg--err { align-self: flex-start; background: var(--amber-light); color: var(--amber); border-bottom-left-radius: 4px; }

.cb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-chip {
  border: 1px solid var(--teal); background: var(--white); color: var(--navy);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 0.84rem; cursor: pointer; text-align: left;
}
.cb-chip:hover { background: var(--teal-light); }

/* WhatsApp-style typing dots */
.cb-msg--typing { padding: 12px 16px; }
.cb-typing { display: inline-flex; align-items: center; gap: 5px; height: 12px; }
.cb-typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--slate-light); animation: cb-dot 1.2s infinite ease-in-out; }
.cb-typing span:nth-child(2) { animation-delay: 0.18s; }
.cb-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes cb-dot { 0%, 70%, 100% { opacity: 0.35; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-5px); } }

.cb-form { display: flex; gap: 8px; padding: 10px 12px 16px; background: var(--white); border-top: 1px solid var(--sky); }
.cb-input {
  flex: 1; min-width: 0; border: 1px solid var(--sky); border-radius: 12px; padding: 10px 12px;
  font: inherit; font-size: 16px; /* 16px stops iOS zoom-on-focus */ color: var(--slate); resize: none;
  max-height: 96px;
}
.cb-input:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
.cb-send {
  flex-shrink: 0; width: 44px; border: none; border-radius: 12px; cursor: pointer;
  background: var(--teal); color: var(--white); display: flex; align-items: center; justify-content: center;
}
.cb-send:hover:not(:disabled) { background: var(--navy); }
.cb-send:disabled { opacity: 0.5; cursor: default; }
.cb-send svg { width: 20px; height: 20px; }

@media (max-width: 480px) {
  .cb-launcher { right: 16px; bottom: 82px; }
  .cb-panel { right: 0; bottom: 0; left: 0; width: 100%; max-width: 100%; height: min(86dvh, 640px); border-radius: var(--card-radius) var(--card-radius) 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cb-panel.open, .cb-msg, .cb-typing span, .cb-launcher { animation: none; transition: none; }
}
