*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.6;
}

body.admin-body {
  overflow-x: hidden;
}

/* 左侧功能菜单 + 主内容区布局 */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #1e293b;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand a {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.sidebar-brand a:hover {
  color: #93c5fd;
  text-decoration: none;
}

.sidebar-brand span {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  padding: 8px 10px 6px;
  margin: 0;
}

.sidebar-nav ul {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.active {
  background: #3b82f6;
  color: #fff;
  font-weight: 500;
}

.sidebar-link-muted:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.sidebar-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
}

.admin-topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.admin-topbar h1 {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-user-badge {
  font-size: 13px;
  color: #64748b;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 20px;
}

.admin-logout-btn {
  font-size: 13px;
  color: #64748b;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.admin-logout-btn:hover {
  color: #ef4444;
  border-color: #fecaca;
  background: #fef2f2;
  text-decoration: none;
}

.admin-content {
  flex: 1;
  padding: 24px 28px 32px;
  overflow-x: auto;
}

a {
  color: #3b82f6;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.admin-container {
  max-width: 100%;
}

.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 24px;
}

.card h2 {
  font-size: 20px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: #3b82f6;
  color: #fff;
}

.btn-primary:hover {
  background: #2563eb;
  text-decoration: none;
  color: #fff;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.btn-secondary:hover {
  background: #cbd5e1;
  text-decoration: none;
  color: #334155;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
}

th {
  background: #f8fafc;
  font-weight: 600;
  color: #64748b;
}

tr:hover td {
  background: #f8fafc;
}

.thumb-cell {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}

.thumb-wrap {
  display: block;
  width: 60px;
  height: 40px;
  overflow: hidden;
  border-radius: 4px;
  line-height: 0;
}

.thumb-wrap .thumb,
table .thumb {
  display: block;
  width: 60px;
  height: 40px;
  max-width: 60px;
  max-height: 40px;
  object-fit: cover;
  border-radius: 4px;
}

.status-published {
  color: #16a34a;
}

.status-pinned {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
}

.pin-cell {
  white-space: nowrap;
}

.pin-cell .status-pinned {
  display: block;
  margin-bottom: 6px;
}

.pin-order-cell {
  min-width: 72px;
  vertical-align: middle;
}

.pin-order-compact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pin-order-value {
  display: inline-block;
  min-width: 20px;
  font-weight: 600;
  color: #334155;
  text-align: center;
}

.pin-order-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.pin-order-edit-btn:hover {
  border-color: #3b82f6;
  color: #2563eb;
  background: #eff6ff;
}

.pin-order-form {
  display: none !important;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0;
}

.pin-order-form[hidden] {
  display: none !important;
}

.pin-order-form.is-open:not([hidden]) {
  display: inline-flex !important;
}

.pin-order-input {
  width: 52px;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
}

td.actions {
  white-space: nowrap;
  vertical-align: middle;
}

/* 操作列按钮间距；勿对 td 使用 flex，否则会打断表格行底线 */
td.actions .btn + .btn {
  margin-left: 8px;
}

.status-draft {
  color: #ca8a04;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 400px;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 24px;
}

.login-box .subtitle {
  text-align: center;
  color: #64748b;
  font-size: 14px;
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #475569;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.preview-img-wrap {
  display: inline-block;
  max-width: 200px;
  max-height: 120px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 6px;
  line-height: 0;
}

.preview-img {
  display: block;
  max-width: 200px;
  max-height: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.checkbox-label input {
  width: auto;
}

.rich-editor-wrap .tox-tinymce {
  border-radius: 8px;
  border-color: #cbd5e1;
}

.rich-editor-wrap .rich-editor-source {
  min-height: 200px;
}

.rich-editor-wrap .rich-editor-paste-hint {
  margin-top: 8px;
  margin-bottom: 0;
  color: #64748b;
  font-size: 13px;
}

.wps-paste-import {
  margin-top: 12px;
  padding: 12px 14px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 13px;
  color: #92400e;
}

.wps-paste-import-title {
  margin: 0 0 8px;
  font-weight: 600;
}

.wps-paste-import-path {
  margin: 0 0 10px;
  line-height: 1.5;
  color: #a16207;
}

.wps-paste-import-path code {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.6);
  padding: 1px 4px;
  border-radius: 3px;
}

.wps-paste-import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.wps-paste-import .btn-sm {
  cursor: pointer;
}

.wps-paste-import .wps-folder-picker {
  display: none;
}

@media (max-width: 768px) {
  .admin-wrapper {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
  }

  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 12px;
  }

  .sidebar-section {
    display: none;
  }

  .sidebar-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
  }

  .admin-content {
    padding: 16px;
  }
}
