/* ============================================================
   元帆小助手 — AI Widget 样式  (机器人主题)
   ============================================================ */

/* ── 浮动触发按钮 ──────────────────────────────────────────── */
#hf-chat-btn {
  position: fixed;
  right: 1.5rem;
  bottom: 2rem;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.1rem 0 0.85rem;
  height: 48px;
  border-radius: 999px;          /* 胶囊形 */
  background: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.45), 0 0 0 0 rgba(0,212,255,0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  user-select: none;
  outline: none;
  /* 3 秒后淡入 */
  opacity: 0;
  animation: hf-btn-fadein 0.5s ease 1.5s forwards;
}

@keyframes hf-btn-fadein {
  to { opacity: 1; }
}

/* 呼吸光晕 */
#hf-chat-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 999px;
  box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.5);
  animation: hf-glow-ring 2.5s ease-out 2s infinite;
  pointer-events: none;
}
@keyframes hf-glow-ring {
  0%   { box-shadow: 0 0 0 0 rgba(0,212,255,0.45); }
  70%  { box-shadow: 0 0 0 10px rgba(0,212,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,212,255,0); }
}

#hf-chat-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 28px rgba(0, 212, 255, 0.6);
}

/* 拖动中：抓手光标 + 轻微放大 + 去除 hover 偏移 */
#hf-chat-btn.hf-btn-dragging {
  cursor: grabbing !important;
  transform: scale(1.06) !important;
  box-shadow: 0 12px 36px rgba(0, 212, 255, 0.7) !important;
  user-select: none;
}

#hf-chat-btn.hf-btn-active {
  background: linear-gradient(135deg, #7c3aed 0%, #00d4ff 100%);
}

/* 机器人图标 */
#hf-chat-btn .hf-btn-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.4));
}

/* 按钮文字 */
#hf-chat-btn .hf-btn-label {
  line-height: 1;
}

/* 红点提示 */
#hf-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff4d6d;
  border: 2px solid #0a0e1a;
  opacity: 0;
  transition: opacity 0.3s;
}
#hf-chat-badge.hf-badge-pulse {
  opacity: 1;
  animation: hf-pulse 1.8s ease infinite;
}
@keyframes hf-pulse {
  0%,100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.6); opacity: 0.5; }
}

/* ── 对话窗口 ──────────────────────────────────────────────── */
#hf-chat-win {
  position: fixed;
  right: 1.5rem;
  bottom: 5.5rem;
  z-index: 9997;
  width: 360px;
  height: 530px;
  max-height: calc(100vh - 7rem);
  background: var(--color-surface);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 8px 40px rgba(0,0,0,0.55),
    0 0 0 1px rgba(0,212,255,0.06),
    inset 0 1px 0 rgba(255,255,255,0.04);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
#hf-chat-win.hf-win-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 顶部彩虹细线 */
#hf-chat-win::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(90deg, #00d4ff, #7c3aed, #00d4ff);
  background-size: 200% 100%;
  animation: hf-rainbow 3s linear infinite;
}
@keyframes hf-rainbow {
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

/* 头部 */
.hf-chat-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem 0.85rem 1rem;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0,212,255,0.1);
}

/* 机器人头像 */
.hf-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0,212,255,0.15), rgba(124,58,237,0.2));
  border: 1px solid rgba(0,212,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hf-chat-avatar svg {
  width: 22px;
  height: 22px;
}

.hf-chat-title {
  flex: 1;
  min-width: 0;
}
.hf-chat-title strong {
  display: block;
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.3;
}
.hf-chat-title .hf-status-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  margin-top: 2px;
}

/* 状态圆点基础 */
.hf-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* 三态颜色 */
.hf-status-checking {
  background: #f59e0b;      /* 黄 — 检测中 */
  animation: hf-checking 0.8s ease infinite alternate;
}
.hf-status-online {
  background: #22c55e;      /* 绿 — 在线 */
  animation: hf-online-blink 2.5s ease infinite;
}
.hf-status-offline {
  background: #ef4444;      /* 红 — 离线/失败 */
}

#hf-status-text {
  color: var(--color-muted);
  transition: color 0.3s;
}
.hf-status-online  ~ #hf-status-text,
.hf-status-row:has(.hf-status-online)  #hf-status-text { color: #22c55e; }
.hf-status-row:has(.hf-status-offline) #hf-status-text { color: #ef4444; }
.hf-status-row:has(.hf-status-checking) #hf-status-text { color: #f59e0b; }

@keyframes hf-checking {
  from { opacity: 0.4; transform: scale(0.85); }
  to   { opacity: 1;   transform: scale(1); }
}
@keyframes hf-online-blink {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.45; }
}

#hf-chat-close {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
#hf-chat-close:hover { color: var(--color-text); background: rgba(255,255,255,0.07); }

/* 标题栏微信按钮 */
#hf-wechat-header-btn {
  background: none;
  border: none;
  color: #07c160;
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
#hf-wechat-header-btn:hover { background: rgba(7,193,96,0.12); }

/* 消息列表 */
#hf-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  scroll-behavior: smooth;
}
#hf-chat-msgs::-webkit-scrollbar { width: 3px; }
#hf-chat-msgs::-webkit-scrollbar-track { background: transparent; }
#hf-chat-msgs::-webkit-scrollbar-thumb { background: rgba(0,212,255,0.18); border-radius: 2px; }

/* 消息行 */
.hf-msg { display: flex; max-width: 88%; }
.hf-msg-user  { align-self: flex-end;   flex-direction: row-reverse; }
.hf-msg-bot   { align-self: flex-start; }
.hf-msg-cta   { align-self: stretch; max-width: 100%; }

/* 气泡 */
.hf-bubble-text {
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}
.hf-msg-user .hf-bubble-text {
  background: linear-gradient(135deg, #00d4ff, var(--color-primary));
  color: #0a0e1a;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}
.hf-msg-bot .hf-bubble-text {
  background: rgba(255,255,255,0.05);
  color: var(--color-text);
  border: 1px solid rgba(0,212,255,0.12);
  border-bottom-left-radius: 4px;
}

/* 思考中 */
.hf-thinking .hf-bubble-text { padding: 0.7rem 1rem; }
.hf-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
  margin: 0 2px;
  opacity: 0.6;
  animation: hf-bounce 1.2s ease infinite;
}
.hf-dot:nth-child(2) { animation-delay: 0.2s; }
.hf-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes hf-bounce {
  0%,80%,100% { transform: translateY(0);   opacity: 0.5; }
  40%          { transform: translateY(-6px); opacity: 1; }
}

/* CTA */
.hf-cta-bubble {
  background: linear-gradient(135deg, rgba(0,212,255,0.07), rgba(124,58,237,0.07));
  border: 1px solid rgba(0,212,255,0.18);
  border-radius: 14px;
  padding: 0.9rem;
}
.hf-cta-hint { font-size: 0.83rem; color: var(--color-muted); margin-bottom: 0.7rem; line-height: 1.5; }
.hf-cta-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.hf-cta-wechat {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 10px; background: #07c160; color: #fff;
  font-size: 0.82rem; font-weight: 600; border: none; cursor: pointer;
  transition: opacity 0.2s;
}
.hf-cta-wechat:hover { opacity: 0.85; }
.hf-cta-form {
  display: inline-flex; align-items: center;
  padding: 0.5rem 0.9rem;
  border-radius: 10px; border: 1px solid rgba(0,212,255,0.35);
  color: var(--color-primary); font-size: 0.82rem; font-weight: 600;
  text-decoration: none; transition: background 0.2s;
}
.hf-cta-form:hover { background: rgba(0,212,255,0.08); color: var(--color-primary); }

/* 输入区 */
.hf-chat-input-wrap {
  display: flex; align-items: flex-end; gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid rgba(0,212,255,0.1);
  flex-shrink: 0;
  background: rgba(0,0,0,0.15);
  border-radius: 0 0 20px 20px;
}

/* 输入框列（textarea + 快捷键提示） */
.hf-input-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hf-send-hint {
  font-size: 0.68rem;
  color: rgba(148,163,184,0.45);
  padding-left: 2px;
  line-height: 1;
  user-select: none;
}

#hf-chat-input {
  width: 100%;
  resize: none;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(0,212,255,0.15);
  border-radius: 10px;
  color: var(--color-text);
  font-family: inherit; font-size: 0.87rem; line-height: 1.5;
  padding: 0.5rem 0.75rem;
  min-height: 36px; max-height: 96px;
  overflow-y: auto;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
#hf-chat-input:focus { outline: none; border-color: rgba(0,212,255,0.5); }
#hf-chat-input::placeholder { color: var(--color-muted); font-size: 0.82rem; }
#hf-chat-input:disabled { opacity: 0.4; cursor: not-allowed; }

#hf-chat-send {
  flex-shrink: 0; padding: 0 1rem; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #00d4ff, #7c3aed);
  color: #fff; font-size: 0.83rem; font-weight: 700;
  border: none; cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  white-space: nowrap;
}
#hf-chat-send:hover:not(:disabled) { opacity: 0.88; transform: scale(1.03); }
#hf-chat-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── 微信弹窗 ───────────────────────────────────────────────── */
#hf-wechat-modal {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}
#hf-wechat-modal.hf-modal-open { opacity: 1; pointer-events: auto; }

.hf-wechat-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  text-align: center;
  max-width: 280px; width: calc(100% - 2rem);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,212,255,0.08);
}
#hf-wechat-close {
  position: absolute; top: 0.8rem; right: 0.8rem;
  background: rgba(255,255,255,0.06); border: none;
  color: var(--color-muted); font-size: 1.1rem; cursor: pointer;
  padding: 0.25rem 0.45rem; border-radius: 8px;
  transition: color 0.2s;
}
#hf-wechat-close:hover { color: var(--color-text); }
.hf-wechat-card h3 { font-size: 1rem; color: var(--color-text); margin-bottom: 1.2rem; }
#hf-wechat-qr-img {
  width: 180px; height: 180px;
  border-radius: 12px; display: block; margin: 0 auto 1rem;
  object-fit: contain; background: #fff; padding: 8px;
}
.hf-wechat-card p { font-size: 0.82rem; color: var(--color-muted); line-height: 1.5; margin-bottom: 0.4rem; }
.hf-wechat-id { font-size: 0.9rem !important; font-weight: 700; color: var(--color-primary) !important; }

/* ── 移动端 ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #hf-chat-btn { right: 1rem; bottom: 1.5rem; }
  #hf-chat-win {
    right: 0; bottom: 0; left: 0;
    width: 100%; height: 80vh; max-height: 80vh;
    border-radius: 20px 20px 0 0;
  }
}
