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

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

  // ===== ROUTES D'ERREUR (publiques) =====
  {
    path: 'error',
    loadChildren: () => import('./modules/auth/error/error.routes').then(mod => mod.ERROR_PAGES_ROUTES),
  },

  // ===== ROUTES PUBLIQUES =====
  {
    path: 'auth',
    loadChildren: () => import('./modules/auth/auth.routes').then(mod => mod.AUTH_ROUTES),
  },

  // ===== ROUTES PROTÉGÉES - Layout Principal =====
  {
    path: '',
    component: VerticalLayout,
    canActivate: [authGuard],
    children: [
      {
        path: '',
        loadChildren: () => import('./modules/modules.routes').then(m => m.ModulesRoutes),
      }
    ]
  },

  // ===== REDIRECTIONS POUR LES ERREURS =====
  { path: '404', redirectTo: '/error/404' },
  { path: '403', redirectTo: '/error/403' },
  { path: '401', redirectTo: '/auth/sign-in' },
  { path: 'unauthorized', redirectTo: '/error/403' },

  // ===== CATCH-ALL =====
  { path: '**', redirectTo: '/error/404' },
];