/* ═══ 在线客服聊天系统 ═══
   与整站一致：深色玻璃 + 金色高亮
   布局：聊天悬浮按钮叠在「返回顶部」上方，互不遮挡 */

/* ── 悬浮按钮（与「返回顶部」同款玻璃风格）──
   默认停在返回顶部的位置；向下滚动时上移让位（.shift-up） */
.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 28px;               /* 默认与「返回顶部」同位置（顶部时返回按钮隐藏） */
  z-index: 120;               /* 高于导航(100)/返回顶部(90)，低于弹窗(200) */
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.70);
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.35);
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease,
              bottom 0.4s cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.chat-fab.shift-up {
  bottom: 108px;               /* 返回顶部按钮出现后上移让位 */
}
.chat-fab:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(3, 43, 171, 0.40);
  color: var(--brand-blue);
  transform: translateY(-2px);
}
.chat-fab:active { transform: translateY(0); }

/* ── 聊天窗口 ── */
.chat-widget {
  position: fixed;
  right: 24px;
  bottom: 185px;              /* 位于悬浮按钮上方 */
  z-index: 120;
  width: 360px;
  height: 500px;
  max-width: calc(100vw - 32px);
  border-radius: var(--radius-lg);
  background: rgba(12, 12, 20, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.28s ease,
              transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.28s;
}
.chat-widget.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* 头部 */
.chat-widget__header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(255, 196, 44, 0.16) 0%, rgba(255, 196, 44, 0.04) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.chat-widget__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--paper);
}
.chat-widget__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.85);
}
.chat-widget__close {
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
}
.chat-widget__close:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.08);
}

/* 内容区 */
.chat-widget__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* 消息列表 */
.chat-widget__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-widget__messages::-webkit-scrollbar { width: 6px; }
.chat-widget__messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
.chat-welcome {
  margin: auto;
  text-align: center;
  color: rgba(255, 255, 255, 0.40);
  font-size: 13px;
  padding: 20px;
}

/* 单条消息 */
.chat-msg {
  display: flex;
}
.chat-msg--user { justify-content: flex-end; }
.chat-msg--admin { justify-content: flex-start; }
.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  color: var(--paper);
}
.chat-msg--admin .chat-bubble {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-bottom-left-radius: 4px;
}
.chat-msg--user .chat-bubble {
  background: linear-gradient(135deg, #FFC42C 0%, #e6a800 100%);
  color: #141414;
  border-bottom-right-radius: 4px;
}
.chat-time {
  font-size: 11px;
  margin-top: 4px;
  text-align: center;
  color: rgba(255, 255, 255, 0.35);
}
.chat-msg--user .chat-time { color: rgba(0, 0, 0, 0.45); }

/* 输入区 */
.chat-widget__input {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}
.chat-widget__input input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  font-size: 14px;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
  transition: border-color 0.2s ease;
}
.chat-widget__input input::placeholder { color: rgba(255, 255, 255, 0.35); }
.chat-widget__input input:focus { border-color: rgba(255, 196, 44, 0.55); }
.chat-widget__send {
  flex: none;
  padding: 10px 20px;
  background: linear-gradient(135deg, #FFC42C 0%, #e6a800 100%);
  color: #141414;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.chat-widget__send:hover { opacity: 0.9; transform: translateY(-1px); }
.chat-widget__send:disabled { background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.35); cursor: not-allowed; transform: none; }

/* ── 移动端：窗口几乎全屏，按钮贴边 ── */
@media (max-width: 768px) {
  .chat-fab {
    right: 14px;
    bottom: 20px;
    width: 38px;
    height: 38px;
    font-size: 18px;
  }
  .chat-fab.shift-up {
    bottom: 76px;              /* 移动端返回顶部按钮出现后上移让位 */
  }
  .chat-widget {
    left: 10px;
    right: 10px;
    bottom: 140px;
    width: auto;
    max-width: none;
    height: calc(100vh - 220px);
  }
}
