/* ==========================
   AI 客服聊天窗口样式
   ========================== */

/* ---------- 遮罩层 ---------- */
.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: overlay-in 0.2s ease;
}

.chat-overlay.hidden {
  display: none;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- 窗口 ---------- */
.chat-window {
  display: flex;
  flex-direction: column;
  width: 680px;
  max-width: 92vw;
  height: 660px;
  max-height: 84vh;
  background: #2f2f2f;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  animation: window-in 0.25s ease;
}

@keyframes window-in {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 头部 ---------- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #262626;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--wood-1), var(--wood-2));
}

.chat-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.chat-title strong {
  font-size: 15px;
  color: #f5f5f5;
}

.chat-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #9a9a9a;
}

.chat-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4cd964;
}

.chat-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #9a9a9a;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* ---------- 消息区 ---------- */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow-y: auto;
}

.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

.msg-user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, var(--wood-1), var(--wood-2));
  border-bottom-right-radius: 4px;
}

.msg-assistant {
  align-self: flex-start;
  color: #ececec;
  background: #3d3d3d;
  border-bottom-left-radius: 4px;
}

.msg-error {
  background: rgba(224, 52, 60, 0.16);
  color: #ff9da2;
}

/* 打字中动画 */
.msg-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}

.msg-typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9a9a9a;
  animation: dot-bounce 1.2s infinite ease-in-out;
}

.msg-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.msg-typing .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- 输入区 ---------- */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #262626;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-input-bar input {
  flex: 1;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 20px;
  outline: none;
  background: #3a3a3a;
  color: #eee;
  font-size: 14px;
  font-family: inherit;
}

.chat-input-bar input::placeholder {
  color: #8a8a8a;
}

.chat-mic,
.chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.2s, background 0.2s;
}

.chat-mic {
  background: transparent;
  color: #9a9a9a;
}

.chat-mic:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ddd;
}

.chat-send {
  color: #fff;
  background: linear-gradient(135deg, var(--wood-1), var(--wood-2));
}

.chat-send:hover {
  filter: brightness(1.12);
}

/* ---------- 语音录音中状态 ---------- */
.chat-overlay.recording .chat-mic,
.chat-mic.recording,
.icon-btn.recording {
  color: #fff;
  background: #c0564a;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 86, 74, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(192, 86, 74, 0); }
}

/* ---------- 滚动条 ---------- */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
}

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .chat-window {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .msg {
    max-width: 86%;
  }
}
