/* ========== 智能问答页面 ========== */
#page6 { height: calc(100vh - 96px); overflow: hidden; margin-top: -24px}
#page6 > .chat-page { padding: 0; }

.chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-page);
}

.chat-header {
  background: linear-gradient(135deg, var(--primary-blue) 0%, #2a5298 100%);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-header-left h1 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-left h1::before {
  content: '';
  width: 4px;
  height: 22px;
  background: var(--accent-red);
  border-radius: 2px;
}

.chat-subtitle {
  margin: 0 0 0 14px;
  font-size: 13px;
  opacity: 0.85;
}

.chat-client-select {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: 6px;
}

.chat-client-select select {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  outline: none;
}

.chat-client-select select option {
  color: var(--text-primary);
}

.chat-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 侧边栏 */
.chat-sidebar {
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
  flex-shrink: 0;
}

.chat-new-btn {
  width: 100%;
  padding: 10px;
  background: var(--primary-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  margin-bottom: 16px;
  transition: background .2s;
}

.chat-new-btn:hover {
  background: #1e40af;
}

.chat-sidebar-section-title {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  padding: 0 4px;
}

.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.chat-history-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid transparent;
}

.chat-history-item:hover {
  background: var(--bg-page);
}

.chat-history-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary-blue);
  font-weight: 500;
}

.chat-history-item-title {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.chat-history-item-time {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-history-item.active .chat-history-item-time {
  color: var(--primary-blue);
  opacity: 0.7;
}

/* 主聊天区 */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  min-height: 400px;
}

.chat-welcome-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--accent-red) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 8px;
}

.chat-welcome h2 {
  margin: 0;
  font-size: 22px;
  color: var(--text-primary);
}

.chat-welcome p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 500px;
}

.chat-quick-questions {
  margin-top: 24px;
  width: 100%;
  max-width: 700px;
}

.chat-quick-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

.chat-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.chat-quick-btn {
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all .2s;
}

.chat-quick-btn:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  background: #eff6ff;
  transform: translateY(-1px);
}

/* 消息气泡 */
.chat-message {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-message.user .chat-avatar {
  background: var(--primary-blue);
  color: #fff;
}

.chat-message.bot .chat-avatar {
  background: linear-gradient(135deg, var(--accent-red) 0%, #d43a4e 100%);
  color: #fff;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.chat-message.user .chat-bubble {
  background: var(--primary-blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.bot .chat-bubble {
  background: #fff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

/* 消息内Markdown样式 */
.chat-bubble h1, .chat-bubble h2, .chat-bubble h3, .chat-bubble h4 {
  margin: 12px 0 8px 0;
  font-weight: 600;
  color: inherit;
}

.chat-bubble h3 { font-size: 15px; }
.chat-bubble h4 { font-size: 14px; }

.chat-message.user .chat-bubble h1,
.chat-message.user .chat-bubble h2,
.chat-message.user .chat-bubble h3,
.chat-message.user .chat-bubble h4 {
  color: #fff;
}

.chat-bubble p {
  margin: 6px 0;
}

.chat-bubble ul, .chat-bubble ol {
  margin: 6px 0;
  padding-left: 24px;
}

.chat-bubble li {
  margin-bottom: 4px;
}

.chat-bubble strong {
  font-weight: 600;
}

.chat-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-family: 'SFMono-Regular', Consolas, monospace;
}

.chat-message.user .chat-bubble code {
  background: rgba(255, 255, 255, 0.2);
}

.chat-bubble pre {
  background: rgba(0, 0, 0, 0.06);
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}

.chat-bubble pre code {
  background: none;
  padding: 0;
}

/* 引用来源卡片 */
.chat-sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.chat-sources-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.chat-source-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-page);
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all .15s;
  font-size: 12px;
  border: 1px solid transparent;
}

.chat-source-card:hover {
  border-color: var(--primary-blue);
  background: #eff6ff;
}

.chat-source-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: var(--primary-blue);
  color: #fff;
  flex-shrink: 0;
}

.chat-source-card[data-type="method"] .chat-source-icon { background: var(--primary-blue); }
.chat-source-card[data-type="knowledge"] .chat-source-icon { background: #10b981; }
.chat-source-card[data-type="policy"] .chat-source-icon { background: var(--accent-red); }
.chat-source-card[data-type="regulation"] .chat-source-icon { background: #8b5cf6; }
.chat-source-card[data-type="survey"] .chat-source-icon { background: #f59e0b; }

.chat-source-info {
  flex: 1;
  min-width: 0;
}

.chat-source-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-source-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-source-type {
  font-size: 10px;
  padding: 1px 6px;
  background: var(--bg-page);
  border-radius: 3px;
  color: var(--text-muted);
}

/* 输入区 */
.chat-input-area {
  padding: 16px 32px 24px;
  background: var(--bg-page);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input-area textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  background: #fff;
}

.chat-input-area textarea:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-send-btn {
  padding: 0 24px;
  height: 44px;
  background: var(--primary-blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
  white-space: nowrap;
}

.chat-send-btn:hover {
  background: #1e40af;
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 打字机效果光标 */
.chat-typing-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--text-primary);
  animation: blink 1s infinite;
  margin-left: 2px;
  vertical-align: text-bottom;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* 正在输入指示器 */
.chat-thinking {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: thinking 1.4s infinite ease-in-out both;
}

.chat-thinking span:nth-child(1) { animation-delay: -0.32s; }
.chat-thinking span:nth-child(2) { animation-delay: -0.16s; }

@keyframes thinking {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* 响应式 */
@media (max-width: 1024px) {
  .chat-sidebar { width: 220px; }
  .chat-header { padding: 16px 20px; }
  .chat-messages { padding: 16px 20px; }
  .chat-input-area { padding: 12px 20px 20px; }
}

@media (max-width: 768px) {
  .chat-sidebar { display: none; }
  .chat-quick-grid { grid-template-columns: 1fr; }
  .chat-header { flex-direction: column; gap: 10px; align-items: flex-start; }
}
