/* ================================================================
   QaQ Chat · 访客端聊天组件样式（Tidio 风格）
   所有类名统一 qc- 前缀，不会污染宿主网站样式
   主色可通过 window.QAQCHAT_CONFIG.accent 覆盖
   ================================================================ */
.qc-root {
  --qc-accent: #2f6bff;
  --qc-accent-dark: #1f4fd8;
  --qc-text: #1b2430;
  --qc-muted: #8e98a9;
  --qc-bg: #f6f8fc;
  --qc-line: #e7ecf5;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--qc-text);
  -webkit-font-smoothing: antialiased;
}
.qc-root *, .qc-root *::before, .qc-root *::after { box-sizing: border-box; }
.qc-root button, .qc-root textarea { font-family: inherit; }
.qc-root svg { display: block; }

/* ---------- 悬浮气泡按钮 ---------- */
.qc-launcher {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5b8cff 0%, var(--qc-accent) 50%, var(--qc-accent-dark) 100%);
  box-shadow: 0 10px 26px rgba(37, 86, 214, .38), 0 2px 6px rgba(20, 35, 70, .14);
  transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s;
}
.qc-launcher:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 14px 32px rgba(37,86,214,.45); }
.qc-launcher:active { transform: scale(.96); }
.qc-launcher svg { width: 26px; height: 26px; }
.qc-launcher .qc-ico-close { display: none; }
.qc-root.is-open .qc-launcher .qc-ico-chat { display: none; }
.qc-root.is-open .qc-launcher .qc-ico-close { display: block; }
.qc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ff4d4f;
  border: 2px solid #fff;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.qc-badge[hidden] { display: none; }

/* ---------- 聊天面板 ---------- */
.qc-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 372px;
  height: min(580px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(20, 35, 70, .06);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 55px rgba(20, 35, 70, .22), 0 2px 8px rgba(20, 35, 70, .08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .28s cubic-bezier(.2,.85,.25,1), visibility .22s;
}
.qc-root.is-open .qc-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

/* ---------- 头部 ---------- */
.qc-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 14px 15px 16px;
  color: #fff;
  background: linear-gradient(120deg, #5b8cff 0%, var(--qc-accent) 48%, var(--qc-accent-dark) 100%);
}
.qc-avatar {
  width: 42px; height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.55);
}
.qc-avatar svg { width: 22px; height: 22px; color: #fff; }
.qc-head-txt { flex: 1 1 auto; min-width: 0; }
.qc-head-txt strong { display: block; font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.qc-head-txt span { display: flex; align-items: center; gap: 5px; margin-top: 2px; font-size: 11.5px; opacity: .92; }
.qc-head-txt em { font-style: normal; }
.qc-dot {
  width: 7px; height: 7px; flex: 0 0 auto;
  border-radius: 50%; background: #43e29a;
  box-shadow: 0 0 0 2px rgba(255,255,255,.28);
}
.qc-min {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border: 0; border-radius: 8px;
  background: rgba(255,255,255,.14);
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s;
}
.qc-min:hover { background: rgba(255,255,255,.3); }
.qc-min svg { width: 17px; height: 17px; }

/* ---------- 消息区 ---------- */
.qc-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 14px 6px;
  background: var(--qc-bg);
}
.qc-body::-webkit-scrollbar { width: 6px; }
.qc-body::-webkit-scrollbar-thumb { background: #d3dbe8; border-radius: 3px; }
.qc-date { text-align: center; font-size: 11px; color: var(--qc-muted); margin: 2px 0 14px; }
.qc-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 14px; }
.qc-row.visitor { flex-direction: row-reverse; }
.qc-mini-avatar {
  width: 26px; height: 26px; flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #5b8cff, var(--qc-accent-dark));
  color: #fff;
}
.qc-mini-avatar svg { width: 15px; height: 15px; }
.qc-col { max-width: 78%; min-width: 0; display: flex; flex-direction: column; }
.qc-row.visitor .qc-col { align-items: flex-end; }
.qc-bubble {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.qc-row.agent .qc-bubble {
  background: #fff;
  color: var(--qc-text);
  border: 1px solid var(--qc-line);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(20,35,70,.04);
}
.qc-row.visitor .qc-bubble {
  background: linear-gradient(135deg, #5b8cff, var(--qc-accent));
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 7px rgba(47,107,255,.22);
}
.qc-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 10.5px; color: var(--qc-muted); }
.qc-auto-tag { background: #eaf1ff; color: var(--qc-accent-dark); border-radius: 4px; padding: 0 4px; font-size: 10px; }
.qc-system {
  max-width: 92%;
  margin: 4px auto 12px;
  padding: 7px 10px;
  text-align: center;
  font-size: 11.5px;
  color: #a1651f;
  background: #fff6e8;
  border: 1px solid #ffe1b3;
  border-radius: 8px;
}
.qc-typing { display: none; align-items: flex-end; gap: 8px; margin: 0 0 14px; }
.qc-root.is-typing .qc-typing { display: flex; }
.qc-typing-bubble {
  display: flex; align-items: center; gap: 4px;
  padding: 11px 13px;
  background: #fff;
  border: 1px solid var(--qc-line);
  border-bottom-left-radius: 4px;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(20,35,70,.04);
}
.qc-typing-bubble i {
  width: 6px; height: 6px; border-radius: 50%; background: #9aa8bd;
  animation: qc-bounce 1.1s infinite ease-in-out;
}
.qc-typing-bubble i:nth-child(2) { animation-delay: .16s; }
.qc-typing-bubble i:nth-child(3) { animation-delay: .32s; }
@keyframes qc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- 快捷问题 ---------- */
.qc-quick {
  flex: 0 0 auto;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 9px 14px;
  background: #fff;
  border-top: 1px solid var(--qc-line);
  scrollbar-width: none;
}
.qc-quick::-webkit-scrollbar { display: none; }
.qc-quick[hidden] { display: none; }
.qc-chip {
  flex: 0 0 auto;
  padding: 6px 11px;
  border: 1px solid #cfdcff;
  border-radius: 999px;
  background: #f4f8ff;
  color: var(--qc-accent-dark);
  font-size: 12px;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.qc-chip:hover { background: #e6efff; transform: translateY(-1px); }

/* ---------- 输入区 ---------- */
.qc-foot { flex: 0 0 auto; padding: 10px 12px 8px; background: #fff; border-top: 1px solid var(--qc-line); }
.qc-input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 6px 6px 6px 12px;
  background: var(--qc-bg);
  border: 1px solid var(--qc-line);
  border-radius: 12px;
  transition: border-color .2s, box-shadow .2s;
}
.qc-input-wrap:focus-within { border-color: var(--qc-accent); box-shadow: 0 0 0 3px rgba(47,107,255,.1); }
.qc-input {
  flex: 1 1 auto; min-width: 0;
  min-height: 22px; max-height: 96px;
  padding: 4px 0;
  border: 0; outline: 0; resize: none;
  background: transparent;
  color: var(--qc-text);
  font-size: 13.5px; line-height: 1.5;
}
.qc-input::placeholder { color: #a7b0c0; }
.qc-send {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border: 0; border-radius: 9px;
  background: var(--qc-accent);
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s, transform .2s;
}
.qc-send:hover:not(:disabled) { background: var(--qc-accent-dark); transform: scale(1.05); }
.qc-send:disabled { background: #c9d2e4; cursor: not-allowed; }
.qc-send svg { width: 17px; height: 17px; }
.qc-powered { margin-top: 7px; text-align: center; font-size: 10px; color: #b3bccb; }

/* ---------- 移动端：全屏面板 ---------- */
@media (max-width: 480px) {
  .qc-root { right: 14px; bottom: 14px; }
  .qc-panel {
    position: fixed;
    inset: 0;
    width: 100%; height: 100%;
    max-height: none;
    border: 0; border-radius: 0;
    transform: translateY(24px);
  }
  .qc-root.is-open .qc-panel { transform: none; }
  .qc-root.is-open .qc-launcher { display: none; }
  .qc-head { padding-top: max(15px, env(safe-area-inset-top)); }
  .qc-foot { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .qc-root *, .qc-root *::before, .qc-root *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
