/* ==========================================================================
   华盾官网 · 管理后台样式
   延续品牌深红 + 米白纸色，编辑器式简洁管理界面
   ========================================================================== */

:root {
  --red: #A61B29;
  --red-deep: #7C1220;
  --red-soft: rgba(166, 27, 41, 0.08);
  --ink: #14161A;
  --ink-2: #1E2126;
  --paper: #F7F6F3;
  --white: #FFFFFF;
  --gray: #6B6B6B;
  --gray-light: #9A9A98;
  --line: #E4E1DA;
  --green: #1C6E37;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --side-w: 232px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body.admin-body {
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============================ 侧栏 ============================ */

.admin-side {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--side-w);
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.admin-brand .logo-mark { width: 38px; height: 38px; flex: none; }
.admin-brand span { display: flex; flex-direction: column; line-height: 1.3; }
.admin-brand strong { font-size: 17px; letter-spacing: 3px; }
.admin-brand em { font-style: normal; font-size: 11px; letter-spacing: 2px; color: rgba(255,255,255,0.5); }

.admin-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  font-size: 14px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.66);
  border-left: 3px solid transparent;
  transition: all 0.25s var(--ease);
  position: relative;
}
.admin-nav a svg { width: 19px; height: 19px; flex: none; }
.admin-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.admin-nav a.active {
  color: #fff;
  background: rgba(166, 27, 41, 0.35);
  border-left-color: var(--red);
  font-weight: 600;
}
.nav-badge {
  margin-left: auto;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
  font-weight: 700;
}

.admin-side-foot {
  padding: 16px 24px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-side-foot a { font-size: 13px; letter-spacing: 1px; color: rgba(255,255,255,0.55); transition: color 0.25s; }
.admin-side-foot a:hover { color: #fff; }
.admin-side-foot .logout { color: rgba(255, 255, 255, 0.4); }

/* ============================ 主区 ============================ */

.admin-main {
  flex: 1;
  margin-left: var(--side-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(247, 246, 243, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.admin-topbar h1 { font-size: 21px; letter-spacing: 2px; font-weight: 700; }
.admin-user { font-size: 13px; color: var(--gray); letter-spacing: 1px; }

.admin-content { padding: 28px 32px 60px; max-width: 1280px; width: 100%; }

/* ============================ 通用组件 ============================ */

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 26px 28px;
  margin-bottom: 22px;
}
.panel--narrow { max-width: 560px; }
.panel-title { font-size: 16px; letter-spacing: 2px; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.panel-empty { padding: 40px 0; text-align: center; color: var(--gray-light); letter-spacing: 1px; }

.flash {
  padding: 13px 18px;
  margin-bottom: 18px;
  border-left: 3px solid;
  font-size: 14px;
  letter-spacing: 1px;
}
.flash--success { background: rgba(28, 110, 55, 0.08); border-color: var(--green); color: var(--green); }
.flash--error { background: rgba(166, 27, 41, 0.07); border-color: var(--red); color: var(--red); }

.toolbar { display: flex; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; align-items: center; }

/* 按钮（后台版） */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 14px;
  letter-spacing: 2px;
  border: 1px solid transparent;
  transition: all 0.28s var(--ease);
  white-space: nowrap;
}
.btn--red { background: var(--red); color: #fff; }
.btn--red:hover { background: var(--red-deep); }
.btn--ghost { border-color: var(--line); color: var(--ink); background: var(--white); }
.btn--ghost:hover { border-color: var(--red); color: var(--red); }
.btn--danger { border-color: rgba(166, 27, 41, 0.4); color: var(--red); background: var(--white); }
.btn--danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn--sm { padding: 7px 16px; font-size: 13px; }
.btn--xs { padding: 4px 12px; font-size: 12px; letter-spacing: 1px; }
.btn--block { width: 100%; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12.5px;
  letter-spacing: 2px;
  color: var(--gray);
  font-weight: 500;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.25s; }
.table tbody tr:hover { background: rgba(166, 27, 41, 0.03); }
.cell-title a { font-weight: 600; letter-spacing: 1px; }
.cell-title a:hover { color: var(--red); }
.cell-muted { color: var(--gray-light); font-size: 13px; }
.th-actions, .cell-actions { text-align: right; }
.cell-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.table--full { background: var(--white); border: 1px solid var(--line); }

/* 状态胶囊 */
.pill {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  letter-spacing: 1px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--gray);
  border-radius: 999px;
}
.pill--ok { background: rgba(28, 110, 55, 0.08); border-color: rgba(28, 110, 55, 0.3); color: var(--green); }
.pill--red { background: rgba(166, 27, 41, 0.08); border-color: rgba(166, 27, 41, 0.3); color: var(--red); font-weight: 600; }

.inline-form { display: inline; }

/* 分页 */
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }
.pager-btn {
  min-width: 38px; height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--white);
  font-size: 13.5px;
  color: var(--ink);
  transition: all 0.25s var(--ease);
}
.pager-btn:hover { border-color: var(--red); color: var(--red); }
.pager-btn.active { background: var(--red); border-color: var(--red); color: #fff; }

/* ============================ 仪表盘 ============================ */

.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 26px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  padding: 24px 26px;
}
.stat-card .num { font-size: 40px; font-weight: 900; line-height: 1.15; letter-spacing: 1px; }
.stat-card .label { color: var(--gray); font-size: 13.5px; letter-spacing: 2px; margin: 6px 0 14px; }
.stat-card a { font-size: 13px; color: var(--red); letter-spacing: 1px; }
.stat-card a:hover { text-decoration: underline; }
.stat-card--red { border-top-color: var(--red); background: linear-gradient(135deg, var(--red-deep), var(--red)); color: #fff; }
.stat-card--red .label { color: rgba(255, 255, 255, 0.8); }
.stat-card--red a { color: #fff; }

.dash-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 22px; align-items: start; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 16px; letter-spacing: 2px; }
.panel-head a { font-size: 13px; color: var(--red); letter-spacing: 1px; }

.mini-list { list-style: none; }
.mini-list li { padding: 13px 0; border-bottom: 1px solid var(--line); }
.mini-list li:last-child { border-bottom: none; }
.mini-list li.unread { background: rgba(166, 27, 41, 0.03); margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
.mini-title { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.mini-text {
  font-size: 13.5px; color: var(--gray);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mini-time { font-size: 12px; color: var(--gray-light); margin-top: 4px; letter-spacing: 1px; }

/* ============================ 表单 ============================ */

.field-label {
  display: block;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--ink-2);
  margin: 18px 0 8px;
}
.field-label .req, .req { color: var(--red); }
.input {
  width: 100%;
  font-family: inherit;
  font-size: 14.5px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  outline: none;
  border-radius: 0;
  transition: border-color 0.25s, background 0.25s;
}
.input:focus { border-color: var(--red); background: var(--white); }
textarea.input { resize: vertical; line-height: 1.75; }
.field-hint { font-size: 12px; color: var(--gray-light); margin-top: 6px; letter-spacing: 0.5px; line-height: 1.7; }

.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-3col { display: grid; grid-template-columns: 1fr 0.6fr 1.4fr; gap: 16px; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
}
.switch-row input { position: absolute; opacity: 0; }
.switch {
  width: 42px; height: 22px;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  flex: none;
  transition: background 0.25s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s var(--ease);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch-row input:checked + .switch { background: var(--red); }
.switch-row input:checked + .switch::after { transform: translateX(20px); }

.cover-preview {
  margin-top: 12px;
  max-width: 240px;
  max-height: 140px;
  border: 1px solid var(--line);
  background: var(--paper);
  object-fit: cover;
  display: block;
}

/* ============================ 文章编辑器 ============================ */

.editor-layout { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-bottom: none;
  background: var(--white);
}
.editor-toolbar button {
  min-width: 34px; height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  letter-spacing: 1px;
  transition: all 0.2s;
}
.editor-toolbar button:hover { background: var(--red-soft); border-color: var(--line); color: var(--red); }
.editor-toolbar button:disabled { opacity: 0.5; cursor: wait; }
.editor-toolbar svg { width: 16px; height: 16px; }
.toolbar-divider { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

.editor-area {
  min-height: 420px;
  border: 1px solid var(--line);
  background: var(--white);
  padding: 22px 26px;
  font-size: 15px;
  line-height: 1.9;
  outline: none;
  color: var(--ink);
}
.editor-area:focus { border-color: var(--red); }
.editor-area:empty::before {
  content: attr(data-placeholder);
  color: var(--gray-light);
  pointer-events: none;
}
.editor-area h2 { font-size: 21px; margin: 18px 0 10px; letter-spacing: 1px; }
.editor-area h3 { font-size: 17px; margin: 14px 0 8px; letter-spacing: 1px; }
.editor-area p { margin-bottom: 12px; }
.editor-area ul, .editor-area ol { margin: 0 0 12px 24px; }
.editor-area blockquote {
  margin: 14px 0;
  padding: 12px 18px;
  border-left: 3px solid var(--red);
  background: var(--red-soft);
  color: var(--ink-2);
}
.editor-area img { max-width: 100%; height: auto; margin: 8px 0; }

.editor-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.sticky-actions {
  position: sticky;
  bottom: 16px;
  z-index: 30;
  background: rgba(247, 246, 243, 0.92);
  backdrop-filter: blur(6px);
  padding: 14px 0;
  margin: 0;
}
.sticky-actions .btn { max-width: 420px; margin: 0 auto; }

/* ============================ 留言列表 ============================ */

.msg-list { display: grid; gap: 16px; }
.msg-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  padding: 20px 24px;
  transition: border-color 0.25s;
}
.msg-card--unread { border-left-color: var(--red); background: rgba(166, 27, 41, 0.02); }
.msg-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.msg-head strong { font-size: 16px; letter-spacing: 1px; }
.msg-company { font-size: 13px; color: var(--gray); }
.msg-time { margin-left: auto; font-size: 12.5px; color: var(--gray-light); letter-spacing: 1px; }
.msg-body {
  margin: 12px 0;
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--ink-2);
  background: var(--paper);
  padding: 14px 18px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-foot { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--gray); }
.msg-actions { margin-left: auto; display: flex; gap: 10px; }

/* ============================ 登录页 ============================ */

body.admin-login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  background: linear-gradient(135deg, var(--red-deep) 0%, var(--red) 45%, var(--ink) 100%);
  padding: 24px;
}
.login-wrap {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 44px 42px 36px;
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .logo-mark { width: 54px; height: 54px; margin: 0 auto 12px; }
.login-brand strong { display: block; font-size: 21px; letter-spacing: 4px; }
.login-brand em { font-style: normal; font-size: 12px; letter-spacing: 3px; color: var(--gray); }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-form label { font-size: 13px; letter-spacing: 2px; color: var(--ink-2); margin-top: 10px; }
.login-form input {
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  outline: none;
}
.login-form input:focus { border-color: var(--red); background: var(--white); }
.login-form .btn { margin-top: 22px; padding: 13px; }
.login-note { margin-top: 18px; font-size: 12px; color: var(--gray-light); text-align: center; line-height: 1.8; }
.login-back { display: block; margin-top: 14px; text-align: center; font-size: 13px; color: var(--gray); }
.login-back:hover { color: var(--red); }
.login-wrap .flash { margin-bottom: 16px; }

/* ============================ 响应式 ============================ */

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .admin-side { width: 200px; }
  .admin-main { margin-left: 200px; }
  .admin-content { padding: 22px 18px 50px; }
  .admin-topbar { padding: 14px 18px; }
  .form-3col { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 720px) {
  body.admin-body { display: block; }
  .admin-side {
    position: static;
    width: 100%;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
  }
  .admin-brand { padding: 6px 8px; border-bottom: none; }
  .admin-nav {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    gap: 4px;
    flex: 1;
  }
  .admin-nav a {
    padding: 7px 12px;
    border-left: none;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    gap: 6px;
  }
  .admin-nav a.active { border-bottom-color: var(--red); background: rgba(166, 27, 41, 0.25); }
  .admin-nav a svg { width: 16px; height: 16px; }
  .nav-badge { position: static; }
  .admin-side-foot { border-top: none; padding: 4px 8px; flex-direction: row; gap: 14px; }
  .admin-main { margin-left: 0; }
  .form-2col { grid-template-columns: 1fr; gap: 0; }
  .cell-actions { flex-wrap: wrap; }
  .table--full { display: block; overflow-x: auto; }
  .msg-time { margin-left: 0; width: 100%; }
  .msg-actions { margin-left: 0; }
}

/* ============================ 键盘可达性 ============================ */

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.admin-side :focus-visible {
  outline-color: #fff;
}

/* ============================ 页面内容管理 ============================ */

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.page-tab {
  padding: 9px 18px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e3e0da;
  color: var(--ink, #222);
  font-size: 14px;
  text-decoration: none;
  transition: all 0.2s;
}
.page-tab:hover { border-color: var(--red, #A61B29); color: var(--red, #A61B29); }
.page-tab.active {
  background: var(--red, #A61B29);
  border-color: var(--red, #A61B29);
  color: #fff;
}

.pages-form { display: none; }
.pages-form.active { display: block; }

.row-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row-editor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  border: 1px solid #e3e0da;
  border-left: 3px solid var(--red, #A61B29);
  border-radius: 8px;
  background: #fbfaf8;
}
.row-field {
  flex: 1 1 220px;
  min-width: 200px;
}
.row-field .field-label {
  margin-bottom: 5px;
  font-size: 12px;
  color: #777;
}
.row-del {
  flex-shrink: 0;
  margin-top: 26px;
  color: #a00;
  border-color: #e3c3c3;
}
.row-del:hover { background: #fdf0f0; }
.row-add {
  align-self: flex-start;
  border-style: dashed;
}
