/* =========================================================
   茂智森 · 在线客服悬浮窗（访客端）
   ========================================================= */
.chat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 90;
  width: 56px; height: 56px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: linear-gradient(120deg, var(--accent, #3358ff), #00a3c4);
  color: #fff;
  box-shadow: 0 10px 26px rgba(51, 88, 255, .38);
  transition: transform .18s ease, box-shadow .18s ease;
}
.chat-fab:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(51, 88, 255, .45); }
.chat-fab:active { transform: scale(.94); }
.chat-fab svg { width: 24px; height: 24px; }
/* v1.2.0：呼吸光圈，提示访客可以点击咨询 */
.chat-fab::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(51, 88, 255, .35);
  animation: fabRing 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes fabRing {
  0%   { transform: scale(.9); opacity: .8; }
  70%  { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.22); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-fab::after { animation: none; }
}
.chat-dot {
  position: absolute; top: 3px; right: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #b6c0d4; border: 2px solid #fff;
  transition: background .2s;
}
.chat-dot.on { background: #22c55e; }

/* ---------- 对话面板 ---------- */
.chat-panel {
  position: fixed; right: 22px; bottom: 90px; z-index: 91;
  width: 320px; height: 440px;
  display: none; flex-direction: column;
  background: #fff; border: 1px solid #e4e9f2; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .18);
  overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(.98);
}
.chat-panel.open { display: flex; animation: panelIn .22s ease forwards; }
@keyframes panelIn { to { opacity: 1; transform: none; } }

.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  background: linear-gradient(120deg, #3358ff, #00a3c4);
  color: #fff; font-size: 14px; font-weight: 600;
}
.chat-close {
  border: 0; background: transparent; color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
  width: 28px; height: 28px; border-radius: 7px;
}
.chat-close:hover { background: rgba(255, 255, 255, .18); }

.chat-msgs {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: #f7f9fc;
}
.chat-msg { max-width: 78%; padding: 9px 13px; border-radius: 13px; font-size: 14px; line-height: 1.55; word-break: break-word; }
.chat-msg.me   { align-self: flex-end; background: #3358ff; color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.admin { align-self: flex-start; background: #fff; border: 1px solid #e4e9f2; color: #0f172a; border-bottom-left-radius: 4px; }
.chat-msg.notice { align-self: center; background: transparent; color: #5b6b84; font-size: 12.5px; padding: 2px; }
.chat-msg time { display: block; margin-top: 3px; font-size: 11px; opacity: .65; }

.chat-form {
  display: flex; gap: 8px; padding: 12px;
  border-top: 1px solid #e4e9f2; background: #fff;
}
.chat-form input {
  flex: 1; min-width: 0; padding: 10px 13px;
  border: 1px solid #e4e9f2; border-radius: 10px;
  font-size: 16px; font-family: inherit; color: #0f172a;
}
.chat-form input:focus { outline: none; border-color: #3358ff; box-shadow: 0 0 0 3px rgba(51, 88, 255, .14); }
.chat-form button {
  padding: 10px 16px; border: 0; border-radius: 10px; cursor: pointer;
  background: linear-gradient(120deg, #3358ff, #00a3c4);
  color: #fff; font-size: 14px; font-weight: 600; font-family: inherit;
}
.chat-form button:active { transform: scale(.96); }

/* ---------- 离线引导 Toast ---------- */
.chat-toast {
  position: fixed; right: 22px; bottom: 90px; z-index: 92;
  max-width: 300px; padding: 14px 16px;
  background: #fff; border: 1px solid #e4e9f2; border-radius: 13px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, .16);
  font-size: 14px; color: #0f172a; line-height: 1.6;
  display: none;
}
.chat-toast.show { display: block; animation: panelIn .22s ease forwards; }

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .chat-fab { right: 16px; bottom: 16px; }
  .chat-panel, .chat-toast.show {
    right: 12px; left: 12px; width: auto;
  }
  .chat-panel { bottom: 84px; height: min(62vh, 440px); }
  .chat-toast { bottom: 84px; }
}

/* ---------- v1.1.0：媒体消息 / 附件 / 待发预览 ---------- */
.chat-media {
  display: block; max-width: 100%; max-height: 180px;
  border-radius: 9px; margin-bottom: 4px; cursor: pointer;
}
.chat-msg.me .chat-media { margin-left: auto; }
video.chat-media { width: 220px; background: #000; }

.chat-attach {
  flex: none; width: 42px; height: 42px; align-self: center;
  border: 1px solid #e4e9f2; border-radius: 10px; background: #fff;
  color: #5b6b84; cursor: pointer; display: grid; place-items: center;
  transition: border-color .15s, color .15s;
}
.chat-attach:hover { border-color: rgba(51, 88, 255, .45); color: #3358ff; }
.chat-attach svg { width: 18px; height: 18px; }

.chat-pending { padding: 0 12px; }
.chat-pending:empty { display: none; }
.cp-item {
  display: block; margin-top: 8px; padding: 7px 12px;
  background: #f0f4ff; border: 1px solid #ccd7ff; border-radius: 8px;
  font-size: 12.5px; color: #3358ff;
}
.cp-err { background: #fef2f2; border-color: #fecaca; color: #dc2626; }
