/* ============================================
   云栖论坛 - 现代化清爽设计
   ============================================ */

:root {
  --primary: #6366F1;
  --primary-light: #818CF8;
  --primary-dark: #4F46E5;
  --primary-bg: #EEF2FF;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #0EA5E9;
  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-hover: #F1F5F9;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --max-width: 1200px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-dark); }

/* === 顶部导航 === */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.navbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.logo:hover { color: var(--primary-dark); }
.nav-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}
.nav-search input {
  width: 100%;
  height: 38px;
  padding: 0 16px 0 40px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  background: var(--bg);
  outline: none;
  transition: all .2s;
}
.nav-search input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-bg); }
.nav-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.nav-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }

/* 用户菜单 */
.user-menu { position: relative; }
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color .2s;
}
.user-avatar:hover { border-color: var(--primary); }
.dropdown {
  position: absolute;
  top: 48px;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  overflow: hidden;
  z-index: 200;
}
.dropdown-item {
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-divider { height: 1px; background: var(--border); }

/* === 布局 === */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px;
}
.layout {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 24px;
}
.sidebar-left { position: sticky; top: 84px; align-self: start; }
.sidebar-right { position: sticky; top: 84px; align-self: start; }

/* === 板块导航 === */
.cat-nav { display: flex; flex-direction: column; gap: 2px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: all .15s;
}
.cat-item:hover { background: var(--bg-hover); }
.cat-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.cat-icon { font-size: 18px; }

/* === 帖子列表 === */
.main-content { min-width: 0; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 18px; font-weight: 700; }
.post-list { display: flex; flex-direction: column; gap: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.post-card {
  display: flex;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.post-card:last-child { border-bottom: none; }
.post-card:hover { background: var(--bg-hover); }
.post-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.post-body { flex: 1; min-width: 0; }
.post-meta-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.post-meta-row .cat-badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; font-weight: 600; }
.post-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.post-card:hover .post-title { color: var(--primary); }
.post-summary { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-stats { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.post-stats span { display: flex; align-items: center; gap: 4px; }
.pin-badge { display: inline-flex; align-items: center; gap: 3px; background: var(--warning); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }

/* === 帖子详情 === */
.post-detail { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.post-detail-title { font-size: 24px; font-weight: 800; margin-bottom: 12px; line-height: 1.4; }
.post-detail-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); padding-bottom: 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.post-detail-content { font-size: 15px; line-height: 1.8; color: var(--text); }
.post-detail-content p { margin-bottom: 16px; }
.post-detail-content pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; overflow-x: auto; margin: 12px 0; }
.post-detail-content code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.post-detail-actions { display: flex; gap: 16px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.action-btn { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border); border-radius: 20px; background: #fff; cursor: pointer; font-size: 14px; color: var(--text-secondary); transition: all .2s; }
.action-btn:hover { border-color: var(--primary); color: var(--primary); }
.action-btn.liked { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }

/* === 评论 === */
.comments-section { margin-top: 32px; }
.comments-header { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.comment-item { display: flex; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.comment-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.comment-body { flex: 1; }
.comment-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.comment-author { font-weight: 600; color: var(--text); font-size: 13px; }
.comment-content { font-size: 14px; color: var(--text); line-height: 1.6; }
.comment-actions { display: flex; gap: 12px; margin-top: 6px; }
.comment-action { font-size: 12px; color: var(--text-muted); cursor: pointer; }
.comment-action:hover { color: var(--primary); }
.reply-form { margin-top: 8px; display: none; }
.reply-form.active { display: block; }

/* === 输入框 === */
.input, .textarea, .select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field { margin-bottom: 16px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* === 卡片 === */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }

/* === 右侧栏 === */
.side-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.side-card-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 13px; }
.stat-row .stat-num { font-weight: 700; color: var(--primary); }
.hot-post { display: block; padding: 6px 0; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); }
.hot-post:last-child { border-bottom: none; }
.hot-post:hover { color: var(--primary); }
.hot-post .rank { display: inline-block; width: 18px; font-weight: 700; color: var(--text-muted); }
.hot-post:nth-child(1) .rank, .hot-post:nth-child(2) .rank, .hot-post:nth-child(3) .rank { color: var(--danger); }

/* === 登录/注册弹窗 === */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 300; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal { background: #fff; border-radius: var(--radius-lg); padding: 36px; width: 420px; max-width: 90vw; box-shadow: var(--shadow-lg); transform: scale(.95); transition: transform .2s; }
.modal-overlay.active .modal { transform: scale(1); }
.modal-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.modal-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }
.modal-close { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 50%; color: var(--text-muted); }
.modal-close:hover { background: var(--bg-hover); }
.modal-switch { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 20px; }

/* === 发帖 === */
.editor-page { max-width: 760px; margin: 0 auto; }
.editor-title { font-size: 22px; font-weight: 800; margin-bottom: 24px; }

/* === 个人页 === */
.profile-header { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; display: flex; gap: 20px; align-items: center; margin-bottom: 24px; }
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; flex-shrink: 0; }
.profile-info h2 { font-size: 20px; font-weight: 800; }
.profile-bio { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.profile-stats { display: flex; gap: 20px; margin-top: 12px; font-size: 13px; color: var(--text-muted); }
.profile-stats b { color: var(--text); font-size: 16px; }

/* === 管理后台 === */
.admin-layout { display: grid; grid-template-columns: 200px 1fr; gap: 24px; min-height: calc(100vh - 60px); }
.admin-nav { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; position: sticky; top: 84px; align-self: start; }
.admin-nav-item { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; color: var(--text); transition: all .15s; }
.admin-nav-item:hover { background: var(--bg-hover); }
.admin-nav-item.active { background: var(--primary); color: #fff; }
.admin-content { padding-bottom: 40px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; }
.stat-card .stat-trend { font-size: 12px; margin-top: 4px; }

/* === 表格 === */
.table-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); background: var(--bg); }
.data-table td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

/* === 标签 === */
.tag { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.tag-success { background: #D1FAE5; color: #065F46; }
.tag-warning { background: #FEF3C7; color: #92400E; }
.tag-danger { background: #FEE2E2; color: #991B1B; }
.tag-info { background: #DBEAFE; color: #1E40AF; }
.tag-muted { background: var(--bg-hover); color: var(--text-muted); }

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

/* === 加载 === */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.spinner { display: inline-block; width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Toast === */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: #fff; padding: 10px 24px; border-radius: var(--radius-sm); font-size: 14px; z-index: 999; opacity: 0; pointer-events: none; transition: all .3s; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* === 分页 === */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 20px; }
.page-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; background: #fff; transition: all .15s; }
.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: .4; cursor: not-allowed; }

/* === 响应式 === */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar-left, .sidebar-right { display: none; }
}
@media (max-width: 768px) {
  .container { padding: 16px; }
  .navbar-inner { padding: 0 16px; gap: 12px; }
  .nav-search { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-nav { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .modal { padding: 24px; }
  .post-detail { padding: 20px; }
}
