/* ============================================================
   hccl 官网 · AI 智能客服悬浮窗
   （前端演示版：纯静态 + 模拟 AI，正式版接 chat.php + DeepSeek）
   配色取自 assets/css/style.css 的设计变量
   ============================================================ */

.hccl-chat {
  --chat-violet: #7C5CFF;
  --chat-blue: #5B8CFF;
  --chat-grad: linear-gradient(135deg, #7C5CFF 0%, #5B8CFF 100%);
  --chat-dark: #0D081D;
  --chat-dark-2: #160B2E;
  --chat-panel: #1D1138;
  --chat-text: #F7F5FD;
  --chat-muted: #9A8FBE;
  --chat-line: rgba(255, 255, 255, .12);
  --chat-glow: 0 18px 40px -12px rgba(124, 92, 255, .55);
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: var(--font, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif);
}

/* ---------- 悬浮按钮 ---------- */
.hccl-chat-launcher {
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--chat-grad);
  box-shadow: var(--chat-glow);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
}
.hccl-chat-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 22px 48px -12px rgba(124, 92, 255, .7); }
.hccl-chat-launcher svg { width: 26px; height: 26px; }
.hccl-chat-launcher .ico-close { display: none; }
.hccl-chat.open .hccl-chat-launcher .ico-chat { display: none; }
.hccl-chat.open .hccl-chat-launcher .ico-close { display: block; }
.hccl-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--chat-dark);
  border: 2px solid #fff;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 5px;
  border-radius: 8px;
  letter-spacing: .04em;
}
/* 呼吸光晕提醒 */
.hccl-chat-launcher::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(124, 92, 255, .5);
  animation: hccl-chat-pulse 2.4s infinite;
  pointer-events: none;
}
@keyframes hccl-chat-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(124, 92, 255, .45); }
  70%  { box-shadow: 0 0 0 16px rgba(124, 92, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0); }
}

/* ---------- 聊天窗 ---------- */
.hccl-chat-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 372px;
  max-height: min(560px, calc(100vh - 110px));
  background: var(--chat-panel);
  border: 1px solid var(--chat-line);
  border-radius: 18px;
  box-shadow: var(--chat-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: hccl-chat-pop .22s ease;
}
@keyframes hccl-chat-pop {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.hccl-chat[hidden], .hccl-chat-panel[hidden] { display: none; }

/* 头部 */
.hccl-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--chat-grad);
  color: #fff;
}
.hccl-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  border: 1.5px solid rgba(255, 255, 255, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}
.hccl-chat-head h4 { margin: 0; font-size: 15px; font-weight: 700; }
.hccl-chat-head .hccl-chat-status {
  font-size: 11px;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.hccl-chat-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7BE0B8;
  display: inline-block;
}
.hccl-chat-close {
  margin-left: auto;
  background: rgba(255, 255, 255, .16);
  border: 0;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hccl-chat-close:hover { background: rgba(255, 255, 255, .28); }

/* 消息区 */
.hccl-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(600px 200px at 80% -40px, rgba(124, 92, 255, .14), transparent 60%);
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 92, 255, .5) transparent;
}
.hccl-chat-tip {
  font-size: 11px;
  color: var(--chat-muted);
  text-align: center;
  background: rgba(255, 255, 255, .04);
  border: 1px dashed var(--chat-line);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 2px;
}

/* 气泡 */
.hccl-msg { display: flex; gap: 8px; align-items: flex-end; }
.hccl-msg .hccl-msg-ava {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--chat-grad);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hccl-msg .hccl-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.hccl-msg.bot { align-self: flex-start; }
.hccl-msg.bot .hccl-bubble {
  background: var(--chat-dark-2);
  border: 1px solid var(--chat-line);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
}
.hccl-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.hccl-msg.user .hccl-msg-ava { background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid var(--chat-line); }
.hccl-msg.user .hccl-bubble {
  background: var(--chat-grad);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.hccl-msg .hccl-msg-time {
  font-size: 10px;
  color: var(--chat-muted);
  padding: 0 2px 2px;
  flex-shrink: 0;
}

/* 打字中 */
.hccl-typing { display: flex; align-items: center; gap: 5px; padding: 10px 14px; }
.hccl-typing[hidden] { display: none; }
.hccl-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chat-muted);
  animation: hccl-typing-bounce 1.2s infinite;
}
.hccl-typing span:nth-child(2) { animation-delay: .15s; }
.hccl-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes hccl-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* 快捷问题 */
.hccl-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 14px 10px;
  border-top: 1px solid var(--chat-line);
}
.hccl-chat-chip {
  background: rgba(124, 92, 255, .12);
  border: 1px solid rgba(124, 92, 255, .4);
  color: #C9BBFF;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.hccl-chat-chip:hover { background: rgba(124, 92, 255, .28); color: #fff; }

/* 输入区 */
.hccl-chat-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--chat-line);
}
.hccl-chat-input textarea {
  flex: 1;
  resize: none;
  background: var(--chat-dark-2);
  border: 1px solid var(--chat-line);
  color: var(--chat-text);
  font-size: 13.5px;
  line-height: 1.5;
  padding: 9px 11px;
  border-radius: 12px;
  min-height: 40px;
  max-height: 96px;
  font-family: inherit;
  outline: none;
}
.hccl-chat-input textarea:focus { border-color: rgba(124, 92, 255, .7); }
.hccl-chat-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 0;
  border-radius: 12px;
  background: var(--chat-grad);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s ease, transform .15s ease;
}
.hccl-chat-send:hover { transform: translateY(-1px); }
.hccl-chat-send:disabled { opacity: .45; cursor: default; transform: none; }
.hccl-chat-send svg { width: 18px; height: 18px; }

/* ---------- 移动端 ---------- */
/* 640px 与站点 .mobile-bar（底部免费咨询条）的显示断点对齐。
   底部条高约 78px + iOS 安全区，悬浮按钮整体抬高让开它。 */
@media (max-width: 640px) {
  .hccl-chat {
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px) + 12px);
  }
  .hccl-chat-panel {
    right: 0;
    bottom: 74px;                    /* 相对悬浮按钮上方 */
    width: min(372px, calc(100vw - 24px));
    max-height: calc(100vh - 220px); /* 让开底部条 + 悬浮按钮，避免顶出屏幕 */
  }
}
