/* ── AI 智能客服悬浮窗 ── */
.cs-float {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  font-family: inherit;
}

/* 悬浮按钮 */
.cs-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1890ff;
  color: #fff;
  border: 0;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(11,134,255,.38);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform .25s ease, box-shadow .25s ease;
  position: relative;
}
.cs-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 36px rgba(11,134,255,.48);
}
.cs-btn svg { width: 26px; height: 26px; fill: currentColor; }
.cs-btn .cs-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0fba81;
  border: 2px solid #fff;
}

/* 聊天面板 */
.cs-panel {
  display: none;
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 600px;
  min-height: 520px;
  max-height: 520px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(18,92,174,.22);
  overflow: hidden;
  animation: csSlideUp .3s ease;
  border: 1px solid rgba(93,164,255,.22);
}
.cs-panel.open { display: flex; flex-direction: column; }

/* 面板头部 */
.cs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #1890ff;
  color: #fff;
  font-weight: 900;
  font-size: 15px;
}
.cs-header-close {
  background: rgba(255,255,255,.18);
  border: 0;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.cs-header-close:hover { background: rgba(255,255,255,.3); }

/* 头部右侧操作区（关闭按钮） */
.cs-header-actions { display: flex; align-items: center; gap: 6px; }

/* 打字机光标（AI 回复逐字显示时末尾闪烁） */
.cs-cursor {
  display: inline-block;
  margin-left: 1px;
  color: #1890ff;
  font-weight: 700;
  animation: csBlink 0.9s steps(1) infinite;
}
@keyframes csBlink { 50% { opacity: 0; } }

/* 消息列表 */
.cs-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100px;
  background: #f8fdff;
}

/* 消息气泡 */
.cs-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  animation: csMsgIn .28s ease;
}
/* 消息正文：pre-wrap 让 textContent 中的 \n 渲染为换行（恢复历史记录时格式不丢失） */
.cs-msg-content {
  white-space: pre-wrap;
}
.cs-msg.user {
  align-self: flex-end;
  background: #1890ff;
  color: #fff;
  border-bottom-right-radius: 6px;
}
.cs-msg.ai {
  align-self: flex-start;
  background: #e6f7ff;
  color: var(--ink);
  border: 1px solid rgba(93,164,255,.2);
  border-bottom-left-radius: 6px;
}
.cs-msg.ai .cs-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.cs-msg.ai .cs-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1890ff;
  animation: csBounce 1.2s infinite;
}
.cs-msg.ai .cs-typing span:nth-child(2) { animation-delay: .15s; }
.cs-msg.ai .cs-typing span:nth-child(3) { animation-delay: .3s; }

/* 输入区 */
.cs-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
}
.cs-input-row input {
  flex: 1;
  border: 1px solid rgba(93,164,255,.28);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  background: #e6f7ff;
  outline: none;
}
.cs-input-row input:focus { border-color: #1890ff; box-shadow: 0 0 0 3px rgba(11,134,255,.1); }
.cs-input-row button {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #1890ff;
  color: #fff;
  border: 0;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.cs-input-row button:hover { opacity: .85; }
.cs-input-row button:disabled { opacity: .5; cursor: not-allowed; }

/* 快捷导航板块（在聊天气泡区里，严格模仿 ai-integration 的 welcome 内 quick-nav 排列） */
.cs-quick-nav {
  margin: 6px 0 12px;
  padding: 12px;
  background: #f0f7ff;
  border: 1px solid rgba(93,164,255,.22);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center; /* 模仿 ai-integration：按钮整体居中排列 */
  gap: 8px;
}
.cs-quick-nav button {
  flex: 0 0 auto;
  width: fit-content;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #e0e0e0; /* 模仿 ai-integration：浅灰边框 */
  border-radius: 20px;       /* 药丸形 */
  color: #333;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  transition: all .2s ease;
}
.cs-quick-nav button:hover {
  background: #1890ff;       /* 模仿 ai-integration：hover 变实心蓝 */
  color: #fff;
  border-color: #1890ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(11,134,255,.3);
}

/* 底部栏（输入框上方）：清空聊天 + 输入框，模仿 ai-integration footer */
.cs-footer {
  border-top: 1px solid rgba(93,164,255,.18);
  background: #fff;
  padding: 8px 12px 10px;
}
.cs-footer-actions {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
/* 快捷导航按钮（底部栏左侧，模仿 ai-integration 的「快速导航」） */
.cs-quick-toggle {
  background: #e6f7ff;
  border: 1px solid rgba(93,164,255,.45);
  color: #2c6fb3;
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s ease;
}
.cs-quick-toggle:hover { background: #bae0ff; }
/* 清空聊天按钮（底部栏右侧） */
.cs-quick-clear {
  background: transparent;
  border: 1px solid rgba(93,164,255,.45);
  color: #3a78c2;
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s ease;
}
.cs-quick-clear:hover { background: rgba(24,144,255,.12); }

/* 动画 */
@keyframes csSlideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes csMsgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes csBounce { 0%,80%,100% { transform: scale(1); opacity: .4; } 40% { transform: scale(1.35); opacity: 1; } }

/* 移动端适配 */
@media (max-width: 640px) {
  .cs-float {
    bottom: 0;
    right: 0;
    left: 0;
  }
  .cs-btn {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1000;
  }
  /* 面板打开时隐藏悬浮按钮，避免和发送按钮重叠 */
  .cs-btn.hidden { display: none; }
  .cs-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    min-height: 80vh;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,.2);
  }
  .cs-quick-nav { gap: 8px; }
  .cs-quick-nav button {
    flex: 1 1 auto;
    min-width: 80px;
    font-size: 12px;
    padding: 7px 8px;
  }
  /* 移动端输入框：文字框占满，图片/发送按钮放大但间距正常不挤占 */
  .cs-input-row {
    gap: 8px;
    padding: 0;
  }
  .cs-input-row button[aria-label="发送"] {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
}
