import { Toaster } from "@/components/ui/toaster";
import { Toaster as Sonner } from "@/components/ui/sonner";
import { TooltipProvider } from "@/components/ui/tooltip";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Index from "./pages/Index";
import Themes from "./pages/Themes";
import Puzzles from "./pages/Puzzles";
import Miscellany from "./pages/Miscellany";
import DiscreteMath from "./pages/theme-pages/DiscreteMath";
import SocialChoice from "./pages/theme-pages/SocialChoice";
import AdvancedAlgorithms from "./pages/theme-pages/AdvancedAlgorithms";
import DataStructures from "./pages/theme-pages/DataStructures";
import Games from "./pages/theme-pages/Games";
import CardsMath from "./pages/theme-pages/CardsMath";
import BinaryNumberGamePage from "./pages/BinaryNumberGamePage";
import BinaryNumberGameGreenScreen from "./pages/BinaryNumberGameGreenScreen";
import BinarySearchTrickPage from "./pages/BinarySearchTrickPage";
import BinarySearchTrickGreenScreen from "./pages/BinarySearchTrickGreenScreen";
import GameOfSimGreenScreen from "./pages/GameOfSimGreenScreen";
import GameOfSimPage from "./pages/GameOfSimPage";
import Foundations from "./pages/theme-pages/discrete-math/Foundations";
import Proofs from "./pages/theme-pages/discrete-math/Proofs";
import Counting from "./pages/theme-pages/discrete-math/Counting";
import Uncertainty from "./pages/theme-pages/discrete-math/Uncertainty";
import Structures from "./pages/theme-pages/discrete-math/Structures";
import Numbers from "./pages/theme-pages/discrete-math/Numbers";
import Graphs from "./pages/theme-pages/discrete-math/Graphs";
import NotFound from "./pages/NotFound";

const queryClient = new QueryClient();

const App = () => (
  <QueryClientProvider client={queryClient}>
    <TooltipProvider>
      <Toaster />
      <Sonner />
      <BrowserRouter>
        <Routes>
          <Route path="/" element={<Index />} />
          <Route path="/themes" element={<Themes />} />
          <Route path="/puzzles" element={<Puzzles />} />
          <Route path="/miscellany" element={<Miscellany />} />
          
          {/* Theme-specific routes */}
          <Route path="/themes/discrete-math" element={<DiscreteMath />} />
          <Route path="/themes/discrete-math/foundations" element={<Foundations />} />
          <Route path="/themes/discrete-math/proofs" element={<Proofs />} />
          <Route path="/themes/discrete-math/counting" element={<Counting />} />
          <Route path="/themes/discrete-math/uncertainty" element={<Uncertainty />} />
          <Route path="/themes/discrete-math/structures" element={<Structures />} />
          <Route path="/themes/discrete-math/numbers" element={<Numbers />} />
          <Route path="/themes/discrete-math/graphs" element={<Graphs />} />
          <Route path="/themes/social-choice" element={<SocialChoice />} />
          <Route path="/themes/advanced-algorithms" element={<AdvancedAlgorithms />} />
          <Route path="/themes/data-structures" element={<DataStructures />} />
          <Route path="/themes/games" element={<Games />} />
          <Route path="/themes/cards-math" element={<CardsMath />} />
          
          {/* Direct interactive routes */}
          <Route path="/binary-number-game" element={<BinaryNumberGamePage />} />
          <Route path="/binary-number-game/:mode" element={<BinaryNumberGameGreenScreen />} />
          <Route path="/binary-search-trick" element={<BinarySearchTrickPage />} />
          <Route path="/binary-search-trick/:mode" element={<BinarySearchTrickGreenScreen />} />
          <Route path="/game-of-sim" element={<GameOfSimPage />} />
          <Route path="/game-of-sim/:mode" element={<GameOfSimGreenScreen />} />
          
          {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
          <Route path="*" element={<NotFound />} />
        </Routes>
      </BrowserRouter>
    </TooltipProvider>
  </QueryClientProvider>
);

export default App;
