/* MediChina - AI care assistant widget */

.chat-launcher {
  position: fixed; inset-inline-end: 24px; bottom: 24px; z-index: 50;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 111, 143, .34);
  font-size: 24px; transition: transform .18s ease;
}
.chat-launcher:hover { transform: scale(1.06); }
.chat-launcher:focus-visible { outline: 3px solid rgba(18, 165, 148, .5); outline-offset: 3px; }

.chat-panel {
  position: fixed; inset-inline-end: 24px; bottom: 92px; z-index: 60;
  width: min(378px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 140px));
  display: flex; flex-direction: column;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0; transform: translateY(14px) scale(.98); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.chat-panel.open { opacity: 1; transform: none; pointer-events: auto; }

.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; color: #fff;
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-dark));
}
.chat-head strong { display: block; font-size: 15px; }
.chat-head em { font-style: normal; font-size: 12px; opacity: .82; }
.chat-head em::before {
  content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: #4ade80; margin-inline-end: 6px;
}
.chat-close {
  background: rgba(255, 255, 255, .16); border: 0; color: #fff;
  font-size: 20px; line-height: 1; width: 30px; height: 30px;
  border-radius: 8px; cursor: pointer;
}
.chat-close:hover { background: rgba(255, 255, 255, .3); }

.chat-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; background: #fbfdfd;
  scroll-behavior: smooth;
}
.msg { max-width: 84%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.msg.bot {
  background: var(--c-accent-soft); color: var(--c-ink);
  border-start-start-radius: 4px; align-self: flex-start;
}
.msg.me {
  background: var(--c-primary); color: #fff;
  border-start-end-radius: 4px; align-self: flex-end;
}
.msg.emergency {
  background: #fff1f0; color: #a8201a; border: 1px solid #f5c6c0; font-weight: 600;
  align-self: stretch; max-width: 100%;
}
.msg.typing { color: var(--c-muted); font-style: italic; }

.chat-suggest { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 10px; }
.chat-suggest button {
  font-family: inherit; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--c-border); background: #fff; color: var(--c-primary);
  border-radius: 999px; padding: 6px 12px;
}
.chat-suggest button:hover { background: var(--c-accent-soft); border-color: var(--c-accent); }

.chat-input {
  display: flex; gap: 8px; padding: 12px 16px 4px; border-top: 1px solid var(--c-border);
}
.chat-input input {
  flex: 1; font-family: inherit; font-size: 14px;
  border: 1px solid var(--c-border); border-radius: 999px; padding: 10px 14px;
  color: var(--c-ink); background: #fff;
}
.chat-input input:focus { outline: 2px solid rgba(18, 165, 148, .3); border-color: var(--c-accent); }
.chat-input button {
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 0; border-radius: 999px; padding: 10px 18px;
  background: var(--c-primary); color: #fff;
}
.chat-input button:hover { background: var(--c-primary-dark); }
.chat-input button:disabled { opacity: .55; cursor: not-allowed; }

.chat-note {
  margin: 0; padding: 8px 16px 12px; font-size: 11.5px; color: var(--c-muted);
  border-top: 0; text-align: center;
}

@media (max-width: 480px) {
  .chat-panel { inset-inline-end: 8px; inset-inline-start: 8px; width: auto; bottom: 88px; }
  .chat-launcher { inset-inline-end: 16px; bottom: 16px; }
  .to-top { bottom: 84px; }
}
