/* ==========================================================================
   ToolHub Design System & Stylesheet
   Theme: Modern, Responsive, Accessible, Light/Dark Modes
   ========================================================================== */

:root {
  /* Light Theme Palette */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.85);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --border-color: #e2e8f0;
  --border-focus: #6366f1;
  
  --brand-primary: #6366f1;
  --brand-primary-hover: #4f46e5;
  --brand-secondary: #06b6d4;
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'JetBrains Mono', Consolas, Monaco, monospace;
  
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* Dark Theme Palette */
  --bg-primary: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-subtle: #1f2937;
  --bg-glass: rgba(17, 24, 39, 0.85);
  
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --border-color: #1f2937;
  --border-focus: #818cf8;
  
  --brand-primary: #818cf8;
  --brand-primary-hover: #6366f1;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(129, 140, 248, 0.3);
}

/* --- Base Body & Resets --- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: var(--transition-fast);
}

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

/* --- Typography Helpers --- */
.gradient-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

/* --- Navbar Glassmorphism --- */
.navbar-custom {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1030;
  padding: 0.75rem 0;
  transition: var(--transition-normal);
}

.brand-logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary) !important;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--brand-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  box-shadow: var(--shadow-sm);
}

.nav-link-custom {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.nav-link-custom:hover, .nav-link-custom.active {
  color: var(--brand-primary);
  background-color: var(--bg-surface-subtle);
}

/* --- Theme Toggle Button --- */
.btn-theme-toggle {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-theme-toggle:hover {
  background: var(--border-color);
  transform: rotate(15deg);
}

/* --- Search Bar Component --- */
.search-container {
  position: relative;
  max-width: 650px;
  margin: 0 auto;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-icon {
  position: absolute;
  left: 1.25rem;
  color: var(--text-muted);
  font-size: 1.2rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 1rem 1.25rem 1rem 3.25rem;
  font-size: 1.05rem;
  border-radius: 50px;
  border: 2px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  transition: var(--transition-normal);
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-glow);
}

/* Search Dropdown Results */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 380px;
  overflow-y: auto;
  z-index: 1050;
  display: none;
}

.search-dropdown.active {
  display: block;
}

.search-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: var(--transition-fast);
}

.search-dropdown-item:last-child {
  border-bottom: none;
}

.search-dropdown-item:hover {
  background-color: var(--bg-surface-subtle);
  text-decoration: none;
}

.search-dropdown-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* --- Tool Cards --- */
.tool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

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

.tool-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-subtle);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin-bottom: 1rem;
  transition: var(--transition-fast);
}

.tool-card:hover .tool-card-icon {
  background: var(--brand-primary);
  color: #ffffff;
}

.tool-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.tool-card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  flex-grow: 1;
  margin-bottom: 1rem;
}

.tool-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge-client-side {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.badge-server-side {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--brand-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* Category Pill Badges */
.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.category-pill:hover, .category-pill.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

/* --- Hero Section --- */
.hero-section {
  padding: 4.5rem 0 3.5rem 0;
  text-align: center;
  position: relative;
  background: radial-gradient(circle at 50% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem auto;
}

/* --- Footer --- */
.footer-custom {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 3.5rem 0 2rem 0;
  margin-top: 4rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.footer-links-header {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.footer-link {
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.5rem;
  transition: var(--transition-fast);
}

.footer-link:hover {
  color: var(--brand-primary);
}

/* --- PWA Banner --- */
#pwa-install-banner {
  background: var(--brand-primary);
  color: #fff;
  padding: 0.75rem 1.25rem;
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Responsive Rules */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2rem;
  }
  .hero-subtitle {
    font-size: 1rem;
  }
  .search-input {
    font-size: 0.95rem;
  }
}
