/* ====== 主题变量 ====== */
:root, [data-theme="light"] {
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-nav: #ffffff;
  --bg-input: #f0f2f5;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #eff6ff;
  --accent: #8b5cf6;
  --danger: #ef4444;
  --tag-bg: #f0f2f5;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1b26;
  --bg-nav: #1a1b26;
  --bg-input: #24252d;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --border: #2d2e3a;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-light: #1e293b;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.4);
  --tag-bg: #24252d;
}

/* ====== 基础样式 ====== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ====== 导航 ====== */
.navbar {
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  transition: background 0.3s;
}
.nav-container {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 60px;
}
.logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.logo:hover { color: var(--primary); }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: var(--bg-input);
}
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}
.theme-toggle:hover { background: var(--bg-input); }

/* ====== 按钮 ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-text {
  background: none;
  color: var(--primary);
  padding: 6px 0;
}
.btn-text:hover { color: var(--primary-hover); }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.back-btn { margin-bottom: 16px; font-size: 0.9rem; }

/* ====== 卡片 ====== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow); }

/* ====== 板块标签 ====== */
.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.category-tab {
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.category-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.category-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ====== 帖子列表 ====== */
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.post-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.post-item.pinned {
  border-left: 3px solid var(--accent);
}
.post-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.post-category {
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--tag-bg);
  color: var(--text-secondary);
}
.pin-badge {
  font-size: 0.75rem;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
}
.post-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}
.post-excerpt {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.post-meta-left { display: flex; align-items: center; gap: 12px; }
.post-meta-right { display: flex; align-items: center; gap: 12px; }
.post-author { font-weight: 500; color: var(--text); }
.post-time { color: var(--text-secondary); }
.post-stats span { margin-left: 4px; }

/* ====== 帖子详情 ====== */
.post-detail {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px;
  margin-bottom: 16px;
}
.post-detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}
.post-detail-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.post-detail-content {
  font-size: 1rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.post-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

/* ====== 回复 ====== */
.replies-section { margin-bottom: 20px; }
.replies-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.reply-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 8px;
}
.reply-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.reply-author { font-weight: 600; color: var(--text); }
.reply-time { color: var(--text-secondary); }
.reply-content {
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ====== 表单 ====== */
.form-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px;
}
.form-card h2 { margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-group textarea { resize: vertical; min-height: 100px; }
.form-error { color: var(--danger); font-size: 0.85rem; margin-bottom: 10px; }
.form-footer { text-align: center; margin-top: 14px; font-size: 0.85rem; color: var(--text-secondary); }

/* ====== 弹窗 ====== */
.modal { 
  position: fixed; 
  top: 0; left: 0; 
  width: 100%; height: 100%; 
  z-index: 1000; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
}
.modal-backdrop {
  position: absolute;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  z-index: 1;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }
.modal-content h2 { margin-bottom: 20px; font-size: 1.3rem; }

/* ====== 用户菜单 ====== */
.user-section { display: flex; align-items: center; gap: 10px; }
.user-menu { position: relative; cursor: pointer; }
.user-displayname {
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.user-displayname:hover { background: var(--bg-input); }
.user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  overflow: hidden;
  z-index: 50;
}
.user-menu:hover .user-dropdown { display: block; }
.user-dropdown a {
  display: block;
  padding: 10px 16px;
  color: var(--text);
  font-size: 0.85rem;
  transition: background 0.2s;
}
.user-dropdown a:hover { background: var(--bg-input); }

/* ====== Hero区域 ====== */
.hero {
  text-align: center;
  padding: 40px 0 30px;
}
.hero h1 { font-size: 2.2rem; margin-bottom: 8px; }
.hero p { color: var(--text-secondary); font-size: 1rem; }

/* ====== 分页 ====== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  padding: 16px 0;
}
.page-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ====== 回复表单 ====== */
.reply-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.reply-form h3 { margin-bottom: 12px; font-size: 1rem; }

/* ====== 用户面板 ====== */
.user-profile-info { text-align: center; padding: 10px 0; }
.user-profile-info .avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 12px;
  color: var(--primary);
}
.user-profile-info h3 { font-size: 1.2rem; margin-bottom: 4px; }
.user-profile-info .role-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 12px;
}
.user-profile-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.user-profile-stats .stat-value { font-size: 1.3rem; font-weight: 700; }
.user-profile-stats .stat-label { font-size: 0.8rem; color: var(--text-secondary); }

/* ====== 空状态 ====== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ====== 搜索框 ====== */
.search-box {
  display: flex;
  gap: 8px;
  margin: 20px 0;
}
.search-box input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
}

/* ====== 页脚 ====== */
.footer {
  text-align: center;
  padding: 30px 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ====== Toast ====== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ====== 响应式 ====== */
@media (max-width: 600px) {
  .nav-container { gap: 8px; }
  .nav-links { display: none; }
  .logo { font-size: 1.1rem; }
  .hero h1 { font-size: 1.6rem; }
  .post-detail { padding: 20px; }
  .modal-content { margin: 16px; padding: 24px; }
  .user-displayname { font-size: 0.85rem; }
}
