/* ============================================
   FreeTools.network — Hub Stylesheet
   Dark/Light theme with system preference
   ============================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Theme: Light (default) --- */
:root {
  --bg-body: #fafafa;
  --bg-card: #ffffff;
  --bg-input: #f5f5f5;
  --bg-hero: #ffffff;
  --border: #e0e0e0;
  --border-hover: #6366f1;
  --text-primary: #1a1a1a;
  --text-secondary: #525252;
  --text-muted: #9ca3af;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: rgba(99, 102, 241, 0.08);
  --accent-glow: rgba(99, 102, 241, 0.15);
  --badge-bg: rgba(99, 102, 241, 0.08);
  --badge-text: #6366f1;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --toggle-bg: #e0e0e0;
  --toggle-knob: #ffffff;
  --category-line: #e0e0e0;
  --search-icon: #9ca3af;
  --count-bg: rgba(99, 102, 241, 0.08);
  --count-text: #6366f1;
}

/* --- Theme: Dark --- */
[data-theme="dark"] {
  --bg-body: #0a0a0a;
  --bg-card: #141414;
  --bg-input: #1a1a1a;
  --bg-hero: #111111;
  --border: #2a2a2a;
  --border-hover: #818cf8;
  --text-primary: #fafafa;
  --text-secondary: #a1a1a1;
  --text-muted: #666666;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-light: rgba(129, 140, 248, 0.1);
  --accent-glow: rgba(129, 140, 248, 0.2);
  --badge-bg: rgba(129, 140, 248, 0.12);
  --badge-text: #818cf8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
  --toggle-bg: #333333;
  --toggle-knob: #fafafa;
  --category-line: #2a2a2a;
  --search-icon: #666666;
  --count-bg: rgba(129, 140, 248, 0.12);
  --count-text: #818cf8;
}

/* --- System preference auto-detect --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-body: #0a0a0a;
    --bg-card: #141414;
    --bg-input: #1a1a1a;
    --bg-hero: #111111;
    --border: #2a2a2a;
    --border-hover: #818cf8;
    --text-primary: #fafafa;
    --text-secondary: #a1a1a1;
    --text-muted: #666666;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-light: rgba(129, 140, 248, 0.1);
    --accent-glow: rgba(129, 140, 248, 0.2);
    --badge-bg: rgba(129, 140, 248, 0.12);
    --badge-text: #818cf8;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
    --toggle-bg: #333333;
    --toggle-knob: #fafafa;
    --category-line: #2a2a2a;
    --search-icon: #666666;
    --count-bg: rgba(129, 140, 248, 0.12);
    --count-text: #818cf8;
  }
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* --- Container --- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 3rem 1.25rem 2rem;
  background: var(--bg-hero);
  border-bottom: 1px solid var(--border);
}

.hero-inner {
  max-width: 700px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo h1 .domain {
  opacity: 0.4;
  font-weight: 500;
}

.hero-tagline {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Search --- */
.search-wrapper {
  position: relative;
  max-width: 500px;
  margin: 0 auto;
}

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

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  font-family: inherit;
  font-size: 1rem;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-stats {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

/* --- Theme Toggle --- */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-md);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.9rem;
  transition: background 0.2s ease;
}

.theme-toggle-icon.active {
  background: var(--accent-light);
}

/* --- Category Sections --- */
.category-section {
  margin-top: 2.5rem;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--category-line);
}

.category-icon {
  font-size: 1.25rem;
}

.category-name {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.category-count {
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--count-bg);
  color: var(--count-text);
  padding: 2px 8px;
  border-radius: 50px;
  font-family: 'JetBrains Mono', monospace;
}

.category-site {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.category-site a {
  color: var(--text-muted);
}

.category-site a:hover {
  color: var(--accent);
}

/* --- Tool Grid --- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* --- Tool Card --- */
.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.tool-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: inherit;
}

.tool-card:active {
  transform: translateY(0);
}

.tool-card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
}

.tool-card-body {
  flex: 1;
  min-width: 0;
}

.tool-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  line-height: 1.3;
}

.tool-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.tool-card-site {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--badge-text);
  background: var(--badge-bg);
  padding: 1px 6px;
  border-radius: 4px;
}

/* --- No Results --- */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.no-results-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.no-results-text {
  font-size: 1rem;
}

.no-results-hint {
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* --- Footer --- */
.footer {
  margin-top: 3rem;
  padding: 2rem 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-brand {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.footer-brand strong {
  color: var(--text-secondary);
}

.footer-sites {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.footer-site-link {
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

.footer-site-link:hover {
  color: var(--accent);
}

.footer-copy {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Support Box --- */
.support-box {
  max-width: 500px;
  margin: 2rem auto 0;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.support-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.support-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
}

.support-link-btn:hover {
  color: var(--accent-hover);
}

.support-divider {
  color: var(--text-muted);
}

/* --- Feedback Form --- */
.feedback-form-container {
  display: none;
  margin-top: 1rem;
  text-align: left;
}

.feedback-form-container.visible {
  display: block;
}

.feedback-field {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  outline: none;
  margin-bottom: 0.5rem;
}

.feedback-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.feedback-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.feedback-success {
  display: none;
  padding: 0.75rem;
  text-align: center;
  color: var(--accent);
  font-size: 0.9rem;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .hero { padding: 2rem 1rem 1.5rem; }
  .logo h1 { font-size: 1.4rem; }
  .hero-tagline { font-size: 1rem; }
  .tool-grid { grid-template-columns: 1fr; }
  .category-site { display: none; }
  .theme-toggle { top: 0.5rem; right: 0.5rem; }
}

@media (max-width: 400px) {
  .logo h1 { font-size: 1.2rem; }
  .logo-icon { width: 36px; height: 36px; font-size: 1.25rem; }
}

/* --- Print --- */
@media print {
  .theme-toggle, .search-wrapper, .support-box, .feedback-form-container { display: none; }
  body { background: #fff; color: #000; }
  .tool-card { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
}
