import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter, Outlet, Route, Routes } from "react-router";
import { AppShell } from "@/components/layout/app-shell";
import { AuthGuard } from "@/components/layout/auth-guard";
import { NotFound } from "@/pages/not-found";
import { AllLeadsPage } from "@/pages/all-leads";
import { CampaignDetailPage } from "@/pages/campaign-detail";
import { CampaignsPage } from "@/pages/campaigns";
import { LeadWorkspacePage } from "@/pages/lead-workspace";
import { LoginPage } from "@/pages/login";
import { OutreachPage } from "@/pages/outreach";
import { AuthProvider } from "@/providers/auth-provider";
import { DataProvider } from "@/providers/data-provider";
import { RouteProvider } from "@/providers/router-provider";
import { ThemeProvider } from "@/providers/theme-provider";
import "@/styles/globals.css";

createRoot(document.getElementById("root")!).render(
    <StrictMode>
        <ThemeProvider>
            <AuthProvider>
                <DataProvider>
                    <BrowserRouter>
                        <RouteProvider>
                    <Routes>
                        <Route path="/login" element={<LoginPage />} />
                        <Route element={<AuthGuard />}>
                            <Route
                                element={
                                    <AppShell>
                                        <Outlet />
                                    </AppShell>
                                }
                            >
                                <Route path="/" element={<LeadWorkspacePage />} />
                                <Route path="/leads" element={<AllLeadsPage />} />
                                <Route path="/campaigns" element={<CampaignsPage />} />
                                <Route path="/campaigns/:id" element={<CampaignDetailPage />} />
                                <Route path="/outreach" element={<OutreachPage />} />
                                <Route path="*" element={<NotFound />} />
                            </Route>
                        </Route>
                    </Routes>
                        </RouteProvider>
                    </BrowserRouter>
                </DataProvider>
            </AuthProvider>
        </ThemeProvider>
    </StrictMode>,
);
