/* ═══════════════════════════════════════════════════════════════
   AI Tools Hub - Main Stylesheet
   Mobile-first, SEO-optimized, dark-theme compatible
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────── */
:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #818cf8;
  --accent: #06b6d4;
  --accent-dark: #0891b2;

  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --header-bg: rgba(255,255,255,0.95);
  --footer-bg: #0f172a;
  --footer-text: #94a3b8;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

  --max-width: 1200px;
  --header-height: 64px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --bg-card: #1e293b;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --border-light: #1e293b;
    --header-bg: rgba(15,23,42,0.95);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
  }
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }
ul, ol { padding-left: 1.25em; }
table { width: 100%; border-collapse: collapse; margin: 1em 0; overflow-x: auto; display: block; }
th, td { padding: 0.75em 1em; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg-alt); font-weight: 600; }
pre, code { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.9em; }
pre { background: var(--bg-alt); padding: 1em; border-radius: var(--radius-sm); overflow-x: auto; margin: 1em 0; }
code { background: var(--bg-alt); padding: 0.2em 0.4em; border-radius: 3px; }
pre code { background: none; padding: 0; }

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

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
}
.site-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15em; color: var(--text); }
.site-logo:hover { color: var(--text); }
.logo-text { display: flex; align-items: center; gap: 6px; }
.logo-cn { font-size: 0.65em; font-weight: 400; color: var(--text-muted); }
.logo-icon { font-size: 1.4em; }

/* Navigation */
.nav-list { display: flex; list-style: none; gap: 4px; }
.nav-list li { position: relative; }
.nav-list a {
  display: block; padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.9em; font-weight: 500;
  transition: all 0.2s;
}
.nav-list a:hover { background: var(--bg-alt); color: var(--text); }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }

/* Dropdown */
.nav-dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  min-width: 220px; z-index: 50; list-style: none; padding: 4px;
}
.dropdown-menu a { padding: 8px 12px; font-size: 0.85em; }
.dropdown-arrow { font-size: 0.6em; vertical-align: middle; }

/* ── Breadcrumbs ────────────────────────────────────────── */
.breadcrumbs { background: var(--bg-alt); padding: 10px 0; font-size: 0.85em; border-bottom: 1px solid var(--border-light); }
.breadcrumbs ol { list-style: none; display: flex; gap: 8px; }
.breadcrumbs li:not(:last-child)::after { content: "/"; margin-left: 8px; color: var(--text-muted); }
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--primary); }

/* ── Hero Section ────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  padding: 60px 0 80px; text-align: center; position: relative;
  overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.3;
}
.hero-content { position: relative; z-index: 1; max-width: 800px; margin: 0 auto; }
.hero-title { color: #fff; font-size: 2.5em; font-weight: 800; line-height: 1.2; margin-bottom: 16px; }
.hero-subtitle { color: rgba(255,255,255,0.9); font-size: 1.15em; margin-bottom: 32px; }
.hero-search { display: flex; max-width: 500px; margin: 0 auto; gap: 8px; }
.hero-search-input {
  flex: 1; padding: 14px 20px; border: none; border-radius: var(--radius);
  font-size: 1em; background: rgba(255,255,255,0.15); color: #fff;
  backdrop-filter: blur(10px); outline: none;
}
.hero-search-input::placeholder { color: rgba(255,255,255,0.6); }
.hero-search-btn {
  padding: 14px 28px; border: none; border-radius: var(--radius);
  background: #fff; color: var(--primary); font-weight: 600;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.hero-search-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }

/* ── Section Headers ─────────────────────────────────────── */
.section { padding: 48px 0; }
.section-header { text-align: center; margin-bottom: 32px; }
.section-header h2 { font-size: 1.75em; font-weight: 700; margin-bottom: 8px; }
.section-header p { color: var(--text-secondary); max-width: 600px; margin: 0 auto; }

/* ── Featured Grid ───────────────────────────────────────── */
.featured-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 24px; }
.featured-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: all 0.3s; display: flex;
}
.featured-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-xl); border-color: var(--primary-light); }
.card-body { padding: 24px; display: flex; flex-direction: column; flex: 1; }
.card-meta { display: flex; gap: 12px; font-size: 0.82em; color: var(--text-muted); margin-bottom: 12px; align-items: center; }
.card-category { color: var(--primary); font-weight: 500; }
.card-title { font-size: 1.1em; font-weight: 600; line-height: 1.4; margin-bottom: 8px; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--primary); }
.card-desc { color: var(--text-secondary); font-size: 0.92em; line-height: 1.6; flex: 1; margin-bottom: 12px; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Categories ──────────────────────────────────────────── */
.categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.category-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 24px;
  text-align: center; transition: all 0.3s; display: block;
}
.category-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }
.category-icon { font-size: 2.5em; margin-bottom: 12px; }
.category-card h3 { font-size: 1.05em; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.category-card p { font-size: 0.85em; color: var(--text-secondary); line-height: 1.5; margin-bottom: 12px; }
.category-count { font-size: 0.82em; color: var(--primary); font-weight: 500; }

/* ── Recent Articles List ───────────────────────────────── */
.recent-list { display: grid; gap: 20px; }
.recent-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  transition: all 0.25s;
}
.recent-item:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.recent-meta { display: flex; gap: 16px; font-size: 0.84em; color: var(--text-muted); margin-bottom: 10px; }
.recent-category { color: var(--primary); font-weight: 500; }
.recent-title { font-size: 1.2em; font-weight: 600; margin-bottom: 8px; }
.recent-title a { color: var(--text); }
.recent-title a:hover { color: var(--primary); }
.recent-desc { color: var(--text-secondary); font-size: 0.92em; line-height: 1.6; margin-bottom: 12px; }
.recent-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Tags ────────────────────────────────────────────────── */
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 0.78em; font-weight: 500; background: var(--bg-alt);
  color: var(--text-secondary); border: 1px solid var(--border); white-space: nowrap;
}
.tag:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.tag-lg {
  display: inline-block; padding: 6px 16px; border-radius: 20px;
  font-size: 0.88em; font-weight: 500; background: var(--bg-alt);
  color: var(--text-secondary); border: 1px solid var(--border);
  margin: 4px; transition: all 0.2s;
}
.tag-lg:hover { background: var(--primary); color: #fff; border-color: var(--primary); transform: scale(1.05); }
.tags-cloud { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.tag-sm {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 0.75em; background: var(--bg-alt); color: var(--text-secondary);
  border: 1px solid var(--border); margin: 2px;
}
.tag-sm:hover { background: var(--primary); color: #fff; }

/* ── FAQ ─────────────────────────────────────────────────── */
.faq-list { max-width: 800px; margin: 0 auto; display: grid; gap: 12px; }
.faq-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.faq-question {
  padding: 18px 24px; cursor: pointer; font-weight: 500;
  position: relative; display: flex; align-items: center; gap: 8px;
}
.faq-question::before { content: "▶"; font-size: 0.7em; color: var(--primary); transition: transform 0.2s; }
.faq-item.active .faq-question::before { transform: rotate(90deg); }
.faq-answer { display: none; padding: 0 24px 18px; color: var(--text-secondary); font-size: 0.92em; line-height: 1.7; }
.faq-item.active .faq-answer { display: block; }

/* ── CTA Section ─────────────────────────────────────────── */
.cta-section { padding: 40px 0; }
.cta-box {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: var(--radius); padding: 48px; text-align: center;
}
.cta-box h2 { color: #fff; font-size: 1.6em; margin-bottom: 12px; }
.cta-box p { color: rgba(255,255,255,0.9); margin-bottom: 24px; }
.cta-btn {
  display: inline-block; padding: 14px 36px; border-radius: var(--radius);
  background: #fff; color: var(--primary); font-weight: 600;
  transition: all 0.2s;
}
.cta-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-xl); }

/* ── Article Page ────────────────────────────────────────── */
.article-page { padding: 24px 0 48px; }
.article-layout { display: grid; grid-template-columns: 1fr 320px; gap: 40px; }
.article-main { min-width: 0; }
.article-header { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.article-meta-top { display: flex; gap: 16px; align-items: center; font-size: 0.88em; color: var(--text-muted); margin-bottom: 16px; }
.article-category { color: var(--primary); font-weight: 500; }
.article-title { font-size: 2em; font-weight: 800; line-height: 1.3; margin-bottom: 12px; }
.article-desc { font-size: 1.1em; color: var(--text-secondary); line-height: 1.6; }
.article-tags { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Article body */
.article-body { font-size: 1.05em; line-height: 1.85; }
.article-body h2 { font-size: 1.5em; font-weight: 700; margin-top: 36px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--border-light); }
.article-body h3 { font-size: 1.2em; font-weight: 600; margin-top: 28px; margin-bottom: 12px; }
.article-body p { margin-bottom: 1em; }
.article-body ul, .article-body ol { margin-bottom: 1em; }
.article-body li { margin-bottom: 0.5em; }
.article-body blockquote {
  border-left: 4px solid var(--primary); padding: 12px 20px;
  margin: 1.5em 0; background: var(--bg-alt); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Share */
.article-share { display: flex; align-items: center; gap: 12px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.article-share span { font-weight: 500; color: var(--text-secondary); }
.article-share a { padding: 6px 14px; border-radius: var(--radius-sm); background: var(--bg-alt); font-size: 0.85em; }

/* Related */
.related-articles { margin-top: 40px; }
.related-articles h2 { font-size: 1.3em; margin-bottom: 20px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.related-card {
  display: block; padding: 20px; border: 1px solid var(--border);
  border-radius: var(--radius); transition: all 0.25s;
}
.related-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); transform: translateY(-2px); }
.related-cat { font-size: 1.4em; display: block; margin-bottom: 8px; }
.related-card h3 { font-size: 0.95em; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.related-card p { font-size: 0.84em; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.related-date { font-size: 0.78em; color: var(--text-muted); }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar-widget { margin-bottom: 28px; }
.sidebar-widget h3 { font-size: 1em; font-weight: 600; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.sidebar-post-list, .sidebar-cat-list { list-style: none; padding: 0; }
.sidebar-post-list li, .sidebar-cat-list li { padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.sidebar-post-list a, .sidebar-cat-list a { font-size: 0.88em; color: var(--text); display: block; }
.sidebar-post-list a:hover, .sidebar-cat-list a:hover { color: var(--primary); }
.sidebar-post-date { font-size: 0.78em; color: var(--text-muted); }
.sidebar-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.toc-widget { position: sticky; top: calc(var(--header-height) + 20px); }
#tocList { list-style: none; padding: 0; }
#tocList li { padding: 4px 0; }
#tocList a { font-size: 0.85em; color: var(--text-secondary); display: block; padding: 2px 0; border-bottom: 1px solid var(--border-light); }
#tocList a:hover { color: var(--primary); }
.toc-h3 { padding-left: 12px; }

/* ── Ad Placements ───────────────────────────────────────── */
.ad-container { margin: 24px 0; text-align: center; min-height: 90px; }
.ad-banner { min-height: 90px; display: flex; align-items: center; justify-content: center; background: var(--bg-alt); border-radius: var(--radius-sm); }
.ad-in-article { margin: 24px 0; text-align: center; min-height: 90px; }
.ad-sidebar { margin-bottom: 28px; min-height: 250px; background: var(--bg-alt); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }

/* ── Archive Pages ───────────────────────────────────────── */
.page-header {
  background: var(--bg-alt); padding: 40px 0; text-align: center;
  border-bottom: 1px solid var(--border);
}
.page-header-content { max-width: 700px; margin: 0 auto; }
.page-icon { font-size: 3em; display: block; margin-bottom: 8px; }
.page-header h1 { font-size: 2em; font-weight: 700; margin-bottom: 8px; }
.page-desc { color: var(--text-secondary); font-size: 1em; }
.page-count { display: inline-block; margin-top: 12px; color: var(--primary); font-weight: 500; font-size: 0.9em; }

.archive-list { display: grid; gap: 20px; }
.archive-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; transition: all 0.25s;
}
.archive-item:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.archive-meta { display: flex; gap: 16px; font-size: 0.84em; color: var(--text-muted); margin-bottom: 10px; align-items: center; }
.archive-cat { color: var(--primary); font-weight: 500; }
.archive-title { font-size: 1.3em; font-weight: 600; margin-bottom: 10px; }
.archive-title a { color: var(--text); }
.archive-title a:hover { color: var(--primary); }
.archive-desc { color: var(--text-secondary); font-size: 0.95em; line-height: 1.6; margin-bottom: 12px; }
.archive-tags { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── About & Content Pages ───────────────────────────────── */
.content-page { max-width: 800px; margin: 0 auto; }
.about-content h2 { font-size: 1.4em; font-weight: 700; margin-top: 32px; margin-bottom: 12px; }
.about-content p { margin-bottom: 1em; color: var(--text-secondary); }
.about-content ul { margin-bottom: 1em; }
.about-content li { margin-bottom: 0.5em; }

/* ── Error Page ──────────────────────────────────────────── */
.error-page { text-align: center; padding: 100px 0; }
.error-content h1 { font-size: 6em; font-weight: 800; color: var(--primary); line-height: 1; margin-bottom: 8px; }
.error-content h2 { font-size: 1.5em; margin-bottom: 16px; }
.error-content p { color: var(--text-secondary); margin-bottom: 24px; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer { background: var(--footer-bg); color: var(--footer-text); padding: 48px 0 0; margin-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.5fr; gap: 32px; }
.footer-section h3, .footer-section h4 { color: #fff; margin-bottom: 16px; font-size: 1em; }
.footer-section p { font-size: 0.88em; line-height: 1.6; margin-bottom: 8px; }
.footer-section ul { list-style: none; padding: 0; }
.footer-section li { margin-bottom: 8px; }
.footer-section a { color: var(--footer-text); font-size: 0.88em; }
.footer-section a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.1); margin-top: 32px; padding: 20px 0; text-align: center; font-size: 0.84em; }
.footer-bottom a { color: var(--primary-light); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud .tag { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.1); color: var(--footer-text); }

/* ── Search Overlay ──────────────────────────────────────── */
.search-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  align-items: flex-start; justify-content: center; padding-top: 100px;
}
.search-overlay.active { display: flex; }
.search-modal { width: 100%; max-width: 600px; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-xl); overflow: hidden; }
.search-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; font-size: 2em; color: var(--text);
  cursor: pointer; width: 40px; height: 40px; display: flex;
  align-items: center; justify-content: center;
}
.search-input {
  width: 100%; padding: 20px; border: none; border-bottom: 1px solid var(--border);
  font-size: 1.1em; background: var(--bg-card); color: var(--text); outline: none;
}
.search-results { max-height: 400px; overflow-y: auto; padding: 8px; }
.search-result-item { padding: 12px; border-radius: var(--radius-sm); display: block; }
.search-result-item:hover { background: var(--bg-alt); }
.search-result-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.search-result-desc { font-size: 0.84em; color: var(--text-secondary); }
.search-result-meta { font-size: 0.78em; color: var(--text-muted); margin-top: 4px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .article-layout { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .hero { padding: 40px 0 60px; }
  .hero-title { font-size: 1.8em; }
  .hero-search { flex-direction: column; }
  .featured-grid { grid-template-columns: 1fr; }
  .categories-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .nav-toggle { display: block; }
  .nav-list { display: none; position: absolute; top: var(--header-height); left: 0; right: 0; background: var(--bg-card); border-bottom: 1px solid var(--border); flex-direction: column; padding: 8px; }
  .nav-list.active { display: flex; }
  .nav-dropdown .dropdown-menu { position: static; display: none; box-shadow: none; border: none; padding-left: 16px; }
  .nav-dropdown:hover .dropdown-menu { display: block; }
  .article-title { font-size: 1.5em; }
  .related-grid { grid-template-columns: 1fr 1fr; }
  .section { padding: 32px 0; }
}

@media (max-width: 480px) {
  .categories-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .cta-box { padding: 28px 20px; }
}
