/* ==========================================================================
   颌顺医疗 · 在线客服挂件（参考 Sobot/智齿 320×520 客服窗口）
   ========================================================================== */

.chat-fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 50px;
  padding: 0 20px 0 16px;
  border-radius: var(--r-pill);
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 14px 34px -10px rgba(46, 76, 134, 0.55);
  transition: transform 0.18s var(--ease), background 0.18s, box-shadow 0.18s;
}
.chat-fab:hover {
  background: var(--brand-strong);
  transform: translateY(-2px);
  box-shadow: 0 18px 40px -12px rgba(46, 76, 134, 0.6);
}
.chat-fab-icon .icon {
  width: 21px;
  height: 21px;
}
.chat-fab-dot {
  position: absolute;
  top: 6px;
  right: 12px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4fe0d8;
  border: 2px solid var(--brand);
  display: none;
}
.chat-fab.has-unread .chat-fab-dot {
  display: block;
}
.chat-fab.has-unread::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: var(--r-pill);
  border: 2px solid rgba(79, 224, 216, 0.35);
  animation: fab-pulse 2s ease-out infinite;
}
@keyframes fab-pulse {
  0% {
    transform: scale(0.96);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.16);
    opacity: 0;
  }
}

.chat-widget {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 950;
  width: 372px;
  max-width: calc(100vw - 32px);
  filter: drop-shadow(0 30px 60px rgba(9, 20, 40, 0.28));
}
.cw-panel {
  display: flex;
  flex-direction: column;
  height: min(620px, calc(100vh - 72px));
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(26, 34, 51, 0.06);
  animation: cw-in 0.22s var(--ease);
}
@keyframes cw-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.cw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(120deg, #1b3159, #2e4c86 72%, #356394);
  color: #fff;
}
.cw-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.cw-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.cw-avatar img {
  width: 24px;
  height: 24px;
}
.cw-brand strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}
.cw-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.72);
}
.cw-status .dot {
  width: 6px;
  height: 6px;
  background: #4fe0d8;
  box-shadow: 0 0 0 3px rgba(79, 224, 216, 0.18);
}
.cw-status .dot.warning {
  background: #ffce56;
  box-shadow: 0 0 0 3px rgba(255, 206, 86, 0.18);
}
.cw-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.cw-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.cw-close .icon {
  width: 17px;
  height: 17px;
}
.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: linear-gradient(180deg, #fbfcfe, #f6f8fb);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.cw-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 86%;
}
.cw-msg .cw-msgnav {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin-top: 2px;
}
.cw-msg .cw-bubble {
  padding: 10px 13px;
  border-radius: 12px;
  border-top-left-radius: 4px;
  background: #fff;
  border: 1px solid #e8eaed;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(26, 34, 51, 0.04);
}
.cw-msg .cw-time {
  font-size: 10.5px;
  color: var(--ink-5);
  margin-top: 5px;
}
.cw-msg.visitor {
  flex-direction: row-reverse;
  margin-left: auto;
}
.cw-msg.visitor .cw-bubble {
  background: var(--teal-soft);
  border-color: var(--teal-line);
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
  color: #0c3f3d;
}
.cw-msg.visitor .cw-time {
  text-align: right;
}
.cw-msg.system {
  max-width: 100%;
  justify-content: center;
}
.cw-msg.system .cw-bubble {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--ink-5);
  font-size: 11.5px;
  padding: 0 8px;
  text-align: center;
}
.cw-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 13px 15px;
}
.cw-typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-5);
  animation: typing-bounce 1.1s infinite ease-in-out;
}
.cw-typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.cw-typing i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
.cw-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 10px;
  background: #fff;
  border-top: 1px solid var(--line);
}
.cw-quick button {
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink-3);
  font-size: 12px;
  transition: all 0.15s;
}
.cw-quick button:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
  background: var(--teal-soft);
}
.cw-inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid var(--line);
}
.cw-tool {
  width: 32px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-4);
  border-radius: 8px;
  flex: none;
}
.cw-tool:hover {
  background: #f2f5f8;
  color: var(--teal-deep);
}
.cw-tool .icon {
  width: 18px;
  height: 18px;
}
.cw-text {
  flex: 1;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13.5px;
  line-height: 1.5;
  resize: none;
  max-height: 96px;
  min-height: 38px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cw-text:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 181, 176, 0.13);
}
.cw-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background 0.15s;
}
.cw-send:hover {
  background: var(--brand-strong);
}
.cw-send .icon {
  width: 17px;
  height: 17px;
  margin-left: -1px;
}
.cw-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px 10px;
  background: #fff;
  font-size: 10.5px;
  color: var(--ink-5);
}
.cw-rate-link {
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 500;
}
.cw-rate-link:hover {
  text-decoration: underline;
}
.cw-contact {
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid var(--line);
  animation: fade-in 0.18s;
}
.cw-contact-head {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.cw-contact-head span {
  font-weight: 400;
  color: var(--ink-5);
}
.cw-contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.cw-input {
  height: 36px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  outline: none;
}
.cw-input:focus {
  border-color: var(--teal);
}
.cw-contact-grid .span-2 {
  grid-column: 1 / -1;
}
.cw-contact-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.cw-btn-sm {
  height: 30px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  font-size: 12.5px;
  color: var(--ink-3);
  background: #fff;
}
.cw-btn-sm.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.cw-btn-sm:hover {
  opacity: 0.9;
}
.cw-rating {
  padding: 14px;
  background: #fff;
  border-top: 1px solid var(--line);
}
.cw-rating-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: center;
}
.cw-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 10px 0;
}
.cw-stars button {
  width: 30px;
  height: 30px;
  color: #d6dbe2;
  transition: color 0.12s, transform 0.12s;
}
.cw-stars button.active,
.cw-stars button:hover {
  color: #ffbc00;
  transform: scale(1.08);
}
.cw-stars button .icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
  stroke: none;
}
.cw-rating-foot {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.cw-ended {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  text-align: center;
  background: #fff;
}
.cw-ended p {
  font-size: 12px;
  color: var(--ink-4);
  margin-bottom: 8px;
}
.cw-restart {
  height: 34px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
}
.cw-restart:hover {
  background: #e0e9f6;
}

@media (max-width: 560px) {
  .chat-fab {
    right: 16px;
    bottom: 16px;
    height: 46px;
    padding: 0 16px 0 13px;
    font-size: 13px;
  }
  .chat-widget {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
  }
  .cw-panel {
    height: min(86vh, 640px);
    border-radius: 18px 18px 0 0;
  }
}
