/* ============================================================
   admin.css - 管理端样式（侧边栏 + 顶栏控制台风格）
   ============================================================ */

.admin-shell {
  display: grid; grid-template-columns: 236px 1fr; min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */
.admin-sidebar {
  background: linear-gradient(180deg, #111827 0%, #1e1b4b 100%);
  color: #cbd5e1; display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-sidebar .side-brand {
  display: flex; align-items: center; gap: 10px; padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 18px;
}
.admin-sidebar .side-brand .logo {
  width: 36px; height: 36px; border-radius: 10px; background: var(--gradient-main);
  display: inline-flex; align-items: center; justify-content: center; font-size: 19px; color: #fff;
}
.admin-sidebar .side-brand .name { font-size: 17px; font-weight: 800; color: #fff; }
.admin-sidebar .side-brand .sub { font-size: 11px; color: #64748b; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav .nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 600; color: #cbd5e1;
  transition: all .16s; border: none; background: transparent; width: 100%; text-align: left;
}
.side-nav .nav-item .nav-icon { font-size: 17px; opacity: .85; width: 20px; text-align: center; }
.side-nav .nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav .nav-item.active {
  background: var(--gradient-brand); color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,.4);
}
.side-nav .nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 8px; }
.side-foot { margin-top: auto; padding-top: 16px; }
.side-foot .admin-user {
  display: flex; align-items: center; gap: 10px; padding: 12px; background: rgba(255,255,255,.06);
  border-radius: 12px; margin-bottom: 10px;
}
.side-foot .admin-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--gradient-main);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px;
}
.side-foot .admin-user .mail { font-size: 12px; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 主内容 ---------- */
.admin-main { min-width: 0; background: #f4f6fb; display: flex; flex-direction: column; }
.admin-topbar {
  position: sticky; top: 0; z-index: 90; height: 64px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 26px;
}
.admin-topbar .topbar-title { font-size: 18px; font-weight: 800; }
.admin-topbar .topbar-actions { display: flex; align-items: center; gap: 12px; }

.admin-content { padding: 26px; flex: 1; }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px;
  border-radius: 50%; opacity: .12;
}
.stat-card .stat-label { color: var(--text-3); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; line-height: 1; }
.stat-card .stat-desc { color: var(--text-3); font-size: 12px; margin-top: 8px; }
.stat-card.c1::after { background: #6366f1; }
.stat-card.c1 .stat-value { color: #6366f1; }
.stat-card.c2::after { background: #10b981; }
.stat-card.c2 .stat-value { color: #10b981; }
.stat-card.c3::after { background: #f59e0b; }
.stat-card.c3 .stat-value { color: #f59e0b; }
.stat-card.c4::after { background: #ef4444; }
.stat-card.c4 .stat-value { color: #ef4444; }

/* ---------- 面板 ---------- */
.panel {
  background: #fff; border-radius: var(--radius-lg); padding: 22px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border); margin-bottom: 24px;
}
.panel-title { font-size: 16px; font-weight: 800; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.panel-title::before { content: ''; width: 4px; height: 16px; border-radius: 2px; background: var(--gradient-main); }

.dash-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 24px; }
.chart-wrap { position: relative; height: 300px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }

/* 排行 */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: #f8fafc; transition: background .15s; }
.rank-item:hover { background: var(--bg-soft); }
.rank-index {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: #e2e8f0; color: var(--text-2); font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.rank-item:nth-child(1) .rank-index { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.rank-item:nth-child(2) .rank-index { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; }
.rank-item:nth-child(3) .rank-index { background: linear-gradient(135deg, #fbbf24, #d97706); color: #fff; }
.rank-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.rank-count { color: var(--primary); font-weight: 800; font-size: 13px; flex-shrink: 0; }

/* 板块入口 */
.cat-mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.cat-mini-card {
  border-radius: var(--radius); overflow: hidden; background: #fff; cursor: pointer;
  border: 1px solid var(--border); transition: all .18s;
}
.cat-mini-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.cat-mini-card .cover { height: 84px; }
.cat-mini-card .cover img, .cat-mini-card .cover .category-cover-fallback { width: 100%; height: 100%; }
.cat-mini-card .cover .category-cover-fallback span { font-size: 28px; }
.cat-mini-card .info { padding: 12px 14px; }
.cat-mini-card .info .n { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.cat-mini-card .info .d { color: var(--text-3); font-size: 12px; }

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px;
  background: #fff; padding: 16px 18px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.toolbar .input, .toolbar .select { width: auto; }
.toolbar .input { min-width: 220px; }
.toolbar .select { min-width: 150px; }
.toolbar .spacer { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 14px; text-align: left; font-size: 14px; border-bottom: 1px solid #f1f5f9; }
.table th { color: var(--text-3); font-size: 13px; font-weight: 600; background: #f8fafc; white-space: nowrap; }
.table td { color: var(--text-2); }
.table tbody tr:hover { background: #f8fafc; }
.table .ops { display: flex; gap: 8px; flex-wrap: wrap; }

/* 徽章 */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-blue { background: var(--bg-soft); color: var(--primary-3); }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-green { background: #d1fae5; color: #059669; }
.badge-gray { background: #f1f5f9; color: var(--text-2); }

/* ---------- 富文本编辑器 ---------- */
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 12px;
  background: #f8fafc; border: 1.5px solid var(--border); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.editor-toolbar button {
  min-width: 34px; height: 34px; padding: 0 8px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; transition: all .14s;
}
.editor-toolbar button:hover { background: #e2e8f0; color: var(--text-1); }
.editor-toolbar button.active { background: var(--bg-soft); color: var(--primary); }
.editor-toolbar .tb-sep { width: 1px; background: var(--border); margin: 4px 6px; }
.editor-body {
  min-height: 320px; border: 1.5px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  padding: 18px; font-size: 15px; line-height: 1.9; outline: none; background: #fff;
}
.editor-body:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99,102,241,.08); }
.editor-body h1, .editor-body h2, .editor-body h3 { margin: 16px 0 10px; }
.editor-body p { margin-bottom: 12px; }
.editor-body ul, .editor-body ol { margin: 10px 0 12px 22px; }
.editor-body ul { list-style: disc; } .editor-body ol { list-style: decimal; }
.editor-body blockquote { border-left: 4px solid var(--primary); padding: 10px 14px; background: var(--bg-soft); border-radius: 0 8px 8px 0; margin: 12px 0; }
.editor-body pre { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px; overflow-x: auto; }

/* ---------- 文章编辑链接行 ---------- */
.link-row { display: grid; grid-template-columns: 160px 1fr 160px 90px; gap: 10px; margin-bottom: 10px; align-items: center; }
.link-row .input { padding: 10px 12px; }

/* 标签选择 */
.tag-select { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-check { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: #f8fafc; border: 1.5px solid var(--border); cursor: pointer; transition: all .15s; font-size: 13px; }
.tag-check input { display: none; }
.tag-check.selected { background: var(--bg-soft); border-color: var(--primary); color: var(--primary-3); font-weight: 600; }

/* ---------- 移动端适配 ---------- */
.admin-mobile-nav { display: none; }
/* 桌面端隐藏抽屉遮罩，避免在 grid 中占位把 admin-main 挤到下一行 */
.admin-sidebar-backdrop { display: none; }
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 1000;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .admin-sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .admin-sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 990; display: none;
  }
  .admin-sidebar-backdrop.show { display: block; }
  .admin-mobile-nav {
    display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 18px;
    background: #111827; color: #fff; position: sticky; top: 0; z-index: 95;
  }
  .admin-mobile-nav .hamburger {
    background: rgba(255,255,255,.1); border: none; color: #fff; width: 38px; height: 38px;
    border-radius: 10px; font-size: 18px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  }
  .admin-mobile-nav .t { font-weight: 800; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 18px 14px; }
  .link-row { grid-template-columns: 1fr; }
  .toolbar .input, .toolbar .select { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .spacer { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .link-row .lk-platform, .link-row .lk-url, .link-row .lk-code { grid-column: 1/-1; }
}

/* ---------- 文章编辑：表单双栏 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- 文章编辑：标签多选 ---------- */
.tag-select { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-radius: 999px; border: 1.5px solid var(--border); background: #fff;
  cursor: pointer; font-size: 14px; color: var(--text-1); transition: all .2s;
  user-select: none;
}
.tag-chip .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tag-chip:hover { border-color: var(--primary); }
.tag-chip.on {
  border-color: var(--primary); background: rgba(99,102,241,.08);
  color: var(--primary); font-weight: 700; box-shadow: 0 4px 14px rgba(99,102,241,.16);
}

/* ---------- 文章编辑：资源链接行 ---------- */
.link-row {
  display: grid; grid-template-columns: 1fr 1.6fr .8fr auto; gap: 8px;
  margin-bottom: 8px; align-items: center;
}
.link-row .input { min-width: 0; }

/* ---------- 文章编辑：开关 ---------- */
.switch-row,
.field > label.switch-row {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 14px; color: var(--text-2);
  flex-wrap: nowrap; line-height: 1.5; min-width: 0;
}
.switch-row input { display: none; }
.switch-track {
  width: 44px; height: 24px; border-radius: 999px; background: #cbd5e1;
  position: relative; transition: background .2s;
  flex: none; flex-shrink: 0;
}
.switch-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left .2s;
}
.switch-row input:checked + .switch-track { background: var(--primary); }
.switch-row input:checked + .switch-track::after { left: 22px; }

/* ---------- 文章列表：分页 ---------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }
.pager .btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 封面上传 ---------- */
.cover-uploader { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cover-preview {
  width: 96px; height: 64px; border-radius: 10px; overflow: hidden;
  background: #f1f5f9; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}

/* 评论管理：内容截断 */
.cmt-content {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.5; color: var(--text-1); word-break: break-all;
}
.cmt-article { color: var(--primary); font-weight: 600; text-decoration: none; }
.cmt-article:hover { text-decoration: underline; }

/* reply rows (admin comments) */
.cmt-row-reply { background: rgba(99,102,241,.04); }
.cmt-reply { color: var(--text-2); font-size: 13px; }
.cmt-reply-info { margin-top: 3px; font-size: 11.5px; color: var(--text-3); word-break: break-all; }


/* ---------- 退出登录按钮（美化） ---------- */
.side-foot .logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 11px 14px; margin-top: 2px;
  border: 1px solid rgba(248,113,113,.35); border-radius: 12px;
  background: linear-gradient(180deg, rgba(248,113,113,.14), rgba(239,68,68,.08));
  color: #fca5a5; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: all .16s;
}
.side-foot .logout-btn .nav-icon { font-size: 16px; opacity: .95; width: auto; }
.side-foot .logout-btn:hover {
  background: linear-gradient(180deg, #ef4444, #dc2626);
  color: #fff; border-color: transparent; box-shadow: 0 6px 18px rgba(239,68,68,.35);
  transform: translateY(-1px);
}
.side-foot .logout-btn:active { transform: translateY(0); }
