/**
 * @license
 * SPDX-License-Identifier: Apache-2.0
 */

import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import { AuthProvider } from './AuthContext';
import { LandingPage } from './pages/LandingPage';
import { StudentExamEntry } from './pages/StudentExamEntry';
import { TeacherAuth } from './pages/TeacherAuth';
import { StudentDashboard } from './pages/StudentDashboard';
import { TeacherDashboard } from './pages/TeacherDashboard';
import { ExamInterface } from './pages/ExamInterface';
import { ExamResults } from './pages/ExamResults';
import { CreateExam } from './pages/CreateExam';
import { ExamReview } from './pages/ExamReview';

import { QuestionBank } from './pages/teacher/QuestionBank';
import { GroupManager } from './pages/teacher/GroupManager';

export default function App() {
  return (
    <AuthProvider>
      <BrowserRouter>
        <Routes>
          {/* Public Routes */}
          <Route path="/" element={<LandingPage />} />
          <Route path="/enter-exam" element={<StudentExamEntry />} />
          
          {/* Auth Routes */}
          <Route path="/auth/student" element={<StudentExamEntry />} />
          <Route path="/auth/teacher" element={<TeacherAuth />} />
          
          {/* Student Routes */}
          <Route path="/student/dashboard" element={<StudentDashboard />} />
          <Route path="/student/exam/:examId" element={<ExamInterface />} />
          <Route path="/student/results/:attemptId" element={<ExamResults />} />
          
          {/* Teacher Routes */}
          <Route path="/teacher/dashboard" element={<TeacherDashboard />} />
          <Route path="/teacher/questions" element={<QuestionBank />} />
          <Route path="/teacher/groups" element={<GroupManager />} />
          <Route path="/teacher/create" element={<CreateExam />} />
          <Route path="/teacher/review/:examId" element={<ExamReview />} />
          
          {/* Fallback */}
          <Route path="*" element={<Navigate to="/" replace />} />
        </Routes>
      </BrowserRouter>
    </AuthProvider>
  );
}

