/* ========================================
   AI工具集 - 自定义样式
   ======================================== */

/* ---------- CSS变量 ---------- */
:root {
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --accent: #f472b6;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border-color: #334155;
  --gradient-start: #6366f1;
  --gradient-end: #a855f7;
  --sidebar-bg: #1e293b;
  --tag-bg: #1e1b4b;
  --tag-text: #a5b4fc;
}

[data-theme="light"] {
  --bg-dark: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --sidebar-bg: #ffffff;
  --tag-bg: #eef2ff;
  --tag-text: #4f46e5;
}

/* ---------- 页面加载动画 ---------- */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader {
  width: 48px;
  height: 48px;
  border: 4px solid var(--primary);
  border-bottom-color: transparent;
  border-radius: 50%;
  animation: rotation 1s linear infinite;
}

@keyframes rotation {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loader-text {
  color: var(--text-primary);
  margin-top: 16px;
  font-size: 14px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ---------- Hero区 ---------- */
.hero-gradient {
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 50%, #1a1a2e 100%);
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .hero-gradient {
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 50%, #faf5ff 100%);
}

.hero-gradient::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 50%);
  animation: heroGlow 8s ease-in-out infinite;
}

@keyframes heroGlow {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(5%, 5%); }
}

/* ---------- 分类Tab ---------- */
.category-tab {
  transition: all 0.3s ease;
  white-space: nowrap;
}

.category-tab.active {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.category-tab:not(.active):hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ---------- 工具卡片 ---------- */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tool-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border-color: var(--primary);
}

.tool-card:hover::before {
  opacity: 1;
}

[data-theme="light"] .tool-card:hover {
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.15);
}

.tool-card .tool-icon {
  font-size: 2.5rem;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
  border-radius: 16px;
  flex-shrink: 0;
}

[data-theme="light"] .tool-card .tool-icon {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(168, 85, 247, 0.05));
}

/* ---------- 标签 ---------- */
.tool-tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  transition: all 0.2s ease;
}

.tool-tag:hover {
  background: var(--primary);
  color: white;
}

/* ---------- 收藏按钮 ---------- */
.fav-btn {
  transition: all 0.3s ease;
}

.fav-btn.active {
  color: #f472b6;
}

.fav-btn:hover {
  transform: scale(1.2);
}

/* ---------- 访问按钮 ---------- */
.visit-btn {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  transition: all 0.3s ease;
}

.visit-btn:hover {
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

/* ---------- 侧边栏 ---------- */
.sidebar-widget {
  background: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
}

.hot-rank-item {
  transition: all 0.2s ease;
  border-radius: 8px;
  padding: 8px 12px;
}

.hot-rank-item:hover {
  background: var(--bg-card-hover);
}

.rank-badge {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.rank-1 { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }
.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: white; }
.rank-3 { background: linear-gradient(135deg, #c2855a, #a16207); color: white; }
.rank-default { background: var(--bg-card-hover); color: var(--text-secondary); }

/* ---------- 广告位 ---------- */
.ad-placeholder {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(168, 85, 247, 0.05));
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 13px;
  min-height: 100px;
}

[data-theme="light"] .ad-placeholder {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.03), rgba(168, 85, 247, 0.03));
}

/* ---------- 搜索框 ---------- */
.search-input {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-secondary);
}

/* ---------- 回到顶部 ---------- */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 100;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-3px);
}

/* ---------- 主题切换按钮 ---------- */
.theme-toggle {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

/* ---------- 页脚 ---------- */
footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

footer a {
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--primary);
}

/* ---------- 卡片入场动画 ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-card {
  animation: fadeInUp 0.4s ease forwards;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .hero-gradient {
    text-align: center;
  }
  
  .category-tabs-scroll {
    -webkit-overflow-scrolling: touch;
  }

  .tool-card:hover {
    transform: translateY(-3px);
  }
}

/* ---------- 标签过滤条 ---------- */
.tag-filter-btn {
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tag-filter-btn:hover,
.tag-filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ---------- 统计数字动画 ---------- */
.stat-number {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- 评分徽章 ---------- */
.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.rating-badge .star {
  font-size: 13px;
}

/* ---------- 定价徽章 ---------- */
.pricing-badge {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 9999px;
  font-weight: 500;
}

.pricing-badge.free {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.pricing-badge.paid {
  background: rgba(244, 114, 182, 0.1);
  color: #f472b6;
  border: 1px solid rgba(244, 114, 182, 0.2);
}

/* ---------- AI热点卡片 ---------- */
.news-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: all 0.25s ease;
  text-decoration: none;
}

.news-card:hover {
  border-color: rgba(239, 68, 68, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.news-rank {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}
