/* =============================================
   管理后台样式
   ============================================= */
:root {
  --primary: #6C63FF;
  --primary-light: #8B85FF;
  --secondary: #FF6584;
  --accent: #43CBFF;
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #F44336;
  --bg: #0D0D1A;
  --bg-card: #16162A;
  --bg-surface: #1E1E35;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --text: #EAEAF5;
  --text-muted: #8888AA;
  --text-dim: #555577;
  --border: rgba(108,99,255,0.2);
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s ease;
  --font: 'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif;
}
[data-theme="light"] {
  --bg: #F0F0FA;
  --bg-card: #FFFFFF;
  --bg-surface: #F8F8FF;
  --text: #1A1A2E;
  --text-muted: #6666AA;
  --text-dim: #AAAACC;
  --border: rgba(108,99,255,0.15);
  --shadow: 0 4px 20px rgba(108,99,255,0.1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }
a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: var(--font); }

/* ---- 登录 ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 30% 40%, rgba(108,99,255,0.12) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 70%, rgba(67,203,255,0.08) 0%, transparent 50%);
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  justify-content: center;
}
.logo-icon { font-size: 28px; }
.logo-text { font-size: 22px; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.login-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.login-sub { color: var(--text-muted); font-size: 14px; text-align: center; margin-bottom: 32px; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; min-height: 20px; margin-bottom: 8px; }
.login-hint { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 20px; }

/* ---- 管理布局 ---- */
.admin-layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform var(--transition);
}
.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-title { font-size: 18px; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; flex: 1; }
.sidebar-close { display: none; color: var(--text-muted); font-size: 18px; background: none; border: none; cursor: pointer; }
.sidebar-nav { padding: 16px 12px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  cursor: pointer;
}
.nav-item:hover { background: rgba(108,99,255,0.1); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,0.2); color: var(--primary-light); font-weight: 600; }
.nav-icon { font-size: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--secondary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  display: none;
}
.nav-badge.show { display: block; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 0; }

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-menu { display: none; font-size: 22px; background: none; border: none; color: var(--text-muted); cursor: pointer; }
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.theme-toggle { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 16px; transition: var(--transition); }
.theme-toggle:hover { border-color: var(--primary); }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-muted); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

.panel-content { flex: 1; padding: 24px; overflow-y: auto; }

/* ---- 面板 ---- */
.panel { display: none; animation: fadeInUp 0.3s ease; }
.panel.active { display: block; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.panel-header h2 { font-size: 22px; font-weight: 700; }
.panel-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ---- 卡片 ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-header h3 { font-size: 16px; font-weight: 700; }

/* ---- 统计卡片 ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.stat-icon { width: 52px; height: 52px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-info .stat-num { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-info .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---- Dashboard行 ---- */
.dashboard-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.category-chart { padding: 8px 0; }
.category-bar { margin-bottom: 12px; }
.category-bar-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.category-bar-track { height: 6px; background: var(--bg-surface); border-radius: 3px; overflow: hidden; }
.category-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 3px; transition: width 0.8s ease; }
.latest-msgs { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.msg-preview {
  padding: 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  font-size: 13px;
}
.msg-preview.unread { border-left-color: var(--secondary); }
.msg-preview-name { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.msg-preview-text { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-preview-time { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ---- 工具栏 ---- */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input, .select-input {
  padding: 9px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}
.search-input { flex: 1; min-width: 200px; }
.search-input:focus, .select-input:focus { border-color: var(--primary); }
.select-input option { background: var(--bg-card); }

/* ---- 表格 ---- */
.works-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead tr { background: var(--bg-surface); }
.data-table th { padding: 12px 16px; text-align: left; color: var(--text-muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.data-table td { padding: 12px 16px; border-top: 1px solid var(--border); }
.data-table tr:hover td { background: rgba(108,99,255,0.04); }
.work-thumb-sm { width: 50px; height: 36px; border-radius: 6px; object-fit: cover; }
.category-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: rgba(108,99,255,0.15); color: var(--primary-light); }
.featured-yes { color: #FFE259; }
.featured-no { color: var(--text-dim); }
.action-btns { display: flex; gap: 8px; }
.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary); }
.btn-icon.delete:hover { border-color: var(--danger); color: var(--danger); }

/* ---- 留言 ---- */
.msgs-list { display: flex; flex-direction: column; gap: 16px; }
.msg-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}
.msg-card.unread { border-left: 3px solid var(--secondary); }
.msg-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.msg-sender h4 { font-size: 16px; font-weight: 700; }
.msg-sender p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.msg-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg-time { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.msg-type-badge { font-size: 12px; padding: 2px 10px; border-radius: 12px; background: rgba(108,99,255,0.15); color: var(--primary-light); }
.msg-body { color: var(--text-muted); font-size: 14px; line-height: 1.7; padding: 12px; background: var(--bg-surface); border-radius: var(--radius-sm); }
.msg-actions { display: flex; gap: 10px; margin-top: 12px; justify-content: flex-end; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 50px; margin-bottom: 12px; }

/* ---- 设置 ---- */
.settings-form { max-width: 720px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.theme-options { display: flex; gap: 16px; }
.theme-option { cursor: pointer; }
.theme-option input { display: none; }
.theme-preview {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  transition: var(--transition);
  min-width: 100px;
  font-size: 13px;
  color: var(--text-muted);
}
.theme-option input:checked + .theme-preview { border-color: var(--primary); color: var(--primary); }
.theme-dots { display: flex; gap: 4px; justify-content: center; margin-bottom: 8px; }
.theme-dots::before, .theme-dots::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.5; }
.dark-preview { background: #16162A; color: #8888AA; }
.light-preview { background: #F0F0FA; color: #6666AA; }

/* ---- 弹窗 ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.25s;
}
.modal-overlay.active .modal-container { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 24px 28px 0; }
.modal-header h3 { font-size: 20px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-surface); border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; transition: var(--transition); }
.modal-close:hover { background: var(--danger); color: #fff; }
.modal-body { padding: 24px 28px; }
.modal-footer { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ---- 确认框 ---- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.confirm-overlay.active { opacity: 1; pointer-events: all; }
.confirm-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  max-width: 360px;
  width: 90%;
}
.confirm-icon { font-size: 40px; margin-bottom: 12px; }
.confirm-box h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.confirm-box p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }

/* ---- 通用按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; border-color: transparent; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-outline { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-danger:hover { opacity: 0.9; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---- 表单 ---- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,99,255,0.15); }
.form-group textarea { resize: vertical; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.required { color: var(--secondary); }
.save-tip { font-size: 13px; color: var(--success); margin-left: 12px; }

/* ---- 响应式 ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .main-content { margin-left: 0; }
  .topbar-menu { display: block; }
  .dashboard-row { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .panel-content { padding: 16px; }
}

/* ---- 图片上传组件 ---- */
.upload-area {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
/* 让 file input 覆盖整个上传区域，用户点区域直接触发文件选择 */
.upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
}
.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--primary);
  background: rgba(108,99,255,0.06);
}
.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}
.upload-icon { font-size: 36px; line-height: 1; }
.upload-placeholder p { font-size: 14px; color: var(--text-muted); margin: 0; }
.upload-placeholder span { font-size: 12px; color: var(--text-dim); }
.upload-preview {
  position: relative;
  width: 100%;
  max-height: 200px;
  overflow: hidden;
  border-radius: calc(var(--radius) - 2px);
}
.upload-preview.wide {
  max-height: 260px;
}
.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: calc(var(--radius) - 2px);
}
.upload-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 2;
}
.upload-remove:hover { background: var(--danger); }
.btn-sm { padding: 7px 16px; font-size: 13px; }
.upload-trigger { display: inline-flex; }
.upload-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  transition: width 0.3s ease;
  border-radius: 0 0 0 var(--radius);
}
.hero-upload-area {
  min-height: 180px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

/* ---- 头像上传 ---- */
.avatar-upload {
  cursor: pointer;
  border-radius: 50% !important;
  overflow: hidden;
}
.avatar-upload .upload-placeholder {
  padding: 12px !important;
}

/* ---- 图集上传 ---- */
.gallery-upload-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 100px;
}
.gallery-list {
  display: contents;
}
.gallery-item {
  position: relative;
  width: 100px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: grab;
  flex-shrink: 0;
  transition: var(--transition);
}
.gallery-item:hover {
  border-color: var(--primary);
  transform: scale(1.03);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.gallery-item .gallery-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
  z-index: 2;
}
.gallery-item:hover .gallery-remove {
  opacity: 1;
}
.gallery-item .gallery-cover-tag {
  position: absolute;
  bottom: 3px;
  left: 3px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  pointer-events: none;
}
.gallery-add-area {
  cursor: pointer;
  border-style: dashed !important;
}
.gallery-add-area:hover {
  border-color: var(--primary) !important;
}
