/* ============================================
   小舸智能导航 - 对话组件样式
   GET关务工具站 · 2026-09
   ============================================ */

:root {
  --xh-primary: #1e3a5f;
  --xh-primary-light: #2c5282;
  --xh-accent: #2563eb;
  --xh-accent-light: #60a5fa;
  --xh-bg-white: #ffffff;
  --xh-text-primary: #1a202c;
  --xh-text-secondary: #4a5568;
  --xh-text-muted: #718096;
  --xh-border-color: #e2e8f0;
  --xh-shadow-lg: 0 10px 30px rgba(30,58,95,0.15);
  --xh-radius-md: 10px;
  --xh-radius-lg: 16px;
}

/* ========== 悬浮气泡按钮 ========== */
.xh-fab {
  position: fixed;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(37,99,235,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 9999;
}
.xh-fab:hover {
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 12px 36px rgba(37,99,235,0.5);
}
.xh-fab img { width: 120px; height: 120px; border-radius: 50%; }
.xh-fab .xh-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 18px; height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: xh-pulse 2s infinite;
}
@keyframes xh-pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ========== 对话面板 ========== */
.xh-panel {
  position: fixed;
  bottom: 110px;
  right: 32px;
  width: 400px;
  height: 580px;
  max-height: calc(100vh - 140px);
  background: var(--xh-bg-white);
  border-radius: var(--xh-radius-lg);
  box-shadow: var(--xh-shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  animation: xh-slide-up 0.3s ease;
}
.xh-panel.open { display: flex; }
@keyframes xh-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 面板头部 */
.xh-header {
  background: linear-gradient(135deg, var(--xh-primary) 0%, var(--xh-primary-light) 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.xh-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.xh-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.xh-header-info h3 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.xh-header-info p { font-size: 12px; opacity: 0.8; }
.xh-header-status {
  margin-left: auto;
  width: 8px; height: 8px;
  background: #22c55e;
  border-radius: 50%;
}

/* 消息区域 */
.xh-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.xh-messages::-webkit-scrollbar { width: 4px; }
.xh-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.xh-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: xh-fade-in 0.3s ease;
}
@keyframes xh-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.xh-msg.ai { align-self: flex-start; }
.xh-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.xh-msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  overflow: hidden;
}
.xh-msg-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.xh-msg.ai .xh-msg-avatar { background: #e8f0fe; }
.xh-msg.user .xh-msg-avatar { background: var(--xh-accent); color: #fff; }

.xh-msg-content {
  padding: 12px 16px;
  border-radius: var(--xh-radius-md);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.xh-msg.ai .xh-msg-content {
  background: #f1f5f9;
  color: var(--xh-text-primary);
  border-bottom-left-radius: 4px;
}
.xh-msg.user .xh-msg-content {
  background: var(--xh-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* 加载动画 */
.xh-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #f1f5f9;
  border-radius: var(--xh-radius-md);
  border-bottom-left-radius: 4px;
}
.xh-typing span {
  width: 6px; height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: xh-bounce 1.4s infinite;
}
.xh-typing span:nth-child(2) { animation-delay: 0.2s; }
.xh-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes xh-bounce {
  0%,80%,100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* 快捷标签 */
.xh-quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}
.xh-tag {
  padding: 6px 14px;
  background: #e8f0fe;
  color: var(--xh-accent);
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.xh-tag:hover { background: var(--xh-accent); color: #fff; }

/* 输入区域 */
.xh-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--xh-border-color);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}
.xh-input-area textarea {
  flex: 1;
  border: 1px solid var(--xh-border-color);
  border-radius: var(--xh-radius-md);
  padding: 10px 14px;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 80px;
  min-height: 42px;
  line-height: 1.5;
  transition: border-color 0.2s;
  font-family: inherit;
}
.xh-input-area textarea:focus { border-color: var(--xh-accent); }
.xh-send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--xh-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.xh-send-btn:hover { background: var(--xh-primary-light); transform: scale(1.05); }
.xh-send-btn svg { width: 20px; height: 20px; }

/* ========== 留资弹窗 ========== */
.xh-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}
.xh-overlay.open { display: flex; }
.xh-lead-modal {
  background: #fff;
  border-radius: var(--xh-radius-lg);
  padding: 32px 28px 28px;
  width: 380px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: xh-fade-in 0.3s ease;
}
.xh-lead-modal h3 {
  font-size: 18px;
  color: var(--xh-primary);
  margin-bottom: 8px;
  text-align: center;
}
.xh-lead-modal .lead-sub {
  font-size: 13px;
  color: var(--xh-text-muted);
  text-align: center;
  margin-bottom: 24px;
}
.xh-lead-modal .lead-form { display: flex; flex-direction: column; gap: 14px; }
.xh-lead-modal label {
  font-size: 13px;
  font-weight: 600;
  color: var(--xh-text-secondary);
  margin-bottom: -8px;
}
.xh-lead-modal input {
  border: 1px solid var(--xh-border-color);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.xh-lead-modal input:focus { border-color: var(--xh-accent); }
.xh-lead-modal .lead-submit {
  width: 100%;
  padding: 12px;
  background: var(--xh-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
  font-family: inherit;
}
.xh-lead-modal .lead-submit:hover { background: var(--xh-primary-light); }
.xh-lead-modal .lead-cancel {
  width: 100%;
  padding: 10px;
  background: none;
  color: var(--xh-text-muted);
  border: none;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.xh-lead-modal .lead-compliance {
  font-size: 11px;
  color: var(--xh-text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ========== 响应式 ========== */
@media (max-width: 480px) {
  .xh-panel {
    right: 0; bottom: 0;
    width: 100%; height: calc(100vh - 80px);
    border-radius: 0;
    max-height: none;
  }
  .xh-fab { bottom: 20px; right: 20px; width: 56px; height: 56px; }
  .xh-fab svg { width: 28px; height: 28px; }
  .xh-panel { bottom: 90px; }
}

/* ========== 页面跳转按钮（【页面名】渲染为可点击按钮） ========== */
.xh-page-link {
  display: inline-block;
  margin: 2px 3px;
  padding: 3px 10px;
  background: #eaf1ff;
  color: #2b5cff;
  border: 1px solid #b9cdff;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s ease;
}
.xh-page-link:hover {
  background: #2b5cff;
  color: #fff;
  border-color: #2b5cff;
}
.xh-page-link::after {
  content: " ↗";
  font-size: 11px;
  font-weight: 400;
}

/* ========== 开屏问候气泡 ========== */
.xh-greeting-bubble {
  position: fixed;
  top: 50%;
  right: 140px;
  transform: translateY(-50%) translateX(20px);
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(30, 58, 95, 0.15);
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.4s ease;
  pointer-events: none;
  z-index: 9999;
  max-width: 280px;
}
.xh-greeting-bubble.xh-greeting-show {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.xh-greeting-text {
  font-size: 14px;
  line-height: 1.6;
  color: #1a202c;
  white-space: normal;
}
.xh-greeting-arrow {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid #ffffff;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

/* 对话框关闭按钮 */
.xh-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.08);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 16px;
  line-height: 1;
  transition: background 0.2s;
  z-index: 10;
}
.xh-close-btn:hover {
  background: rgba(0,0,0,0.15);
  color: #333;
}
