/* ============================================================
   雀竹AI 在线客服组件
   主题：与官网一致的深石板灰 × 靛蓝（同 ADP 设计语言）
   ============================================================ */

.chat-root {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 500;
  font-family: inherit;
}

/* ---------------- 悬浮启动球 ---------------- */

.chat-launcher {
  position: relative;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--indigo-500, #6366f1), var(--indigo-700, #4338ca));
  box-shadow: 0 14px 30px -8px rgba(79, 70, 229, 0.7);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chat-launcher:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 38px -8px rgba(79, 70, 229, 0.8);
}
.chat-launcher svg { width: 26px; height: 26px; }
.chat-launcher .ic-close { display: none; }
.chat-root.open .chat-launcher .ic-chat { display: none; }
.chat-root.open .chat-launcher .ic-close { display: block; }

.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff5f57;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}
.chat-badge[hidden] { display: none; }

/* ---------------- 聊天面板 ---------------- */

.chat-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--dark-800, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 18px;
  box-shadow: 0 30px 70px -18px rgba(2, 6, 23, 0.85);
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transform-origin: bottom right;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}
.chat-root.open .chat-panel {
  opacity: 1;
  transform: none;
  visibility: visible;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #334155);
  color: var(--fg, #e2e8f0);
  background:
    radial-gradient(220px 90px at 90% -20%, rgba(99, 102, 241, 0.22), transparent 70%),
    linear-gradient(135deg, #1e293b, #0f172a);
}
.chat-head-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--indigo-500, #6366f1), var(--indigo-700, #4338ca));
}
.chat-avatar svg { width: 22px; height: 22px; }
.chat-title { font-size: 0.98rem; font-weight: 700; color: #fff; line-height: 1.3; }
.chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  color: var(--muted, #94a3b8);
  line-height: 1.3;
}
.chat-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-400, #34d399);
  animation: chat-blink 1.6s infinite;
}
@keyframes chat-blink { 50% { opacity: 0.3; } }

.chat-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  color: rgba(226, 232, 240, 0.75);
  background: rgba(148, 163, 184, 0.12);
  transition: background 0.2s ease, color 0.2s ease;
}
.chat-close:hover { background: rgba(148, 163, 184, 0.22); color: #fff; }

/* ---------------- 消息区 ---------------- */

.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--dark-900, #0f172a);
  scrollbar-width: thin;
  scrollbar-color: var(--border, #334155) transparent;
}
.chat-msgs::-webkit-scrollbar { width: 5px; }
.chat-msgs::-webkit-scrollbar-thumb { background: var(--border, #334155); border-radius: 3px; }

.msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: msg-in 0.25s ease both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.msg-bot { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, var(--indigo-500, #6366f1), var(--indigo-700, #4338ca));
}
.msg-avatar svg { width: 16px; height: 16px; }

.msg-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg-bot .msg-bubble {
  color: var(--fg, #e2e8f0);
  background: var(--dark-800, #1e293b);
  border: 1px solid var(--border, #334155);
  border-top-left-radius: 5px;
  box-shadow: 0 2px 8px -4px rgba(2, 6, 23, 0.6);
}
.msg-user .msg-bubble {
  color: #fff;
  background: var(--indigo-600, #4f46e5);
  border-top-right-radius: 5px;
  box-shadow: 0 6px 16px -8px rgba(79, 70, 229, 0.8);
}

.msg.typing .msg-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 13px 15px;
}
.msg.typing .msg-bubble i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748b;
  animation: typing-dot 1.1s infinite;
}
.msg.typing .msg-bubble i:nth-child(2) { animation-delay: 0.18s; }
.msg.typing .msg-bubble i:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-dot {
  0%, 60%, 100% { transform: none; opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------------- 快捷问题 ---------------- */

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 14px 4px;
  background: var(--dark-900, #0f172a);
  border-top: 1px solid rgba(51, 65, 85, 0.6);
}
.chat-chip {
  border: 1px solid var(--border, #334155);
  background: rgba(30, 41, 59, 0.6);
  color: var(--indigo-300, #a5b4fc);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.chat-chip:hover { background: rgba(99, 102, 241, 0.14); border-color: var(--indigo-500, #6366f1); }
.chat-chip.lead { color: #fff; background: var(--indigo-600, #4f46e5); border-color: transparent; }
.chat-chip.lead:hover { background: var(--indigo-700, #4338ca); }

/* ---------------- 输入区 ---------------- */

.chat-input {
  display: flex;
  gap: 9px;
  padding: 11px 13px;
  background: var(--dark-800, #1e293b);
  border-top: 1px solid rgba(51, 65, 85, 0.6);
}
.chat-input input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--fg, #e2e8f0);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border, #334155);
  border-radius: 11px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.chat-input input::placeholder { color: #64748b; }
.chat-input input:focus {
  border-color: var(--indigo-500, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
.chat-input button {
  flex-shrink: 0;
  padding: 0 18px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  background: var(--indigo-600, #4f46e5);
  transition: background 0.2s ease, transform 0.15s ease;
}
.chat-input button:hover { background: var(--indigo-700, #4338ca); }
.chat-input button:active { transform: scale(0.96); }

/* ---------------- 移动端 ---------------- */

@media (max-width: 640px) {
  .chat-root { right: 16px; bottom: 16px; }
  .chat-panel {
    right: 0;
    width: min(100vw - 32px, 372px);
    height: min(70vh, 560px);
  }
}
