/* ============ CSS Variables & Theme ============ */
:root {
  --bg-primary: #0f0f12;
  --bg-secondary: #1a1a24;
  --bg-card: #1e1e2e;
  --bg-hover: #2a2a3a;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-muted: #6a6a80;
  --accent: #6c5ce7;
  --accent-hover: #7c6df7;
  --accent-light: rgba(108,92,231,0.15);
  --border: #2a2a3a;
  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #e17055;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

[data-theme="light"] {
  --bg-primary: #f5f5fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f0f0f5;
  --text-primary: #1a1a2e;
  --text-secondary: #5a5a7a;
  --text-muted: #8a8aa0;
  --border: #e0e0ea;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

/* ============ Reset & Base ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; }
input, textarea, select, button { font-family: inherit; }

/* ============ Layout ============ */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ============ Header ============ */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}
.logo svg { width: 28px; height: 28px; color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: color var(--transition);
}
.nav-links a:hover, .nav-links a.active { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* Theme toggle */
.theme-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--accent-light); color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; transform: translateY(-1px); }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ Cards ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.card-body { padding: 20px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* Resource card */
.resource-card .card-icon {
  height: 140px;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.resource-card .card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.resource-card .card-icon svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}
.resource-card .card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.resource-card .card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
  min-height: 40px;
}
.resource-card .card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.resource-card .card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.resource-card .card-meta svg { width: 14px; height: 14px; }

/* ============ Tags ============ */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--accent-light);
  color: var(--accent);
}
.tag-software { background: rgba(108,92,231,0.15); color: #6c5ce7; }
.tag-game { background: rgba(0,184,148,0.15); color: #00b894; }
.tag-resource { background: rgba(253,203,110,0.15); color: #e17055; }
.tag-tool { background: rgba(116,185,255,0.15); color: #74b9ff; }
.tag-pending { background: rgba(253,203,110,0.15); color: #e17055; }
.tag-approved { background: rgba(0,184,148,0.15); color: #00b894; }
.tag-rejected { background: rgba(225,112,85,0.15); color: #e17055; }

/* ============ Forms ============ */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition);
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
}
.form-textarea { resize: vertical; min-height: 120px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236a6a80' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ============ Auth Pages ============ */
.auth-container {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
}
.auth-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}
.auth-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}
.auth-card .form-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============ Section ============ */
.section { padding: 60px 0; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.section-title {
  font-size: 22px;
  font-weight: 700;
}

/* ============ Hero ============ */
.hero {
  padding: 80px 0 60px;
  text-align: center;
}
.hero h1 {
  font-size: 42px;
  font-weight: 800;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 32px;
}
.search-bar {
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  overflow: hidden;
  transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  flex: 1;
  padding: 14px 24px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
}
.search-bar button {
  padding: 14px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
}
.search-bar button:hover { background: var(--accent-hover); }
.search-bar button svg { width: 16px; height: 16px; }

/* ============ Category Tabs ============ */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.category-tab {
  padding: 8px 20px;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.category-tab:hover { border-color: var(--accent); color: var(--accent); }
.category-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============ Detail Page ============ */
.detail-header {
  display: flex;
  gap: 32px;
  margin-bottom: 40px;
}
.detail-icon {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  background: var(--bg-hover);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.detail-icon img { width: 100%; height: 100%; object-fit: cover; }
.detail-icon svg { width: 48px; height: 48px; color: var(--text-muted); }
.detail-info { flex: 1; }
.detail-info h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}
.detail-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-meta svg { width: 16px; height: 16px; }
.detail-actions { display: flex; gap: 12px; margin-top: 20px; }

/* ============ Comments ============ */
.comment-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.comment-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.comment-user { font-weight: 600; font-size: 14px; }
.comment-time { font-size: 12px; color: var(--text-muted); }
.comment-content { font-size: 14px; color: var(--text-secondary); line-height: 1.7; }
.comment-form { margin-top: 20px; }

/* ============ Pagination ============ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 40px;
}
.pagination button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ Admin Layout ============ */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}
.admin-sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  flex-shrink: 0;
}
.admin-sidebar a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: all var(--transition);
}
.admin-sidebar a:hover { background: var(--bg-hover); color: var(--text-primary); }
.admin-sidebar a.active { background: var(--accent-light); color: var(--accent); border-right: 3px solid var(--accent); }
.admin-sidebar a svg { width: 18px; height: 18px; }
.admin-content { flex: 1; padding: 32px; overflow-x: auto; }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.stat-card .stat-icon svg { width: 20px; height: 20px; }

/* Table */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.table th {
  background: var(--bg-hover);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-hover); }

/* ============ Empty State ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state p { font-size: 14px; }

/* ============ Footer ============ */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 60px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============ Mobile Menu Backdrop ============ */
.mobile-menu-backdrop {
  display: none;
}

/* ============ Mobile ============ */
.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}
.mobile-menu-btn svg { width: 24px; height: 24px; }

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    gap: 0;
    z-index: 98;
    overflow-y: auto;
    border-top: 1px solid var(--border);
  }
  .nav-links.show { display: flex; }
  .nav-links a {
    display: block;
    width: 100%;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    color: var(--text-primary);
  }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .hero { padding: 40px 0 30px; }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 15px; }
  .search-bar { max-width: 100%; }
  .card-grid { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .sort-bar { flex-wrap: wrap; width: 100%; gap: 8px; }
  .sort-bar select { margin-left: auto; }
  .detail-header { flex-direction: column; align-items: center; text-align: center; }
  .detail-actions { justify-content: center; }
  .admin-sidebar {
    position: fixed;
    left: -240px;
    top: 64px;
    bottom: 0;
    z-index: 99;
    transition: left var(--transition);
  }
  .admin-sidebar.open { left: 0; }
  .admin-content { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .header-inner { padding: 0 16px; }
  .mobile-menu-backdrop.show {
    display: block;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 97;
  }
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 80px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  z-index: 999;
  transform: translateX(120%);
  transition: transform 0.3s ease;
}
.toast.show { transform: translateX(0); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ============ Loading ============ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Sort bar */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.sort-bar select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
}
