/* 全局基础样式 */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, "Noto Sans SC", "Hiragino Sans GB", "PingFang SC", "Heiti SC", "WenQuanYi Micro Hei", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
}

/* 布局容器 */
.container {
  display: flex;
  flex-direction: row;
  width: 100%;
  min-height: 100vh; /* 确保容器填满视口高度 */
  background: rgba(255, 255, 255, 0.92);
}

/* 侧边栏 */
.sidebar {
  width: 280px;
  background: rgba(44, 62, 80, 0.92);
  color: white;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.sidebar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
}

.sidebar h1 .icon {
  margin-right: 10px;
  font-size: 22px;
}

.sidebar p.subtitle {
  margin-top: 8px;
  font-size: 14px;
  color: #ecf0f1;
}

/* 导航 */
.nav {
  margin-top: 20px;
}

.nav .nav-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  color: #ecf0f1;
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav .nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(4px);
}

.nav .nav-item.active {
  background: rgba(255, 255, 255, 0.18);
}

.nav .nav-item .icon {
  margin-right: 10px;
  font-size: 18px;
}

/* 主内容区 */
.main {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

/* 欢迎区 */
.welcome {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: white;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  display: none; /* 默认隐藏，进入时显示 */
}

.welcome.show {
  display: block;
  animation: fadeInUp 0.6s ease;
}

.welcome h2 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 700;
}

.welcome p {
  margin: 0;
  font-size: 13px;
}

/* 聊天容器 */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: 12px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  overflow: hidden;
}

/* 聊天消息区域 */
.messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

/* 单条消息 */
.message {
  display: flex;
  margin-bottom: 16px;
}

.message .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #ecf0f1; color: #2c3e50;
  margin-right: 10px;
  font-size: 16px;
}

.message .bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  font-size: 14px;
  line-height: 1.6;
}

.message.user .bubble {
  background: #e7f3ff;
  border: 1px solid #cfe8ff;
}

.message.agent .bubble {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
}

/* Markdown 表格样式 */
.message .bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}
.message .bubble th, .message .bubble td {
  border: 1px solid #ddd;
  padding: 6px 8px;
}
.message .bubble th {
  background: #f1f3f5;
}

/* Markdown 列表样式 */
.message .bubble ul, .message .bubble ol {
  margin: 8px 0 8px 20px;
}

/* 代码块样式 */
.message .bubble pre {
  background: #2c3e50;
  color: #ecf0f1;
  padding: 8px 10px;
  border-radius: 8px;
  overflow-x: auto;
}

.message .bubble code {
  background: #f1f3f5;
  padding: 2px 4px;
  border-radius: 4px;
}

/* 输入区域 */
.input-area {
  display: flex;
  align-items: center;
  padding: 12px;
  border-top: 1px solid #e9ecef;
  background: #fafafa;
}

.input-area textarea {
  flex: 1;
  resize: none;
  height: 48px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid #e9ecef;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.input-area textarea:focus {
  border-color: #3498db;
  box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.input-area button {
  margin-left: 10px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.input-area button:hover { transform: translateY(-1px); }
.input-area button:active { transform: translateY(1px); }

/* 顶部标题动画 */
.header-title {
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: 700;
}

.header-title .title-text {
  position: relative;
}

.header-title .title-text::after {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, #3498db, #9b59b6);
  animation: lineFlow 2s infinite;
}

@keyframes lineFlow {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

/* 打字指示器 */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
}

.typing-indicator .dot {
  width: 6px; height: 6px;
  background: #3498db;
  border-radius: 50%;
  margin: 0 2px;
  animation: typing 1s infinite ease-in-out;
}

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

@keyframes typing {
  0% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-4px); opacity: 1; }
  100% { transform: translateY(0); opacity: 0.5; }
}

/* 加载动画 */
.loading-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid #e9ecef;
  border-top-color: #3498db;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 管理按钮和入口 */
.admin-link {
  margin-top: 12px;
}
.admin-link a {
  color: #ecf0f1;
  text-decoration: none;
  font-size: 13px;
}
.admin-link a:hover {
  color: #fff;
}

.admin-btn {
  margin-top: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
}
.admin-btn:hover { background: rgba(255,255,255,0.18); }

/* 管理密码弹窗（若保留） */
.modal {
  position: fixed; left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
  background: #fff; color: #333; border-radius: 10px;
  width: 320px; max-width: 92%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  padding: 14px 16px;
}
.modal-header { display:flex; align-items:center; justify-content:space-between; }
.modal-header h3 { margin:0; font-size:16px; }
.modal-body { margin: 8px 0; }
.modal-body input {
  width: 100%; border: 2px solid #e9ecef; border-radius: 8px; padding: 8px 10px;
}
.modal-footer { display:flex; justify-content:flex-end; gap:8px; }
.modal-footer button { padding: 6px 10px; border-radius: 8px; }
.modal-error { color: #e74c3c; font-size: 12px; display:none; margin-top: 6px; }
.modal-error.show { display:block; }

/* 响应式优化 */
@media (max-width: 1024px) {
  .sidebar { width: 240px; }
}
@media (max-width: 820px) {
  .container { flex-direction: column; }
  .sidebar { width: 100%; }
}
@media (max-width: 480px) {
  .message .bubble { max-width: 88%; }
  .input-area textarea { height: 70px; }
}

/* 自定义滚动条 */
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: #cfd8dc; border-radius: 8px; }
.messages::-webkit-scrollbar-track { background: #f5f5f5; }

/* 流式输出的闪烁效果（可选） */
.stream-highlight {
  animation: streamBlink 0.8s ease-in-out infinite;
}
@keyframes streamBlink {
  0% { background: rgba(255,255,0,0.06); }
  50% { background: rgba(255,255,0,0.12); }
  100% { background: rgba(255,255,0,0.06); }
}

