/* ========== 在线聊天组件样式 ========== */

#chat-widget {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* 浮动按钮 */
#chat-toggle-btn {
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #4f6ef7, #6366f1);
  color: #fff; cursor: pointer;
  box-shadow: 0 4px 20px rgba(79,110,247,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease;
  position: relative; z-index: 2;
}
#chat-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(79,110,247,0.5);
}
#chat-toggle-btn::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid rgba(79,110,247,0.3);
  animation: chatPulse 2s ease-in-out infinite;
}
@keyframes chatPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0; }
}

/* 聊天窗口 */
#chat-window { position:relative; 
  position: absolute; bottom: 72px; right: 0;
  width: 360px; height: 500px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}
.chat-window-hidden {
  opacity: 0; visibility: hidden;
  transform: scale(0.85) translateY(20px);
  pointer-events: none;
}
.chat-window-visible {
  opacity: 1; visibility: visible;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* 聊天窗口头部 */
.chat-header {
  background: linear-gradient(135deg, #1a1f36, #1e293b);
  padding: 14px 18px; color: #fff;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
}
.chat-title { font-size: 15px; font-weight: 600; }
.chat-subtitle { font-size: 11px; opacity: 0.75; margin-top: 1px; }

/* 消息区域 */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  background: #f5f6fa;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* 欢迎消息 */
.chat-welcome { text-align: center; padding: 20px 10px; }
.chat-welcome-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: #eef1ff; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
}
.chat-welcome-text p { font-size: 13px; color: #6b7280; line-height: 1.6; margin: 0; }

/* 消息气泡 */
.chat-msg { display: flex; gap: 8px; max-width: 85%; }
.chat-msg.visitor { align-self: flex-start; }
.chat-msg.admin { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45;
  word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.chat-msg.visitor .chat-msg-bubble { background: #fff; color: #334155; border-bottom-left-radius: 4px; }
.chat-msg.admin .chat-msg-bubble { background: #4f6ef7; color: #fff; border-bottom-right-radius: 4px; }
.chat-msg-time { font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* 输入区域 */
.chat-input-area {
  padding: 12px 14px; border-top: 1px solid #e5e7eb;
  display: flex; gap: 10px; align-items: center;
  background: #fff;
}
.chat-input-area input {
  flex: 1; padding: 10px 16px; border: 1px solid #e5e7eb;
  border-radius: 24px; font-size: 14px; outline: none;
  transition: border-color 0.2s;
}
.chat-input-area input:focus { border-color: #4f6ef7; }
.chat-input-area button {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: #4f6ef7; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s; flex-shrink: 0;
}
.chat-input-area button:hover { background: #3d5bd9; }
.chat-input-area button:disabled { opacity: 0.5; cursor: not-allowed; }

/* 响应式 */
@media (max-width: 480px) {
  #chat-window { position:relative;  width: calc(100vw - 32px); right: -8px; height: 460px; }
  #chat-toggle-btn { width: 48px; height: 48px; bottom: 16px; right: 16px; }
}


/* Emoji Picker */
.chat-emoji-picker {
  position:absolute; bottom:50px; left:8px; right:8px; max-height:240px;
  background:#fff; border-radius:10px; box-shadow:0 -2px 16px rgba(0,0,0,0.12);
  z-index:100; overflow:hidden; display:flex; flex-direction:column;
}
.chat-emoji-cats {
  display:flex; padding:4px 6px; gap:2px; border-bottom:1px solid #eee;
  overflow-x:auto; flex-shrink:0;
}
.chat-emoji-cat-btn {
  width:28px; height:28px; border-radius:6px; border:none; background:transparent;
  cursor:pointer; font-size:14px; display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.chat-emoji-cat-btn:hover, .chat-emoji-cat-btn.active { background:#eef1ff; }
.chat-emoji-grid {
  flex:1; overflow-y:auto; padding:6px; display:grid;
  grid-template-columns:repeat(7, 1fr); gap:3px;
}
.chat-emoji-grid::-webkit-scrollbar { width:4px; }
.chat-emoji-grid::-webkit-scrollbar-thumb { background:#d1d5db; border-radius:2px; }
.chat-emoji-item {
  width:32px; height:32px; border-radius:4px; border:none; background:transparent;
  cursor:pointer; font-size:17px; display:flex; align-items:center; justify-content:center;
}
.chat-emoji-item:hover { background:#eef1ff; transform:scale(1.12); }

/* Tool button */
.chat-tool-btn {
  width:34px; height:34px; border-radius:50%; border:none; background:transparent;
  color:#999; cursor:pointer; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; padding:0;
}
.chat-tool-btn:hover { background:#eef1ff; color:#4f6ef7; }

/* Image in message */
.chat-msg-bubble img { max-width:180px; max-height:180px; border-radius:8px; cursor:pointer; display:block; }

