/* 在线咨询（AI 聊天体验官，2026-10-31）
   规格对齐接口文档 §5：桌面 56px 气泡 + 360×560 面板；移动端全宽底部抽屉 70vh。
   全部类名带 xzc- 前缀，不碰站点自有样式；z-index 高于前台所有层（弹窗除外）。 */
#xz-chat { position: fixed; right: 20px; bottom: 20px; z-index: 9990; font-family: inherit; }
#xz-chat[hidden] { display: none; }

/* hidden 属性必须显式生效：.xzc-panel 的 display:flex 会压过 hidden 的 UA 默认
   display:none，导致点 × 关闭后面板仍可见（2026-10-31 生产反馈）。 */
#xz-chat [hidden] { display: none !important; }

/* 气泡 */
.xzc-bubble {
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff;
  box-shadow: 0 6px 20px rgba(79, 70, 229, .38);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, box-shadow .15s ease;
}
.xzc-bubble:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(79, 70, 229, .45); }
.xzc-bubble .xzc-dot {
  position: absolute; top: 2px; right: 2px; width: 10px; height: 10px;
  border-radius: 50%; background: #ef4444; border: 2px solid #fff;
}

/* 弹窗遮罩：只在移动端抽屉形态出现。桌面是 360px 悬浮聊天面板，属于常驻
   辅助工具而非全屏模态；若桌面显示遮罩，会压暗正文并拦截输入点击。
   默认态必须由共享层完整定义：display:none + pointer-events:none，
   ≤768px 断点再显式开启。 */
.xzc-mask {
  position: fixed; inset: 0; z-index: -1;
  display: none;
  pointer-events: none;
  background: var(--xz-chat-mask, rgba(0, 0, 0, .45));
  cursor: pointer;
}
.xzc-mask[hidden] { display: none !important; }

/* 面板 */
.xzc-panel {
  width: 360px; height: 560px; max-height: 70vh;
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 12px 48px rgba(15, 23, 42, .22);
  display: flex; flex-direction: column;
}
/* 头部/联系顾问条：本身不滚，touch-action:none 让按在这里的拖拽不再带动整页
   （消息区用 pan-y 保住自身滚动，两者互不影响）。 */
.xzc-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; flex: none;
  touch-action: none;
}
.xzc-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.xzc-headtxt { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.xzc-headtxt strong { font-size: 14px; }
.xzc-status { font-size: 11px; opacity: .92; display: flex; align-items: center; gap: 4px; }
.xzc-status i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; transition: background .2s ease; }
/* 离线：圆点转红（真实状态由后端探活/发送成败决定，见 chat-widget.js） */
.xzc-status.is-offline i { background: #f04438; }
.xzc-status.is-offline { opacity: 1; }
.xzc-close {
  border: none; background: rgba(255,255,255,.16); color: #fff; width: 28px; height: 28px;
  border-radius: 8px; font-size: 18px; line-height: 1; cursor: pointer;
}
.xzc-close:hover { background: rgba(255,255,255,.3); }
.xzc-clear {
  border: none; background: rgba(255,255,255,.16); color: #fff; height: 28px;
  border-radius: 8px; font-size: 12px; padding: 0 8px; cursor: pointer; white-space: nowrap;
}
.xzc-clear:hover { background: rgba(255,255,255,.3); }

/* 联系顾问与查询工单：联系信息由数据库决定，查询入口由当前业务线决定。
   上下各留 10px：按钮不贴消息区，也不贴输入框分隔线（2026-11-01 反馈）。 */
.xzc-actions { padding: 10px 12px; background: #fff; flex: none; touch-action: none; display: flex; gap: 8px; flex-wrap: wrap; }
.xzc-contact {
  border: 1px solid #c7d2fe; background: #eef2ff; color: #4338ca;
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer;
}
.xzc-contact:hover { background: #e0e7ff; }

/* 消息流
   滚动闸门（2026-11-09 AF 批，机制层，全站生效）：
   - overscroll-behavior: contain 切断「内层滚到顶/到底 → 滚动链交给整页」；
   - touch-action: pan-y 让手势被消息区独占（横向平移/双指缩放不在这里起手）；
   两者都缺时，手机上在抽屉里划一下会把整页推走（生产反馈的「穿透」成因之二）。 */
.xzc-msgs {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  padding: 12px; background: #f6f7fb; display: flex; flex-direction: column; gap: 10px;
}
/* 「加载更早」提示条：由 chat-widget.js 注入在消息区最上方，纯文字、无动画。
   颜色复用本文件 .xzc-msg.sys 的灰阶口径，不写品牌色（租户皮肤不依赖它）。 */
.xzc-loader {
  align-self: center; font-size: 12px; line-height: 1.5; color: #94a3b8;
  padding: 2px 0; white-space: nowrap;
}
.xzc-loader[hidden] { display: none; }
.xzc-msg { max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.xzc-msg.bot { background: #fff; color: #1f2937; border: 1px solid #e8eaf2; align-self: flex-start; border-top-left-radius: 4px; }
.xzc-msg.me { background: #4f46e5; color: #fff; align-self: flex-end; border-top-right-radius: 4px; }
.xzc-msg.sys { background: transparent; color: #94a3b8; font-size: 12px; align-self: center; text-align: center; }
.xzc-msg.typing { display: flex; align-items: center; gap: 4px; padding: 13px 14px; }
.xzc-msg.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #a5b4fc;
  animation: xzc-bounce 1.2s infinite ease-in-out;
}
.xzc-msg.typing span:nth-child(2) { animation-delay: .2s; }
.xzc-msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes xzc-bounce {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}
.xzc-status.is-typing i { animation: xzc-pulse 1s infinite ease-in-out; }
@keyframes xzc-pulse { 50% { opacity: .3; } }

/* 输入区 */
/* 输入区
   这里刻意不写 touch-action：它会沿祖先向下取交集，一旦给行加 none，
   输入框（max-height 96px，长文本可内滚）就没法用手指滚动了。
   抽屉打开时整页已被 html.xzc-lock 锁住，缝隙处带动页面的风险由那条兜住。 */
.xzc-inputrow { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #eceef5; background: #fff; flex: none; align-items: flex-end; }
#xzChatText {
  flex: 1; min-height: 38px; max-height: 96px; resize: none; border: 1px solid #dfe3ee;
  border-radius: 10px; padding: 8px 10px; font-size: 13.5px; font-family: inherit; line-height: 1.5;
}
#xzChatText:focus { outline: none; border-color: #6366f1; }
.xzc-send {
  border: none; border-radius: 10px; padding: 9px 14px; cursor: pointer;
  background: #4f46e5; color: #fff; font-size: 13px;
}
.xzc-send:disabled { background: #c7cbe8; cursor: default; }

/* 移动端：全宽底部抽屉（规格 §5） */
@media (max-width: 768px) {
  #xz-chat { right: 12px; bottom: 12px; left: auto; }
  .xzc-bubble { width: 48px; height: 48px; }
  .xzc-bubble svg { width: 22px; height: 22px; }
  .xzc-mask:not([hidden]) {
    display: block;
    pointer-events: auto;
  }
  .xzc-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; height: 70vh; max-height: none;
    border-radius: 12px 12px 0 0;
  }
  /* 抽屉打开时锁整页：html.xzc-lock 由 chat-widget.js 在 open/close 时挂/摘，
     且只在 ≤768 断点内生效（桌面是 360px 悬浮面板，不加类、零变化）。
     这是穿透的最后一道闸门：即便 overscroll/touch-action 在个别安卓 WebView 上判不准，
     页面也滚不动。滚动位置由浏览器保留，关闭后回到原处（不用 position:fixed，
     那会和站内锚点、回顶火箭打架）。 */
  html.xzc-lock body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .xzc-bubble, .xzc-panel { transition: none; }
  .xzc-msg.typing span, .xzc-status.is-typing i { animation: none; }
}
