/* ==========================================================================
   Toolit Performance-Optimized Styles
   Ultra-fast loading, smooth animations, zero lag
   ========================================================================== */

:root {
  /* Core Colors - Dark Mode First */
  --bg-primary: #0a0a0b;
  --bg-secondary: #111113;
  --bg-elevated: #18181b;
  --bg-accent: #1f1f23;

  /* Text Hierarchy */
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;

  /* Brand Colors */
  --brand-blue: #3b82f6;
  --brand-cyan: #06b6d4;
  --brand-success: #10b981;

  /* Border System */
  --border-subtle: #27272a;
  --border-strong: #3f3f46;

  /* Typography */
  --font: 'Inter', system-ui, -apple-system, sans-serif;

  /* Optimized Transitions - 60fps Performance */
  --speed-instant: 0ms;
  --speed-fast: 150ms;
  --speed-normal: 250ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Spacing Scale */
  --s-xs: 0.25rem;
  --s-sm: 0.5rem;
  --s-md: 1rem;
  --s-lg: 1.5rem;
  --s-xl: 2rem;
  --s-2xl: 3rem;

  /* Radius Scale */
  --r-sm: 0.375rem;
  --r-md: 0.5rem;
  --r-lg: 0.75rem;
  --r-xl: 1rem;

  /* Optimized Shadows */
  --shadow-subtle: 0 1px 3px 0 rgb(0 0 0 / 0.4);
  --shadow-medium: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-large: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

/* ==========================================================================
   Performance-First Base Styles
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  /* Optimize for GPU acceleration only where needed */
  will-change: auto;
}

html {
  scroll-behavior: smooth;
  /* Optimize scrolling performance */
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  line-height: 1.6;
  background: var(--bg-primary);
  color: var(--text-primary);
  /* Optimized font rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
  /* Prevent layout shifts */
  overflow-x: hidden;
}

/* ==========================================================================
   Ultra-Lightweight Background Pattern
   Single static pattern - zero animation overhead
   ========================================================================== */

.geometric-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  /* Single static grid pattern - no animations */
  background-image:
    linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  /* Remove any animations to prevent scroll lag */
}

/* ==========================================================================
   Optimized Component System
   ========================================================================== */

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

/* Header - Optimized for performance */
.header {
  background: rgba(10, 10, 11, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 1000;
  /* Optimize layer creation */
  will-change: transform;
}

.header.scrolled {
  background: rgba(10, 10, 11, 0.98);
  box-shadow: var(--shadow-medium);
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-md) var(--s-lg);
}

.header-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--s-xs);
}

.header-logo .dot {
  width: 8px;
  height: 8px;
  background: var(--brand-cyan);
  border-radius: 50%;
  /* Simplified pulse - lower CPU usage */
  animation: simplePulse 4s ease-in-out infinite;
}

@keyframes simplePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Navigation - Simplified and efficient */
.nav-links {
  display: flex;
  align-items: center;
  gap: var(--s-xl);
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--speed-fast) var(--ease);
  position: relative;
}

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

/* Simplified underline animation */
.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-cyan);
  transform: scaleX(0);
  transition: transform var(--speed-fast) var(--ease);
}

.nav-link:hover::after {
  transform: scaleX(1);
}

/* Optimized Button System */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-sm);
  padding: var(--s-sm) var(--s-lg);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--r-md);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--speed-fast) var(--ease);
  /* Prevent layout shifts */
  backface-visibility: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-blue), #2563eb);
  color: white;
  box-shadow: var(--shadow-subtle);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-medium);
}

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

.btn-secondary:hover {
  background: var(--bg-accent);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: var(--s-xs) var(--s-md);
  font-size: 0.8rem;
}

/* Hero Section - Optimized */
.hero {
  padding: var(--s-2xl) 0;
  text-align: center;
  position: relative;
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: var(--s-lg);
  /* Optimized gradient text */
  background: linear-gradient(135deg, var(--text-primary), var(--brand-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: var(--s-xl);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-buttons {
  display: flex;
  gap: var(--s-md);
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--s-xl);
}

.highlight {
  background: linear-gradient(135deg, var(--brand-cyan), var(--brand-blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Trust Badges */
.trust-badges {
  display: flex;
  justify-content: center;
  gap: var(--s-lg);
  flex-wrap: wrap;
}

.trust-badge {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  padding: var(--s-sm) var(--s-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.trust-badge svg {
  color: var(--brand-success);
}

/* Enhanced Tool Cards - Performance optimized */
.tool-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-xl);
  transition: all var(--speed-fast) var(--ease);
  /* Prevent layout shifts from tags */
  margin: 8px 8px 4px 4px;
}

.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(6, 182, 212, 0.03));
  opacity: 0;
  transition: opacity var(--speed-fast) var(--ease);
  z-index: 0;
  border-radius: inherit;
}

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

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

.tool-card > * {
  position: relative;
  z-index: 1;
}

.tool-card-icon {
  width: 4rem;
  height: 4rem;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-cyan));
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--s-lg);
  transition: transform var(--speed-fast) var(--ease);
}

.tool-card:hover .tool-card-icon {
  transform: scale(1.05);
}

.tool-card-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  color: white;
}

.tool-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--s-sm);
}

.tool-card-desc {
  color: var(--text-secondary);
  margin-bottom: var(--s-lg);
  line-height: 1.5;
}

.tool-card-link {
  color: var(--brand-cyan);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  transition: all var(--speed-fast) var(--ease);
}

.tool-card-link:hover {
  color: var(--brand-blue);
  transform: translateX(4px);
}

/* Grid Layouts - Optimized for performance */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: var(--s-lg);
  margin-top: var(--s-2xl);
  /* Account for absolutely positioned elements */
  padding: 8px;
}

.all-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-md);
  padding: 4px;
}

/* Category Filter Pills - Fixed filtering logic */
.filter-bar {
  display: flex;
  gap: var(--s-sm);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--s-xl);
}

.filter-pill {
  padding: var(--s-sm) var(--s-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--speed-fast) var(--ease);
  border: none;
}

.filter-pill:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.filter-pill.active {
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-cyan));
  color: white;
}

/* Small Tool Cards */
.small-tool-card {
  display: flex;
  align-items: flex-start;
  gap: var(--s-md);
  padding: var(--s-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  text-decoration: none;
  color: inherit;
  transition: all var(--speed-fast) var(--ease);
}

.small-tool-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.small-tool-icon {
  width: 3rem;
  height: 3rem;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.small-tool-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--brand-cyan);
}

.small-tool-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--s-xs);
}

.small-tool-desc {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

/* Mobile Navigation - Single unified system */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--s-sm);
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: all var(--speed-fast) var(--ease);
  border-radius: 1px;
}

/* Sections */
.section {
  padding: var(--s-2xl) 0;
}

.section-header {
  text-align: center;
  margin-bottom: var(--s-xl);
}

.section-title {
  font-size: clamp(2rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--s-md);
}

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

.section-label {
  display: inline-block;
  padding: var(--s-xs) var(--s-md);
  background: linear-gradient(135deg, var(--brand-cyan), var(--brand-blue));
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--r-lg);
  margin-bottom: var(--s-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tool Category Colors */
.tool-card[data-color="red"] .tool-card-icon {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.tool-card[data-color="indigo"] .tool-card-icon {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
}

.tool-card[data-color="purple"] .tool-card-icon {
  background: linear-gradient(135deg, #8b5cf6, #6b21a8);
}

.tool-card[data-color="orange"] .tool-card-icon {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.tool-card[data-color="green"] .tool-card-icon {
  background: linear-gradient(135deg, #10b981, #047857);
}

.tool-card[data-color="cyan"] .tool-card-icon {
  background: linear-gradient(135deg, #06b6d4, #0e7490);
}

/* How It Works */
.steps-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--s-xl);
  margin-top: var(--s-2xl);
}

.step {
  text-align: center;
  padding: var(--s-xl);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
}

.step-number {
  width: 3rem;
  height: 3rem;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-cyan));
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0 auto var(--s-lg);
}

.step-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--s-sm);
}

.step-desc {
  color: var(--text-secondary);
}

/* Privacy Section */
.privacy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2xl);
  align-items: center;
}

.privacy-statement {
  font-size: 1.125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--s-xl);
}

.privacy-features {
  display: grid;
  gap: var(--s-md);
}

.privacy-feature {
  display: flex;
  align-items: center;
  gap: var(--s-md);
}

.privacy-check {
  width: 2rem;
  height: 2rem;
  background: linear-gradient(135deg, var(--brand-success), #047857);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.privacy-check svg {
  width: 1rem;
  height: 1rem;
  color: white;
}

.privacy-feature-text {
  font-weight: 500;
  color: var(--text-primary);
}

.privacy-cta {
  color: var(--brand-cyan);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  margin-top: var(--s-lg);
  transition: all var(--speed-fast) var(--ease);
}

.privacy-cta:hover {
  color: var(--brand-blue);
  transform: translateX(4px);
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: var(--s-2xl) 0 var(--s-xl);
  margin-top: var(--s-2xl);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--s-xl);
  margin-bottom: var(--s-xl);
}

.footer-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--s-md);
}

.footer-brand-desc {
  color: var(--text-secondary);
  line-height: 1.6;
}

.footer-heading {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--s-md);
}

.footer-list {
  list-style: none;
  display: grid;
  gap: var(--s-sm);
}

.footer-list a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--speed-fast) var(--ease);
}

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

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--s-lg);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font-size: 0.875rem;
  flex-wrap: wrap;
  gap: var(--s-md);
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 9999;
  padding: var(--s-sm) var(--s-md);
  background: var(--brand-blue);
  color: white;
  text-decoration: none;
  border-radius: var(--r-md);
}

.skip-link:focus {
  left: var(--s-md);
  top: var(--s-md);
}

/* Simple fade animations - minimal CPU usage */
.fade-up {
  opacity: 0;
  animation: fadeUp 0.6s ease-out forwards;
}

.fade-up-delay-1 { animation-delay: 0.1s; }
.fade-up-delay-2 { animation-delay: 0.2s; }
.fade-up-delay-3 { animation-delay: 0.3s; }

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

/* Hide empty ad sections */
.ad-section:empty {
  display: none;
}

.ad-section .adsense-slot:empty {
  display: none;
}

/* ==========================================================================
   RESPONSIVE OPTIMIZATIONS - Mobile First
   ========================================================================== */

@media (max-width: 768px) {
  /* Optimized mobile navigation */
  .nav-links {
    display: none;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-links.open {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(10, 10, 11, 0.98);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--s-lg);
    gap: var(--s-md);
    z-index: 999;
    box-shadow: var(--shadow-medium);
  }

  /* Touch-optimized buttons */
  .btn {
    min-height: 44px;
    padding: var(--s-md) var(--s-lg);
    font-size: 1rem;
  }

  .btn-sm {
    min-height: 40px;
    padding: var(--s-sm) var(--s-md);
    font-size: 0.9rem;
  }

  /* Optimized grids */
  .featured-grid {
    grid-template-columns: 1fr;
    gap: var(--s-md);
    padding: 4px;
  }

  .all-tools-grid {
    grid-template-columns: 1fr;
    gap: var(--s-md);
  }

  /* Better hero section */
  .hero {
    padding: var(--s-xl) 0;
  }

  .hero-title {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .hero-subtitle {
    font-size: 1.125rem;
    padding: 0 var(--s-sm);
  }

  .hero-buttons {
    flex-direction: column;
    gap: var(--s-md);
  }

  .hero-buttons .btn {
    width: 100%;
    max-width: 280px;
  }

  /* Improved container */
  .container {
    padding: 0 var(--s-md);
  }

  /* Better sections */
  .steps-row {
    grid-template-columns: 1fr;
    gap: var(--s-lg);
  }

  .privacy-grid {
    grid-template-columns: 1fr;
    gap: var(--s-lg);
    text-align: center;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  /* Tool card optimizations */
  .tool-card {
    margin: 4px 4px 2px 2px;
  }
}

@media (max-width: 480px) {
  /* Ultra-small device optimizations */
  .container {
    padding: 0 var(--s-sm);
  }

  .hero-title {
    font-size: clamp(1.75rem, 7vw, 2.5rem);
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .section-title {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }

  .tool-card {
    padding: var(--s-md);
  }
}

/* ==========================================================================
   DARK THEME TOOL PAGES OPTIMIZATION
   ========================================================================== */

.tool-page {
  min-height: 100vh;
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: var(--s-lg) 0;
}

.tool-header {
  text-align: center;
  margin-bottom: var(--s-2xl);
}

.tool-header h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  margin-bottom: var(--s-md);
  background: linear-gradient(135deg, var(--text-primary), var(--brand-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tool-header p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* File upload zones */
.file-drop-zone {
  border: 2px dashed var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-2xl);
  text-align: center;
  background: var(--bg-secondary);
  transition: all var(--speed-fast) var(--ease);
}

.file-drop-zone:hover {
  border-color: var(--brand-cyan);
  background: var(--bg-elevated);
}

.file-drop-zone.drag-over {
  border-color: var(--brand-blue);
  background: rgba(59, 130, 246, 0.05);
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: var(--s-md);
}

.drop-text {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: var(--s-lg);
}

.select-files-btn {
  background: var(--brand-blue);
  color: white;
  border: none;
  padding: var(--s-md) var(--s-xl);
  border-radius: var(--r-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--speed-fast) var(--ease);
}

.select-files-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

/* Tool content areas */
.tool-content {
  max-width: 800px;
  margin: 0 auto;
}

.conversion-options {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-xl);
  margin: var(--s-xl) 0;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s-lg);
}

.option-group label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--s-sm);
}

.option-group select,
.option-group input {
  width: 100%;
  padding: var(--s-sm) var(--s-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.option-group small {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  margin-top: var(--s-xs);
  display: block;
}

/* Performance optimizations complete */