import { Routes } from '@angular/router';
import { AuthGuard } from './shared/services/auth/auth.guard';

export const routes: Routes = [
    // Rota de autenticação - fora do layout principal
    { 
      path: '', 
      pathMatch: 'full',
      redirectTo: 'signin'
    },
    { 
      path: 'signin', 
      loadComponent: () => import('./domain/session/signin/signin.component')
        .then(m => m.SigninComponent)
    },
    // Rotas protegidas - dentro do layout principal
    {
      path: 'app',
      loadComponent: () => import('./shared/components/main-layout/main-layout.component')
        .then(m => m.MainLayoutComponent),
      canActivate: [AuthGuard],
      children: [
        { 
          path: 'dashboard',
          loadComponent: () => import('./pages/dashboard/dashboard.component')
            .then(m => m.DashboardComponent)
        },
        { 
          path: 'typography',
          loadComponent: () => import('./shared/components/typography-showcase/typography-showcase.component')
            .then(m => m.TypographyShowcaseComponent)
        },
        { 
          path: 'drivers',
          loadComponent: () => import('./domain/drivers/drivers.component')
            .then(m => m.DriversComponent)
         },
         {
          path: 'driverperformance',
          loadComponent: () => import('./domain/driverperformance/driverperformance.component')
            .then(m => m.DriverperformanceComponent)
        },
        {
          path: 'vehicles',
          loadComponent: () => import('./domain/vehicles/vehicles.component')
            .then(m => m.VehiclesComponent)
        },
        {
          path: 'fuelcontroll',
          loadComponent: () => import('./domain/fuelcontroll/fuelcontroll.component')
            .then(m => m.FuelcontrollComponent)
        },    
        {
          path: 'devicetracker',
          loadComponent: () => import('./domain/devicetracker/devicetracker.component')
            .then(m => m.DevicetrackerComponent)
        },
        { 
          path: 'tollparking',
          loadComponent: () => import('./domain/tollparking/tollparking.component')
            .then(m => m.TollparkingComponent)
        },        
        { 
          path: 'maintenance',
          loadComponent: () => import('./pages/maintenance/maintenance.component')
            .then(m => m.MaintenanceComponent)
        },
        { 
          path: 'fuel',
          loadComponent: () => import('./pages/fuel/fuel.component')
            .then(m => m.FuelComponent)
        },
        { 
          path: 'finances/accountpayable',
          loadComponent: () => import('./domain/finances/account-payable/components/account-payable.component')
            .then(m => m.AccountPayableComponent)
        },
        { 
          path: 'finances/categories',
          loadComponent: () => import('./domain/finances/financial-category/financial-categories.component')
            .then(m => m.FinancialCategoriesComponent)
        },
        {
          path: 'finances/supplier',
          loadComponent: () => import('./domain/supplier/supplier.component')
            .then(m => m.SupplierComponent)
        },
        {
          path: 'contract',
          loadComponent: () => import('./domain/contract/contract.component')
            .then(m => m.ContractComponent)
        },
        { 
          path: 'routes',
          loadComponent: () => import('./domain/routes/routes.component')
            .then(m => m.RoutesComponent)
        },
        { 
          path: 'routes/mercado-live',
          loadComponent: () => import('./domain/routes/mercado-live/components/mercado-livre.component')
            .then(m => m.MercadoLiveComponent)
        },
        { 
          path: 'routes/shopee',
          loadComponent: () => import('./domain/routes/shopee/components/shopee.component')
            .then(m => m.ShopeeComponent)
        },
        { 
          path: 'reports',
          loadComponent: () => import('./pages/reports/reports.component')
            .then(m => m.ReportsComponent)
        },
        { 
          path: 'integration',
          loadComponent: () => import('./domain/integration/integration.component')
            .then(m => m.IntegrationComponent)
        },
        { 
          path: 'company',
          loadComponent: () => import('./domain/company/company.component')
            .then(m => m.CompanyComponent)
        },
        { 
          path: 'person',
          loadComponent: () => import('./domain/person/person.component')
            .then(m => m.PersonComponent)
        },
        { 
          path: 'settings',
          loadComponent: () => import('./pages/settings/settings.component')
            .then(m => m.SettingsComponent)
        },
        {
          path: 'product',
          loadComponent: () => import('./domain/product/product.component')
            .then(m => m.ProductComponent)
        },
        { 
          path: 'user',
          loadComponent: () => import('./domain/user/user.component')
            .then(m => m.UserComponent)
        },
        { 
          path: 'profile',
          loadComponent: () => import('./pages/profile/profile.component')
            .then(m => m.ProfileComponent)
        },
        { 
          path: 'customer',
          loadComponent: () => import('./domain/customer/customer.component')
            .then(m => m.CustomerComponent)
        },
        { 
          path: 'fines',
          loadComponent: () => import('./domain/fines/fines.component')
            .then(m => m.FinesComponent)
        },        
        {
          path: '', 
          redirectTo: 'dashboard', 
          pathMatch: 'full' 
        },
        { 
          path: 'design-system', 
          loadComponent: () => import('./pages/design-system/design-system.component')
            .then(m => m.DesignSystemComponent)
        },
      ]
    },
    // Wildcard route - redireciona para signin se não autenticado, senão para app
    { 
      path: '**', 
      redirectTo: 'signin' 
    }
]
