/* ==========================================================================
   世宝恒盛 · 悬浮客服条（xd = xjsbhs dock）
   与 style.css 共用 :root 令牌，类名全部 xd- 前缀，不污染现有样式
   ========================================================================== */

/* ---------- 1. 悬浮条 ---------- */
.xd-dock {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 850;
  display: flex;
  flex-direction: column;
  background: var(--paper-2, #fff);
  border: 1px solid var(--line, #E4E2D9);
  border-right: 0;
  border-radius: 14px 0 0 14px;
  box-shadow: 0 2px 8px rgba(11, 21, 18, .06), 0 18px 44px rgba(11, 21, 18, .10);
  overflow: hidden;
  transition: box-shadow .2s ease;
}
.xd-dock:hover { box-shadow: 0 4px 14px rgba(11, 21, 18, .08), 0 24px 56px rgba(11, 21, 18, .14); }

.xd-dock-i {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-bottom: 1px solid var(--line, #E4E2D9);
  background: transparent;
  color: var(--text, #16211D);
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  width: 70px;
  padding: 11px 4px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  text-decoration: none;
  transition: background .18s ease, color .18s ease;
  overflow: hidden;
}
.xd-dock-i:last-child { border-bottom: 0; }
.xd-dock-i span { white-space: nowrap; }
.xd-dock-i:hover,
.xd-dock-i:focus-visible {
  background: var(--brand, #12A05C);
  color: #fff;
  outline: none;
}
.xd-dock-i svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.xd-dock-i.is-hot { color: var(--heat, #E2571E); }
.xd-dock-i.is-hot:hover { background: var(--heat, #E2571E); color: #fff; }

/* 未读红点（AI 有回复时提示） */
.xd-dot {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #E8342B;
  box-shadow: 0 0 0 2px #fff;
}
.xd-dock-i { position: relative; }

/* ---------- 2. 面板 ---------- */
.xd-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  width: 388px;
  height: min(608px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  background: var(--paper-2, #fff);
  border: 1px solid var(--line, #E4E2D9);
  border-radius: 18px;
  box-shadow: 0 4px 14px rgba(11, 21, 18, .08), 0 32px 70px rgba(11, 21, 18, .22);
  overflow: hidden;
  transform-origin: 100% 100%;
  animation: xdIn .22s cubic-bezier(.22, .61, .36, 1);
}
@keyframes xdIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.xd-panel[hidden] { display: none; }

/* 头部 */
.xd-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  background: var(--ink, #0B1512);
  color: #fff;
  flex: none;
}
.xd-hd-t { flex: 1; min-width: 0; }
.xd-hd-t b {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
}
.xd-hd-t span {
  display: block;
  font-size: 11.5px;
  opacity: .62;
  line-height: 1.5;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xd-x {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  flex: none;
  transition: background .18s ease;
}
.xd-x:hover { background: rgba(255, 255, 255, .24); }

/* 视图容器 */
.xd-bd { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.xd-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.xd-view[hidden] { display: none; }

/* ---------- 3. 对话区 ---------- */
.xd-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 6px;
  background: var(--paper, #F7F6F1);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.xd-m {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.66;
  white-space: pre-wrap;
  word-break: break-word;
}
.xd-m-bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line, #E4E2D9);
  border-bottom-left-radius: 4px;
  color: var(--text, #16211D);
}
.xd-m-me {
  align-self: flex-end;
  background: var(--brand, #12A05C);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.xd-m-sys {
  align-self: center;
  background: transparent;
  border: 1px dashed var(--line, #E4E2D9);
  color: var(--muted, #5F6D66);
  font-size: 12px;
  padding: 6px 12px;
  max-width: 100%;
  text-align: center;
}
.xd-m a { color: var(--brand-2, #0C7B45); text-decoration: underline; }
.xd-m-me a { color: #fff; }

/* 正在输入 */
.xd-typing { display: inline-flex; gap: 3px; align-items: center; height: 16px; }
.xd-typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted, #5F6D66); opacity: .35;
  animation: xdBounce 1.1s infinite;
}
.xd-typing i:nth-child(2) { animation-delay: .16s; }
.xd-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes xdBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-3px); opacity: .9; }
}

/* 快捷问题 */
.xd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  flex: none;
  background: var(--paper, #F7F6F1);
  scrollbar-width: none;
}
.xd-chips button {
  appearance: none;
  flex: none;
  border: 1px solid var(--line, #E4E2D9);
  background: #fff;
  color: var(--text, #16211D);
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .16s ease, color .16s ease;
}
.xd-chips button:hover { border-color: var(--brand, #12A05C); color: var(--brand-2, #0C7B45); }

/* 输入区 */
.xd-in {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line, #E4E2D9);
  background: #fff;
  flex: none;
  align-items: flex-end;
}
.xd-in textarea {
  flex: 1;
  min-height: 42px;
  max-height: 108px;
  resize: none;
  border: 1px solid var(--line, #E4E2D9);
  border-radius: 10px;
  padding: 10px 11px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text, #16211D);
  background: var(--paper, #F7F6F1);
  outline: none;
  transition: border-color .16s ease, background .16s ease;
}
.xd-in textarea:focus { border-color: var(--brand, #12A05C); background: #fff; }
.xd-send {
  appearance: none;
  border: 0;
  background: var(--brand, #12A05C);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  cursor: pointer;
  flex: none;
  transition: background .16s ease, opacity .16s ease;
}
.xd-send:hover { background: var(--brand-2, #0C7B45); }
.xd-send:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 4. 表单 ---------- */
.xd-form { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 11px; }
.xd-lead { font-size: 12.5px; color: var(--muted, #5F6D66); line-height: 1.7; margin: 0 0 2px; }
.xd-f { display: flex; flex-direction: column; gap: 5px; }
.xd-f label { font-size: 12.5px; color: var(--muted, #5F6D66); font-weight: 600; }
.xd-f input, .xd-f textarea {
  border: 1px solid var(--line, #E4E2D9);
  border-radius: 9px;
  padding: 10px 11px;
  font: inherit;
  font-size: 14px;
  color: var(--text, #16211D);
  background: var(--paper, #F7F6F1);
  outline: none;
  transition: border-color .16s ease, background .16s ease;
  width: 100%;
}
.xd-f input:focus, .xd-f textarea:focus { border-color: var(--brand, #12A05C); background: #fff; }
.xd-f textarea { resize: vertical; min-height: 78px; line-height: 1.6; }
.xd-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.xd-sub {
  appearance: none;
  border: 0;
  background: var(--brand, #12A05C);
  color: #fff;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .16s ease, opacity .16s ease;
  margin-top: 2px;
}
.xd-sub:hover { background: var(--brand-2, #0C7B45); }
.xd-sub:disabled { opacity: .5; cursor: not-allowed; }
.xd-err { color: #C0392B; font-size: 12.5px; min-height: 1em; }
.xd-ok { text-align: center; padding: 34px 20px; }
.xd-ok-ico {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--brand-soft, #E8F5EE); color: var(--brand, #12A05C);
  display: grid; place-items: center; margin: 0 auto 12px;
}
.xd-ok-ico svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.xd-ok h4 { font-size: 16px; margin: 0 0 6px; }
.xd-ok p { font-size: 13px; color: var(--muted, #5F6D66); line-height: 1.7; margin: 0; }

/* ---------- 5. 电话卡 ---------- */
.xd-call { padding: 18px 16px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.xd-call-a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line, #E4E2D9);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text, #16211D);
  background: var(--paper, #F7F6F1);
  transition: border-color .16s ease, background .16s ease;
}
.xd-call-a:hover { border-color: var(--brand, #12A05C); background: #fff; }
.xd-call-a svg { width: 24px; height: 24px; stroke: var(--brand, #12A05C); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.xd-call-a b { display: block; font-size: 17px; letter-spacing: .01em; font-family: var(--mono, monospace); }
.xd-call-a span { display: block; font-size: 12px; color: var(--muted, #5F6D66); margin-top: 1px; }
.xd-call-note { font-size: 12.5px; color: var(--muted, #5F6D66); line-height: 1.75; margin: 4px 0 0; }

/* ---------- 6. 移动端：底部横条 ---------- */
@media (max-width: 900px) {
  .xd-dock {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    flex-direction: row;
    border: 0;
    border-top: 1px solid var(--line, #E4E2D9);
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 12px rgba(11, 21, 18, .07);
  }
  .xd-dock-i {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    border-bottom: 0;
    border-right: 1px solid var(--line, #E4E2D9);
    padding: 8px 2px 9px;
    font-size: 11.5px;
    gap: 3px;
  }
  .xd-dock-i span { white-space: nowrap; }
  .xd-dock-i:last-child { border-right: 0; }
  .xd-dock-i svg { width: 20px; height: 20px; }
  .xd-dot { top: 6px; right: calc(50% - 16px); }

  .xd-panel {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
    animation: xdUp .24s cubic-bezier(.22, .61, .36, 1);
  }
  @keyframes xdUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
  .xd-hd { padding-top: calc(13px + env(safe-area-inset-top, 0)); }
  .xd-in { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0)); }
  body.xd-open { overflow: hidden; }
}

/* ---------- 7. 减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .xd-panel, .xd-typing i { animation: none !important; }
  .xd-msgs { scroll-behavior: auto; }
}
