import { Navigate, Route, Routes } from "react-router-dom";
import { DocsLayout } from "./layouts/DocsLayout";
import { NotFound } from "./components/NotFound";
import { CustomPagesProvider } from "./lib/customPagesStore";
import { OverviewPage } from "./pages/docs/OverviewPage";
import { ArchitecturePage } from "./pages/docs/ArchitecturePage";
import { TechStackPage } from "./pages/docs/TechStackPage";
import { BackendPage } from "./pages/docs/BackendPage";
import { AgentsPage } from "./pages/docs/AgentsPage";
import { GameplayPage } from "./pages/docs/GameplayPage";
import { ShipsPage } from "./pages/docs/ShipsPage";
import { EconomyPage } from "./pages/docs/EconomyPage";
import { SocialPage } from "./pages/docs/SocialPage";
import { ShipAIPage } from "./pages/docs/ShipAIPage";
import { RoadmapPage } from "./pages/docs/RoadmapPage";
import { RisksPage } from "./pages/docs/RisksPage";
import { DemoGalleryPage } from "./pages/docs/DemoGalleryPage";
import { GapAnalysisPage } from "./pages/docs/GapAnalysisPage";
import { VerticalSliceEvaluationPage } from "./pages/docs/VerticalSliceEvaluationPage";
import { DesignDocPage } from "./pages/docs/DesignDocPage";
import { KanbanBoardPage } from "./pages/docs/KanbanBoardPage";
import { CustomPagesIndexPage } from "./pages/docs/CustomPagesIndexPage";
import { CustomPageView } from "./pages/docs/CustomPageView";
import { StarMapDemo } from "./prototypes/existing-demos/StarMapDemo";
import { ShipMovementDemo } from "./prototypes/existing-demos/ShipMovementDemo";
import { WarpTravelDemo } from "./prototypes/existing-demos/WarpTravelDemo";
import { GameLoopSliceDemo } from "./prototypes/existing-demos/GameLoopSliceDemo";
import { CombatDemo } from "./prototypes/existing-demos/CombatDemo";
import { MarketDemo } from "./prototypes/existing-demos/MarketDemo";
import { FittingDemo } from "./prototypes/existing-demos/FittingDemo";
import { RefiningDemo } from "./prototypes/existing-demos/RefiningDemo";
import { ProgressionDemo } from "./prototypes/existing-demos/ProgressionDemo";
import { BountyDemo } from "./prototypes/existing-demos/BountyDemo";
import { GameHudDemo } from "./prototypes/existing-demos/GameHudDemo";
import { ChatDemo } from "./prototypes/existing-demos/ChatDemo";
import { ZoraDemo } from "./prototypes/existing-demos/ZoraDemo";
import { GalaxyDemo } from "./prototypes/existing-demos/GalaxyDemo";
import { GameHudPrototype } from "./prototypes/standalone-huds/GameHudPrototype";

export function App() {
  return (
    <CustomPagesProvider>
      <Routes>
        <Route path="/" element={<Navigate to="/docs" replace />} />

        <Route path="/docs" element={<DocsLayout />}>
          <Route index element={<Navigate to="/docs/overview" replace />} />
          <Route path="overview" element={<OverviewPage />} />
          <Route path="architecture" element={<ArchitecturePage />} />
          <Route path="tech-stack" element={<TechStackPage />} />
          <Route path="backend" element={<BackendPage />} />
          <Route path="agents" element={<AgentsPage />} />
          <Route path="gameplay" element={<GameplayPage />} />
          <Route path="ships" element={<ShipsPage />} />
          <Route path="economy" element={<EconomyPage />} />
          <Route path="social" element={<SocialPage />} />
          <Route path="ship-ai" element={<ShipAIPage />} />
          <Route path="roadmap" element={<RoadmapPage />} />
          <Route path="risks" element={<RisksPage />} />
          <Route path="demo-gallery" element={<DemoGalleryPage />} />
          <Route path="gap-analysis" element={<GapAnalysisPage />} />
          <Route path="vertical-slice-evaluation" element={<VerticalSliceEvaluationPage />} />
          <Route path="design-doc" element={<DesignDocPage />} />
          <Route path="kanban-board" element={<KanbanBoardPage />} />

          {/* User-created dynamic documentation pages */}
          <Route path="custom" element={<CustomPagesIndexPage />} />
          <Route path="custom/new" element={<CustomPageView mode="create" />} />
          <Route path="custom/:slug" element={<CustomPageView mode="view" />} />

          <Route path="demos/starmap" element={<StarMapDemo />} />
          <Route path="demos/game-loop" element={<GameLoopSliceDemo />} />
          <Route path="demos/movement" element={<ShipMovementDemo />} />
          <Route path="demos/warp" element={<WarpTravelDemo />} />
          <Route path="demos/combat" element={<CombatDemo />} />
          <Route path="demos/market" element={<MarketDemo />} />
          <Route path="demos/fitting" element={<FittingDemo />} />
          <Route path="demos/refining" element={<RefiningDemo />} />
          <Route path="demos/progression" element={<ProgressionDemo />} />
          <Route path="demos/bounty" element={<BountyDemo />} />
          <Route path="demos/game-hud" element={<GameHudDemo />} />
          <Route path="demos/chat" element={<ChatDemo />} />
          <Route path="demos/zora" element={<ZoraDemo />} />
          <Route path="demos/galaxy" element={<GalaxyDemo />} />

          <Route path="prototypes/game-hud" element={<GameHudPrototype />} />
          <Route path="*" element={<NotFound />} />
        </Route>

        <Route path="*" element={<NotFound />} />
      </Routes>
    </CustomPagesProvider>
  );
}
