import { createBrowserRouter } from "react-router-dom";
import { AppLayout } from "@/components/AppLayout";
import { ProtectedRoute } from "@/components/ProtectedRoute";
import { LoginPage } from "@/pages/LoginPage";
import { OverviewPage } from "@/pages/OverviewPage";
import { PoliciesPage } from "@/pages/PoliciesPage";
import { UsersPage } from "@/pages/UsersPage";
import { ProvidersPage } from "@/pages/ProvidersPage";
import { AlertsPage } from "@/pages/AlertsPage";
import { LogsPage } from "@/pages/LogsPage";
import { PlaygroundPage } from "@/pages/PlaygroundPage";
import { SecurityPage } from "@/pages/SecurityPage";
import { CostsPage } from "@/pages/CostsPage";
import { CompliancePage } from "@/pages/CompliancePage";
import { NotFoundPage } from "@/pages/NotFoundPage";

export const router = createBrowserRouter([
  {
    path: "/login",
    element: <LoginPage />,
  },
  {
    path: "/callback",
    // OIDC redirect handler — AuthProvider handles the callback automatically
    element: <LoginPage />,
  },
  {
    path: "/",
    element: (
      <ProtectedRoute>
        <AppLayout />
      </ProtectedRoute>
    ),
    children: [
      { index: true, element: <OverviewPage /> },
      { path: "playground", element: <PlaygroundPage /> },
      { path: "policies", element: <PoliciesPage /> },
      { path: "users", element: <UsersPage /> },
      { path: "providers", element: <ProvidersPage /> },
      { path: "security", element: <SecurityPage /> },
      { path: "costs", element: <CostsPage /> },
      { path: "alerts", element: <AlertsPage /> },
      { path: "logs", element: <LogsPage /> },
      { path: "compliance", element: <CompliancePage /> },
      { path: "*", element: <NotFoundPage /> },
    ],
  },
]);
