import { createBrowserRouter } from 'react-router-dom';
import { HomePage } from './components/home/HomePage';
import { LoginForm } from './components/auth/LoginForm';
import { SchoolRegistrationForm } from './components/auth/SchoolRegistrationForm';
import { RegistrationForm } from './components/RegistrationForm';
import { StoryViewer } from './components/StoryViewer';
import { AuthCallback } from './pages/AuthCallback';
import { DashboardLayout } from './pages/dashboard/DashboardLayout';
import { DashboardHome } from './pages/dashboard/DashboardHome';
import { ClassesPage } from './pages/dashboard/classes/ClassesPage';
import { CreateClassPage } from './pages/dashboard/classes/CreateClassPage';
import { TeachersPage } from './pages/dashboard/teachers/TeachersPage';
import { InviteTeacherPage } from './pages/dashboard/teachers/InviteTeacherPage';
import { StudentsPage } from './pages/dashboard/students/StudentsPage';
import { AddStudentPage } from './pages/dashboard/students/AddStudentPage';
import { SettingsPage } from './pages/dashboard/settings/SettingsPage';
import { StudentDashboardPage } from './pages/student-dashboard/StudentDashboardPage';
import { StudentDashboardLayout } from './pages/student-dashboard/StudentDashboardLayout';
import { StudentStoriesPage } from './pages/student-dashboard/StudentStoriesPage';
import { StudentSettingsPage } from './pages/student-dashboard/StudentSettingsPage';
import { CreateStoryPage } from './pages/student-dashboard/CreateStoryPage';
import { StoryPageDemo } from './pages/demo/StoryPageDemo';
import { StoryPage } from './pages/student-dashboard/StoryPage';
import { ProtectedRoute } from './components/auth/ProtectedRoute';
import { UserManagementPage } from './pages/admin/UserManagementPage';
import { AchievementsPage } from './pages/student-dashboard/AchievementsPage';
import { StudentClassPage } from './pages/student-dashboard/StudentClassPage';
import { DemoPage } from './pages/demo/DemoPage';
import { ParentsLandingPage } from './pages/landing/ParentsLandingPage';

export const router = createBrowserRouter([
  {
    path: '/',
    element: <HomePage />,
  },
  {
    path: '/para-pais',
    element: <ParentsLandingPage />,
  },
  {
    path: '/login',
    children: [
      {
        path: 'school',
        element: <LoginForm userType="school" />,
      },
      {
        path: 'teacher',
        element: <LoginForm userType="teacher" />,
      },
      {
        path: 'student',
        element: <LoginForm userType="student" />,
      }
    ]
  },
  {
    path: '/register',
    children: [
      {
        path: 'school',
        element: <SchoolRegistrationForm />,
      },
      {
        path: 'teacher',
        element: <RegistrationForm 
          userType="teacher"
          onComplete={(userData) => {
            console.log('Registro completo:', userData);
          }} 
        />,
      }
    ]
  },
  {
    path: '/dashboard',
    element: (
      <ProtectedRoute allowedRoles={['school']}>
        <DashboardLayout />
      </ProtectedRoute>
    ),
    children: [
      {
        index: true,
        element: <DashboardHome />,
      },
      {
        path: 'turmas',
        children: [
          {
            index: true,
            element: <ClassesPage />,
          },
          {
            path: 'nova',
            element: <CreateClassPage />,
          }
        ]
      },
      {
        path: 'professores',
        children: [
          {
            index: true,
            element: <TeachersPage />,
          },
          {
            path: 'convidar',
            element: <InviteTeacherPage />,
          }
        ]
      },
      {
        path: 'alunos',
        children: [
          {
            index: true,
            element: <StudentsPage />,
          },
          {
            path: 'novo',
            element: <AddStudentPage />,
          }
        ]
      },
      {
        path: 'configuracoes',
        element: <SettingsPage />
      }
    ]
  },
  {
    path: '/demo',
    element: <StoryPageDemo />
  },
  {
    path: '/auth/callback',
    element: <AuthCallback />
  },
  {
    path: '/aluno',
    element: (
      <ProtectedRoute allowedRoles={['student']}>
        <StudentDashboardLayout />
      </ProtectedRoute>
    ),
    children: [
      {
        index: true,
        element: <StudentDashboardPage />,
      },
      {
        path: 'historias',
        children: [
          {
            index: true,
            element: <StudentStoriesPage />,
          },
          {
            path: 'nova',
            element: <CreateStoryPage />,
          },
          {
            path: ':id',
            element: <StoryPage />,
          }
        ]
      },
      {
        path: 'configuracoes',
        element: <StudentSettingsPage />,
      },
      {
        path: 'conquistas',
        element: <AchievementsPage />,
      },
      {
        path: 'turmas/:classId',
        element: <StudentClassPage />,
      }
    ]
  },
  {
    path: '/admin/users',
    element: (
      <ProtectedRoute allowedRoles={['admin']}>
        <UserManagementPage />
      </ProtectedRoute>
    ),
  }
]); 