/* ═══════════════════════════════════════════════
   AI Trend Radar · 全局样式
   ═══════════════════════════════════════════════ */

:root {
  --bg:        #080d18;
  --bg2:       #0c1220;
  --bg3:       #101828;
  --card:      #131e30;
  --card2:     #182236;
  --card-hover:#1c2840;
  --border:    #1e2d45;
  --border2:   #2a3f5f;
  --border3:   #3a5278;

  --accent:    #4f8ef7;
  --accent-h:  #6aa0f8;
  --accent2:   #7c6af7;
  --green:     #3dd68c;
  --green-h:   #50e09a;
  --orange:    #f59e3a;
  --red:       #f0536a;
  --yellow:    #f5d03a;
  --purple:    #b06af7;
  --cyan:      #3ad6d6;

  --text:      #e2eaf8;
  --text2:     #8fa3c0;
  --text3:     #4e6280;
  --text4:     #2e3e55;

  --font:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:      'JetBrains Mono', 'Fira Code', monospace;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.3);

  --sidebar-w: 240px;
  --header-h:  60px;
  --transition: 0.18s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--font); cursor: pointer; border: none; outline: none; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: var(--font); }

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border3); }

/* ════════════════════════════════
   布局：侧边栏 + 主内容
════════════════════════════════ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── 侧边栏 ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 3px; }

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.logo-text h1 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.logo-text span {
  font-size: 10px;
  color: var(--text3);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.nav-group {
  margin-bottom: 6px;
}
.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.1px;
  padding: 10px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}
.nav-item:hover {
  background: var(--card);
  color: var(--text);
}
.nav-item.active {
  background: rgba(79,142,247,0.12);
  color: var(--accent);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(79,142,247,0.18);
  color: var(--accent);
}
.nav-badge.green { background: rgba(61,214,140,0.15); color: var(--green); }
.nav-badge.hot   { background: rgba(240,83,106,0.15); color: var(--red); }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-footer .status-dot {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text3);
}
.status-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── 主内容区 ── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* 让整页在 main-wrap 内滚动，footer 不会被 page-content 局部滚动截断 */
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── 顶部导航栏 ── */
.topbar {
  height: var(--header-h);
  background: rgba(8,13,24,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.topbar-subtitle {
  font-size: 12px;
  color: var(--text3);
  margin-left: 4px;
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  margin: 0 auto;
  position: relative;
}
.topbar-search input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 16px 7px 36px;
  font-size: 13px;
  color: var(--text);
  transition: border-color var(--transition);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--accent);
}
.topbar-search input::placeholder { color: var(--text3); }
.topbar-search i {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.topbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
}
.topbar-btn.primary {
  background: var(--accent);
  color: white;
}
.topbar-btn.primary:hover {
  background: var(--accent-h);
  transform: translateY(-1px);
}
.topbar-btn.ghost {
  background: var(--card);
  color: var(--text2);
  border: 1px solid var(--border);
}
.topbar-btn.ghost:hover {
  color: var(--text);
  border-color: var(--border2);
}
.refresh-icon { transition: transform 0.6s ease; }
.refreshing .refresh-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 页面主体 ── */
.page-content {
  flex: 1;
  padding: 28px 28px 40px;
  overflow-y: visible;
}

/* ════════════════════════════════
   通用组件
════════════════════════════════ */

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), transform var(--transition);
}
.card:hover {
  border-color: var(--border2);
}
.card-elevated {
  box-shadow: var(--shadow);
}

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-blue   { background: rgba(79,142,247,0.15);  color: var(--accent);  border: 1px solid rgba(79,142,247,0.25); }
.tag-green  { background: rgba(61,214,140,0.15);  color: var(--green);   border: 1px solid rgba(61,214,140,0.25); }
.tag-orange { background: rgba(245,158,58,0.15);  color: var(--orange);  border: 1px solid rgba(245,158,58,0.25); }
.tag-red    { background: rgba(240,83,106,0.15);  color: var(--red);     border: 1px solid rgba(240,83,106,0.25); }
.tag-purple { background: rgba(176,106,247,0.15); color: var(--purple);  border: 1px solid rgba(176,106,247,0.25); }
.tag-gray   { background: rgba(78,98,128,0.2);    color: var(--text2);   border: 1px solid rgba(78,98,128,0.3); }
.tag-cyan   { background: rgba(58,214,214,0.12);  color: var(--cyan);    border: 1px solid rgba(58,214,214,0.25); }

/* 源标志 */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}
.source-hn     { background: rgba(255,102,0,0.12); color: #ff6600; }
.source-github { background: rgba(100,180,100,0.12); color: #6cc665; }
.source-reddit { background: rgba(255,69,0,0.12); color: #ff4500; }
.source-devto  { background: rgba(60,130,246,0.12); color: #5b8fd9; }
.source-ph     { background: rgba(218,90,40,0.12); color: #da5a28; }

/* 分数徽章 */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}
.score-high   { background: rgba(61,214,140,0.15);  color: var(--green);  border: 1px solid rgba(61,214,140,0.3); }
.score-mid    { background: rgba(245,158,58,0.15);  color: var(--orange); border: 1px solid rgba(245,158,58,0.3); }
.score-low    { background: rgba(78,98,128,0.2);    color: var(--text2);  border: 1px solid rgba(78,98,128,0.3); }

/* 增长率 */
.growth {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
}
.growth.up   { color: var(--green); }
.growth.down { color: var(--red); }
.growth.flat { color: var(--text3); }

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--card) 25%, var(--card2) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text3);
  text-align: center;
  gap: 12px;
}
.empty-state i { font-size: 36px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* 加载动画 */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Toast 通知 */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--card2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
  pointer-events: auto;
  min-width: 240px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* 分割线 */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ════════════════════════════════
   页面级布局
════════════════════════════════ */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-left h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.page-header-left p {
  font-size: 13px;
  color: var(--text3);
}
.page-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 统计栏 */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border2); }
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(79,142,247,0.12); color: var(--accent); }
.stat-icon.green  { background: rgba(61,214,140,0.12); color: var(--green); }
.stat-icon.orange { background: rgba(245,158,58,0.12); color: var(--orange); }
.stat-icon.purple { background: rgba(176,106,247,0.12); color: var(--purple); }
.stat-icon.red    { background: rgba(240,83,106,0.12); color: var(--red); }
.stat-info {}
.stat-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 3px;
}
.stat-label {
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
}

/* 双栏布局 */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* 筛选栏 */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover, .filter-btn.active {
  background: rgba(79,142,247,0.12);
  border-color: rgba(79,142,247,0.3);
  color: var(--accent);
}
.filter-select {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  appearance: none;
}

/* ════════════════════════════════
   趋势条目卡片
════════════════════════════════ */
.trend-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.trend-item:hover {
  border-color: var(--border2);
  background: var(--card-hover);
  transform: translateX(3px);
}
.trend-rank {
  font-size: 13px;
  font-weight: 800;
  color: var(--text3);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
  padding-top: 2px;
}
.trend-rank.top { color: var(--orange); }
.trend-body { flex: 1; min-width: 0; }
.trend-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.trend-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.trend-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text3);
}
.trend-stat i { font-size: 10px; }
.trend-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

/* ════════════════════════════════
   进度条
════════════════════════════════ */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.8s ease;
}
.progress-fill.blue   { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.progress-fill.green  { background: linear-gradient(90deg, var(--green), var(--cyan)); }
.progress-fill.orange { background: linear-gradient(90deg, var(--orange), var(--yellow)); }
.progress-fill.red    { background: linear-gradient(90deg, var(--red), var(--orange)); }

/* ════════════════════════════════
   响应式
════════════════════════════════ */
@media (max-width: 1100px) {
  :root { --sidebar-w: 200px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .three-col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .page-content { padding: 18px 16px 32px; }
  .topbar { padding: 0 16px; }
  .topbar-search { display: none; }
}
