import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
import { AuthProvider } from './context/AuthContext'
import { ProtectedRoute } from './components/ProtectedRoute'
import { LoginPage } from './pages/LoginPage'
import { RegisterPage } from './pages/RegisterPage'
import { DashboardPage } from './pages/DashboardPage'
import { UsersPage } from './pages/UsersPage'
import { LdapSettingsPage } from './pages/LdapSettingsPage'
import { TimeTrackingPage } from './pages/TimeTrackingPage'
import { AbsencesPage } from './pages/AbsencesPage'
import { SmtpSettingsPage } from './pages/SmtpSettingsPage'
import { ForgotPasswordPage } from './pages/ForgotPasswordPage'
import { ResetPasswordPage } from './pages/ResetPasswordPage'
import { WorkSchedulePage } from './pages/WorkSchedulePage'
import { CalendarPage } from './pages/CalendarPage'
import { ReportsPage } from './pages/ReportsPage'
import { CaldavSettingsPage } from './pages/CaldavSettingsPage'
import { AbsenceTypesPage } from './pages/AbsenceTypesPage'
import ImportPage from './pages/ImportPage'
import UserImportPage from './pages/UserImportPage'
import { CompanySettingsPage } from './pages/CompanySettingsPage'
import { QrStampSettingsPage } from './pages/QrStampSettingsPage'
import { ProfilePage } from './pages/ProfilePage'
import { KioskDevicesPage } from './pages/KioskDevicesPage'
import { AuditLogPage } from './pages/AuditLogPage'
import { KioskSetupPage } from './pages/KioskSetupPage'
import { KioskStampPage } from './pages/KioskStampPage'
import { PublicStampPage } from './pages/PublicStampPage'
import { MobilePage } from './pages/mobile/MobilePage'
import { MobileLoginPage } from './pages/mobile/MobileLoginPage'
import { SpecialAssignmentsPage } from './pages/SpecialAssignmentsPage'
import { HoursPayoutPage } from './pages/HoursPayoutPage'
import { TenantsPage } from './pages/TenantsPage'
import { ResellerCompaniesPage } from './pages/ResellerCompaniesPage'
import { SettingsPage } from './pages/SettingsPage'

export default function App() {
  return (
    <BrowserRouter>
      <AuthProvider>
        <Routes>
          <Route path='/login'              element={<LoginPage />} />
          <Route path='/register'           element={<RegisterPage />} />
          <Route path='/forgot-password'    element={<ForgotPasswordPage />} />
          <Route path='/auth/reset-password' element={<ResetPasswordPage />} />
          <Route path='/kiosk/setup' element={<KioskSetupPage />} />
          <Route path='/kiosk'       element={<KioskStampPage />} />
          <Route path='/stamp'        element={<PublicStampPage />} />
          <Route path='/mobile'       element={<MobilePage />} />
          <Route path='/mobile/login' element={<MobileLoginPage />} />
          <Route element={<ProtectedRoute />}>
            <Route path='/dashboard'      element={<DashboardPage />} />
            <Route path='/time'           element={<TimeTrackingPage />} />
            <Route path='/absences'       element={<AbsencesPage />} />
            <Route path='/users'          element={<UsersPage />} />
            <Route path='/users/import'   element={<UserImportPage />} />
            <Route path='/settings'       element={<SettingsPage />} />
            <Route path='/settings/ldap'  element={<LdapSettingsPage />} />
            <Route path='/settings/smtp'  element={<SmtpSettingsPage />} />
            <Route path='/work-schedules' element={<WorkSchedulePage />} />
            <Route path='/calendar'       element={<CalendarPage />} />
            <Route path='/reports'           element={<ReportsPage />} />
            <Route path='/settings/caldav'         element={<CaldavSettingsPage />} />
            <Route path='/settings/absence-types'  element={<AbsenceTypesPage />} />
            <Route path='/settings/import'         element={<ImportPage />} />
            <Route path='/settings/company'        element={<CompanySettingsPage />} />
            <Route path='/settings/kiosk'          element={<KioskDevicesPage />} />
            <Route path='/settings/qr-stamp'       element={<QrStampSettingsPage />} />
            <Route path='/settings/audit-log'      element={<AuditLogPage />} />
            <Route path='/hr/special-assignments'  element={<SpecialAssignmentsPage />} />
            <Route path='/hr/payouts'              element={<HoursPayoutPage />} />
            <Route path='/admin/tenants'           element={<TenantsPage />} />
            <Route path='/reseller'                element={<ResellerCompaniesPage />} />
            <Route path='/profile'                 element={<ProfilePage />} />
          </Route>
          <Route path='*' element={<Navigate to='/login' replace />} />
        </Routes>
      </AuthProvider>
    </BrowserRouter>
  )
}
