/* ============================================
   内容管理后台 — 全局样式
   ============================================ */

:root {
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 64px;
  --sidebar-bg: #1e1e2d;
  --sidebar-hover-bg: #27273a;
  --sidebar-active-bg: rgba(51, 112, 255, 0.12);
  --sidebar-text: #9899ac;
  --sidebar-text-active: #ffffff;
  --header-height: 56px;
  --primary: #3370ff;
  --primary-light: rgba(51, 112, 255, 0.1);
  --primary-dark: #2b5fd9;
  --success: #00b578;
  --success-light: rgba(0, 181, 120, 0.1);
  --warning: #ff8f1f;
  --warning-light: rgba(255, 143, 31, 0.1);
  --danger: #ff3141;
  --danger-light: rgba(255, 49, 65, 0.1);
  --info: #909399;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --border-light: #f0f0f0;
  --bg-page: #f5f6fa;
  --bg-white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-sm: 4px;
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body, #app {
  height: 100%;
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* ============================================
   App Shell
   ============================================ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   Sidebar
   ============================================ */
.app-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  overflow: hidden;
  z-index: 100;
}

.app-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}

.sidebar-logo {
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo .logo-icon {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  margin-right: 10px;
}

.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.app-sidebar.collapsed .sidebar-logo { padding: 0 18px; }
.app-sidebar.collapsed .logo-text { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 20px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
  font-size: 14px;
  user-select: none;
}

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

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

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
  font-size: 18px;
}

.nav-item .nav-label {
  overflow: hidden;
}

.app-sidebar.collapsed .nav-item { padding: 0 22px; }
.app-sidebar.collapsed .nav-label { display: none; }

/* ============================================
   Main Area
   ============================================ */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ============================================
   Header
   ============================================ */
.app-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 99;
}

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

.header-toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 18px;
  transition: var(--transition);
}

.header-toggle:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

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

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.header-user:hover { background: var(--bg-page); }

.header-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

/* ============================================
   Content Area
   ============================================ */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { }

/* ============================================
   Stats Cards
   ============================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card .stat-delta {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }
.stat-delta.flat { color: var(--text-muted); }

/* ============================================
   Filters Bar
   ============================================ */
.filters-bar {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.filters-row .el-input,
.filters-row .el-select,
.filters-row .el-date-picker {
  max-width: 200px;
}

.filters-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Quick filter chips */
.quick-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.quick-filter-chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
}

.quick-filter-chip:hover,
.quick-filter-chip.active {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ============================================
   Tables
   ============================================ */
.data-table-wrapper {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.data-table-wrapper .el-table {
  --el-table-border-color: var(--border-light);
}

.data-table-wrapper .el-table th.el-table__cell {
  background: #fafbfc;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
  height: 44px;
  border-bottom: 2px solid var(--border-color);
}

.data-table-wrapper .el-table .el-table__row:hover > td {
  background: #f8f9ff;
}

.data-table-wrapper .el-table .el-table__row--striped td {
  background: #fafbfc;
}

/* Action links */
.action-links {
  display: flex;
  gap: 12px;
}

.action-links .action-link {
  font-size: 13px;
  cursor: pointer;
  color: var(--primary);
  transition: var(--transition);
  white-space: nowrap;
}

.action-links .action-link:hover { color: var(--primary-dark); }
.action-links .action-link.danger { color: var(--danger); }
.action-links .action-link.danger:hover { color: #d42a36; }
.action-links .action-link.warning { color: var(--warning); }
.action-links .action-link.warning:hover { color: #e67e1a; }

/* ============================================
   Status Badges
   ============================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.success {
  background: var(--success-light);
  color: var(--success);
}

.status-badge.warning {
  background: var(--warning-light);
  color: var(--warning);
}

.status-badge.danger {
  background: var(--danger-light);
  color: var(--danger);
}

.status-badge.info {
  background: rgba(144, 147, 153, 0.1);
  color: var(--info);
}

.status-badge.primary {
  background: var(--primary-light);
  color: var(--primary);
}

/* ============================================
   Hot Score Colors
   ============================================ */
.hot-score { font-weight: 600; }
.hot-score.high { color: var(--danger); }
.hot-score.medium { color: var(--warning); }
.hot-score.low { color: var(--text-muted); }

/* ============================================
   Metric Cards (Post Detail)
   ============================================ */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  background: #fafbfc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-card .metric-label {
  font-size: 12px;
  color: var(--text-muted);
}

.metric-card .metric-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================
   Tags / Chips
   ============================================ */
.tag-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary);
  margin-right: 6px;
  margin-bottom: 4px;
  gap: 4px;
}

.tag-chip .chip-close {
  cursor: pointer;
  font-size: 14px;
  opacity: 0.6;
}

.tag-chip .chip-close:hover { opacity: 1; }

/* ============================================
   Pagination
   ============================================ */
.pagination-wrap {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px;
  background: var(--bg-white);
  border-top: 1px solid var(--border-light);
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
}

.login-card {
  width: 400px;
  background: var(--bg-white);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  padding: 40px;
}

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

.login-card .login-logo {
  width: 48px;
  height: 48px;
  background: var(--primary);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  margin-bottom: 16px;
}

.login-card .login-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.login-card .login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ============================================
   Post Content Preview
   ============================================ */
.content-preview {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 13px;
}

.cover-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: #f0f0f0;
}

.author-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.author-cell .author-name {
  font-weight: 500;
  font-size: 13px;
}

.author-cell .author-school {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================
   Post Detail
   ============================================ */
.post-detail-content {
  max-width: 900px;
  margin: 0 auto;
}

.post-detail-content .el-image {
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.post-detail-content .el-image:hover { opacity: 0.9; }

.chart-container {
  width: 100%;
  height: 300px;
}

/* ============================================
   Image Gallery
   ============================================ */
.image-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.image-gallery .gallery-item {
  width: 120px;
  height: 120px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}

.image-gallery .gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

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

/* ============================================
   Empty States
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state .empty-text {
  font-size: 14px;
}

/* ============================================
   Back Button
   ============================================ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 16px;
  transition: var(--transition);
}

.back-link:hover { color: var(--primary); }

/* ============================================
   Utility
   ============================================ */
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-12 { margin-top: 12px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono { font-family: "SF Mono", "Monaco", "Menlo", monospace; font-size: 12px; }

/* ============================================
   Element Plus Overrides
   ============================================ */
.el-button--primary {
  --el-button-bg-color: var(--primary);
  --el-button-border-color: var(--primary);
  --el-button-hover-bg-color: var(--primary-dark);
  --el-button-hover-border-color: var(--primary-dark);
}

.el-pagination.is-background .el-pager li.is-active {
  background-color: var(--primary);
}

.el-menu {
  border-right: none !important;
}

.el-breadcrumb__inner {
  font-size: 14px;
}

/* Compact table for data-heavy pages */
.el-table--compact .el-table__cell { padding: 8px 0; }

/* Dialog */
.el-dialog__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.el-dialog__body { padding: 20px; }

.el-dialog__footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
}

/* Message box */
.el-message-box__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

/* Input/Select compact */
.el-input--small .el-input__wrapper { font-size: 13px; }

/* Tabs */
.el-tabs__nav-wrap::after { height: 1px; }

/* Badge dot */
.el-badge__content { border: none; }

/* Responsive */
@media (max-width: 1280px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
  }
  .app-sidebar.collapsed { left: calc(-1 * var(--sidebar-width)); }
  .stats-row { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: 1fr; }
  .filters-row .el-input,
  .filters-row .el-select { max-width: 100%; flex: 1; }
}

/* ======================== Algorithm page ======================== */
.algo-page .expand-detail { padding: 12px 20px; background: #fafbfc; font-size: 13px; }
.algo-page .expand-detail .detail-row { margin-bottom: 6px; }
.algo-page .expand-detail .detail-label { color: #909399; margin-right: 4px; }
.algo-page .expand-detail .detail-code { background: #f0f2f5; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.algo-page .algo-locked { background: #3370ff; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.algo-page .algo-hot { background: #fef0f0; color: #f56c6c; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.algo-page .algo-rising { background: #fdf6ec; color: #e6a23c; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.algo-page .algo-normal { color: #909399; font-size: 12px; }
.algo-page .algo-config-bar { margin-top: 16px; padding: 12px 16px; background: #fafbfc; border-radius: 8px; border: 1px solid #ebeef5; }
.algo-page .el-table .algo-row-locked { background: #f0f5ff; }
