/* ========== 客服聊天窗口样式 ========== */
/* @Author: 黄俊波 @Email: cyjunbo@126.com */
/* ========== 基础样式 ========== */
.demo-info h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.demo-info p { color: #475569; line-height: 1.5; }
.demo-badge {
  margin-top: 1rem; background: #eef2ff; padding: 0.5rem 1rem;
  border-radius: 40px; font-size: 0.85rem; display: inline-block;
}
.gooxi-custom-kefu { position: static; }

/* ===== 背景遮罩（爱番番全屏风格） ===== */
.kefu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 998;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.25s ease, visibility 0.25s;
}
.kefu-overlay.open {
  visibility: visible;
  opacity: 1;
}

/* ===== 悬浮按钮（爱番番风格） ===== */
.kefu-main-btn {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 50px; height: 50px;
  background: #4e6ef2;
  border-radius: 50%;
  display: flex;
  align-items: center; justify-content: center;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(78, 110, 242, 0.35);
  transition: all 0.2s ease;
  z-index: 1000;
  color: white;
  border: none;
  animation: mainBtnEntrance 0.4s ease both;
}
@keyframes mainBtnEntrance {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.kefu-main-btn i { font-size: 22px; }
.kefu-main-btn:hover {
  transform: scale(1.08);
  background: #3b56d9;
  box-shadow: 0 6px 20px rgba(78, 110, 242, 0.45);
}
.kefu-main-btn:active { transform: scale(0.95); }

/* ===== 聊天面板（爱番番风格） ===== */
.kefu-chat-panel {
  position: fixed;
  bottom: 88px; right: 24px;
  width: 380px; height: 600px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999;
  transition: opacity 0.2s ease, transform 0.25s ease, visibility 0.2s;
  visibility: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
}
.kefu-chat-panel.open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ===== 头部（爱番番风格：白底灰字 + 绿点状态） ===== */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: #4e6ef2;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-header-left .status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4caf50;
  display: inline-block;
  box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}
.chat-header-left .header-title {
  font-size: 14px;
  letter-spacing: 0;
}
.chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-switch {
  background: rgba(255,255,255,0.15);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
}
.mode-switch.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(255,255,255,0.08);
}
.mode-switch:hover:not(.disabled) {
  background: rgba(255,255,255,0.25);
}
.mode-label {
  font-size: 11px;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.12);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  white-space: nowrap;
}
.close-chat {
  font-size: 18px;
  cursor: pointer;
  width: 30px; height: 30px;
  display: flex;
  align-items: center; justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  background: transparent;
  color: rgba(255,255,255,0.8);
}
.close-chat:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* ===== 消息区域 ===== */
.chat-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: #f5f7fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.chat-messages-area::-webkit-scrollbar { width: 4px; }
.chat-messages-area::-webkit-scrollbar-track { background: transparent; }
.chat-messages-area::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* ===== 消息行 ===== */
.message-row {
  display: flex;
  align-items: flex-start;
  max-width: 85%;
  animation: fadeInUp 0.25s ease;
}
.message-row.user { align-self: flex-end; flex-direction: row-reverse; }
.message-row.assistant { align-self: flex-start; flex-direction: row; }

/* ===== 头像 ===== */
.msg-icon {
  width: 32px; height: 32px;
  display: flex;
  align-items: center; justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 13px;
}
.user .msg-icon {
  background: #4e6ef2;
  color: white;
  margin-left: 8px;
}
.assistant .msg-icon {
  background: #eef1f7;
  color: #5f7d9c;
  margin-right: 8px;
}

/* ===== 气泡包裹 ===== */
.bubble-wrapper {
  display: flex;
  flex-direction: column;
}
.user .bubble-wrapper { align-items: flex-end; }
.assistant .bubble-wrapper { align-items: flex-start; }

/* ===== 气泡 ===== */
.bubble {
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
}
.user .bubble {
  background: #4e6ef2;
  color: white;
  border-radius: 14px 14px 4px 14px;
}
.assistant .bubble {
  background: white;
  color: #1a1a1a;
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* ===== 消息元信息 ===== */
.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  padding: 0 2px;
  font-size: 0.7rem;
  line-height: 1;
}
.user .message-meta { justify-content: flex-end; }
.assistant .message-meta { justify-content: flex-start; }

.msg-from-name {
  color: #4e6ef2;
  font-weight: 600;
  font-size: 0.72rem;
  background: #eef0fc;
  padding: 1px 7px;
  border-radius: 8px;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-time { color: #999; font-size: 0.68rem; }
.msg-read-status {
  font-size: 0.62rem;
  color: #f5a623;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 6px;
  background: #fff8e1;
  transition: all 0.3s ease;
}
.msg-read-status.read { color: #43a047; background: #e8f5e9; }

/* ===== 媒体 ===== */
.bubble img, .bubble video {
  max-width: 180px; max-height: 180px;
  border-radius: 8px;
  margin-top: 3px;
  cursor: pointer;
  display: block;
}
.file-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  color: #4e6ef2;
  text-decoration: none;
  transition: all 0.2s ease;
}
.file-attachment:hover { background: #e2e8f0; }

.message-time {
  font-size: 0.62rem;
  color: #999;
  margin-top: 3px;
}

/* ===== 转人工按钮 ===== */
.transfer-human-btn {
  font-size: 11px;
  color: #4e6ef2;
  background: none;
  border: 1px solid rgba(78,110,242,0.2);
  cursor: pointer;
  padding: 4px 10px;
  margin-top: 5px;
  border-radius: 14px;
  transition: all 0.2s ease;
  font-weight: 500;
}
.transfer-human-btn:hover { background: #eef0fc; border-color: #4e6ef2; }

/* ===== 输入区域（爱番番风格） ===== */
.chat-input-area {
  background: #fff;
  border-top: 1px solid #e8eaed;
  flex-shrink: 0;
  position: relative;
}
.input-toolbar {
  display: flex;
  align-items: center;
  padding: 3px 10px 0;
  background: #fff;
}
.toolbar-btn {
  background: none; border: none;
  color: #888; font-size: 17px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.12s ease;
}
.toolbar-btn:hover { background: #f0f0f0; color: #555; }
.toolbar-btn:active { background: #e0e0e0; }

.input-body {
  display: flex;
  flex-direction: column;
  padding: 4px 10px 8px;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}
.input-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 0.88rem;
  outline: none;
  background: #f8f9fa;
  font-family: inherit;
  resize: none;
  overflow-y: auto;
  min-height: 60px;
  max-height: 120px;
  line-height: 1.5;
  box-sizing: border-box;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.input-body textarea::placeholder { color: #c0c4cc; font-size: 0.85rem; }
.input-body textarea:focus {
  border-color: #4e6ef2;
  background: #fff;
}
.input-footer {
  display: flex;
  justify-content: flex-end;
  padding: 6px 0 0;
}
.input-footer button {
  background: #4e6ef2;
  border: none;
  color: white;
  padding: 6px 18px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  gap: 4px;
  transition: all 0.12s ease;
  flex-shrink: 0;
  line-height: 1;
}
.input-footer button:hover { background: #3b56d9; }
.input-footer button:active { transform: scale(0.96); }
.input-footer button:disabled { background: #b0b0b0; cursor: not-allowed; }

/* ===== 表情选择器 ===== */
.emoji-picker-container {
  position: absolute;
  bottom: 140px; left: 10px;
  z-index: 200;
  display: none;
}
.emoji-picker-container.show { display: block; }
.emoji-grid {
  width: 300px;
  height: 340px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border: 1px solid #e8e8e8;
  padding: 6px 4px;
}
.emoji-grid .emoji-item {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 20px;
  user-select: none;
  border-radius: 4px;
  transition: background 0.15s;
}
.emoji-grid .emoji-item:hover { background: #f0f0f0; }

/* ===== 拖拽 ===== */
.chat-input-area.drag-over { border-top: 2px dashed #4e6ef2; }
.chat-input-area.drag-over .input-toolbar { background: #eef0fc; }
.chat-input-area.drag-over .input-body { background: #eef0fc; }
.chat-input-area.drag-over textarea { border-color: #4e6ef2; background: #f0f4ff; }
.drag-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(78,110,242,0.06);
  backdrop-filter: blur(2px);
  border-radius: 12px;
  align-items: center; justify-content: center;
  font-size: 14px; color: #4e6ef2; font-weight: 600;
  pointer-events: none; z-index: 10;
  border: 2px dashed rgba(78,110,242,0.3);
  margin: 3px;
}
.drag-overlay.show { display: flex; }

/* ===== 邀请弹窗 ===== */
.embed-invite {
  position: fixed;
  bottom: 84px;
  right: 24px;
  z-index: 1001;
  display: none;
  animation: inviteFadeIn 0.35s ease both;
  transform-origin: bottom right;
}
.embed-invite.show { display: block; }
.embed-invite-body {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
  overflow: hidden;
  width: 280px;
}
.embed-invite-content {
  padding: 20px 20px 12px;
}
.embed-invite-welcome {
  font-size: 14px;
  color: #333;
  line-height: 1.6;
  text-align: center;
}
.embed-invite-footer {
  padding: 8px 20px 16px;
  text-align: center;
}
.embed-invite-chat-button {
  display: inline-block;
  background: #4e6ef2;
  color: #fff;
  font-size: 14px;
  padding: 8px 28px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  user-select: none;
}
.embed-invite-chat-button:hover { background: #3b56d9; }
.embed-invite-chat-button:active { transform: scale(0.96); }
.embed-invite-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #999;
  font-size: 14px;
  border-radius: 50%;
  transition: background 0.2s ease, color 0.2s ease;
}
.embed-invite-close:hover { background: #f0f0f0; color: #333; }

@keyframes inviteFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .kefu-chat-panel {
    width: calc(100vw - 24px);
    right: 12px; left: 12px;
    bottom: 76px;
    height: 75vh;
    border-radius: 10px;
  }
  .kefu-main-btn { bottom: 18px; right: 18px; width: 46px; height: 46px; }
  .kefu-main-btn i { font-size: 20px; }
  .message-row { max-width: 92%; }
  .emoji-grid { width: 260px; height: 300px; }
  .emoji-grid .emoji-item { width: 32px; height: 32px; font-size: 18px; }
  .chat-header { padding: 12px 14px; }
  .chat-header-left .header-title { font-size: 14px; }
  .chat-messages-area { padding: 12px 10px; gap: 10px; }
  .input-toolbar { padding: 2px 8px 0; }
  .toolbar-btn { width: 28px; height: 28px; font-size: 15px; }
  .input-body { padding: 3px 8px 6px; }
  .input-body textarea { padding: 8px 10px; min-height: 50px; font-size: 0.85rem; }
  .input-footer { padding: 4px 0 0; }
  .input-footer button { padding: 5px 14px; font-size: 12px; }
  .message-meta { font-size: 0.62rem; }
  .msg-from-name { font-size: 0.65rem; padding: 1px 5px; }
  .msg-read-status { font-size: 0.58rem; }
  emoji-picker { --emoji-picker-width: 260px; --emoji-picker-height: 300px; }
  .bubble { padding: 8px 12px; font-size: 0.85rem; }
  .embed-invite { right: 18px; bottom: 74px; }
  .embed-invite-body { width: 250px; }
  .embed-invite-content { padding: 16px 16px 8px; }
  .embed-invite-welcome { font-size: 13px; }
  .embed-invite-footer { padding: 6px 16px 14px; }
  .embed-invite-chat-button { padding: 7px 24px; font-size: 13px; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 震屏动画 ===== */
.shake-animation { animation: shakeEffect 0.5s ease-in-out; }
@keyframes shakeEffect {
  0%,100% { transform: translateX(0); }
  10% { transform: translateX(-5px); }
  20% { transform: translateX(5px); }
  30% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  50% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  70% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

/* ===== 重新连接链接样式 ===== */
.reconnect-link {
  color: #4e6ef2;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}
.reconnect-link:hover {
  color: #3b57d9;
}

/* ===== 图片预览（Lightbox） ===== */
.img-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.25s ease, visibility 0.25s;
  cursor: zoom-out;
}
.img-preview-overlay.open {
  visibility: visible;
  opacity: 1;
}
.img-preview-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain;
  transform: scale(0.9);
  transition: transform 0.25s ease;
}
.img-preview-overlay.open img {
  transform: scale(1);
}
.img-preview-close {
  position: fixed;
  top: 20px;
  right: 28px;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  z-index: 10000;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: background 0.2s;
}
.img-preview-close:hover {
  background: rgba(255,255,255,0.3);
}