.chat-fab { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; align-items: center; gap: 8px; background: var(--green); color: #fff; border: 0; border-radius: 999px; padding: 14px 20px; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.chat-fab:hover { background: var(--green-dark); }
.chat-fab[hidden] { display: none; }
.chat-badge { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: #d64533; color: #fff; font-size: .75rem; display: grid; place-items: center; }
.chat-panel { position: fixed; right: 20px; bottom: 20px; z-index: 50; width: min(370px, calc(100vw - 24px)); height: min(560px, calc(100vh - 40px)); background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 48px rgba(0,0,0,.28); display: flex; flex-direction: column; overflow: hidden; }
.chat-panel[hidden] { display: none; }
.chat-panel header { display: flex; justify-content: space-between; align-items: center; background: var(--green); color: #fff; padding: 14px 16px; }
.chat-panel header small { display: block; opacity: .85; }
.chat-close { background: none; border: 0; color: #fff; font-size: 1.8rem; line-height: 1; cursor: pointer; min-width: 44px; min-height: 44px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; background: var(--alt); display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 85%; display: flex; flex-direction: column; }
.chat-msg.me { align-self: flex-end; align-items: flex-end; }
.chat-bubble { padding: 9px 13px; border-radius: 14px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg.me .chat-bubble { background: var(--green); color: #fff; border-color: var(--green); }
.chat-msg small { color: var(--muted); font-size: .72rem; margin-top: 2px; }
.chat-note { margin: 0; padding: 8px 14px; font-size: .78rem; color: var(--muted); background: #fff6e6; border-top: 1px solid var(--line); }
.chat-err { margin: 0; padding: 0 14px; color: #c0392b; font-size: .85rem; }
.chat-err:empty { display: none; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); align-items: end; }
.chat-form .chat-name { grid-column: 1 / -1; }
.chat-form .chat-name[hidden] { display: none; }
.chat-form input, .chat-form textarea { margin: 0; resize: none; }
@media (max-width: 600px) {
  .chat-fab { right: 14px; bottom: 14px; padding: 12px 16px; }
  .chat-fab-text { display: none; }
  .chat-fab-icon { font-size: 1.4rem; }
  .chat-panel { inset: 0; width: 100%; height: 100dvh; border-radius: 0; border: 0; }
}

/* Shown instead of the message box when the clinic is closed */
.chat-closed { padding: 16px 18px; background: #fff; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.chat-closed[hidden] { display: none; }
.chat-closed strong { color: var(--green-dark); font-size: 1.05rem; }
.chat-closed p { margin: 0; color: var(--ink); font-size: .93rem; }
.chat-closed-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chat-closed-actions .btn { text-align: center; }
