import { Navigate, Route, Routes } from "react-router-dom";
import { AppShell } from "@/layouts/app-shell";
import { ProtectedRoute } from "@/components/ProtectedRoute";
import LoginPage from "@/pages/login";
import DashboardPage from "@/pages/admin/dashboard";
import UsersPage from "@/pages/admin/users";
import UserDetailsPage from "@/pages/admin/users/[id]";
import UserActivityPage from "@/pages/admin/users/[id]/activity";
import ActivityLogPage from "@/pages/activity-log";
import SettingsPage from "@/pages/admin/settings";
import MaintenancePage from "@/pages/admin/maintenance";
import AnnouncementsPage from "@/pages/admin/announcements";
import AuditPage from "@/pages/admin/audit";
import SecurityPage from "@/pages/admin/security";
import FailedLoginsPage from "@/pages/admin/security/failed-logins";
import SuspiciousActivityPage from "@/pages/admin/security/suspicious";
import ApiKeysPage from "@/pages/admin/security/api-keys";
import RateLimitsPage from "@/pages/admin/security/rate-limits";
import SessionsPage from "@/pages/admin/security/sessions";
import AnalyticsPage from "@/pages/admin/analytics";
import AnalyticsOverviewPage from "@/pages/admin/analytics/overview";
import AnalyticsUsersPage from "@/pages/admin/analytics/users";
import AnalyticsRevenuePage from "@/pages/admin/analytics/revenue";
import AnalyticsStoragePage from "@/pages/admin/analytics/storage";
import AnalyticsApiPage from "@/pages/admin/analytics/api";
import HealthPage from "@/pages/admin/health";
import NotificationsPage from "@/pages/notifications";
import PaymentsListPage from "@/pages/admin/payments/payments-list";
import PaymentRequestsPage from "@/pages/admin/payments/payment-requests";
import InvoicesPage from "@/pages/admin/invoices/invoices-list";
import ProformaPage from "@/pages/admin/invoices/proforma-list";
import ProformaRequestsPage from "@/pages/admin/invoices/proforma-requests";

function App() {
  return (
    <Routes>
      <Route path="/login" element={<LoginPage />} />
      <Route
        element={
          <ProtectedRoute>
            <AppShell />
          </ProtectedRoute>
        }
      >
        <Route index element={<Navigate to="/admin/dashboard" replace />} />
        <Route path="admin/dashboard" element={<DashboardPage />} />
        <Route path="admin/users" element={<UsersPage />} />
        <Route path="admin/users/:id" element={<UserDetailsPage />} />
        <Route path="admin/users/:id/activity" element={<UserActivityPage />} />
        <Route path="admin/logs" element={<ActivityLogPage />} />
        <Route path="admin/logs/errors" element={<ActivityLogPage />} />
        <Route path="admin/logs/access" element={<ActivityLogPage />} />
        <Route path="admin/logs/:id" element={<ActivityLogPage />} />
        <Route path="admin/settings" element={<SettingsPage />} />
        <Route path="admin/maintenance" element={<MaintenancePage />} />
        <Route path="admin/announcements" element={<AnnouncementsPage />} />
        <Route path="admin/audit" element={<AuditPage />} />
        <Route path="admin/security" element={<SecurityPage />} />
        <Route
          path="admin/security/failed-logins"
          element={<FailedLoginsPage />}
        />
        <Route
          path="admin/security/suspicious"
          element={<SuspiciousActivityPage />}
        />
        <Route path="admin/security/api-keys" element={<ApiKeysPage />} />
        <Route path="admin/security/rate-limits" element={<RateLimitsPage />} />
        <Route path="admin/security/sessions" element={<SessionsPage />} />
        <Route path="admin/analytics" element={<AnalyticsPage />} />
        <Route
          path="admin/analytics/overview"
          element={<AnalyticsOverviewPage />}
        />
        <Route path="admin/analytics/users" element={<AnalyticsUsersPage />} />
        <Route
          path="admin/analytics/revenue"
          element={<AnalyticsRevenuePage />}
        />
        <Route
          path="admin/analytics/storage"
          element={<AnalyticsStoragePage />}
        />
        <Route path="admin/analytics/api" element={<AnalyticsApiPage />} />
        <Route path="admin/payments" element={<PaymentsListPage />} />
        <Route
          path="admin/payment-requests"
          element={<PaymentRequestsPage />}
        />
        <Route path="admin/invoices" element={<InvoicesPage />} />
        <Route path="admin/proforma" element={<ProformaPage />} />
        <Route
          path="admin/proforma-requests"
          element={<ProformaRequestsPage />}
        />
        <Route path="admin/health" element={<HealthPage />} />
        <Route path="notifications" element={<NotificationsPage />} />
      </Route>
      <Route path="*" element={<Navigate to="/admin/dashboard" replace />} />
    </Routes>
  );
}

export default App;
