/* 八禧达官网 · AI 客服挂件样式
   取自站点 tech.css 的同一套设计令牌（深色 #0b0e13 / 文字 #14181f / 强调 #c8102e），
   保证挂件与官网是同一个视觉体系，而不是外挂一个第三方聊天框。 */

.bxchat {
  --c-ink: #14181f;
  --c-mut: #5b6472;
  --c-line: #e4e8ee;
  --c-dark: #0b0e13;
  --c-red: #c8102e;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  font-family: inherit;
}

/* ── 悬浮按钮 ─────────────────────────────────────────────────────────── */
/* 默认用品牌红而不是深色：官网首屏与页脚都是近黑的 #0b0e13，
   深色按钮压在上面几乎看不见（只剩白色图标），红色在深底和浅底都清楚。 */
.bxchat-launch {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--c-red);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(11, 14, 19, .34), 0 0 0 3px rgba(255, 255, 255, .16);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.bxchat-launch:hover { transform: translateY(-2px); background: #a90d27; box-shadow: 0 14px 34px rgba(11, 14, 19, .42), 0 0 0 3px rgba(255, 255, 255, .22); }
.bxchat-launch svg { width: 24px; height: 24px; fill: currentColor; }
/* 展开后转深色，兼作「点这里收起」的状态提示 */
.bxchat.is-open .bxchat-launch { background: var(--c-dark); }

/* ── 面板 ─────────────────────────────────────────────────────────────── */
.bxchat-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 360px;
  max-height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(11, 14, 19, .26);
}
.bxchat-panel[hidden] { display: none; }
/* ⚠️ 作者样式里的 display 会盖掉浏览器对 [hidden] 的 display:none。
   .bxchat-form/.bxchat-lead 都显式设了 display，所以必须逐个补 [hidden] 规则，
   否则「转人工」表单和聊天输入框会同时显示（实测踩过）。 */
.bxchat-form[hidden], .bxchat-lead[hidden], .bxchat-foot[hidden] { display: none; }

.bxchat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: var(--c-dark);
  color: #fff;
}
.bxchat-head strong { display: block; font-size: .96rem; font-weight: 600; line-height: 1.3; }
.bxchat-head span { display: block; font-size: .74rem; opacity: .66; margin-top: 2px; }
.bxchat-x {
  border: 0; background: transparent; color: #fff; opacity: .7;
  font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 4px;
}
.bxchat-x:hover { opacity: 1; }

/* ── 消息区 ───────────────────────────────────────────────────────────── */
.bxchat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f8fa;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* min-height 必须是 0：flex 子项默认 min-height:auto 会拒绝收缩，
     内容一多就把面板撑破、顶部消息被裁掉。 */
  min-height: 0;
}
.bxchat-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: .875rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.bxchat-bot { align-self: flex-start; background: #fff; border: 1px solid var(--c-line); color: var(--c-ink); border-bottom-left-radius: 4px; }
.bxchat-user { align-self: flex-end; background: var(--c-dark); color: #fff; border-bottom-right-radius: 4px; }

.bxchat-typing { display: flex; gap: 4px; align-items: center; padding: 13px; }
.bxchat-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #b9c0cb; display: block;
  animation: bxchat-blink 1.2s infinite ease-in-out;
}
.bxchat-typing i:nth-child(2) { animation-delay: .18s; }
.bxchat-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes bxchat-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ── 输入 ─────────────────────────────────────────────────────────────── */
.bxchat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px 8px;
  background: #fff;
  border-top: 1px solid var(--c-line);
}
.bxchat-in {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--c-line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: .875rem;
  color: var(--c-ink);
}
.bxchat-in:focus { outline: 2px solid rgba(200, 16, 46, .28); outline-offset: 1px; border-color: var(--c-red); }
.bxchat-send {
  border: 0; border-radius: 8px; background: var(--c-red); color: #fff;
  padding: 0 16px; font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer;
}
.bxchat-send:hover { background: #a90d27; }

.bxchat-foot { padding: 0 14px 12px; background: #fff; }
.bxchat-agent {
  width: 100%; border: 1px solid var(--c-line); background: #fff; color: var(--c-mut);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: .8rem; cursor: pointer;
}
.bxchat-agent:hover { border-color: var(--c-red); color: var(--c-red); }

/* ── 转人工表单 ───────────────────────────────────────────────────────── */
.bxchat-lead { padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #fff; }
.bxchat-lead h4 { margin: 0 0 2px; font-size: .92rem; color: var(--c-ink); }
.bxchat-lead input, .bxchat-lead textarea {
  border: 1px solid var(--c-line); border-radius: 8px; padding: 9px 11px;
  font: inherit; font-size: .84rem; color: var(--c-ink); resize: vertical;
}
.bxchat-lead input:focus, .bxchat-lead textarea:focus { outline: 2px solid rgba(200, 16, 46, .28); border-color: var(--c-red); }
.bxchat-leadbtns { display: flex; gap: 8px; align-items: center; }
.bxchat-leadbtns button[type=submit] {
  flex: 1; border: 0; border-radius: 8px; background: var(--c-red); color: #fff;
  padding: 10px; font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer;
}
.bxchat-leadbtns button[type=submit]:disabled { opacity: .6; cursor: default; }
.bxchat-back { border: 0; background: transparent; color: var(--c-mut); font: inherit; font-size: .8rem; cursor: pointer; }
.bxchat-ok { margin: 6px 0; font-size: .88rem; line-height: 1.7; color: var(--c-ink); }

/* ── 窄屏：铺满可用宽度 ───────────────────────────────────────────────── */
@media (max-width: 520px) {
  .bxchat { right: 12px; bottom: 12px; }
  .bxchat-panel {
    position: fixed;
    left: 12px; right: 12px; bottom: 80px;
    width: auto;
    max-height: calc(100vh - 110px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .bxchat-launch, .bxchat-typing i { transition: none; animation: none; }
}

/* ══════════════════════════════════════════════════════════════════════
   内嵌模式（报价页：上面表单、下面 AI 对话）
   页面里放 <div id="bxChatInline"></div> 即生效；此时不生成悬浮按钮，面板常显。
   ══════════════════════════════════════════════════════════════════════ */
.bxchat--inline {
  position: static;
  right: auto;
  bottom: auto;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}
.bxchat--inline .bxchat-panel {
  position: static;
  right: auto;
  bottom: auto;
  width: 100%;
  max-height: none;
  height: 520px;
  box-shadow: 0 10px 30px rgba(11, 14, 19, .10);
}
@media (max-width: 640px) {
  .bxchat--inline .bxchat-panel { height: 460px; }
}
