/* ============================================================
   admin.css - 内容管理后台
   ============================================================ */

body.admin { background: var(--bg); min-height: 100vh; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(800px 400px at 20% 0%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 60%),
    radial-gradient(700px 400px at 90% 100%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 34px 30px; box-shadow: var(--shadow-lg); text-align: center;
}
.login-card .logo-mark { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 16px; }
.login-card .logo-mark svg { width: 28px; height: 28px; }
.login-card h2 { font-size: 20px; letter-spacing: -.02em; }
.login-card p { font-size: 13px; color: var(--muted); margin-top: 6px; }
.login-card input {
  width: 100%; height: 42px; margin-top: 22px; padding: 0 14px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--bg-2); outline: none; font-size: 14px; text-align: center;
}
.login-card input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-card .btn-full {
  width: 100%; height: 42px; margin-top: 12px; border-radius: 11px; font-size: 14.5px; font-weight: 600;
  background: linear-gradient(140deg, var(--brand-2), var(--brand)); color: #fff;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand) 70%, transparent);
}
.login-card .btn-full:hover { transform: translateY(-1px); }
.login-tip { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.login-tip code { background: var(--bg-2); padding: 2px 7px; border-radius: 5px; font-family: var(--font-mono); color: var(--brand); }

/* ---------- 后台外框 ---------- */
.admin-shell { display: grid; grid-template-columns: 226px minmax(0, 1fr); min-height: 100vh; }

.admin-side {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
  position: sticky; top: 0; height: 100vh;
}
.admin-side .logo { padding: 4px 8px 18px; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav .group { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .1em; padding: 14px 12px 6px; text-transform: uppercase; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  font-size: 13.8px; font-weight: 500; color: var(--text-2); transition: .16s var(--ease);
}
.admin-nav a svg { width: 17px; height: 17px; opacity: .8; flex-shrink: 0; }
.admin-nav a:hover { background: var(--bg-2); color: var(--text); }
.admin-nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.admin-nav a.active svg { opacity: 1; }
.admin-nav a .badge {
  margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
  background: var(--bg-2); color: var(--muted);
}
.admin-side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.admin-side-foot .mode {
  font-size: 11.5px; color: var(--muted); padding: 8px 12px; border-radius: 9px; background: var(--bg-2);
  display: flex; align-items: center; gap: 7px; margin-bottom: 8px;
}
.admin-side-foot .mode i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-2); }

.admin-main { display: flex; flex-direction: column; min-width: 0; }

.admin-top {
  height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 22px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100;
}
.admin-top h1 { font-size: 16.5px; letter-spacing: -.02em; }
.admin-top .sub { font-size: 12.5px; color: var(--muted); }
.admin-top .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.admin-body { padding: 22px; flex: 1; }
.page { display: none; animation: fadeUp .3s var(--ease); }
.page.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 按钮 ---------- */
.btn {
  height: 36px; padding: 0 15px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; transition: .17s var(--ease);
  background: var(--bg-2); color: var(--text-2); border: 1px solid transparent;
}
.btn:hover { background: var(--border); color: var(--text); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: linear-gradient(140deg, var(--brand-2), var(--brand)); color: #fff; box-shadow: 0 4px 12px -5px color-mix(in srgb, var(--brand) 70%, transparent); }
.btn.primary:hover { transform: translateY(-1px); }
.btn.danger { background: var(--accent-soft); color: var(--accent); }
.btn.danger:hover { background: var(--accent); color: #fff; }
.btn.outline { background: transparent; border-color: var(--border); }
.btn.outline:hover { border-color: var(--brand); color: var(--brand); background: transparent; }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ---------- 数据卡片 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 17px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -18px; top: -18px; width: 76px; height: 76px; border-radius: 50%;
  background: var(--brand-soft);
}
.kpi .k { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k svg { width: 14px; height: 14px; }
.kpi .v { font-size: 27px; font-weight: 800; letter-spacing: -.035em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.kpi.red::after { background: var(--accent-soft); }
.kpi.red .v { color: var(--accent); }
.kpi.gold::after { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.kpi.blue::after { background: color-mix(in srgb, var(--blue) 14%, transparent); }

/* ---------- 面板 ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head b { font-size: 14.5px; }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 18px; }

.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }

/* 迷你柱状图 */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.bars .bar i {
  display: block; width: 100%; max-width: 34px; border-radius: 7px 7px 3px 3px;
  background: linear-gradient(var(--brand-2), var(--brand)); min-height: 4px; transition: height .6s var(--ease);
}
.bars .bar span { font-size: 10.5px; color: var(--muted); }
.bars .bar b { font-size: 11px; font-variant-numeric: tabular-nums; }

/* 分类占比条 */
.dist { display: flex; flex-direction: column; gap: 11px; }
.dist-row .t { display: flex; font-size: 13px; margin-bottom: 5px; }
.dist-row .t b { margin-left: auto; font-variant-numeric: tabular-nums; }
.dist-row .b { height: 7px; border-radius: 4px; background: var(--bg-2); overflow: hidden; }
.dist-row .b i { display: block; height: 100%; border-radius: 4px; transition: width .7s var(--ease); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
table.data th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { transition: background .15s var(--ease); }
table.data tbody tr:hover { background: var(--bg-2); }
table.data .t-title { font-weight: 600; font-size: 13.8px; display: block; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data .t-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
table.data .actions { display: flex; gap: 6px; justify-content: flex-end; }
table.data input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.status {
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 7px; white-space: nowrap;
}
.status.published { background: var(--brand-soft); color: var(--brand); }
.status.draft { background: var(--bg-2); color: var(--muted); }

.thumb { width: 62px; height: 40px; border-radius: 7px; object-fit: cover; background: var(--bg-2); flex-shrink: 0; }

/* ---------- 筛选栏 ---------- */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filters input, .filters select {
  height: 34px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; outline: none;
}
.filters input:focus, .filters select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.filters .sp { margin-left: auto; }

/* ---------- 编辑器页 ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.editor-main { display: flex; flex-direction: column; gap: 14px; }
.title-input {
  width: 100%; padding: 14px 18px; border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface); font-size: 21px; font-weight: 700; outline: none; letter-spacing: -.02em;
  box-shadow: var(--shadow-sm); transition: .18s var(--ease);
}
.title-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.title-input::placeholder { color: var(--muted); font-weight: 600; }

.editor-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 74px; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-2); font-size: 13.5px; outline: none; transition: .18s var(--ease);
}
.field textarea { resize: vertical; min-height: 72px; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input.warn, .field select.warn, .field textarea.warn { border-color: #eab308; box-shadow: 0 0 0 3px rgba(234,179,8,.18); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.6; }
.field .warn-msg { font-size: 11.5px; color: #b45309; background: #fff7ed; border: 1px solid #fde68a; padding: 6px 10px; border-radius: 8px; margin-top: 6px; line-height: 1.6; }

.cover-preview {
  width: 100%; aspect-ratio: 16/9; border-radius: var(--r); background: var(--bg-2); object-fit: cover;
  border: 1px dashed var(--border-2); display: block;
}
.cover-actions { display: flex; gap: 6px; margin-top: 8px; }

.tag-input-wrap {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 9px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-2); min-height: 38px; align-items: center;
}
.tag-input-wrap .chip { display: inline-flex; align-items: center; gap: 5px; }
.tag-input-wrap .chip button { color: inherit; opacity: .6; font-size: 14px; line-height: 1; }
.tag-input-wrap .chip button:hover { opacity: 1; }
.tag-input-wrap input { flex: 1; min-width: 80px; border: none; background: none; outline: none; font-size: 13px; padding: 2px; }

.switch { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; padding: 5px 0; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 21px; border-radius: 99px; background: var(--border-2); position: relative; transition: .2s var(--ease); flex-shrink: 0;
}
.switch .track::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; transition: .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(17px); }

/* ---------- 模板卡片 ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tpl-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 17px; box-shadow: var(--shadow-sm); transition: .2s var(--ease);
  display: flex; flex-direction: column;
}
.tpl-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.tpl-card .ico { font-size: 24px; line-height: 1; margin-bottom: 10px; }
.tpl-card b { font-size: 14.5px; }
.tpl-card .desc { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.65; flex: 1; }
.tpl-card .pat { font-size: 11.5px; color: var(--text-2); margin-top: 10px; background: var(--bg-2); padding: 7px 9px; border-radius: 8px; font-family: var(--font-mono); line-height: 1.5; word-break: break-all; }
.tpl-card .acts { display: flex; gap: 6px; margin-top: 12px; }
.tpl-card.add {
  border: 2px dashed var(--border-2); background: transparent; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13.5px; cursor: pointer; min-height: 180px; gap: 8px;
}
.tpl-card.add:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); transform: none; }

/* ---------- 模板选择弹窗 ---------- */
.tpl-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl-pick button {
  text-align: left; padding: 13px 14px; border-radius: var(--r); border: 1px solid var(--border);
  background: var(--surface-2); transition: .18s var(--ease);
}
.tpl-pick button:hover { border-color: var(--brand); background: var(--brand-soft); }
.tpl-pick .ico { font-size: 20px; }
.tpl-pick b { display: block; font-size: 13.5px; margin-top: 6px; }
.tpl-pick small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.55; }

/* ---------- 空状态 ---------- */
.admin-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.admin-empty svg { width: 42px; height: 42px; opacity: .3; margin-bottom: 12px; }
.admin-empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 5px; }

/* ---------- 移动端 ---------- */
.admin-burger { display: none; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-side { position: static; }
}

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side {
    position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 400;
    transform: translateX(-100%); transition: transform .28s var(--ease); box-shadow: var(--shadow-lg);
  }
  .admin-side.open { transform: none; }
  .admin-burger { display: grid; }
  .admin-body { padding: 14px; }
  .admin-top { padding: 0 14px; }
  .admin-top h1 { font-size: 15px; }
  .admin-top .sub { display: none; }
  .kpi .v { font-size: 22px; }
  .title-input { font-size: 18px; padding: 12px 14px; }
  .tpl-pick { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 13px 14px; }
  .filters { padding: 10px 12px; }
  .filters input { flex: 1; min-width: 0; }
  .panel-body { padding: 14px; }
}
