/* ============================================================
   管理工作台样式
   ============================================================ */

/* ======================== 设计令牌 ======================== */
:root {
  --red: #C41E24;
  --red-dark: #8B1A1A;
  --red-light: #E84C51;
  --red-muted: rgba(196, 30, 36, 0.08);
  --gold: #D4A843;

  --bg-white: #FFFFFF;
  --bg-light: #F5F6FA;
  --bg-sidebar: #1E1F2E;
  --bg-sidebar-hover: #2A2B3D;
  --bg-sidebar-active: rgba(196, 30, 36, 0.15);

  --text-primary: #2D2D2D;
  --text-secondary: #666666;
  --text-muted: #999999;
  --text-sidebar: rgba(255, 255, 255, 0.65);
  --text-sidebar-active: #FFFFFF;
  --border-color: #E8E8E8;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.14);

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.3s var(--ease);

  --font-sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --header-h: 60px;
  --sidebar-w: 220px;
}

/* ======================== 重置 ======================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-sans); color: var(--text-primary); background: var(--bg-light); line-height: 1.6; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { border: none; background: none; cursor: pointer; font-family: inherit; font-size: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* ======================== 登录页 ======================== */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--bg-light);
}

.login-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 50%, #3D0A0D 100%);
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 65%);
}

.login-card {
  position: relative;
  z-index: 2;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 48px 40px 36px;
  width: 400px;
  max-width: calc(100vw - 48px);
  box-shadow: var(--shadow-lg);
  animation: loginSlideUp 0.6s var(--ease);
}

@keyframes loginSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-emblem {
  margin-bottom: 16px;
  filter: drop-shadow(0 2px 8px rgba(212, 168, 67, 0.3));
}

.login-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-muted);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

/* Checkbox */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  cursor: pointer;
}

.form-checkbox span {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* 富文本编辑器 */
.rich-editor {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.rich-editor:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-muted);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.editor-btn {
  width: 32px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.editor-btn:hover {
  background: var(--bg-white);
  color: var(--red);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.editor-btn:active {
  background: var(--red-muted);
}

.editor-sep {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

.editor-content {
  min-height: 180px;
  max-height: 400px;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-primary);
  outline: none;
}

.editor-content:empty::before {
  content: '请输入内容...';
  color: var(--text-muted);
  pointer-events: none;
}

.editor-content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 12px 0 6px;
}

.editor-content blockquote {
  border-left: 3px solid var(--red);
  padding: 8px 12px;
  margin: 8px 0;
  background: var(--red-muted);
  border-radius: 0 4px 4px 0;
}

.editor-content ul, .editor-content ol {
  padding-left: 20px;
  margin: 6px 0;
}

.editor-content li {
  margin-bottom: 2px;
}

/* 图片上传管理 */
.image-upload-area {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  width: 100%;
}

.image-preview-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 4/3;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.image-preview-item:hover img {
  transform: scale(1.05);
}

.image-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(200, 30, 30, 0.85);
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  border: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.image-preview-item:hover .image-remove-btn {
  opacity: 1;
}

.image-cover-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.image-upload-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 64px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 4px;
}

.image-upload-btn:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-muted);
}

.upload-icon {
  font-size: 1.2rem;
}

.image-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.image-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.login-error {
  font-size: 0.82rem;
  color: var(--red);
  min-height: 20px;
  margin-bottom: 4px;
  text-align: center;
}

.btn-login {
  width: 100%;
  padding: 12px;
  background: var(--red);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  letter-spacing: 0.15em;
  transition: background var(--transition), transform var(--transition);
}

.btn-login:hover {
  background: var(--red-dark);
}

.btn-login:active {
  transform: scale(0.98);
}

.login-hint {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.login-hint p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ======================== 仪表盘布局 ======================== */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部栏 */
.dash-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.dash-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-header-left h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  margin-right: 4px;
}

.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.btn-outline:hover {
  border-color: var(--red);
  color: var(--red);
}

.dash-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dash-user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.btn-logout {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-logout:hover {
  color: var(--red);
  background: var(--red-muted);
}

/* 主体 */
.dash-body {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* 侧边栏 */
.dash-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: transform var(--transition);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  font-size: 0.9rem;
  font-weight: 400;
  transition: all var(--transition);
  text-align: left;
  width: 100%;
}

.sidebar-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.sidebar-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 500;
}

.sidebar-item.active .sidebar-icon {
  transform: scale(1.1);
}

.sidebar-icon {
  font-size: 1.1rem;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.sidebar-bottom {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-back {
  font-size: 0.82rem;
  color: var(--text-sidebar);
  transition: color var(--transition);
}

.sidebar-back:hover {
  color: var(--gold);
}

/* 内容区 */
.dash-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  min-height: calc(100vh - var(--header-h));
}

/* ======================== 内容区组件 ======================== */

/* 页面标题栏 */
.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.content-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.content-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 分类筛选下拉框 */
.category-select {
  padding: 8px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-white);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.category-select:focus {
  border-color: var(--red);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--red-dark);
}

.btn-cancel {
  background: var(--bg-light);
  color: var(--text-secondary);
}

.btn-cancel:hover {
  background: var(--border-color);
}

.btn-danger {
  background: #dc3545;
  color: #fff;
}

.btn-danger:hover {
  background: #b02a37;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-light);
  color: var(--text-primary);
}

.btn-icon.edit:hover {
  color: var(--red);
  background: var(--red-muted);
}

.btn-icon.delete:hover {
  color: #dc3545;
  background: rgba(220, 53, 69, 0.08);
}

/* 数据表格 */
.data-table {
  width: 100%;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.data-table th,
.data-table td {
  padding: 14px 18px;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: var(--bg-light);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.data-table tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}

.data-table .cell-title {
  font-weight: 500;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table .cell-date {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.data-table .cell-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--red-muted);
  color: var(--red);
}

.data-table .cell-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.cell-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.cell-badge.new {
  background: rgba(40, 167, 69, 0.1);
  color: #28a745;
}

.cell-badge.normal {
  background: var(--bg-light);
  color: var(--text-muted);
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ======================== 模态框 ======================== */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.admin-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.admin-modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 580px;
  max-width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(0.97);
  transition: transform var(--transition);
}

.admin-modal-overlay.open .admin-modal {
  transform: translateY(0) scale(1);
}

.admin-modal--sm {
  width: 420px;
}

.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.admin-modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.admin-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition);
}

.admin-modal-close:hover {
  background: var(--red-muted);
  color: var(--red);
}

.admin-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.admin-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.delete-msg {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Admin form in modal */
.admin-form .form-group {
  margin-bottom: 18px;
}

.admin-form .form-group:last-child {
  margin-bottom: 0;
}

/* ======================== Toast 通知 ======================== */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: #fff;
  background: #2d2d2d;
  box-shadow: var(--shadow-md);
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
  pointer-events: none;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.success {
  background: #28a745;
}

.toast.error {
  background: #dc3545;
}

/* ======================== 响应式 ======================== */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex;
  }

  .dash-sidebar {
    transform: translateX(-100%);
  }

  .dash-sidebar.open {
    transform: translateX(0);
  }

  .dash-main {
    margin-left: 0;
    padding: 20px 16px;
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .data-table table {
    min-width: 500px;
  }

  .admin-modal {
    width: 100%;
    max-height: 90vh;
    border-radius: var(--radius);
  }

  .admin-modal-body {
    padding: 16px;
  }

  .dash-header-right .btn-outline span,
  .dash-user-name {
    display: none;
  }

  .login-card {
    padding: 36px 24px 28px;
  }
}

/* Sidebar overlay on mobile */
@media (max-width: 768px) {
  .dash-sidebar.open::after {
    content: '';
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
  }
}
