import { Routes } from '@angular/router'
import { VerticalLayout } from '@layouts/vertical-layout/vertical-layout'
import { authGuard } from '@core/guards/auth.guard'
import { roleGuard } from '@core/guards/role.guard'

export const routes: Routes = [
  { path: '', redirectTo: '/dcb-dashboard', pathMatch: 'full' },

  // Routes publiques (auth)
  {
    path: '',
    loadChildren: () =>
      import('./modules/auth/auth.route').then(mod => mod.Auth_ROUTES),
  },

  // Routes d'erreur (publiques)
  {
    path: '',
    loadChildren: () =>
      import('./modules/auth/error/error.route').then(mod => mod.ERROR_PAGES_ROUTES),
  },

  // Routes protégées
  {
    path: '',
    component: VerticalLayout,
    canActivate: [authGuard, roleGuard],
    loadChildren: () =>
      import('./modules/modules-routing.module').then(
        m => m.ModulesRoutingModule
      ),
  },

  // Redirections pour les erreurs courantes
  { path: '404', redirectTo: '/error/404' },
  { path: '403', redirectTo: '/error/403' },

  // Catch-all - Rediriger vers 404 au lieu de login
  { path: '**', redirectTo: '/error/404' },
]