/* ==========================================================================
   MiMo Blog — 后台管理面板
   ========================================================================== */

:root {
  --a-bg: #f5f5f3;
  --a-panel: #ffffff;
  --a-side: #16161c;
  --a-side-2: #202028;
  --a-ink: #1a1a1f;
  --a-ink-2: #5b5b64;
  --a-ink-3: #93939d;
  --a-line: #e6e6e1;
  --a-brand: #2563eb;
  --a-danger: #dc2626;
  --a-ok: #15803d;

  --a-radius: 10px;
  --a-radius-sm: 6px;

  --a-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --a-mono: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--a-bg);
  color: var(--a-ink);
  font-family: var(--a-font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

/* ------------------------------- 骨架 ------------------------------- */

.admin {
  display: flex;
  min-height: 100vh;
}

.admin-side {
  flex-shrink: 0;
  width: 232px;
  background: var(--a-side);
  color: #c8c8d0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.admin-side__brand {
  padding: 20px 22px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-side__brand span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--a-brand);
}

.admin-side__nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
}

.admin-side__group {
  margin: 16px 0 6px;
  padding: 0 10px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6b6b78;
}

.admin-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--a-radius-sm);
  color: #c8c8d0;
  font-size: 13.5px;
  transition: background 0.14s, color 0.14s;
}

.admin-link:hover {
  background: var(--a-side-2);
  color: #fff;
}

.admin-link.is-active {
  background: var(--a-brand);
  color: #fff;
}

.admin-link__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.75;
}

.admin-link__badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--a-danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 600;
}

.admin-side__footer {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12.5px;
  color: #8b8b99;
}

.admin-side__footer a {
  color: #c8c8d0;
}

.admin-side__footer a:hover {
  color: #fff;
}

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

.admin-top {
  height: 60px;
  padding: 0 28px;
  background: var(--a-panel);
  border-bottom: 1px solid var(--a-line);
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-top__title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
}

.admin-top__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--a-ink-2);
}

.admin-top__right a:hover {
  color: var(--a-brand);
}

.admin-content {
  padding: 24px 28px 56px;
  flex: 1;
}

.side-toggle {
  display: none;
}

/* ------------------------------- 卡片 ------------------------------- */

.card {
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
}

.card__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--a-line);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card__title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}

.card__head .btn {
  margin-left: auto;
}

.card__body {
  padding: 20px;
}

.card__body--flush {
  padding: 0;
}

/* ------------------------------ 指标卡 ------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  padding: 16px 18px;
}

.stat__label {
  font-size: 12.5px;
  color: var(--a-ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat__value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat__meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--a-ink-3);
}

.stat__meta strong {
  color: var(--a-ok);
  font-weight: 600;
}

.stat__meta strong.is-down {
  color: var(--a-danger);
}

/* ------------------------------- 表格 ------------------------------- */

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.data th {
  padding: 11px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--a-ink-3);
  background: #fafaf8;
  border-bottom: 1px solid var(--a-line);
  white-space: nowrap;
}

table.data td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--a-line);
  vertical-align: middle;
}

table.data tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr:hover {
  background: #fbfbf9;
}

table.data .num {
  font-variant-numeric: tabular-nums;
  color: var(--a-ink-2);
}

.cell-title {
  font-weight: 500;
  color: var(--a-ink);
  display: block;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-title:hover {
  color: var(--a-brand);
}

.cell-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--a-ink-3);
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

/* ------------------------------- 徽标 ------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid;
  white-space: nowrap;
}

.badge--pub {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.badge--draft {
  background: #f8f8f6;
  border-color: #e6e6e1;
  color: #6b6b64;
}

.badge--pending {
  background: #fffbeb;
  border-color: #fde68a;
  color: #a16207;
}

.badge--spam {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.badge--top {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.badge--admin {
  background: #faf5ff;
  border-color: #e9d5ff;
  color: #7e22ce;
}

/* ------------------------------- 按钮 ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: #fff;
  background: var(--a-brand);
  border: 1px solid var(--a-brand);
  border-radius: var(--a-radius-sm);
  cursor: pointer;
  transition: opacity 0.14s;
  white-space: nowrap;
}

.btn:hover {
  opacity: 0.9;
}

.btn--ghost {
  color: var(--a-ink-2);
  background: #fff;
  border-color: var(--a-line);
}

.btn--ghost:hover {
  color: var(--a-ink);
  border-color: #cfcfc8;
  opacity: 1;
}

.btn--danger {
  color: var(--a-danger);
  background: #fff;
  border-color: #fecaca;
}

.btn--danger:hover {
  background: #fef2f2;
  opacity: 1;
}

.btn--sm {
  padding: 5px 11px;
  font-size: 12.5px;
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ------------------------------- 表单 ------------------------------- */

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.field {
  margin-bottom: 16px;
}

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--a-ink-2);
}

.field__hint {
  margin-top: 5px;
  font-size: 12px;
  color: var(--a-ink-3);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--a-ink);
  background: #fff;
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius-sm);
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--a-brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  resize: vertical;
  line-height: 1.65;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--a-ink-2);
  cursor: pointer;
}

.check input {
  width: auto;
  margin: 0;
}

/* ------------------------------ 编辑器 ------------------------------ */

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.editor__main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.title-input {
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  outline: none;
  background: #fff;
}

.title-input:focus {
  border-color: var(--a-brand);
}

.editor-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--a-line);
}

.editor-tab {
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--a-ink-3);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.editor-tab.is-active {
  color: var(--a-brand);
  border-bottom-color: var(--a-brand);
  font-weight: 500;
}

.editor-pane {
  display: none;
}

.editor-pane.is-active {
  display: block;
}

.md-textarea {
  width: 100%;
  min-height: 480px;
  padding: 20px;
  border: 0;
  border-radius: 0 0 var(--a-radius) var(--a-radius);
  font-family: var(--a-mono);
  font-size: 13.5px;
  line-height: 1.8;
  resize: vertical;
  outline: none;
  background: #fff;
}

.md-preview {
  min-height: 480px;
  padding: 24px;
  background: #fff;
  border-radius: 0 0 var(--a-radius) var(--a-radius);
  font-size: 15px;
  line-height: 1.8;
}

.md-preview h2 {
  font-size: 22px;
  margin: 1.4em 0 0.6em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--a-line);
}

.md-preview h3 {
  font-size: 18px;
  margin: 1.2em 0 0.5em;
}

.md-preview pre {
  padding: 14px 16px;
  background: #1b1b20;
  color: #e4e4e7;
  border-radius: var(--a-radius-sm);
  overflow-x: auto;
  font-family: var(--a-mono);
  font-size: 12.5px;
}

.md-preview code {
  font-family: var(--a-mono);
  font-size: 0.9em;
}

.md-preview blockquote {
  margin: 1em 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--a-brand);
  color: var(--a-ink-2);
}

.md-preview table {
  border-collapse: collapse;
  width: 100%;
}

.md-preview th,
.md-preview td {
  border: 1px solid var(--a-line);
  padding: 7px 10px;
}

.cover-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cover-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px dashed var(--a-line);
  border-radius: var(--a-radius-sm);
  object-fit: cover;
  background: #fafaf8;
  display: none;
}

.cover-preview.is-shown {
  display: block;
}

/* ------------------------------- 筛选 ------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.filters input[type="search"],
.filters select {
  width: auto;
  min-width: 140px;
}

.filters .spacer {
  margin-left: auto;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* 批量操作条 */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  margin-bottom: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--a-radius-sm);
  font-size: 13px;
  color: #1d4ed8;
}

.batch-bar__actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.batch-bar[hidden] {
  display: none;
}

.tab {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--a-ink-2);
  background: #fff;
  border: 1px solid var(--a-line);
  border-radius: 999px;
}

.tab.is-active {
  color: #fff;
  background: var(--a-ink);
  border-color: var(--a-ink);
}

/* ------------------------------- 分页 ------------------------------- */

.pager {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 18px;
  border-top: 1px solid var(--a-line);
  font-size: 13px;
}

.page-link {
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius-sm);
  color: var(--a-ink-2);
}

a.page-link:hover {
  border-color: var(--a-brand);
  color: var(--a-brand);
}

.page-link.active {
  background: var(--a-brand);
  border-color: var(--a-brand);
  color: #fff;
}

.page-link.disabled {
  opacity: 0.5;
}

.page-gap {
  color: var(--a-ink-3);
  padding: 0 2px;
}

/* ------------------------------- 图表 ------------------------------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 160px;
  padding: 8px 0 0;
}

.chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

.chart__bar {
  width: 100%;
  max-width: 46px;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  position: relative;
  transition: opacity 0.15s;
}

.chart__bar:hover {
  opacity: 0.85;
}

.chart__bar[data-value]:hover::after {
  content: attr(data-value);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -4px);
  padding: 2px 7px;
  background: #1a1a1f;
  color: #fff;
  font-size: 11px;
  border-radius: 4px;
  white-space: nowrap;
}

.chart__label {
  font-size: 11px;
  color: var(--a-ink-3);
  white-space: nowrap;
}

/* ------------------------------- 提示 ------------------------------- */

.notice {
  padding: 11px 15px;
  border-radius: var(--a-radius-sm);
  font-size: 13.5px;
  border: 1px solid;
  margin-bottom: 16px;
}

.notice--ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.notice--error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.notice--info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 22px;
  background: #1a1a1f;
  color: #fff;
  border-radius: 999px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
}

.toast.is-shown {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.is-error {
  background: var(--a-danger);
}

/* ------------------------------- 登录 ------------------------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1e293b, #0f172a 60%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 34px 32px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.login-card__title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login-card__sub {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--a-ink-3);
}

.login-card .field:last-of-type {
  margin-bottom: 20px;
}

.login-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--a-ink-3);
}

.login-foot a:hover {
  color: var(--a-brand);
}

/* --------------------------- 弹窗 / 空状态 --------------------------- */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, 0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.is-open {
  display: flex;
}

.modal__box {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: var(--a-radius);
  overflow: hidden;
}

.modal__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--a-line);
  font-size: 14.5px;
  font-weight: 600;
}

.modal__body {
  padding: 20px;
}

.modal__foot {
  padding: 14px 20px;
  border-top: 1px solid var(--a-line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fafaf8;
}

.empty-state {
  padding: 56px 20px;
  text-align: center;
  color: var(--a-ink-3);
  font-size: 13.5px;
}

.error-page {
  padding: 90px 0;
  text-align: center;
}

.error-page h1 {
  font-size: 22px;
  margin: 0 0 10px;
}

.error-page p {
  color: var(--a-ink-3);
  margin: 0 0 24px;
}

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 1080px) {
  .editor {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .admin-side {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }

  .admin-side.is-open {
    transform: translateX(0);
  }

  .side-toggle {
    display: inline-flex;
  }

  .admin-content {
    padding: 18px;
  }

  .admin-top {
    padding: 0 18px;
  }

  .admin-top__title {
    font-size: 14px;
  }
}
