/* ═══════════════════════════════════════════════════════════════
   L8AB TOOLS — UX Upgrades v3.0
   • Instant search with highlights & "no results" state
   • Smooth Dark / Light mode with transitions
   • Mobile: full-screen nav overlay, bottom search bar,
             touch-friendly cards, scroll-snap categories
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. SMOOTH THEME TRANSITIONS ─────────────────────────────── */
*, *::before, *::after {
  transition:
    background-color 0.35s ease,
    color            0.25s ease,
    border-color     0.25s ease,
    box-shadow       0.25s ease !important;
}
/* Don't animate transforms (breaks hover effects) */
.tool-card, .feature-card, .filter-btn, button {
  transition:
    background-color 0.35s ease,
    color            0.25s ease,
    border-color     0.25s ease,
    box-shadow       0.25s ease,
    transform        0.25s cubic-bezier(0.22,1,0.36,1),
    opacity          0.25s ease !important;
}

/* ── 2. LIGHT MODE ───────────────────────────────────────────── */
body.light-mode {
  --dark:       #f0f4ff;
  --dark-card:  #ffffff;
  --text:       #1e293b;
  --text-muted: #64748b;
  --border:     rgba(99,102,241,0.15);
  background: #f0f4ff !important;
  color: #1e293b !important;
}
body.light-mode .navbar {
  background: rgba(240,244,255,0.9) !important;
  border-bottom: 1px solid rgba(99,102,241,0.15) !important;
}
body.light-mode .tool-card,
body.light-mode .feature-card,
body.light-mode .card {
  background: #ffffff !important;
  border-color: rgba(99,102,241,0.12) !important;
  color: #1e293b !important;
  box-shadow: 0 2px 16px rgba(99,102,241,0.06) !important;
}
body.light-mode .tool-card:hover {
  border-color: rgba(99,102,241,0.35) !important;
  box-shadow: 0 8px 32px rgba(99,102,241,0.15) !important;
}
body.light-mode .tool-card h3,
body.light-mode .tool-card p {
  color: #1e293b !important;
}
body.light-mode .tool-card p { color: #64748b !important; }
body.light-mode .search-box {
  background: #ffffff !important;
  border-color: rgba(99,102,241,0.2) !important;
}
body.light-mode .search-box input {
  background: transparent !important;
  color: #1e293b !important;
}
body.light-mode .filter-btn {
  background: rgba(99,102,241,0.06) !important;
  color: #475569 !important;
  border-color: rgba(99,102,241,0.12) !important;
}
body.light-mode .filter-btn.active,
body.light-mode .filter-btn:hover {
  background: rgba(99,102,241,0.15) !important;
  color: #4f46e5 !important;
}
body.light-mode .category-title { color: #334155 !important; }
body.light-mode .hero { background: transparent !important; }
body.light-mode .hero-title { color: #0f172a !important; }
body.light-mode .hero-subtitle { color: #475569 !important; }
body.light-mode .feature-badge {
  background: rgba(99,102,241,0.08) !important;
  color: #4f46e5 !important;
  border-color: rgba(99,102,241,0.2) !important;
}
body.light-mode .nav-menu a { color: #475569 !important; }
body.light-mode .nav-menu a:hover { color: #4f46e5 !important; }
body.light-mode .logo-text { /* keep gradient */ }
body.light-mode::before {
  background-image: radial-gradient(rgba(99,102,241,0.04) 1px, transparent 1px) !important;
}
body.light-mode footer {
  background: rgba(240,244,255,0.95) !important;
  color: #475569 !important;
}
body.light-mode .stat-label { color: #94a3b8 !important; }

/* ── 3. THEME TOGGLE BUTTON ─────────────────────────────────── */
#l8ab-theme-btn {
  position: fixed;
  bottom: 5rem; right: 1.25rem;
  z-index: 200;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(11,17,40,0.9);
  border: 1px solid rgba(99,102,241,0.3);
  backdrop-filter: blur(12px);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1),
              box-shadow 0.2s !important;
}
#l8ab-theme-btn:hover {
  transform: scale(1.1) rotate(15deg);
  box-shadow: 0 6px 28px rgba(99,102,241,0.4);
}
body.light-mode #l8ab-theme-btn {
  background: rgba(255,255,255,0.95) !important;
  border-color: rgba(99,102,241,0.2) !important;
}

/* ── 4. SEARCH — ENHANCED ────────────────────────────────────── */
.search-box {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  background: rgba(11,17,40,0.8) !important;
  border: 1.5px solid rgba(99,102,241,0.2) !important;
  border-radius: 14px !important;
  padding: 0.6rem 1rem !important;
  backdrop-filter: blur(12px) !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
}
.search-box:focus-within {
  border-color: rgba(99,102,241,0.6) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1),
              0 4px 20px rgba(99,102,241,0.12) !important;
}
.search-box input {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  color: #e2e8f0 !important;
  font-size: 0.95rem !important;
  width: 100% !important;
  font-family: inherit !important;
  box-shadow: none !important;
}
.search-box input::placeholder { color: #64748b !important; }
#clear-search {
  background: rgba(99,102,241,0.15) !important;
  border: none !important;
  color: #94a3b8 !important;
  border-radius: 6px !important;
  width: 24px; height: 24px;
  font-size: 0.75rem !important;
  cursor: pointer !important;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, color 0.2s !important;
  flex-shrink: 0;
}
#clear-search:hover {
  background: rgba(244,63,94,0.2) !important;
  color: #f43f5e !important;
}

/* Search result count badge */
#l8ab-search-count {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 0.5rem;
  transition: opacity 0.3s;
}

/* Highlight matched text */
.search-highlight {
  background: rgba(99,102,241,0.3);
  color: #c7d2fe;
  border-radius: 3px;
  padding: 0 2px;
}

/* No results state */
#l8ab-no-results {
  display: none;
  text-align: center;
  padding: 4rem 2rem;
  color: #475569;
}
#l8ab-no-results .no-results-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}
#l8ab-no-results h3 {
  font-size: 1.25rem;
  color: #64748b;
  margin-bottom: 0.5rem;
}
#l8ab-no-results p { font-size: 0.9rem; color: #475569; }

/* Tool cards — add transition for hide/show */
.tool-card {
  transition:
    transform 0.25s cubic-bezier(0.22,1,0.36,1),
    opacity   0.2s ease,
    box-shadow 0.25s,
    border-color 0.25s !important;
}
.tool-card.search-hidden {
  display: none !important;
}

/* ── 5. FILTER BUTTONS ───────────────────────────────────────── */
.filter-buttons {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.5rem !important;
}
.filter-btn {
  padding: 0.45rem 1rem !important;
  border-radius: 20px !important;
  border: 1px solid rgba(99,102,241,0.2) !important;
  background: rgba(99,102,241,0.06) !important;
  color: #94a3b8 !important;
  font-size: 0.85rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  white-space: nowrap !important;
}
.filter-btn:hover {
  background: rgba(99,102,241,0.12) !important;
  color: #c7d2fe !important;
  border-color: rgba(99,102,241,0.35) !important;
}
.filter-btn.active {
  background: linear-gradient(135deg,rgba(99,102,241,0.25),rgba(14,165,233,0.2)) !important;
  color: #a5b4fc !important;
  border-color: rgba(99,102,241,0.5) !important;
  font-weight: 600 !important;
}

/* ── 6. MOBILE IMPROVEMENTS ─────────────────────────────────── */
@media (max-width: 768px) {

  /* Full-screen nav overlay */
  .nav-menu {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important; right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    background: rgba(2,8,23,0.97) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    z-index: 999 !important;
    padding: 0 !important;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22,1,0.36,1) !important;
  }
  .nav-menu.open {
    opacity: 1 !important;
    pointer-events: all !important;
    transform: scale(1) !important;
  }
  .nav-menu li {
    width: 100% !important;
    text-align: center !important;
    border-bottom: 1px solid rgba(99,102,241,0.08) !important;
  }
  .nav-menu a {
    display: block !important;
    padding: 1.25rem 2rem !important;
    font-size: 1.2rem !important;
    font-weight: 600 !important;
    color: #e2e8f0 !important;
    letter-spacing: 0.02em !important;
  }
  .nav-menu a:hover { color: #818cf8 !important; }

  /* Hamburger → X transform */
  .hamburger {
    position: relative !important;
    z-index: 1000 !important;
  }

  /* 2 columns grid on mobile */
  .tools-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  /* Smaller tool cards on mobile */
  .tool-card {
    padding: 1rem !important;
  }
  .tool-card h3 { font-size: 0.9rem !important; }
  .tool-card p  { font-size: 0.78rem !important; display: -webkit-box !important; -webkit-line-clamp: 2 !important; -webkit-box-orient: vertical !important; overflow: hidden !important; }

  /* Filter scroll */
  .filter-buttons {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    padding-bottom: 0.5rem !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }
  .filter-buttons::-webkit-scrollbar { display: none !important; }

  /* Bigger touch targets */
  .filter-btn {
    flex-shrink: 0 !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.82rem !important;
  }

  /* Sticky search on mobile */
  .tools-controls {
    position: sticky !important;
    top: 60px !important;
    z-index: 50 !important;
    background: rgba(2,8,23,0.95) !important;
    backdrop-filter: blur(16px) !important;
    padding: 0.75rem 0 !important;
    margin: 0 -1rem !important;
    padding-left: 1rem !important; padding-right: 1rem !important;
    border-bottom: 1px solid rgba(99,102,241,0.1) !important;
  }

  /* Hero on mobile */
  .hero { padding: 3rem 0 2rem !important; }
  .hero-title { font-size: 1.9rem !important; line-height: 1.15 !important; }
  .hero-subtitle { font-size: 1rem !important; }
  .hero-features { gap: 0.5rem !important; }
  .feature-badge { font-size: 0.78rem !important; padding: 0.3rem 0.65rem !important; }

  /* Hero stats row */
  .hero-stats {
    flex-wrap: wrap !important;
    gap: 1rem !important;
  }
  .stat-item { flex: 1 1 40% !important; }

  /* Theme and back-to-top buttons */
  #l8ab-theme-btn {
    bottom: 5rem !important;
    right: 1rem !important;
    width: 44px !important; height: 44px !important;
  }
  #back-to-top {
    bottom: 1rem !important;
    right: 1rem !important;
  }

  /* Section title smaller */
  .section-title { font-size: 1.6rem !important; }

  /* Modal full-screen */
  .modal-content {
    width: 100% !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  /* Announcement smaller */
  #l8ab-announcement-overlay .ann-card {
    padding: 1.5rem !important;
    margin: 0.5rem !important;
    max-height: 90dvh !important;
  }
}

/* ── 7. BACK TO TOP BUTTON ──────────────────────────────────── */
#back-to-top {
  position: fixed !important;
  bottom: 1.5rem !important; right: 1.25rem !important;
  z-index: 200 !important;
  width: 48px !important; height: 48px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #6366f1, #0ea5e9) !important;
  border: none !important;
  color: #fff !important;
  font-size: 1.2rem !important;
  cursor: pointer !important;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4) !important;
  opacity: 0; pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.3s, transform 0.3s !important;
}
#back-to-top.visible {
  opacity: 1 !important;
  pointer-events: all !important;
  transform: translateY(0) !important;
}
#back-to-top:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 8px 28px rgba(99,102,241,0.55) !important;
}

/* ── 8. KEYBOARD SHORTCUT HINT ──────────────────────────────── */
.search-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.72rem;
  color: #64748b;
  font-family: monospace;
  margin-left: auto;
  flex-shrink: 0;
}
@media (max-width: 768px) { .search-shortcut { display: none; } }

/* ── 9. TOOL CARD COUNT BADGE ───────────────────────────────── */
.category-title {
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
}
.category-count {
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 20px;
  padding: 1px 10px;
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 500;
}
