/* ============================================================
   灵感魔方 PromptCube — 全局样式（CSDN蓝色风格）
   ============================================================ */

/* 第九章：字体加载优化 — font-display:swap 防止 FOIT */
@font-face {
  font-family: 'SystemUI';
  src: local('-apple-system'), local('BlinkMacSystemFont'), local('Segoe UI');
  font-display: swap;
}

:root {
  --primary:      #1890ff;
  --primary-dark: #096dd9;
  --primary-light:#e6f7ff;
  --text-main:    #1a1a1a;
  --text-sub:     #666;
  --text-muted:   #767676;
  --border:       #e8e8e8;
  --bg:           #f5f6f7;
  --bg-card:      #fff;
  --sidebar-w:    260px;
  --header-h:     56px;
  --radius:       6px;
  --shadow:       0 1px 4px rgba(0,0,0,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text-main);
  background: var(--bg);
  line-height: 1.6;
}

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

img { max-width: 100%; }

/* ── 顶部导航 ───────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.header-logo {
  font-size: 18px; font-weight: 700;
  color: var(--primary); white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}

.header-nav { display: flex; gap: 4px; }
.header-nav a {
  padding: 6px 12px; border-radius: var(--radius);
  color: var(--text-sub); font-size: 14px; white-space: nowrap;
  transition: background .15s, color .15s;
}
.header-nav a:hover, .header-nav a.active {
  background: var(--primary-light); color: var(--primary);
}

.header-search {
  flex: 1; max-width: 360px;
  display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: 20px;
  overflow: hidden; background: var(--bg);
}
.header-search input {
  border: none; outline: none; background: transparent;
  flex: 1; padding: 6px 14px; font-size: 13px;
}
.header-search button {
  padding: 6px 14px; background: var(--primary); color: #fff;
  border: none; cursor: pointer; font-size: 13px;
}
.header-search button:hover { background: var(--primary-dark); }

.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.btn { display: inline-flex; align-items: center; gap: 6px;
       padding: 6px 16px; border-radius: var(--radius);
       font-size: 14px; cursor: pointer; border: 1px solid transparent;
       transition: all .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: #ff4d4f; color: #fff; border-color: #ff4d4f; }
.btn-danger:hover { background: #cf1322; }

/* ── 用户头像/菜单 ─────────────────────────────────────────── */
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; cursor: pointer;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}

.user-menu-wrap { position: relative; }
.user-menu {
  display: none; position: absolute; right: 0; top: 40px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 140px; z-index: 200;
}
.user-menu a, .user-menu button {
  display: block; width: 100%; text-align: left;
  padding: 9px 16px; color: var(--text-main); font-size: 13px;
  background: none; border: none; cursor: pointer;
}
.user-menu a:hover, .user-menu button:hover { background: var(--bg); }
.user-menu-wrap.open .user-menu { display: block; }
.user-avatar { cursor: pointer; }

/* ── 页面主体布局 ──────────────────────────────────────────── */
.page-wrap {
  max-width: 1200px; margin: 0 auto;
  padding: 20px 16px;
  display: flex; gap: 20px; align-items: flex-start;
}

.main-content { flex: 1; min-width: 0; }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; }

/* ── 卡片 ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
  display: flex; align-items: center; justify-content: space-between;
}
/* card-header 用 h2/h3 语义标签时，清除标题默认 margin 并继承字号 */
h1.card-header, h2.card-header, h3.card-header,
h4.card-header, h5.card-header, h6.card-header {
  margin: 0; font-size: 15px;
}
.card-body { padding: 18px; }

/* ── 帖子列表卡片 ──────────────────────────────────────────── */
.post-list { display: flex; flex-direction: column; gap: 1px; }
.post-item {
  background: #fff; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.post-item:last-child { border-bottom: none; }
.post-item:hover { background: #fafcff; }

.post-item-title {
  font-size: 16px; font-weight: 600; line-height: 1.4;
  color: var(--text-main); margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
/* 标题作为 h3 时，内部链接显示黑色，仅 hover 变蓝 */
.post-item-title a { color: var(--text-main); text-decoration: none; }
.post-item-title a:hover { color: var(--primary); }

.post-item-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; color: var(--text-muted); font-size: 12px;
}
.post-item-meta .author { color: var(--primary); font-weight: 500; }
.post-item-meta .sep { color: var(--border); }

.tag {
  display: inline-block; padding: 6px 12px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 12px; font-size: 12px; margin: 3px 6px 3px 0;
  min-height: 24px; line-height: 1.4;
}
.tag:hover { background: var(--primary); color: #fff; }

.level-badge {
  display: inline-block; padding: 1px 7px;
  border-radius: 10px; font-size: 11px; font-weight: 600;
}
.level-1 { background: #f0f0f0; color: #888; }
.level-2 { background: #e6fffb; color: #13c2c2; }
.level-3 { background: #e6f7ff; color: #1890ff; }
.level-4 { background: #fff7e6; color: #fa8c16; }
.level-5 { background: #fff1f0; color: #f5222d; }

/* ── 分类筛选栏 ───────────────────────────────────────────── */
.filter-bar {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  margin-bottom: 12px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.filter-bar .label { color: var(--text-sub); margin-right: 4px; }
.filter-btn {
  padding: 4px 12px; border-radius: 14px; font-size: 13px;
  border: 1px solid var(--border); background: #fff;
  cursor: pointer; color: var(--text-sub); transition: all .15s;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.sort-select {
  margin-left: auto; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; font-size: 13px; cursor: pointer; outline: none;
}

/* ── 面包屑导航 ──────────────────────────────────────────── */
.breadcrumb {
  display: flex; flex-wrap: wrap; align-items: center;
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 12px; padding: 2px 0;
}
.breadcrumb a { color: var(--text-sub); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumb .sep { margin: 0 8px; color: var(--text-muted); }
.breadcrumb .current { color: var(--text-main); font-weight: 500; }

/* ── 分页 ────────────────────────────────────────────────── */
.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; padding: 20px 0;
}
.page-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s; color: var(--text-main);
}
.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; }

/* ── 帖子详情 ─────────────────────────────────────────────── */
.post-detail-title { font-size: 22px; font-weight: 700; line-height: 1.4; margin-bottom: 12px; }
.post-detail-meta { color: var(--text-muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.post-detail-content { line-height: 1.9; font-size: 15px; overflow-x: auto; }
.post-detail-content pre { background: #282c34; color: #abb2bf; padding: 14px; border-radius: var(--radius); overflow-x: auto; margin: 12px 0; }
.post-detail-content code { font-family: "JetBrains Mono", Consolas, monospace; font-size: 13px; }
.post-detail-content p code { background: #f5f5f5; padding: 2px 6px; border-radius: 3px; color: #c7254e; }
.post-detail-content h2, .post-detail-content h3 { margin: 16px 0 8px; }
.post-detail-content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.post-detail-content th, .post-detail-content td { border: 1px solid var(--border); padding: 8px 12px; }
.post-detail-content th { background: var(--bg); font-weight: 600; }
.post-detail-content blockquote { border-left: 4px solid var(--primary); padding: 8px 16px; background: var(--primary-light); margin: 12px 0; }

/* ── 回复区 ───────────────────────────────────────────────── */
.comment-item { padding: 16px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.comment-item:last-child { border-bottom: none; }
.comment-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.comment-main { flex: 1; min-width: 0; }
.comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.comment-author { font-weight: 600; color: var(--primary); }
.comment-time { color: var(--text-muted); font-size: 12px; }
.comment-content { line-height: 1.7; }
.comment-actions { margin-top: 8px; display: flex; gap: 12px; }
.comment-like { color: var(--text-muted); font-size: 12px; cursor: pointer; }
.comment-like:hover, .comment-like.liked { color: #f5222d; }
.comment-children { margin-top: 12px; padding-left: 16px; border-left: 2px solid var(--border); }

/* ── 回复输入框 ──────────────────────────────────────────── */
.reply-box { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.reply-box textarea {
  width: 100%; min-height: 100px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; resize: vertical; outline: none; font-family: inherit;
  transition: border-color .2s;
}
.reply-box textarea:focus { border-color: var(--primary); }

/* ── 发帖编辑器 ──────────────────────────────────────────── */
.editor-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.editor-toolbar { padding: 8px 12px; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 4px; }
.editor-toolbar button { padding: 4px 8px; border: 1px solid var(--border); border-radius: 3px; background: #fff; cursor: pointer; font-size: 13px; }
.editor-toolbar button:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
#postContent { width: 100%; min-height: 300px; padding: 16px; border: none; outline: none; font-size: 15px; line-height: 1.8; resize: vertical; font-family: inherit; }

/* ── 表单 ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-sub); }
.form-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; outline: none; transition: border-color .2s; font-family: inherit;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(24,144,255,.1); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M6 7L0 0h12z' fill='%23999'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
.form-error { color: #f5222d; font-size: 12px; margin-top: 4px; }

/* ── 登录/注册页 ──────────────────────────────────────────── */
.auth-page {
  min-height: calc(100vh - var(--header-h));
  display: flex; align-items: center; justify-content: center; padding: 40px 16px;
}
.auth-box {
  background: #fff; border-radius: 8px; padding: 36px 40px;
  width: 100%; max-width: 420px; box-shadow: 0 2px 16px rgba(0,0,0,.1);
}
.auth-box h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.auth-box .sub { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }

/* ── 侧边栏组件 ──────────────────────────────────────────── */
.sidebar .card { margin-bottom: 16px; }
.sidebar-tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.sidebar-user-list { display: flex; flex-direction: column; gap: 10px; }
.sidebar-user-item { display: flex; align-items: center; gap: 10px; }

/* ── 用户主页 ────────────────────────────────────────────── */
.profile-header {
  background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  padding: 32px 24px; border-radius: var(--radius);
  color: #fff; margin-bottom: 20px;
  display: flex; align-items: center; gap: 20px;
}
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; border: 3px solid rgba(255,255,255,.8); object-fit: cover; }
.profile-name { font-size: 20px; font-weight: 700; }
.profile-bio { font-size: 13px; opacity: .85; margin-top: 4px; }
.profile-stats { display: flex; gap: 24px; margin-top: 12px; }
.profile-stat { text-align: center; }
.profile-stat-val { font-size: 20px; font-weight: 700; }
.profile-stat-label { font-size: 12px; opacity: .8; }

/* ── 后台管理 ────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: calc(100vh - var(--header-h)); }
.admin-sidebar {
  width: 200px; background: #001529; flex-shrink: 0;
  padding: 20px 0;
}
.admin-sidebar a {
  display: block; padding: 11px 20px;
  color: rgba(255,255,255,.65); font-size: 14px;
  transition: all .15s;
}
.admin-sidebar a:hover, .admin-sidebar a.active {
  background: var(--primary); color: #fff;
}
.admin-content { flex: 1; padding: 24px; }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; text-align: center;
}
.stat-card .val { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── 进度条 ──────────────────────────────────────────────── */
.progress-wrap { background: #f0f0f0; border-radius: 10px; height: 8px; overflow: hidden; margin: 8px 0; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 10px; transition: width .3s; }

/* ── 数据表格 ────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table th { background: var(--bg); font-weight: 600; color: var(--text-sub); }
.data-table tr:hover td { background: #fafcff; }

/* ── 提示消息 ────────────────────────────────────────────── */
.toast-wrap { position: fixed; top: 70px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 18px; border-radius: var(--radius);
  background: #333; color: #fff; font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2); opacity: 1;
  transition: opacity .3s; max-width: 320px;
}
.toast.success { background: #52c41a; }
.toast.error   { background: #f5222d; }
.toast.info    { background: var(--primary); }
.toast.fade-out { opacity: 0; }

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

/* ── 骨架屏 ──────────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── 响应式 ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .page-wrap { padding: 12px 10px; }
  .header { padding: 0 12px; }
  .header-nav { display: none; }
  .auth-box { padding: 24px 20px; }
}
