/* QA Bot Icon - 悬浮按钮 */
#qa-bot-icon {
  position: fixed;
  right: 24px;
  bottom: 24px;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #4a90d9;
  border-radius: 24px;
  padding: 10px 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

#qa-bot-icon:hover {
  background: #3a7bc8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#qa-bot-icon span {
  color: #fff;
  font-size: 14px;
}

#qa-bot-icon svg {
  flex-shrink: 0;
}

/* 弹窗容器 - 遮罩层 */
#qa-bot-popup-container {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}

/* 弹窗主体 - 加大尺寸 */
#qa-bot-popup {
  width: 900px;
  max-width: 95vw;
  height: 80vh;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

html.dark #qa-bot-popup {
  background: #1a1a1a;
  color: #ddd;
}

/* 消息列表区域 */
#qa-bot-message-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 消息通用样式 */
.qa-bot-message,
.qa-bot-user-message {
  display: flex;
  gap: 12px;
  line-height: 1.6;
}

/* Bot 消息 */
.qa-bot-message {
  align-items: flex-start;
}

.qa-bot-message-icon,
.qa-bot-user-message-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
}

.qa-bot-message-text {
  flex: 1;
  background: #f5f5f5;
  padding: 14px 18px;
  border-radius: 4px 16px 16px 16px;
  word-break: break-word;
  font-size: 15px;
}

html.dark .qa-bot-message-text {
  background: #2a2a2a;
}

/* 用户消息 */
.qa-bot-user-message {
  flex-direction: row-reverse;
}

.qa-bot-user-message-text {
  flex: 1;
  max-width: 70%;
  background: #4a90d9;
  color: #fff;
  padding: 14px 18px;
  border-radius: 16px 4px 16px 16px;
  word-break: break-word;
  text-align: left;
  font-size: 15px;
}

html.dark .qa-bot-user-message-text {
  background: #3a7bc8;
}

/* Markdown 内容样式 */
.qa-bot-message-text h1,
.qa-bot-message-text h2,
.qa-bot-message-text h3,
.qa-bot-message-text h4 {
  margin: 16px 0 8px 0;
  font-weight: 600;
}

.qa-bot-message-text h1 { font-size: 1.4em; }
.qa-bot-message-text h2 { font-size: 1.25em; }
.qa-bot-message-text h3 { font-size: 1.1em; }

.qa-bot-message-text p {
  margin: 8px 0;
}

.qa-bot-message-text ul,
.qa-bot-message-text ol {
  margin: 8px 0;
  padding-left: 20px;
}

.qa-bot-message-text li {
  margin: 4px 0;
}

.qa-bot-message-text code {
  background: #e8e8e8;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
}

html.dark .qa-bot-message-text code {
  background: #3a3a3a;
}

.qa-bot-message-text pre {
  background: #282c34;
  color: #abb2bf;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
}

.qa-bot-message-text pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.qa-bot-message-text blockquote {
  border-left: 4px solid #4a90d9;
  padding-left: 12px;
  margin: 12px 0;
  color: #666;
}

html.dark .qa-bot-message-text blockquote {
  color: #aaa;
}

.qa-bot-message-text table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}

.qa-bot-message-text th,
.qa-bot-message-text td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
}

html.dark .qa-bot-message-text th,
html.dark .qa-bot-message-text td {
  border-color: #444;
}

.qa-bot-message-text th {
  background: #f0f0f0;
}

html.dark .qa-bot-message-text th {
  background: #333;
}

.qa-bot-message-text a {
  color: #4a90d9;
  text-decoration: none;
}

.qa-bot-message-text a:hover {
  text-decoration: underline;
}

.qa-bot-message-text hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 16px 0;
}

html.dark .qa-bot-message-text hr {
  border-color: #444;
}

/* 用户输入区域 */
#qa-bot-user-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-top: 1px solid #eee;
  background: #fafafa;
}

html.dark #qa-bot-user-input {
  border-color: #333;
  background: #1e1e1e;
}

/* 输入框 */
#qa-bot-question-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s;
}

#qa-bot-question-input:focus {
  border-color: #4a90d9;
}

html.dark #qa-bot-question-input {
  background: #2a2a2a;
  border-color: #444;
  color: #ddd;
}

html.dark #qa-bot-question-input:focus {
  border-color: #4a90d9;
}

/* 提交按钮 */
#qa-bot-submit-button {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: #4a90d9;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

#qa-bot-submit-button:hover:not(:disabled) {
  background: #3a7bc8;
}

#qa-bot-submit-button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

html.dark #qa-bot-submit-button:disabled {
  background: #444;
  color: #888;
}

/* 加载动画 */
#qa-bot-loading-icon {
  display: none;
  width: 24px;
  height: 24px;
  border: 2px solid #ddd;
  border-top-color: #4a90d9;
  border-radius: 50%;
  animation: qa-bot-spin 0.6s linear infinite;
}

@keyframes qa-bot-spin {
  to { transform: rotate(360deg); }
}

/* 相关文档区域 */
.qa-bot-related-files {
  background: #f0f7ff;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-left: 48px;
  border: 1px solid #d0e3f7;
}

html.dark .qa-bot-related-files {
  background: #1e2a3a;
  border-color: #2a3a4a;
}

.qa-bot-related-files-title {
  color: #4a90d9;
  margin-bottom: 8px;
  font-weight: 500;
}

.qa-bot-related-files ul {
  margin: 0;
  padding-left: 20px;
  color: #555;
}

html.dark .qa-bot-related-files ul {
  color: #aaa;
}

.qa-bot-related-files li {
  margin-bottom: 4px;
}

/* 底部信息 */
#qa-bot-powered-by {
  font-size: 12px;
  padding: 10px;
  text-align: center;
  color: #999;
  border-top: 1px solid #eee;
}

html.dark #qa-bot-powered-by {
  border-color: #333;
  color: #666;
}

#qa-bot-powered-by a {
  color: #4a90d9;
  text-decoration: none;
}

/* 错误消息 */
.qa-bot-error-message {
  color: #c00;
  background: #fff0f0;
  padding: 14px 16px;
  border-radius: 8px;
  margin-left: 48px;
  font-size: 14px;
  border: 1px solid #ffdddd;
}

html.dark .qa-bot-error-message {
  background: #3a2020;
  border-color: #4a2020;
  color: #f88;
}

/* 滚动条美化 */
#qa-bot-message-list::-webkit-scrollbar {
  width: 6px;
}

#qa-bot-message-list::-webkit-scrollbar-track {
  background: transparent;
}

#qa-bot-message-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

#qa-bot-message-list::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

html.dark #qa-bot-message-list::-webkit-scrollbar-thumb {
  background: #444;
}

html.dark #qa-bot-message-list::-webkit-scrollbar-thumb:hover {
  background: #555;
}