/* ============================================================
   效优仪器 · 官网在线咨询（悬浮聊天窗口）
   仅使用站点 CSS 变量，自动跟随 html[data-theme="dark"] 深浅主题
   命名统一 xy- 前缀，避免与站点样式冲突
   ============================================================ */

/* ---------- 悬浮按钮 ---------- */
.xy-chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 3000;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 32px rgba(0, 158, 138, 0.38), 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.xy-chat-fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 18px 42px rgba(0, 158, 138, 0.46); }
.xy-chat-fab:active { transform: scale(0.96); }
.xy-chat-fab svg { width: 26px; height: 26px; pointer-events: none; }
.xy-chat-fab .xy-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #28c76f;
  border: 2px solid var(--bg);
  animation: xy-pulse 2.4s ease-in-out infinite;
}
@keyframes xy-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ---------- 面板 ---------- */
.xy-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 94px;
  z-index: 3000;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100dvh - 130px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--txt);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.24s var(--ease), transform 0.24s var(--ease);
}
.xy-chat-panel.xy-open { opacity: 1; pointer-events: auto; transform: none; }

/* ---------- 头部 ---------- */
.xy-chat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 15px;
  background: var(--grad);
  color: #fff;
  flex: none;
}
.xy-chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.xy-chat-avatar svg { width: 18px; height: 18px; }
.xy-chat-title { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.xy-chat-sub { font-size: 11.5px; opacity: 0.88; display: flex; align-items: center; gap: 5px; margin-top: 1px; }
.xy-chat-sub::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #7dffc4; box-shadow: 0 0 6px #7dffc4; }
.xy-chat-close {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.16);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex: none;
}
.xy-chat-close:hover { background: rgba(255, 255, 255, 0.32); }

/* ---------- 消息区 ---------- */
.xy-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 15px 13px 6px;
  background: var(--bg);
  overscroll-behavior: contain;
}
.xy-chat-body::-webkit-scrollbar { width: 5px; }
.xy-chat-body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
.xy-msg { display: flex; margin-bottom: 11px; animation: xy-in 0.26s var(--ease); }
@keyframes xy-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.xy-msg.bot { justify-content: flex-start; }
.xy-msg.user { justify-content: flex-end; }
.xy-bubble {
  max-width: 84%;
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.62;
  border-radius: 14px;
  word-break: break-word;
  white-space: pre-wrap;
}
.xy-msg.bot .xy-bubble {
  background: var(--panel);
  color: var(--txt);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.xy-msg.user .xy-bubble { background: var(--cy); color: #fff; border-bottom-right-radius: 5px; }
.xy-msg.bot .xy-bubble b { color: var(--cy); font-weight: 700; }
.xy-typing { display: inline-flex; gap: 4px; align-items: center; padding: 3px 1px; }
.xy-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dimmer); animation: xy-bounce 1.2s infinite; }
.xy-typing i:nth-child(2) { animation-delay: 0.15s; }
.xy-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes xy-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- 快捷问题 ---------- */
.xy-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 2px 13px 10px;
  background: var(--bg);
  flex: none;
}
.xy-chip {
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--dim);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
.xy-chip:hover { border-color: var(--cy); color: var(--cy); background: var(--panel-2); }

/* ---------- 输入区 ---------- */
.xy-chat-foot {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex: none;
}
.xy-chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--txt);
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.xy-chat-input::placeholder { color: var(--dimmer); }
.xy-chat-input:focus { border-color: var(--cy); }
.xy-chat-send {
  flex: none;
  border: none;
  background: var(--cy);
  color: #fff;
  border-radius: 11px;
  padding: 0 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.2s, transform 0.12s;
}
.xy-chat-send:hover { filter: brightness(1.08); }
.xy-chat-send:active { transform: scale(0.96); }

/* ---------- 留资表单视图 ---------- */
.xy-form {
  display: none;
  flex-direction: column;
  gap: 9px;
  padding: 15px 14px;
  background: var(--bg);
  flex: 1;
  overflow-y: auto;
}
.xy-form.xy-show { display: flex; }
.xy-form h4 { font-size: 14.5px; color: var(--txt); margin-bottom: 1px; }
.xy-form .xy-form-desc { font-size: 12px; color: var(--dim); line-height: 1.55; margin-bottom: 3px; }
.xy-form label { font-size: 11.5px; color: var(--dim); letter-spacing: 0.04em; margin-top: 2px; }
.xy-form input,
.xy-form textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--txt);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.xy-form textarea { min-height: 58px; resize: vertical; }
.xy-form input:focus,
.xy-form textarea:focus { border-color: var(--cy); }
.xy-form-actions { display: flex; gap: 8px; margin-top: 5px; }
.xy-btn-ghost {
  flex: 1;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--dim);
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.xy-btn-primary {
  flex: 1.5;
  border: none;
  background: var(--grad);
  color: #fff;
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.xy-btn-primary:disabled { opacity: 0.6; cursor: default; }
.xy-form-tip { font-size: 11px; color: var(--dimmer); line-height: 1.5; }

/* ---------- 移动端：全屏 ---------- */
@media (max-width: 560px) {
  .xy-chat-fab { right: 16px; bottom: 16px; width: 54px; height: 54px; }
  .xy-chat-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    transform-origin: bottom center;
  }
}
