/* ============================================
   现代化后台管理系统样式
   ============================================ */

/* CSS 变量 - 浅色主题 */
:root {
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-light: #DBEAFE;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;

  --bg-primary: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --bg-tertiary: #F3F4F6;

  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;

  --border-color: #E5E7EB;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --sidebar-width: 260px;
  --header-height: 64px;
}

/* CSS 变量 - 深色主题 */
[data-theme='dark'] {
  --bg-primary: #1F2937;
  --bg-secondary: #111827;
  --bg-tertiary: #374151;

  --text-primary: #F9FAFB;
  --text-secondary: #D1D5DB;
  --text-tertiary: #9CA3AF;

  --border-color: #374151;
}

/* 基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   后台布局
   ============================================ */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 100;
}

.admin-sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.admin-sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-sidebar-nav {
  flex: 1;
  padding: 1.5rem 0.75rem;
  overflow-y: auto;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
}

.admin-nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.admin-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.admin-nav-item svg {
  width: 20px;
  height: 20px;
}

.admin-sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

/* 主内容区 */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

/* 顶部导航栏 */
.admin-header {
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-header-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-header-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.admin-header-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.admin-header-btn svg {
  width: 18px;
  height: 18px;
}

/* 内容区域 */
.admin-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

/* ============================================
   通用组件
   ============================================ */

/* 卡片 */
.admin-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: box-shadow 0.2s ease;
}

.admin-card:hover {
  box-shadow: var(--shadow);
}

/* 按钮 */
.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.admin-btn-primary {
  background: var(--primary);
  color: white;
}

.admin-btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.admin-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.admin-btn-danger {
  background: var(--danger);
  color: white;
}

.admin-btn-danger:hover {
  background: #DC2626;
}

.admin-btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.admin-btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.admin-btn svg {
  width: 16px;
  height: 16px;
}

/* 输入框 */
.admin-input {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: all 0.2s ease;
}

.admin-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.admin-input::placeholder {
  color: var(--text-tertiary);
}

/* 标签 */
.admin-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.admin-tag-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.admin-tag-success {
  background: #D1FAE5;
  color: #059669;
}

.admin-tag-warning {
  background: #FEF3C7;
  color: #D97706;
}

.admin-tag-danger {
  background: #FEE2E2;
  color: #DC2626;
}

/* 表格 */
.admin-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

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

.admin-table thead {
  background: var(--bg-tertiary);
}

.admin-table th,
.admin-table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.admin-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table tbody tr {
  transition: background 0.2s ease;
}

.admin-table tbody tr:hover {
  background: var(--bg-secondary);
}

/* ============================================
   仪表盘
   ============================================ */

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: box-shadow 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.blue {
  background: var(--primary-light);
  color: var(--primary);
}

.stat-icon.green {
  background: #D1FAE5;
  color: #059669;
}

.stat-icon.yellow {
  background: #FEF3C7;
  color: #D97706;
}

.stat-icon.red {
  background: #FEE2E2;
  color: #DC2626;
}

.stat-content {
  flex: 1;
  padding-left: 1rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

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

.stat-change {
  font-size: 0.8125rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-change.positive {
  color: var(--success);
}

.stat-change.negative {
  color: var(--danger);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

/* 图表容器 */
.chart-container {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  min-height: 300px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* 活动列表 */
.activity-list {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* ============================================
   响应式设计
   ============================================ */

/* 移动端菜单按钮 */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

/* 遮罩层 */
.admin-sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

/* 平板 */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* 手机 */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

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

  .admin-sidebar.open {
    transform: translateX(0);
    --sidebar-width: 260px;
  }

  .admin-sidebar-overlay.show {
    display: block;
  }

  .admin-main {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: block;
  }

  .admin-header {
    padding: 0 1rem;
  }

  .admin-content {
    padding: 1rem;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   动画效果
   ============================================ */

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

.admin-card {
  animation: fadeIn 0.3s ease;
}

/* ============================================
   Toast 通知
   ============================================ */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

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

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-icon {
  font-size: 1.25rem;
}

.toast-message {
  font-size: 0.875rem;
  color: var(--text-primary);
}
