import React from "react";
import { Navigate, Route, Routes } from "react-router-dom";
import LoginRedirect from "../components/auth/LoginRedirect";
import ScrollToTop from "../components/common/ScrollToTop";
import { activityLogRoutes } from "../components/features/activitylog/routes";
import { auditManagementRoutes } from "../components/features/audit-management/routes";
import { dashboardRoutes } from "../components/features/dashboard/routes";
import { formRoutes } from "../components/features/form/routes";
import { questionsManagementRoutes } from "../components/features/questions-management/routes";
import { themeManagementRoutes } from "../components/features/theme-management/routes";
import { ticketingRoutes } from "../components/features/ticketing/routes";
import { userManagementRoutes } from "../components/features/user-management/routes";
import { siteAndWorkareaRoutes } from "../pages/routes";

/**
 * Application routes: composed from feature-owned route arrays with lazy-loaded screens.
 * Arrays are expanded so `<Route>` elements remain direct children of `<Routes>` (RR v6).
 */
export default function AppRoutes() {
  return (
    <>
      <ScrollToTop />
      <Routes>
        <Route path="/login" element={<LoginRedirect />} />
        {dashboardRoutes}
        {activityLogRoutes}
        {userManagementRoutes}
        {siteAndWorkareaRoutes}
        {themeManagementRoutes}
        {formRoutes}
        {questionsManagementRoutes}
        {auditManagementRoutes}
        {ticketingRoutes}
        <Route path="*" element={<Navigate to="/dashboard" replace />} />
      </Routes>
    </>
  );
}
