/* ============================================================
   Wemings · 在线客服浮窗（真人）
   与 style.css 同一套陶瓷色板；面板固定右下，移动端全屏。
   ============================================================ */

.wsup {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9000;
  font-family: var(--font-sans);
  --wsup-ink: #3B3732;
  --wsup-line: #E9E1D5;
  --wsup-bg: #FAF7F2;
  --wsup-brand: #547168;
  --wsup-brand-deep: #3F5B52;
}

/* ---------------- 气泡按钮 ---------------- */
.wsup-launch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 20px 0 17px;
  border: 0;
  border-radius: 28px;
  background: linear-gradient(135deg, #6C8D82, #3F5B52);
  color: #fff;
  font: 600 14px/1 var(--font-sans);
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 14px 32px -12px rgba(63, 91, 82, .55), 0 2px 6px rgba(63, 91, 82, .18);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1), box-shadow .22s;
}
.wsup-launch:hover { transform: translateY(-2px); box-shadow: 0 20px 40px -14px rgba(63, 91, 82, .6); }
.wsup-launch:active { transform: translateY(0) scale(.98); }
.wsup-launch-ico { width: 22px; height: 22px; flex: 0 0 auto; }
.wsup-launch-close { display: none; width: 20px; height: 20px; }
.wsup.is-open .wsup-launch-ico { display: none; }
.wsup.is-open .wsup-launch-close { display: block; }
.wsup.is-open .wsup-launch-text { display: none; }
.wsup.is-open .wsup-launch { padding: 0 16px; }

/* 在线小绿点（呼吸）；离线时换成灰点且不闪 */
.wsup-ping {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4CAF7D;
  border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(76, 175, 125, .55);
  animation: wsup-pulse 2.2s infinite;
}
.wsup[data-online="0"] .wsup-ping { background: #B9B0A2; animation: none; box-shadow: none; }
.wsup.is-open .wsup-ping { display: none; }

@keyframes wsup-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(76, 175, 125, .5); }
  70%  { box-shadow: 0 0 0 9px rgba(76, 175, 125, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 175, 125, 0); }
}

.wsup-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #C0392B;
  color: #fff;
  font: 700 11px/20px var(--font-sans);
  text-align: center;
  box-shadow: 0 2px 6px rgba(192, 57, 43, .4);
}

/* ---------------- 面板 ---------------- */
.wsup-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 372px;
  height: min(566px, calc(100vh - 118px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 30px 70px -22px rgba(63, 91, 82, .42), 0 0 0 1px rgba(63, 91, 82, .06);
  overflow: hidden;
  transform-origin: bottom right;
  animation: wsup-in .24s cubic-bezier(.34, 1.3, .64, 1);
}
.wsup-panel[hidden] { display: none; }

@keyframes wsup-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.wsup-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(120deg, #6C8D82, #3F5B52);
  color: #fff;
}
.wsup-id { display: flex; align-items: center; gap: 11px; min-width: 0; }
.wsup-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .32);
  color: #fff;
  font: 600 17px/40px var(--font-serif, Georgia, serif);
  text-align: center;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}
.wsup-id-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.wsup-id-text strong {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wsup-state {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  opacity: .92;
  line-height: 1.3;
}
.wsup-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #4CAF7D;
}
.wsup-dot.off { background: #C8BEAF; }
.wsup-min {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  cursor: pointer;
  transition: background .2s;
}
.wsup-min:hover { background: rgba(255, 255, 255, .24); }
.wsup-min svg { width: 16px; height: 16px; }

/* ---------------- 消息区 ---------------- */
.wsup-log {
  flex: 1 1 0;
  min-height: 40px;   /* 允许收缩：离线留言表单较长时，不能把 footer 顶出面板 */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 6px;
  background: var(--wsup-bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.wsup-row { display: flex; }
.wsup-row.me { justify-content: flex-end; }
.wsup-row.them { justify-content: flex-start; }
.wsup-bubble {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.8px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.wsup-row.them .wsup-bubble {
  background: #fff;
  color: var(--wsup-ink);
  border: 1px solid var(--wsup-line);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px -4px rgba(63, 91, 82, .16);
}
.wsup-row.me .wsup-bubble {
  background: var(--wsup-brand-deep);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.wsup-row.sys { justify-content: center; }
.wsup-row.sys .wsup-bubble {
  background: transparent;
  color: #9A9186;
  font-size: 11.5px;
  text-align: center;
  padding: 2px 8px;
  border: 0;
}
.wsup-bubble.pending { opacity: .62; }
.wsup-bubble.failed { background: #FBE9E7 !important; color: #9C3A2E !important; border-color: #F2C9C2 !important; }
.wsup-who {
  font-size: 10.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #9A9186;
  margin-bottom: 3px;
}

/* ---------------- AI 回答 ---------------- */
/* AI 气泡加一枚小标：访客必须一眼看出「这句不是人说的」，
   否则真人接手后会以为客服已经承诺过某些事 */
.wsup-row.bot .wsup-bubble.bot { position: relative; padding-top: 16px; }
.wsup-bot-tag {
  position: absolute;
  top: 5px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 600 9px/1 var(--font-sans);
  letter-spacing: .08em;
  color: #7C8F86;
}
.wsup-bot-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7FA290;
  box-shadow: 0 0 0 2px rgba(127, 162, 144, .18);
}

/* ---------------- 快捷提问 ---------------- */
.wsup-quick {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 12px 10px;
  background: var(--wsup-bg);
}
.wsup-quick[hidden] { display: none; }
.wsup-chip {
  border: 1px solid #DCE6E1;
  background: #fff;
  color: var(--wsup-brand-deep);
  border-radius: 14px;
  padding: 6px 11px;
  font: 500 12px/1.25 var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background .18s, border-color .18s;
}
.wsup-chip:hover { background: #F1F6F3; border-color: #C6D8D0; }

/* ---------------- 转人工 ---------------- */
.wsup-human {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 12px 10px;
  padding: 8px 10px;
  border: 1px dashed #D5C9B8;
  border-radius: 12px;
  background: transparent;
  color: #7A6A55;
  font: 500 12px/1 var(--font-sans);
  cursor: pointer;
  transition: background .18s, border-color .18s;
}
.wsup-human[hidden] { display: none; }
.wsup-human:hover { background: #FBF6EE; border-color: #C9B99F; }
.wsup-human svg { width: 14px; height: 14px; flex: 0 0 auto; }
.wsup-human:disabled { opacity: .5; cursor: default; }

.wsup-typing {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 20px 8px;
  background: var(--wsup-bg);
}
.wsup-typing[hidden] { display: none; }
.wsup-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #B4BDB7;
  animation: wsup-bounce 1.1s infinite ease-in-out;
}
.wsup-typing span:nth-child(2) { animation-delay: .16s; }
.wsup-typing span:nth-child(3) { animation-delay: .32s; }
@keyframes wsup-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .55; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ---------------- 输入区 ---------------- */
.wsup-compose {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--wsup-line);
  background: #fff;
}
.wsup-compose[hidden] { display: none; }
.wsup-compose textarea {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 104px;
  padding: 10px 14px;
  border: 1px solid var(--wsup-line);
  border-radius: 20px;
  background: #FDFBF8;
  color: var(--wsup-ink);
  font: 400 13.8px/1.4 var(--font-sans);
  resize: none;
  outline: none;
  transition: border-color .2s, background .2s;
}
.wsup-compose textarea:focus { border-color: #9FB6AC; background: #fff; }
.wsup-send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--wsup-brand-deep);
  color: #fff;
  cursor: pointer;
  transition: transform .18s, opacity .18s;
}
.wsup-send svg { width: 18px; height: 18px; }
.wsup-send:hover { transform: scale(1.05); }
.wsup-send:disabled { opacity: .45; cursor: default; transform: none; }

/* ---------------- 离线留言 ---------------- */
.wsup-leave {
  flex: 0 1 auto;
  max-height: 66%;      /* 小屏时表单自身可滚动，不挤压底部提示 */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--wsup-line);
  background: #fff;
}
.wsup-leave[hidden] { display: none; }
.wsup-leave-note {
  margin: 0 0 2px;
  font-size: 12.4px;
  line-height: 1.5;
  color: #6E675E;
}
.wsup-leave input,
.wsup-leave textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--wsup-line);
  border-radius: 10px;
  background: #FDFBF8;
  color: var(--wsup-ink);
  font: 400 13.4px/1.45 var(--font-sans);
  outline: none;
  resize: none;
}
.wsup-leave input:focus,
.wsup-leave textarea:focus { border-color: #9FB6AC; background: #fff; }
.wsup-send-btn {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--wsup-brand-deep);
  color: #fff;
  font: 600 13.6px/1 var(--font-sans);
  cursor: pointer;
  transition: opacity .2s, transform .18s;
}
.wsup-send-btn:hover { opacity: .92; }
.wsup-send-btn:disabled { opacity: .5; cursor: default; }
.wsup-err {
  margin: 0;
  font-size: 12px;
  color: #9C3A2E;
}
.wsup-err[hidden] { display: none; }

.wsup-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 7px 16px 9px;
  background: #fff;
  border-top: 1px solid #F4EEE5;
  font-size: 10.8px;
  color: #9A9186;
}
.wsup-foot a { color: #547168; text-decoration: none; }
.wsup-foot a:hover { text-decoration: underline; }

/* 会话结束后「重新开始」按钮（嵌在系统提示气泡里） */
.wsup-again {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 16px;
  border: 1px solid #C9D6D0;
  border-radius: 16px;
  background: #fff;
  color: #3F5B52;
  font: 600 12.5px/1 var(--font-sans);
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.wsup-again:hover { background: #F4F8F6; border-color: #9FB6AC; }

.wsup-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------------- 移动端：全屏 ---------------- */
@media (max-width: 560px) {
  .wsup { right: 16px; bottom: 16px; }
  .wsup-launch { width: 54px; height: 54px; padding: 0; justify-content: center; border-radius: 50%; }
  .wsup-launch-text { display: none; }
  .wsup.is-open .wsup-launch { padding: 0; }
  .wsup-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    bottom: 0;
    animation: none;
  }
  .wsup-panel .wsup-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .wsup-foot { padding-bottom: max(9px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .wsup-launch, .wsup-panel, .wsup-typing span, .wsup-ping { animation: none !important; transition: none !important; }
}
