/* ============================================================
 * 后台管理样式
 * 风格：极简卡片 + 留白 + 一致的操作反馈
 * ============================================================ */

:root {
  /* 后台映射到前台朴素主题变量（由 themes.css 提供）。
   * 已移除多主题切换，只有单一朴素风格。 */
  --bg:         var(--c-bg);
  --card:       var(--c-bg-alt);
  --text:       var(--c-text);
  --text-soft:  var(--c-text-soft);
  --text-fade:  var(--c-text-fade);
  --border:     var(--c-border);
  --accent:     var(--c-accent);
  --accent-dk:  var(--c-accent-dk);
  --success:    #2e7d32;
  --warning:    #ed6c02;
  --danger:     #d32f2f;
  --bg-hover:   rgba(125,125,125,.08);

  --radius:    6px;
  --shadow:    0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.08);

  --serif:     var(--serif-text);
  --sans:      -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  --mono:      "JetBrains Mono", "Source Code Pro", Menlo, monospace;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

input, textarea, select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(161,61,45,.12);
}
textarea { resize: vertical; min-height: 80px; }

label {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: .02em;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f3ef 0%, #ebe7e0 100%);
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 8px;
  text-align: center;
}
.login-card .sub {
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  margin-bottom: 28px;
}
.login-card .field { margin-bottom: 18px; }
.login-card .btn-primary { width: 100%; }
.login-card .error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  min-height: 18px;
}

/* ---------- 后台布局 ---------- */
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* 侧栏 */
.sidebar {
  background: #1a1a1a;
  color: #fff;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  padding: 0 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 16px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(161,61,45,.18); color: #fff; border-left: 3px solid var(--accent); padding-left: 17px; }
.sidebar nav a .icon { font-size: 16px; opacity: .9; }
.sidebar .footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
  color: rgba(255,255,255,.4);
}
.sidebar .footer .logout {
  color: rgba(255,255,255,.6);
  font-size: 13px;
  text-decoration: none;
}
.sidebar .footer .logout:hover { color: #fff; }

/* 主区 */
.main {
  padding: 32px 40px;
  max-width: 100%;
  overflow-x: auto;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h1 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  margin: 0;
}
.page-header .actions { display: flex; gap: 10px; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

/* 表单 */
.form-row { margin-bottom: 18px; }
.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* 表格 */
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th, table.data td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data th {
  font-size: 12px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-fade);
  font-weight: 500;
  background: #fafafa;
}
table.data tr:hover { background: #fafafa; }
table.data tr:last-child td { border-bottom: none; }
table.data .cover-thumb {
  width: 60px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-hover);
}
table.data .title-cell {
  font-weight: 500;
  color: var(--text);
}
table.data .meta-cell { color: var(--text-soft); font-size: 12px; }
table.data .row-actions { white-space: nowrap; }
table.data .row-actions a,
table.data .row-actions button {
  margin-right: 8px;
  font-size: 12px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-soft);
}
table.data .row-actions a:hover,
table.data .row-actions button:hover { color: var(--accent); }
table.data .row-actions .delete:hover { color: var(--danger); }

/* 标签 */
.tag {
  display: inline-block;
  background: var(--bg-hover);
  color: var(--text-soft);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  margin-right: 4px;
}
.tag.published { background: #e8f5e9; color: var(--success); }
.tag.draft     { background: #fff3e0; color: var(--warning); }

/* 仪表盘 */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}
.stat-card .value {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 600;
  color: var(--text);
}
.stat-card .sub { font-size: 12px; color: var(--text-fade); margin-top: 4px; }

/* 提示框 */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert.info    { background: #e3f2fd; color: #0d47a1; }
.alert.success { background: #e8f5e9; color: var(--success); }
.alert.warning { background: #fff3e0; color: var(--warning); }
.alert.error   { background: #ffebee; color: var(--danger); }

/* Toast */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: slideIn .2s ease-out;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* 上传区 */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fafafa;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(161,61,45,.04);
}
.upload-zone .icon {
  font-size: 32px;
  color: var(--text-fade);
  margin-bottom: 8px;
}
.upload-zone .text {
  color: var(--text-soft);
  font-size: 13px;
}

/* 图片网格（编辑器内） */
.photo-grid-edit {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.photo-edit-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--card);
}
.photo-edit-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--bg-hover);
}
.photo-edit-card .photo-meta {
  padding: 8px 10px;
}
.photo-edit-card .photo-meta input {
  font-size: 12px;
  padding: 4px 8px;
  margin-bottom: 4px;
}
.photo-edit-card .photo-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
}
.photo-edit-card .photo-actions button {
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-edit-card .photo-actions button:hover { background: var(--danger); }

/* 编辑器（简易富文本） */
.editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: #fafafa;
  flex-wrap: wrap;
}
.editor-toolbar button {
  background: none;
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-soft);
}
.editor-toolbar button:hover { background: var(--bg-hover); color: var(--text); }
.editor-content {
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  padding: 16px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.8;
  background: #fff;
}
.editor-content:focus { outline: none; border-color: var(--accent); }
.editor-content h1, .editor-content h2, .editor-content h3 { font-family: var(--serif); }
.editor-content img { max-width: 100%; height: auto; margin: 16px 0; border-radius: 4px; }
.editor-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  color: var(--text-soft);
  font-style: italic;
}

/* 响应式 */
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .sidebar nav { display: flex; flex-wrap: wrap; padding: 0 12px 12px; }
  .sidebar nav a { padding: 8px 12px; border-left: none !important; border-bottom: 2px solid transparent; }
  .sidebar nav a.active { border-left: none; border-bottom-color: var(--accent); }
  .main { padding: 20px; }
  .form-row.two-col, .form-row.three-col { grid-template-columns: 1fr; }
}
