/* ===== 基础重置 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --accent: #06b6d4;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: linear-gradient(135deg, #2563eb, #06b6d4);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.15);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.6;
}

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

/* ===== 侧边栏 ===== */
#sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 2px 0 12px rgba(0,0,0,.2);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: linear-gradient(135deg, rgba(37,99,235,.3), rgba(6,182,212,.15));
}

.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: bold; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
}

.logo-title {
  font-size: 15px; font-weight: 700; color: #f1f5f9;
  letter-spacing: .3px;
}
.logo-sub {
  font-size: 11px; color: #94a3b8; margin-top: 1px;
  letter-spacing: .5px;
}

.nav-list { list-style: none; padding: 12px 10px; flex: 1; overflow-y: auto; }

.nav-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin-bottom: 3px;
  transition: all .2s;
  color: #94a3b8;
  font-size: 14px;
}
.nav-list li:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-list li.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.nav-icon { font-size: 16px; flex-shrink: 0; }
.nav-label { font-weight: 500; }

/* ===== 主内容 ===== */
#main-content {
  flex: 1; overflow-y: auto;
  padding: 28px 32px;
  background: var(--bg-main);
}

.page { display: none; }
.page.active { display: block; }

.page-title {
  font-size: 22px; font-weight: 700;
  color: var(--text-main);
  margin-bottom: 24px;
  display: flex; align-items: center; gap: 10px;
}
.page-title::before {
  content: '';
  display: inline-block;
  width: 4px; height: 22px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border-radius: 2px;
}

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

/* ===== 按钮 ===== */
.btn {
  padding: 9px 22px;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px; font-weight: 500;
  transition: all .2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(37,99,235,.45); transform: translateY(-1px); }
.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,.3);
}
.btn-success:hover { box-shadow: 0 4px 16px rgba(16,185,129,.4); transform: translateY(-1px); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.btn:hover { opacity: .92; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ===== 输入框 ===== */
textarea, input[type=text], input[type=password], select {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; outline: none;
  font-family: inherit;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  color: var(--text-main);
}
textarea:focus, input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea { resize: vertical; min-height: 80px; }

/* ===== 欢迎语 ===== */
.chat-welcome {
  font-size: 14px; color: var(--text-muted);
  margin-bottom: 18px; padding: 12px 16px;
  background: linear-gradient(135deg, #eff6ff, #ecfeff);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
}

/* ===== 聊天界面 ===== */
#chat-messages {
  height: 440px; overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.msg { margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-end; }
.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.msg.user .msg-avatar { background: linear-gradient(135deg, #2563eb, #06b6d4); color: #fff; }
.msg.assistant .msg-avatar { background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff; }

.msg-bubble {
  max-width: 72%; padding: 11px 16px;
  border-radius: 16px; font-size: 14px; line-height: 1.7;
  white-space: pre-wrap;
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff; border-radius: 16px 4px 16px 16px;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.msg.assistant .msg-bubble {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  box-shadow: var(--shadow-sm);
}

.chat-input-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-input-row textarea { flex: 1; min-height: 46px; max-height: 120px; }

/* ===== 结果区 ===== */
.result-box {
  background: #f8fafc; border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  margin-top: 16px; line-height: 1.9;
  white-space: pre-wrap; font-size: 14px;
}

/* ===== 题目卡片 ===== */
.question-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.question-text { font-size: 15px; line-height: 1.9; margin-bottom: 18px; color: var(--text-main); }
.options-list { list-style: none; }
.options-list li {
  padding: 10px 16px; margin: 6px 0;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all .2s; font-size: 14px;
}
.options-list li:hover { background: #eff6ff; border-color: var(--primary-light); }
.options-list li.selected { background: #eff6ff; border-color: var(--primary); color: var(--primary); font-weight: 500; }
.options-list li.correct { background: #f0fdf4; border-color: #10b981; color: #065f46; }
.options-list li.wrong { background: #fef2f2; border-color: #ef4444; color: #991b1b; }

/* ===== 标签组 ===== */
.tag-group { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tag {
  padding: 6px 16px; border: 1.5px solid var(--border);
  border-radius: 20px; cursor: pointer; font-size: 13px;
  transition: all .2s; color: var(--text-muted); background: #fff;
}
.tag:hover { border-color: var(--primary); color: var(--primary); }
.tag.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(37,99,235,.3); }

/* ===== 统计卡片 ===== */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 22px; text-align: center;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-num { font-size: 34px; font-weight: 700; background: linear-gradient(135deg, #2563eb, #06b6d4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* ===== 文件上传 ===== */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px; text-align: center; cursor: pointer;
  transition: all .2s; background: #f8fafc; color: var(--text-muted);
}
.upload-area:hover { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.upload-area input { display: none; }

/* ===== 加载动画 ===== */
.loading {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid #e2e8f0; border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 历史列表 ===== */
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid #f1f5f9;
  cursor: pointer; transition: background .2s; border-radius: var(--radius-sm);
}
.history-item:hover { background: #f8fafc; }
.history-title { font-size: 14px; font-weight: 500; color: var(--text-main); }
.history-meta { font-size: 12px; color: var(--text-muted); }

/* ===== 登录页 ===== */
#login-page {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}

#login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(37,99,235,.15) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 50%, rgba(6,182,212,.1) 0%, transparent 60%);
}

.login-box {
  background: rgba(255,255,255,.97);
  border-radius: 20px; padding: 44px 40px;
  width: 400px;
  box-shadow: 0 25px 80px rgba(0,0,0,.4);
  position: relative; z-index: 1;
  backdrop-filter: blur(10px);
}

.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: bold; color: #fff;
  margin: 0 auto 14px;
  box-shadow: 0 8px 24px rgba(37,99,235,.4);
}
.login-logo-title { font-size: 20px; font-weight: 700; color: #0f172a; }
.login-logo-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.login-tabs { display: flex; border-bottom: 2px solid #f1f5f9; margin-bottom: 26px; }
.login-tab {
  flex: 1; text-align: center; padding: 10px;
  cursor: pointer; font-size: 15px; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s;
}
.login-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

#login-form { display: flex; flex-direction: column; gap: 14px; }
#login-form input {
  padding: 13px 16px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 15px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.login-submit { padding: 13px; font-size: 15px; border-radius: var(--radius-sm); }
.login-error { color: #ef4444; font-size: 13px; min-height: 18px; }

/* ===== 侧边栏用户区 ===== */
#sidebar-user {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  background: rgba(0,0,0,.15);
}
.sidebar-username {
  font-size: 13px; color: #94a3b8; margin-bottom: 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.btn-logout {
  width: 100%; padding: 8px;
  background: transparent; border: 1px solid rgba(255,255,255,.15);
  color: #94a3b8; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; transition: all .2s;
}
.btn-logout:hover { background: rgba(239,68,68,.2); border-color: #ef4444; color: #fca5a5; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
