/* ============ 清清哥的小屋 · 后台样式 ============ */
:root {
  --primary: #2b4a72;
  --primary-dark: #1d3557;
  --danger: #b3563f;
  --success: #3e7d4f;
  --warn: #b98a2f;
  --bg: #eef1f6;
  --card: #fbfcfe;
  --text: #2f3644;
  --text-light: #69727f;
  --border: #d9dfe8;
  --sidebar-w: 230px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20,35,63,.07), 0 4px 12px rgba(20,35,63,.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; outline: none; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
textarea { resize: vertical; line-height: 1.6; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-light); margin-bottom: 6px; }

/* ---------- 布局 ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: var(--sidebar-w); background: #14233f; color: #cbd5e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.admin-logo { padding: 22px 20px; font-size: 17px; font-weight: 800; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.admin-menu { flex: 1; padding: 14px 12px; overflow-y: auto; }
.menu-item {
  display: block; padding: 10px 14px; border-radius: 8px; color: #cbd5e1; font-size: 14px;
  margin-bottom: 3px; width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
}
.menu-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.menu-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.admin-side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
  background: #fff; padding: 0 28px; height: 62px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.admin-topbar h1 { font-size: 18px; font-weight: 700; }
.admin-user { color: var(--text-light); }
.admin-content { padding: 26px 28px; }

/* ---------- 卡片 ---------- */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px; }
.panel h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.stat-box .num { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat-box .num.warn { color: var(--warn); }
.stat-box .lbl { color: var(--text-light); font-size: 13px; margin-top: 2px; }
.stat-box .sub { color: var(--text-light); font-size: 12px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; padding: 10px 12px; font-size: 12.5px; color: var(--text-light);
  border-bottom: 2px solid var(--border); white-space: nowrap; font-weight: 600;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:hover td { background: #f8fafc; }
.tbl .title-cell { font-weight: 600; max-width: 340px; }
.tbl .title-cell a { color: var(--text); }
.tbl .title-cell a:hover { color: var(--primary); }
.tbl .ops { white-space: nowrap; }
.tbl .ops button { margin-right: 6px; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 徽章 / 按钮 ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-published { background: #dcfce7; color: #166534; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-top { background: #e0e7ff; color: #3730a3; }
.badge-type { background: #e0f2fe; color: #075985; }

.btn {
  display: inline-block; padding: 7px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all .15s; background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: #f8faff; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-warn { background: var(--warn); }
.btn-warn:hover { background: #b45309; }
.btn-sm { padding: 4px 11px; font-size: 12.5px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 筛选工具条 ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 240px; }
.toolbar select { max-width: 160px; }
.tabs-inline { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs-inline .tab {
  padding: 6px 16px; border-radius: 8px; border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-light);
}
.tabs-inline .tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-field.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ---------- 编辑器 ---------- */
.editor-row { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.editor-main, .editor-preview { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.editor-preview { position: sticky; top: 84px; max-height: calc(100vh - 120px); overflow-y: auto; }
.editor-preview h3 { font-size: 14px; color: var(--text-light); margin-bottom: 12px; }
.cover-preview { max-width: 220px; border-radius: 8px; margin-top: 8px; display: block; }
.mkd-body { font-size: 15px; line-height: 1.8; }
.mkd-body h1, .mkd-body h2, .mkd-body h3 { margin: 1em 0 .5em; }
.mkd-body code { background: #f1f5f9; padding: 2px 6px; border-radius: 5px; font-size: .88em; }
.mkd-body pre { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 8px; overflow-x: auto; }
.mkd-body pre code { background: none; color: inherit; padding: 0; }
.mkd-body blockquote { border-left: 3px solid var(--primary); padding-left: 14px; color: var(--text-light); margin: .8em 0; }
.mkd-body table { border-collapse: collapse; width: 100%; margin: .8em 0; }
.mkd-body th, .mkd-body td { border: 1px solid var(--border); padding: 6px 10px; }
.mkd-body img { max-width: 100%; }

/* ---------- 评论 ---------- */
.comment-row { border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin-bottom: 12px; background: #fff; }
.comment-row .c-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.comment-row .c-head b { font-size: 14px; }
.comment-row .c-meta { color: var(--text-light); font-size: 12.5px; }
.comment-row p { color: #334155; margin: 6px 0 10px; }
.comment-row .c-ops { display: flex; gap: 8px; }

/* ---------- 分页 ---------- */
.pagination { display: flex; gap: 6px; margin-top: 18px; justify-content: center; }
.page-btn { padding: 6px 13px; border-radius: 7px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 13px; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Toast / Alert ---------- */
#toastBox { position: fixed; top: 18px; right: 18px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #1e293b; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); animation: slideIn .25s ease; max-width: 340px; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.alert { padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.alert-error { background: #fee2e2; color: #991b1b; }

.empty-state { text-align: center; padding: 40px; color: var(--text-light); }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(165deg, #14233f, #1d3557);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 38px; width: 380px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); text-align: center;
}
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-sub { color: var(--text-light); font-size: 13px; margin-bottom: 22px; }
.login-form label { text-align: left; }
.login-form input { margin-bottom: 16px; }
.login-tip { margin-top: 18px; font-size: 12px; color: var(--text-light); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .editor-row { grid-template-columns: 1fr; }
  .admin-sidebar { position: fixed; left: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .admin-shell.menu-open .admin-sidebar { transform: none; }
  .admin-main { margin-left: 0; }
}
