/* ===== 主题变量 ===== */
:root {
  --primary: #e63946;
  --primary-dark: #c1121f;
  --radius: 10px;
  --font: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --transition-theme: background 0.25s, color 0.25s, border-color 0.25s;
}

/* 深色主题（默认） */
[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-header: #111;
  --bg-card: #1a1a1a;
  --bg-hover: #252525;
  --text: #f0f0f0;
  --text-muted: #888;
  --border: #2a2a2a;
  --shadow: rgba(0,0,0,0.4);
  --placeholder-grad: linear-gradient(135deg, #1a1a2e, #16213e);
}

/* 浅色主题 */
[data-theme="light"] {
  --bg: #f5f5f5;
  --bg-header: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f0f0f0;
  --text: #1a1a1a;
  --text-muted: #888;
  --border: #e0e0e0;
  --shadow: rgba(0,0,0,0.1);
  --placeholder-grad: linear-gradient(135deg, #e8eaf6, #e3f2fd);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  transition: var(--transition-theme);
}

/* ===== 主题切换按钮 ===== */
.theme-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px;
}
.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1;
  transition: background 0.2s;
  color: var(--text-muted);
}
.theme-btn.active {
  background: var(--primary);
}
.theme-btn:hover:not(.active) { background: var(--bg-hover); }

.container { max-width: 1400px; margin: 0 auto; padding: 0 16px; }

/* Header */
.header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header .container {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  overflow: hidden;
}

.logo { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.logo-icon { font-size: 24px; }
.logo-text { font-size: 20px; font-weight: 700; color: var(--primary); }
.logo-sub { font-size: 12px; color: var(--text-muted); }

.nav-cats {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.nav-cats::-webkit-scrollbar { display: none; }

.cat-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.2s;
}
.cat-btn:hover { border-color: var(--primary); color: var(--text); }
.cat-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.sort-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}
.sort-btn:hover { color: var(--text); }
.sort-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.admin-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.2s;
}
.admin-link:hover { color: var(--primary); border-color: var(--primary); }

/* Main */
.main { padding: 20px 16px; }

/* Featured */
.featured-section { position: relative; margin-bottom: 24px; border-radius: var(--radius); overflow: hidden; }
.featured-slider { position: relative; height: 320px; }
.featured-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); background: var(--bg-card); border-radius: var(--radius); }

.featured-item {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
}
.featured-item.active { display: block; }
.featured-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
}
.featured-item:hover img { transform: scale(1.03); }
.featured-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  padding: 40px 20px 16px;
}
.featured-tag {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.featured-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.featured-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px;
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all 0.2s;
}
.dot.active { background: var(--primary); width: 18px; border-radius: 3px; }

/* Layout */
.content-layout { display: grid; grid-template-columns: 1fr 280px; gap: 24px; }
@media (max-width: 1024px) { .content-layout { grid-template-columns: 1fr; } }

/* Section */
.section { margin-bottom: 28px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.section-header h2 { font-size: 16px; font-weight: 600; }
.total-count { font-size: 12px; color: var(--text-muted); }

/* Hot Grid */
.hot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* Video Grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* Video Card */
.video-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border);
}
.video-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--shadow);
  border-color: var(--primary);
}

.card-thumb {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #222;
}
.card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.video-card:hover .card-thumb img { transform: scale(1.05); }
.card-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: var(--placeholder-grad);
}
.play-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px;
  background: rgba(230,57,70,0.85);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.2s;
}
.video-card:hover .play-icon { opacity: 1; }

.card-source-badge {
  position: absolute;
  top: 6px; left: 6px;
  background: rgba(0,0,0,0.7);
  color: var(--text-muted);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.card-body { padding: 10px; }
.card-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 6px;
}
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}
.card-views { color: #ff6b6b; }

/* Ranking */
.cat-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition-theme);
}

.ranking-list { list-style: none; }
.ranking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}
.ranking-item:hover { background: var(--bg-hover); margin: 0 -8px; padding: 10px 8px; }
.rank-num {
  font-size: 16px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
  color: var(--text-muted);
}
.ranking-item:nth-child(1) .rank-num { color: #ffd700; }
.ranking-item:nth-child(2) .rank-num { color: #c0c0c0; }
.ranking-item:nth-child(3) .rank-num { color: #cd7f32; }
.rank-thumb {
  width: 60px; height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: #222;
  flex-shrink: 0;
}
.rank-info { flex: 1; min-width: 0; }
.rank-title {
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.rank-views { font-size: 11px; color: var(--primary); }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
}
.page-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Loading */
.loading-placeholder { color: var(--text-muted); padding: 40px; text-align: center; width: 100%; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.footer .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

/* Responsive */
@media (max-width: 768px) {
  .featured-slider { height: 200px; }
  .featured-title { font-size: 14px; }
  .hot-grid { grid-template-columns: repeat(2, 1fr); }
  .video-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
@media (max-width: 480px) {
  .video-grid { grid-template-columns: 1fr; }
  .hot-grid { grid-template-columns: 1fr; }
}
