/* ===== CSS Variables ===== */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --accent: #ec4899;
  --accent-dark: #db2777;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --text: #1e293b;
  --text-light: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --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 -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 1200px;
  --gradient: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  --gradient-text: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
}

[data-theme="dark"] {
  --primary: #818cf8;
  --primary-dark: #6366f1;
  --primary-light: #a5b4fc;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text: #f1f5f9;
  --text-light: #cbd5e1;
  --text-muted: #64748b;
  --border: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.85);
  transition: all 0.3s;
}

[data-theme="dark"] .header {
  background: rgba(15,23,42,0.85);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 800;
}

.logo-icon {
  font-size: 28px;
}

.logo-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav a {
  color: var(--text-light);
  font-size: 15px;
  font-weight: 500;
  transition: color 0.2s;
}

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

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  color: var(--text);
}

.theme-toggle:hover {
  background: var(--bg-hover);
}

/* ===== Hero ===== */
.hero {
  padding: 80px 0 60px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(99,102,241,0.1) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(236,72,153,0.1) 0%, transparent 50%);
  z-index: -1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.hero-badge .dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.hero h1 {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

.hero h1 .gradient {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: clamp(16px, 2vw, 20px);
  color: var(--text-light);
  max-width: 600px;
  margin: 0 auto 36px;
}

/* ===== Search ===== */
.search-wrap {
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 16px 20px 16px 52px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 100px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: all 0.3s;
  box-shadow: var(--shadow);
}

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

.search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
}

.stat-num {
  font-size: 28px;
  font-weight: 800;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Categories ===== */
.section {
  padding: 60px 0;
}

.section-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.section-desc {
  color: var(--text-light);
  font-size: 15px;
  margin-bottom: 32px;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 40px;
}

.cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
}

.cat-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.cat-btn.active {
  background: var(--gradient);
  border-color: transparent;
  color: white;
}

.cat-btn .cat-count {
  background: rgba(0,0,0,0.08);
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 12px;
}

.cat-btn.active .cat-count {
  background: rgba(255,255,255,0.25);
}

/* ===== Tool Cards ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tool-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

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

.tool-card.featured {
  border-color: var(--primary-light);
}

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

.tool-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tool-icon {
  font-size: 36px;
  line-height: 1;
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.tool-badge.free {
  background: rgba(16,185,129,0.1);
  color: #10b981;
}

.tool-badge.paid {
  background: rgba(245,158,11,0.1);
  color: #f59e0b;
}

.tool-badge.featured {
  background: rgba(99,102,241,0.1);
  color: var(--primary);
}

.tool-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.tool-desc {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 16px;
  flex-grow: 1;
}

.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tool-tag {
  padding: 3px 10px;
  background: var(--bg-hover);
  border-radius: 100px;
  font-size: 12px;
  color: var(--text-muted);
}

.tool-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.tool-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
}

.tool-rating .stars {
  color: #fbbf24;
}

.tool-visit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--gradient);
  color: white;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.tool-visit:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

/* ===== No Results ===== */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.no-results .emoji {
  font-size: 48px;
  margin-bottom: 16px;
}

/* ===== Ad Section ===== */
.ad-section {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin: 40px 0;
}

.ad-section .ad-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.ad-section .ad-content {
  color: var(--text-light);
  font-size: 14px;
}

.ad-section .ad-content strong {
  color: var(--primary);
}

/* ===== Featured Banner ===== */
.featured-banner {
  background: var(--gradient);
  border-radius: var(--radius);
  padding: 40px;
  color: white;
  margin: 40px 0;
  position: relative;
  overflow: hidden;
}

.featured-banner::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -10%;
  width: 300px;
  height: 300px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.featured-banner h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  position: relative;
}

.featured-banner p {
  font-size: 15px;
  opacity: 0.9;
  margin-bottom: 20px;
  position: relative;
}

.featured-banner .banner-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: white;
  color: var(--primary);
  border-radius: 100px;
  font-weight: 600;
  font-size: 15px;
  transition: all 0.3s;
  position: relative;
}

.featured-banner .banner-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ===== Footer ===== */
.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 40px 0 24px;
  margin-top: 60px;
}

.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}

.footer-brand .logo {
  margin-bottom: 12px;
}

.footer-brand p {
  font-size: 14px;
  color: var(--text-light);
  max-width: 300px;
}

.footer-col h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.footer-col a {
  display: block;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 8px;
  transition: color 0.2s;
}

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

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 50;
  font-size: 20px;
  color: var(--text);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav {
    display: none;
  }

  .hero {
    padding: 48px 0 40px;
  }

  .hero-stats {
    gap: 24px;
  }

  .footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }

  .tools-grid {
    grid-template-columns: 1fr;
  }

  .featured-banner {
    padding: 24px;
  }
}

@media (max-width: 480px) {
  .hero-stats {
    gap: 16px;
  }

  .stat-num {
    font-size: 22px;
  }

  .categories {
    gap: 8px;
  }

  .cat-btn {
    padding: 8px 14px;
    font-size: 13px;
  }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ===== Loading Skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-card) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
