/* Purui multilingual AI chat widget */
#purui-chat-root {
  position: fixed;
  inset: 0;
  z-index: 100000;
  pointer-events: none;
}

/* 站内 custom-cursor 会隐藏系统指针；聊天区内恢复可见光标 */
body.custom-cursor #purui-chat-root,
body.custom-cursor #purui-chat-root * {
  cursor: auto !important;
}

body.purui-chat-active .cursor-dot,
body.purui-chat-active .cursor-ring {
  opacity: 0 !important;
}

.purui-chat-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1;
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #0369a1);
  color: #fff;
  box-shadow: 0 12px 32px rgba(3, 105, 161, 0.35);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.purui-chat-fab:hover { transform: translateY(-2px); }
.purui-chat-fab svg { width: 26px; height: 26px; fill: currentColor; }

.purui-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  z-index: 2;
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 120px));
  min-height: 320px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  isolation: isolate;
}
.purui-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.purui-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0c4a6e, #075985);
  border-bottom: 1px solid #164e63;
}
.purui-chat-header strong { font-size: 0.95rem; }
.purui-chat-header span { display: block; font-size: 0.75rem; color: #bae6fd; margin-top: 2px; }
.purui-chat-close {
  background: transparent;
  border: 0;
  color: #e2e8f0;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.purui-chat-messages {
  flex: 1 1 auto;
  min-height: 140px;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #0b1220;
  overscroll-behavior: contain;
}
.purui-chat-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.purui-chat-msg--bot {
  align-self: flex-start;
  background: #1e293b;
  border: 1px solid #334155;
}
.purui-chat-msg--user {
  align-self: flex-end;
  background: #0369a1;
  color: #f8fafc;
}
.purui-chat-msg--typing {
  opacity: 0.7;
  font-style: italic;
}

.purui-chat-lead {
  display: none;
  flex-shrink: 0;
  max-height: 42%;
  overflow: auto;
  padding: 12px 14px;
  border-top: 1px solid #334155;
  background: #111827;
}
.purui-chat-lead.is-visible { display: block; }
.purui-chat-lead h4 { margin: 0 0 8px; font-size: 0.9rem; }
.purui-chat-lead label { display: block; font-size: 0.75rem; color: #94a3b8; margin: 6px 0 4px; }
.purui-chat-lead input,
.purui-chat-lead textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1220;
  color: #e2e8f0;
  font: inherit;
}
.purui-chat-lead textarea { min-height: 64px; resize: vertical; }
.purui-chat-lead-actions { display: flex; gap: 8px; margin-top: 10px; }
.purui-chat-lead-actions button {
  flex: 1;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  font-weight: 600;
}
.purui-chat-lead-submit { background: #38bdf8; color: #0f172a; }
.purui-chat-lead-cancel { background: transparent; color: #94a3b8; border: 1px solid #334155 !important; }

.purui-chat-footer {
  flex-shrink: 0;
  border-top: 1px solid #334155;
  padding: 10px;
  background: #0f172a;
}
.purui-chat-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.purui-chat-tools button {
  flex: 1;
  background: #1e293b;
  color: #bae6fd;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 0.78rem;
  cursor: pointer;
}
.purui-chat-input-row { display: flex; gap: 8px; }
.purui-chat-input-row input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #0b1220;
  color: #e2e8f0;
  padding: 10px 12px;
  font: inherit;
}
.purui-chat-input-row button {
  border: 0;
  border-radius: 10px;
  background: #0ea5e9;
  color: #0f172a;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}

html[dir="rtl"] .purui-chat-fab,
html[dir="rtl"] .purui-chat-panel {
  right: auto;
  left: 20px;
}
html[dir="rtl"] .purui-chat-msg--user { align-self: flex-start; }
html[dir="rtl"] .purui-chat-msg--bot { align-self: flex-end; }

@media (max-width: 480px) {
  .purui-chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 82px;
  }
  html[dir="rtl"] .purui-chat-panel { left: 12px; right: 12px; }
}

/* 避免与「返回顶部」按钮重叠遮挡 */
body.purui-chat-active .back-top {
  right: 92px;
}
