/* ClinicalVillage — live chat bubble (self-contained) */
.cv-chat { position: fixed; right: 20px; bottom: 20px; z-index: 9980; font: 400 14px/1.45 system-ui, -apple-system, sans-serif; }
.cv-chat-fab {
    display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 20px 0 16px; border-radius: 999px; border: 0; cursor: pointer;
    background: linear-gradient(180deg, var(--chat, var(--brand-600)), var(--chat-dark, var(--brand-700))); color: #fff; font: 600 15px/1 system-ui, sans-serif;
    box-shadow: 0 16px 40px -12px rgba(15, 23, 42, .5); position: relative; transition: transform .15s;
}
.cv-chat-fab:hover { transform: translateY(-2px); }
.cv-chat-ico-close { display: none; }
.cv-chat.is-open .cv-chat-ico-open, .cv-chat.is-open .cv-chat-label { display: none; }
.cv-chat.is-open .cv-chat-ico-close { display: block; }
.cv-chat.is-open .cv-chat-fab { width: 56px; padding: 0; justify-content: center; }
.cv-chat-badge { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; border-radius: 99px; background: #e11d48; color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; padding: 0 6px; border: 2px solid #fff; }
.cv-chat-panel {
    position: absolute; right: 0; bottom: 72px; width: 370px; max-width: calc(100vw - 32px); height: 540px; max-height: calc(100vh - 110px);
    background: #fff; border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 30px 80px -20px rgba(15, 23, 42, .45); border: 1px solid #e2e8f0;
}
.cv-chat-panel[hidden], .cv-chat-badge[hidden] { display: none; }
.cv-chat-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 16px 18px; background: linear-gradient(135deg, var(--chat-dark, var(--brand-700)), var(--chat-darker, var(--brand-900))); color: #fff; }
.cv-chat-avatar { width: 38px; height: 38px; border-radius: 12px; background: rgba(255, 255, 255, .16); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cv-chat-title { margin: 0; font-weight: 600; font-size: 15px; }
.cv-chat-status { margin: 2px 0 0; font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.cv-chat-dot { width: 8px; height: 8px; border-radius: 99px; background: #fbbf24; display: inline-block; }
.cv-chat-dot.on { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .3); }
.cv-chat-x { margin-left: auto; background: none; border: 0; color: #fff; font-size: 26px; line-height: 1; cursor: pointer; opacity: .8; }
.cv-chat-body { flex: 1; overflow-y: auto; padding: 16px; background: #f8fafc; display: flex; flex-direction: column; gap: 10px; }
.cv-chat-msg { display: flex; flex-direction: column; max-width: 84%; }
.cv-chat-msg.me { align-self: flex-end; align-items: flex-end; }
.cv-chat-msg.system { align-self: center; max-width: 92%; }
.cv-chat-bubble { padding: 9px 13px; border-radius: 16px; background: #fff; color: #0f172a; border: 1px solid #e2e8f0; white-space: normal; word-wrap: break-word; }
.cv-chat-msg.admin .cv-chat-bubble { border-bottom-left-radius: 4px; }
.cv-chat-msg.me .cv-chat-bubble { background: var(--chat, var(--brand-600)); color: #fff; border-color: var(--chat, var(--brand-600)); border-bottom-right-radius: 4px; }
.cv-chat-msg.system .cv-chat-bubble { background: #fffbeb; border-color: #fde68a; color: #78350f; font-size: 13px; text-align: center; }
.cv-chat-time { font-size: 11px; color: #94a3b8; margin-top: 3px; padding: 0 4px; }
.cv-chat-intro { display: flex; gap: 6px; padding: 10px 12px 0; background: #fff; border-top: 1px solid #e2e8f0; }
.cv-chat-intro[hidden] { display: none; }
.cv-chat-intro input { flex: 1; min-width: 0; border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; }
.cv-chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; background: #fff; }
.cv-chat-intro:not([hidden]) + .cv-chat-form { padding-top: 8px; }
.cv-chat-intro[hidden] + .cv-chat-form { border-top: 1px solid #e2e8f0; }
.cv-chat-form textarea { flex: 1; resize: none; border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px 12px; font: inherit; max-height: 120px; outline: none; }
.cv-chat-form textarea:focus, .cv-chat-intro input:focus { border-color: var(--chat, var(--brand-500)); box-shadow: 0 0 0 3px rgba(100,116,139,.15); outline: none; }
.cv-chat-form button { width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--chat, var(--brand-600)); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cv-chat-hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.cv-chat-wa { display: block; text-align: center; font-size: 12px; color: #047857; padding: 0 0 10px; background: #fff; text-decoration: none; }
@media (max-width: 520px) { .cv-chat { right: 12px; bottom: 12px; } .cv-chat-label { display: none; } .cv-chat-fab { width: 56px; padding: 0; justify-content: center; } }
body.cv-editing .cv-chat { display: none; }
.cv-chat *, .cv-chat *::before, .cv-chat *::after { box-sizing: border-box; }
.cv-chat p { margin: 0; }
.cv-chat [hidden] { display: none !important; }
