/* ===========================================
   灵智研-AI教育科研 - 主样式表
   Theme: Clean Academic Design
   =========================================== */

/* ── 变量定义 ── */
:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-dark: #0e2f44;
  --accent: #e67e22;
  --accent-light: #f39c12;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f1c40f;
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dee2e6;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ── 全局 ── */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  line-height: 1.7;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 顶部导航 ── */
.navbar {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary)) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 0.6rem 1rem;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff !important;
  letter-spacing: 0.5px;
}

.navbar-brand small {
  font-weight: 400;
  opacity: 0.7;
  font-size: 0.75rem;
  margin-left: 8px;
}

.navbar .nav-link {
  color: rgba(255,255,255,0.85) !important;
  font-size: 0.9rem;
  padding: 0.5rem 0.9rem !important;
  border-radius: 6px;
  transition: all 0.2s;
  margin: 0 2px;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
  background: rgba(255,255,255,0.15);
  color: #fff !important;
}

.navbar .nav-link .nav-icon {
  margin-right: 4px;
}

/* ── 主容器 ── */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ── 页面标题 ── */
.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 6px 0;
}

.page-header .subtitle {
  color: var(--text-light);
  font-size: 0.95rem;
  margin: 0;
}

/* ── 卡片 ── */
.card {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
  margin-bottom: 20px;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 1.05rem;
}

.card-body {
  padding: 20px;
}

.card-footer {
  background: transparent;
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}

/* ── 首页模块卡片网格 ── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.module-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: all 0.25s;
  cursor: pointer;
  text-decoration: none !important;
  display: block;
  color: var(--text);
  position: relative;
  overflow: hidden;
}

.module-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.module-card .module-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.module-card h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--primary);
}

.module-card p {
  font-size: 0.88rem;
  color: var(--text-light);
  margin: 0;
  line-height: 1.5;
}

.module-card .module-badge {
  display: inline-block;
  background: var(--primary-light);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 10px;
}

/* ── 按钮 ── */
.btn {
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  padding: 8px 18px;
  font-weight: 500;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #219a52;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: #d35400;
}

.btn-sm {
  font-size: 0.82rem;
  padding: 5px 12px;
}

/* ── 表单 ── */
.form-label {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: var(--text);
}

.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
  width: 100%;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  outline: none;
  box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.12);
}

textarea.form-control {
  min-height: 120px;
  line-height: 1.6;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* ── 标签/徽章 ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 500;
}

.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ── 原则提示条 ── */
.principle-bar {
  background: linear-gradient(135deg, #fef9e7, #fdebd0);
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.principle-bar strong {
  color: var(--accent);
}

/* ── 加载状态 ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-light);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}

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

/* ── 结果容器 ── */
.result-box {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ── 统计数据卡片 ── */
.stat-card {
  text-align: center;
  padding: 20px;
}

.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* ── 标签列表 ── */
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  background: #eef2f7;
  color: var(--text);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
}

/* ── 步骤条 ── */
.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.step {
  flex: 1;
  text-align: center;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-light);
}

.step.active {
  background: var(--primary);
  color: #fff;
}

.step.done {
  background: var(--success);
  color: #fff;
}

/* ── 知识卡片 ── */
.knowledge-card {
  background: linear-gradient(135deg, #ebf5fb, #d6eaf8);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 16px;
}

.knowledge-card h4 {
  font-size: 0.95rem;
  color: var(--primary);
  margin: 0 0 6px 0;
}

/* ── 列表样式 ── */
.list-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.list-item:last-child {
  border-bottom: none;
}

/* ── 响应式 ── */
@media (max-width: 768px) {
  .main-container { padding: 16px 12px; }
  .module-grid { grid-template-columns: 1fr; }
  .navbar-brand { font-size: 1rem; }
  .page-header h1 { font-size: 1.4rem; }
  .stat-card .stat-number { font-size: 1.5rem; }
}

/* ── 文件上传区 ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  background: #fafafa;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary-light);
  background: #ebf5fb;
}

.upload-zone .upload-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  opacity: 0.5;
}

.upload-zone .upload-text {
  font-size: 0.95rem;
  color: var(--text-light);
}

/* ── 参考文献检查 ── */
.issue-item {
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
  background: #fffbf0;
}

.issue-item.error {
  border-left-color: var(--danger);
  background: #fef2f2;
}

.issue-item.success {
  border-left-color: var(--success);
  background: #f0fdf4;
}

/* ── 页脚 ── */
.footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-light);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer .principle-footer {
  max-width: 600px;
  margin: 0 auto;
  font-size: 0.8rem;
  opacity: 0.7;
}

/* ── HTMX 加载指示器 ── */
.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  color: var(--text-light);
  font-size: 0.95rem;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.htmx-request {
  opacity: 0.6;
  transition: opacity 0.2s;
}

.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator {
  display: inline-block;
}

/* ── Toast 动画 ── */
@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── 响应式导航增强 ── */
@media (max-width: 576px) {
  .navbar .navbar-nav {
    max-height: 70vh;
    overflow-y: auto;
  }
  .page-header h1 { font-size: 1.2rem; }
}
