/* Crysound 咨询机器人 · 前端样式（v2.5 历史定稿恢复） */
:root {
  --cfb-bg: #fff;
  --cfb-text: #1f2937;
  --cfb-text-soft: #6b7280;
  --cfb-border: #e5e7eb;
  --cfb-radius: 16px;
  --cfb-shadow: 0 12px 32px rgba(0,0,0,.18);
}

#crysound-fb-root, #crysound-fb-root * { box-sizing: border-box; }

/* ─────────── FAB · 直接使用设计稿 PNG，CSS 仅做定位 ─────────── */
.cfb-fab-wrap {
  position: fixed;
  z-index: 9996;
  width: 250px;
  height: 160px;
}

/* 文字气泡 PNG（占据左侧） */
.cfb-fab-card-img {
  position: absolute;
  top: 0;
  left: 0;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
  z-index: 1;
}
.cfb-fab-card-img img {
  display: block;
  width: 150px;
  height: auto;
  -webkit-user-drag: none;
  user-select: none;
}

/* 圆头像 PNG（贴右、垂直居中，叠在气泡右侧） */
.cfb-fab-avatar-img {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
  z-index: 2;
}
.cfb-fab-avatar-img img {
  display: block;
  width: 115px;
  height: 115px;
  -webkit-user-drag: none;
  user-select: none;
}

/* 无设计稿时的 fallback：纯圆按钮 */
.cfb-fab {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: #2E2A6B;
  color: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(46,42,107,.4);
  position: absolute;
  right: 0; bottom: 0;
}
.cfb-fab svg { width: 28px; height: 28px; }

/* 抽屉打开时，FAB 淡出 */
.cfb-fab-wrap.cfb-fab-collapsed .cfb-fab-card-img,
.cfb-fab-wrap.cfb-fab-collapsed .cfb-fab-avatar-img {
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

/* ─────────── 抽屉 ─────────── */
.cfb-drawer {
  position: fixed;
  z-index: 9997;
  width: 380px;
  height: 620px;
  max-height: calc(100vh - 40px);
  background: var(--cfb-bg);
  border-radius: var(--cfb-radius);
  box-shadow: var(--cfb-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.96) translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.cfb-drawer.open { opacity: 1; pointer-events: auto; transform: scale(1) translateY(0); }

/* Header（深紫色 #2E2A6B） */
.cfb-header {
  padding: 14px 16px;
  background: #2E2A6B;
  color: #fff;
  display: flex; align-items: center; gap: 12px;
}
.cfb-header-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  overflow: hidden;
  flex: 0 0 auto;
}
.cfb-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cfb-header-info { flex: 1; min-width: 0; }
.cfb-header-name { font-size: 15px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfb-header-min {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px 8px;
  opacity: .85;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.cfb-header-min:hover { background: rgba(255,255,255,.12); opacity: 1; }

/* 进度条容器（默认隐藏） */
.cfb-progress { display: none; }

/* Body */
.cfb-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  background: #F4F4F6;
  scroll-behavior: smooth;
}
.cfb-body::-webkit-scrollbar { width: 6px; }
.cfb-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.cfb-msg { display: block; margin-bottom: 12px; }
.cfb-msg-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 4px;
}
.cfb-msg-user .cfb-msg-meta { justify-content: flex-end; }
.cfb-msg-bubble {
  display: inline-block;
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  color: var(--cfb-text);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
}
.cfb-msg-user { text-align: right; }
.cfb-msg-user .cfb-msg-bubble {
  background: #2E2A6B;
  color: #fff;
}
.cfb-msg-ai .cfb-msg-bubble { background: #fff; }

/* 欢迎语 QR */
.cfb-qr-wrap {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #F1F3F5;
}
.cfb-qr-caption {
  font-size: 13px;
  line-height: 1.5;
  color: var(--cfb-text-soft);
  margin-bottom: 10px;
}
.cfb-qr-img {
  width: 140px;
  height: 140px;
  display: block;
  margin: 0 auto;
}

/* 建议问题 chips */
.cfb-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 6px 0 12px;
}
.cfb-chip {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--cfb-text);
  cursor: pointer;
}
.cfb-chip:hover { border-color: #2E2A6B; color: #2E2A6B; }

.cfb-complete-banner {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}
.cfb-error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 12px;
}

/* "需要人工帮助" 独立模块 */
.cfb-need-help-bar {
  display: flex;
  justify-content: flex-end;
  background: #F4F4F6;
  padding: 8px 14px 4px;
}
.cfb-need-help {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  display: inline-flex;
  transition: opacity .15s ease, transform .15s ease;
}
.cfb-need-help:hover { opacity: .85; }
.cfb-need-help:active { transform: scale(.97); }
.cfb-need-help img {
  display: block;
  height: 28px;
  width: auto;
}

/* Footer 输入区 */
.cfb-footer {
  padding: 10px 14px 14px;
  background: #fff;
}
.cfb-input-row {
  display: flex;
  align-items: center;
  height: 36px;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  transition: border-color .15s ease;
}
.cfb-input-row:focus-within { border-color: #D1D5DB; }
.cfb-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0 0 0 14px;
  font-size: 14px;
  resize: none;
  outline: none;
  line-height: 20px;
  height: 20px;
  max-height: 60px;
  font-family: inherit;
  color: var(--cfb-text);
  overflow-y: auto;
  scrollbar-width: none;
  box-sizing: border-box;
  display: block;
}
.cfb-input::placeholder,
.cfb-input::-webkit-input-placeholder,
.cfb-input::-moz-placeholder {
  color: #9ca3af;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  opacity: 1;
}
.cfb-send {
  background: #C7C9CC;
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 4px;
  cursor: not-allowed;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
  flex: 0 0 auto;
  align-self: center;
  margin-right: 3px;
}
.cfb-send.cfb-send-active { background: #2E2A6B; cursor: pointer; }
.cfb-send.cfb-send-active:hover { background: #3a3680; }

/* 企微弹窗（fallback 二维码） */
.cfb-wecom-mask {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 9999999;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.cfb-wecom-card {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 22px 22px 18px;
  width: 320px;
  max-width: 100%;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0,0,0,.2);
}
.cfb-wecom-close {
  position: absolute;
  top: 10px; right: 14px;
  background: transparent;
  border: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 22px;
  color: var(--cfb-text-soft);
  cursor: pointer;
  line-height: 1;
}
.cfb-wecom-close:hover { background: #f1f5f9; color: var(--cfb-text); }
.cfb-wecom-card h3 { margin: 0 0 8px; font-size: 17px; color: var(--cfb-text); }
.cfb-wecom-card p { margin: 0 0 16px; font-size: 13px; color: var(--cfb-text-soft); }
.cfb-wecom-card strong { color: var(--cfb-text); }
.cfb-wecom-qr {
  width: 220px; height: 220px;
  margin: 0 auto 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid var(--cfb-border);
}
.cfb-wecom-qr img { width: 100%; height: 100%; object-fit: contain; }

/* "是否需要人工协助" 弹窗（仅覆盖在抽屉内） */
.cfb-human-mask {
  position: absolute;
  inset: 0;
  background: rgba(17,24,39,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: inherit;
  animation: cfbFadeIn .15s ease;
}
@keyframes cfbFadeIn { from { opacity: 0; } to { opacity: 1; } }
.cfb-human-card {
  width: calc(100% - 48px);
  max-width: 320px;
  background: #fff;
  border-radius: 14px;
  padding: 22px 22px 18px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.cfb-human-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #EEEDF6;
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
}
.cfb-human-title { margin: 0 0 6px; font-size: 16px; font-weight: 600; color: var(--cfb-text); }
.cfb-human-desc { margin: 0 0 18px; font-size: 13px; line-height: 1.5; color: var(--cfb-text-soft); }
.cfb-human-actions { display: flex; flex-direction: column; gap: 8px; }
.cfb-human-btn { height: 38px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease; font-family: inherit; }
.cfb-human-btn-primary { background: #2E2A6B; color: #fff; border: 1px solid #2E2A6B; }
.cfb-human-btn-primary:hover { background: #3a3680; border-color: #3a3680; }
.cfb-human-btn-ghost { background: #fff; color: var(--cfb-text); border: 1px solid #E5E7EB; }
.cfb-human-btn-ghost:hover { background: #f8fafc; }

/* 隐藏 Custom-Contact-Buttons-Extension 的右下角浮窗，避免与本机器人重叠 */
body .ccb-side-contact,
body .ccb-side-contact-btn,
body .ccb-side-contact.ccb-side-bottom,
body .ccb-side-contact.ccb-side-right { display: none !important; }

/* 移动端 */
@media (max-width: 480px) {
  .cfb-drawer {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
  }
  /* 移动端：仅显示圆头像 PNG，文字气泡隐藏 */
  .cfb-fab-wrap { width: 84px; height: 84px; }
  .cfb-fab-wrap .cfb-fab-card-img { display: none; }
  .cfb-fab-wrap .cfb-fab-avatar-img img { width: 84px; height: 84px; }
}
