/**
 * chat.css - 在线客服、浮动按钮、微信弹窗共享样式
 * 所有子页面统一引用此文件
 */

/* ===== CSS 变量（子页面可能缺失，在此兜底） ===== */
:root {
  --primary: #0a3d7c;
  --primary-dark: #082d5c;
  --accent: #c8a951;
  --text-main: #1a1a2e;
  --text-sub: #5a6477;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --bg-light: #f3f4f6;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.3s ease;
}

/* ===== 浮动服务按钮 ===== */
.float-service {
  position: fixed;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 900;
}
.float-item {
  position: relative;
  width: 44px; height: 44px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(10,61,124,0.25);
  cursor: pointer;
  transition: all var(--transition);
}
.float-item svg { width: 18px; height: 18px; }
.float-item:hover { background: var(--accent); transform: scale(1.1); }
.float-tooltip {
  position: absolute;
  right: 56px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--primary-dark);
  color: #fff;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.float-tooltip::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: var(--primary-dark);
}
.float-item:hover .float-tooltip { opacity: 1; }

/* ===== 微信二维码弹窗 ===== */
.wechat-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}
.wechat-modal.show {
  opacity: 1;
  visibility: visible;
}
.wechat-modal-content {
  background: #fff;
  padding: 32px;
  border-radius: var(--radius);
  text-align: center;
  position: relative;
  max-width: 320px;
  width: 90%;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}
.wechat-modal.show .wechat-modal-content {
  transform: scale(1);
}
.wechat-modal-content h3 {
  font-size: 18px;
  color: var(--text-main);
  margin-bottom: 20px;
}
.wechat-modal-content img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  margin-bottom: 16px;
}
.wechat-modal-content p {
  font-size: 14px;
  color: var(--text-sub);
}
.wechat-close {
  position: absolute;
  top: 12px; right: 16px;
  font-size: 28px;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}
.wechat-close:hover { color: var(--text-main); }

/* ===== 在线客服聊天窗口 ===== */
.chat-widget {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  background: #fff;
  transform: scale(0) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s;
  pointer-events: none;
}
.chat-widget.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.chat-toggle.active {
  background: var(--primary) !important;
  color: #fff;
}
.chat-header {
  background: linear-gradient(135deg, var(--primary), #1a3a6b);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.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.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.chat-header-name {
  font-size: 14px;
  font-weight: 600;
}
.chat-header-status {
  font-size: 11px;
  opacity: 0.8;
}
.chat-header-status::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: #4ade80;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity .2s;
}
.chat-close:hover { opacity: 1; }

/* 消息区域 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fb;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: 360px;
}
.chat-msg {
  display: flex;
  max-width: 85%;
}
.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }
.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}
.chat-msg.bot .chat-bubble {
  background: #fff;
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chat-msg.user .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* 打字动画 */
.typing-dots {
  display: inline-flex;
  gap: 4px;
}
.typing-dots span {
  width: 7px; height: 7px;
  background: #b0b8c8;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* 输入区域 */
.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #fff;
  gap: 8px;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 80px;
  line-height: 1.5;
  transition: border-color .2s;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}
.chat-send:hover { background: #1a3a6b; }
.chat-send:active { transform: scale(0.92); }
.chat-send svg { width: 18px; height: 18px; }
.chat-send:disabled {
  background: #c0c8d8;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .chat-widget {
    right: 0; bottom: 0;
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
}
