/* ===== CSS Variables ===== */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --border-color: #e2e8f0;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;
  --success-color: #10b981;
  --error-color: #ef4444;
  --info-color: #0ea5e9;
  --info-light: #e0f2fe;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #64748b;
  --border-color: #334155;
  --accent-light: #1e3a5f;
  --info-light: #0c4a6e;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition:
    background-color var(--transition-normal),
    color var(--transition-normal);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 20px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2rem;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ===== Search ===== */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
}

#searchInput {
  width: 320px;
  padding: 12px 100px 12px 44px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

#searchInput:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px var(--accent-light);
}

#searchInput::placeholder {
  color: var(--text-tertiary);
}

.search-kbd {
  position: absolute;
  right: 12px;
  padding: 4px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-family: inherit;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

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

.sun-icon {
  display: block;
}
.moon-icon {
  display: none;
}
[data-theme="dark"] .sun-icon {
  display: none;
}
[data-theme="dark"] .moon-icon {
  display: block;
}

/* ===== Main Content ===== */
.main {
  padding: 32px 0;
  min-height: calc(100vh - 200px);
}

/* ===== Contribution Notice ===== */
.contribution-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--info-light);
  border: 1px solid var(--info-color);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  color: var(--text-primary);
}

.contribution-notice svg {
  flex-shrink: 0;
  color: var(--info-color);
}

.contribution-notice p {
  font-size: 0.95rem;
  margin: 0;
}

.contribution-notice a {
  color: var(--info-color);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
}

.contribution-notice a:hover {
  border-bottom-color: var(--info-color);
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: flex;
  gap: 32px;
  padding: 20px 28px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-color);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Filters Section ===== */
.filters-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 24px;
  margin-bottom: 28px;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.filter-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.clear-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--error-color);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.clear-filters:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ===== Category Buttons ===== */
.category-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.category-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.category-btn:hover {
  border-color: var(--accent-color);
  background: var(--accent-light);
}

.category-btn.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

.category-btn .count {
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.category-btn:not(.active) .count {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

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

/* ===== Tool Card ===== */
.tool-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.4s ease forwards;
  opacity: 0;
  display: flex;
  flex-direction: column;
}

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

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

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

.tool-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tool-card-title a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.tool-card-title a:hover {
  color: var(--accent-color);
}

.tool-card-category {
  padding: 4px 10px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-color);
  white-space: nowrap;
  flex-shrink: 0;
}

.tool-card-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  flex-grow: 1;
}

.tool-card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.tool-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent-color);
  border-radius: var(--radius-md);
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.tool-link:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.tool-link.secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.tool-link.secondary:hover {
  background: var(--border-color);
}

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

.no-results svg {
  margin-bottom: 20px;
  opacity: 0.5;
}

.no-results h3 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* ===== Footer ===== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 24px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer-note {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.footer kbd {
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  background: var(--accent-color);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all var(--transition-normal);
  z-index: 99;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent-hover);
  transform: translateY(-4px);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }

  .logo {
    justify-content: center;
  }

  .header-actions {
    justify-content: center;
  }

  #searchInput {
    width: 100%;
    max-width: 400px;
  }

  .search-kbd {
    display: none;
  }

  .contribution-notice {
    flex-direction: column;
    text-align: center;
  }

  .stats-bar {
    justify-content: center;
    text-align: center;
  }

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

  .tool-card-header {
    flex-direction: column;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 10px;
}

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

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

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

::selection {
  background: var(--accent-color);
  color: white;
}
