/* 商企亿脉 AI 助手 - H5 对话页面样式（适配移动端 / 小程序 web-view） */
:root {
  --brand: #4f6ef7;
  --brand-2: #6a5cf7;
  --brand-grad: linear-gradient(135deg, #4f6ef7, #6a5cf7);
  --bg: #f5f6fa;
  --text: #333;
  --text-sub: #889;
  --bubble-user-grad: linear-gradient(135deg, #4f6ef7, #6a5cf7);
  --shadow: 0 2px 10px rgba(79, 110, 247, 0.12);
  --shadow-lg: 0 10px 30px rgba(79, 110, 247, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* 头部 */
.chat-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 14px;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 2px 12px rgba(79, 110, 247, 0.35);
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-size: 18px;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}
.brand-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.online-dot {
  font-size: 10px;
  font-weight: 400;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.online-dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #5cf2a0;
  box-shadow: 0 0 0 2px rgba(92, 242, 160, 0.4);
}
.brand-sub { font-size: 11px; opacity: 0.85; }
.header-clear {
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 14px;
  cursor: pointer;
}

/* 消息区 */
.msg-list {
  padding: 68px 12px 150px;
  overflow-y: auto;
  height: 100vh;
}

/* 欢迎卡 */
.welcome-card {
  background: #fff;
  border: 1px solid #eef0f6;
  border-radius: 14px;
  padding: 14px 14px 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  animation: fadeInUp 0.4s ease;
}
.welcome-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.welcome-text { font-size: 13px; line-height: 1.7; color: #555; }

.msg { display: flex; margin-bottom: 12px; animation: fadeInUp 0.3s ease; }
.msg-user { justify-content: flex-end; }
.msg-ai { justify-content: flex-start; }
.bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-ai .bubble {
  background: var(--bubble-ai, #fff);
  border: 1px solid #eee;
  border-top-left-radius: 4px;
  box-shadow: var(--shadow);
}
.msg-user .bubble {
  background: var(--bubble-user-grad);
  color: #fff;
  border-top-right-radius: 4px;
  box-shadow: var(--shadow);
}

/* 打字机光标 */
.bubble.typing::after {
  content: "▍";
  color: var(--brand);
  animation: blink 1s step-start infinite;
}

/* AI 消息的 Markdown 渲染样式 */
.msg-ai .bubble.md { white-space: normal; }
.bubble.md p { margin: 0 0 6px; }
.bubble.md p:last-child { margin-bottom: 0; }
.bubble.md ul,
.bubble.md ol { margin: 4px 0 6px; padding-left: 18px; }
.bubble.md li { margin-bottom: 3px; }
.bubble.md strong { font-weight: 600; }
.bubble.md a { color: var(--brand); text-decoration: underline; }
.bubble.md h1,
.bubble.md h2,
.bubble.md h3,
.bubble.md h4 { margin: 6px 0; font-size: 15px; }
.bubble.md code {
  background: #f0f0f0;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 12px;
}

/* 推荐问题 */
.quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.q-chip {
  padding: 7px 12px;
  font-size: 13px;
  color: var(--brand);
  background: #eef1ff;
  border: 1px solid #d6ddff;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.q-chip:active { transform: scale(0.96); background: #e0e6ff; }
.q-chip:hover { background: #e4e9ff; }

/* 快捷联系条 */
.contact-strip {
  position: fixed;
  bottom: 58px; left: 0; right: 0;
  z-index: 9;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(to top, var(--bg), rgba(245, 246, 250, 0));
}
.contact-btn {
  flex: 1;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--brand);
  background: #fff;
  border: 1px solid #d6ddff;
  border-radius: 18px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.contact-btn:active { transform: scale(0.97); }

/* 输入区 */
.chat-input-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #eee;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
}
.chat-input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
.chat-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12); }
.send-btn {
  height: 38px;
  padding: 0 18px;
  border: none;
  border-radius: 20px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.send-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.send-btn:not(:disabled):active { transform: scale(0.96); }

/* 留资弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  animation: fadeIn 0.2s ease;
}
.modal {
  width: 84%;
  max-width: 360px;
  padding: 22px 18px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.25s ease;
}
.modal-icon { font-size: 30px; text-align: center; margin-bottom: 6px; }
.modal h3 { font-size: 17px; text-align: center; margin-bottom: 4px; }
.modal-tip { font-size: 12px; color: var(--text-sub); text-align: center; margin-bottom: 14px; }
.lead-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
.lead-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12); }
.lead-textarea { height: 68px; padding-top: 10px; resize: none; }
.lead-submit {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.lead-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.lead-close {
  width: 100%;
  height: 36px;
  margin-top: 8px;
  border: none;
  background: none;
  color: #999;
  font-size: 13px;
  cursor: pointer;
}

/* 留资成功态 */
.lead-success { text-align: center; padding: 8px 0; }
.success-icon { font-size: 40px; margin-bottom: 8px; }
.lead-success h3 { margin-bottom: 6px; }
.lead-success p { font-size: 13px; color: #666; line-height: 1.7; margin-bottom: 16px; }

/* 轻提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%) translateY(10px);
  z-index: 30;
  padding: 9px 16px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 13px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 动画 */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes blink {
  50% { opacity: 0; }
}