/* ============================================================
   淼来 / ChronoTec AI 客服组件  —  暖白主题（与主站统一）
   嵌入方式：<link rel="stylesheet" href="/ai-chat/chat-widget.css">
            <script src="/ai-chat/chat-widget.js" defer></script>
   ============================================================ */

:root {
  --cb-bg: #FAF7F2;
  --cb-card: #FFFFFF;
  --cb-beige: #F3EDE4;
  --cb-text: #3A322B;
  --cb-muted: #8A7F74;
  --cb-line: #EAE2D8;
  --cb-accent: #C8864A;      /* 暖橙，友好引导色 */
  --cb-accent-2: #E8A87C;
  --cb-green: #6E9E62;       /* 初级款色 */
  --cb-radius: 16px;
  --cb-shadow: 0 12px 40px rgba(58, 50, 43, 0.18);
  --cb-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* 浮动客服头像按钮 */
.cb-avatar {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-accent-2), var(--cb-accent));
  box-shadow: var(--cb-shadow);
  cursor: pointer;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #fff;
  transition: transform .2s ease, box-shadow .2s ease;
}
.cb-avatar:hover { transform: scale(1.06); }
.cb-avatar svg { width: 32px; height: 32px; }
.cb-avatar .cb-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 16px; height: 16px;
  background: #e0533d; border-radius: 50%;
  border: 2px solid #fff;
}
.cb-avatar.cb-hidden { display: none; }

/* 对话面板 */
.cb-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 48px);
  background: var(--cb-bg);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--cb-font);
  color: var(--cb-text);
  transform: translateY(20px) scale(.98);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s ease, opacity .22s ease;
}
.cb-panel.cb-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* 面板头部 */
.cb-header {
  background: linear-gradient(135deg, var(--cb-accent-2), var(--cb-accent));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.cb-header .cb-logo {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
}
.cb-header .cb-logo svg { width: 22px; height: 22px; }
.cb-header .cb-title { font-size: 15px; font-weight: 600; line-height: 1.2; }
.cb-header .cb-sub { font-size: 11px; opacity: .9; margin-top: 2px; }
.cb-header .cb-close {
  margin-left: auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: none; color: #fff;
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
.cb-header .cb-close:hover { background: rgba(255,255,255,.3); }

/* 消息区 */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--cb-bg);
}
.cb-msg { display: flex; gap: 8px; max-width: 100%; }
.cb-msg .cb-ava {
  width: 30px; height: 30px; border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.cb-msg.cb-bot .cb-ava { background: var(--cb-accent); color: #fff; }
.cb-msg.cb-user { flex-direction: row-reverse; }
.cb-msg.cb-user .cb-ava { background: var(--cb-beige); color: var(--cb-accent); }

/* bot 消息内容区：纵向排列，bubble + chips 垂直堆叠 */
.cb-msg.cb-bot .cb-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.cb-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  max-width: 100%;
  word-break: break-word;
  white-space: pre-wrap;
}
.cb-bot .cb-bubble {
  background: var(--cb-card);
  border: 1px solid var(--cb-line);
  border-top-left-radius: 4px;
}
.cb-user .cb-bubble {
  background: linear-gradient(135deg, var(--cb-accent-2), var(--cb-accent));
  color: #fff;
  border-top-right-radius: 4px;
}

/* 知识点引导气泡 — 始终在回复正文下方独立一行 */
.cb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}
.cb-chip {
  background: #fff;
  border: 1px solid var(--cb-accent);
  color: var(--cb-accent);
  border-radius: 16px;
  padding: 5px 11px;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  font-family: var(--cb-font);
}
.cb-chip:hover { background: var(--cb-accent); color: #fff; }
.cb-chip:active { transform: scale(.96); }

/* 回复中的图片（安装示意图 / 二维码等） */
.cb-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.cb-img {
  display: block;
  width: 132px;
  height: 96px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--cb-line);
  background: #fff;
  transition: border-color .15s ease, transform .15s ease;
}
.cb-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cb-img:hover { border-color: var(--cb-accent); transform: translateY(-1px); }

/* 输入区 */
.cb-inputbar {
  flex-shrink: 0;
  border-top: 1px solid var(--cb-line);
  background: var(--cb-card);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.cb-inputbar textarea {
  flex: 1;
  border: 1px solid var(--cb-line);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--cb-font);
  resize: none;
  max-height: 96px;
  outline: none;
  color: var(--cb-text);
  background: var(--cb-bg);
}
.cb-inputbar textarea:focus { border-color: var(--cb-accent); }
.cb-send {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--cb-accent);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.cb-send:disabled { opacity: .5; cursor: default; }
.cb-send svg { width: 20px; height: 20px; }

.cb-typing { font-size: 12px; color: var(--cb-muted); padding: 2px 4px; }

/* 移动端 */
@media (max-width: 480px) {
  .cb-panel {
    right: 0; left: 0; bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 82vh;
    max-height: 82vh;
    border-radius: 18px 18px 0 0;
  }
  .cb-avatar { right: 16px; bottom: 16px; }
}
