/* 企业知识库问答系统 - 样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  background: #f5f7fa;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* 侧边栏 */
#sidebar {
  width: 320px;
  background: #fff;
  border-right: 1px solid #e8ecf1;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s;
}

#sidebar.hidden {
  margin-left: -320px;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e8ecf1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  font-size: 18px;
  color: #1a1a1a;
}

#toggle-sidebar {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #666;
}

.ingest-section, .documents-section {
  padding: 20px;
  border-bottom: 1px solid #e8ecf1;
}

.ingest-section h3, .documents-section h3 {
  font-size: 14px;
  color: #333;
  margin-bottom: 12px;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 14px;
}

.input-group button {
  padding: 8px 16px;
  background: #1677ff;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.input-group button:hover {
  background: #4096ff;
}

.ingest-status {
  margin-top: 8px;
  font-size: 12px;
  color: #666;
  min-height: 20px;
}

#documents-list {
  flex: 1;
  overflow-y: auto;
}

.doc-item {
  padding: 12px;
  border: 1px solid #e8ecf1;
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.doc-item:hover {
  background: #f5f7fa;
}

.doc-item h4 {
  font-size: 14px;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.doc-item .meta {
  font-size: 12px;
  color: #999;
}

/* 主聊天区域 */
#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f5f7fa;
}

header {
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #e8ecf1;
  display: flex;
  align-items: center;
  gap: 16px;
}

header h1 {
  font-size: 20px;
  color: #1a1a1a;
  flex: 1;
}

#toggle-sidebar-2 {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #666;
  display: none;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.kb-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
}

#clear-btn {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
}

#clear-btn:hover {
  background: #f5f7fa;
}

/* 聊天容器 */
#chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

#messages {
  max-width: 800px;
  margin: 0 auto;
}

.message {
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
}

.message.user {
  flex-direction: row-reverse;
}

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

.message.assistant .avatar {
  background: #e6f4ff;
}

.message.user .avatar {
  background: #f6ffed;
}

.message .content {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.message.assistant .content {
  background: #fff;
  color: #1a1a1a;
}

.message.user .content {
  background: #1677ff;
  color: #fff;
}

.message .sources {
  margin-top: 8px;
  padding: 8px 12px;
  background: #f5f7fa;
  border-radius: 6px;
  font-size: 12px;
  color: #666;
}

/* 输入区域 */
#input-area {
  padding: 16px 24px;
  background: #fff;
  border-top: 1px solid #e8ecf1;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

#user-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
}

#user-input:focus {
  border-color: #1677ff;
}

#send-btn {
  padding: 10px 24px;
  background: #1677ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

#send-btn:hover {
  background: #4096ff;
}

#send-btn:disabled {
  background: #d9d9d9;
  cursor: not-allowed;
}

/* 打字指示器 */
#typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  color: #999;
  font-size: 14px;
}

#typing-indicator.hidden {
  display: none;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* 响应式 */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 100;
  }
  
  #toggle-sidebar-2 {
    display: block;
  }
}
