import { Component, ChangeDetectorRef } from "@angular/core";
import { CommonModule, DatePipe } from "@angular/common";
import { TitleService } from "../../../../shared/services/theme/title.service";
import { HeaderActionsService } from "../../../../shared/services/header-actions.service";
import { MercadoLivreService } from "../services/mercado-livre.service";
import { MercadoLiveRoute, MercadoLiveRouteRaw, FirstMileRoute, LineHaulRoute, LastMileRoute } from "../interfaces/mercado-livre.interface";
import { 
  FirstMileRoute as FirstMileRouteType, 
  LineHaulRoute as LineHaulRouteType, 
  LastMileRoute as LastMileRouteType,
  MercadoLiveRouteRaw as MercadoLiveRouteRawType 
} from "../interfaces/mercado-livre-types.interface";
import { TabSystemComponent } from "../../../../shared/components/tab-system/tab-system.component";
import { BaseDomainComponent, DomainConfig } from "../../../../shared/components/base-domain/base-domain.component";
import { TabFormConfigService } from "../../../../shared/components/tab-system/services/tab-form-config.service";
import { BulkAction } from "../../../../shared/interfaces/bulk-action.interface";
// import { MercadoLivreServiceAdapter } from "../services/mercado-livre-service-adapter";
import { Observable, forkJoin, map, of } from 'rxjs';
import { Logger } from "../../../../shared/services/logger";
import { TabFormConfig } from "../../../../shared/interfaces/generic-tab-form.interface";

/**
 * 🎯 MercadoLiveComponent - Filtros Avançados + 3 Consultas Específicas
 * 
 * ✨ Funcionalidades:
 * 1. **3 Consultas Simultâneas**: first_mile, line_haul, last_mile
 * 2. **Mapeamento Específico**: Cada tipo tem seu próprio mapper
 * 3. **Unificação**: Todos os resultados em uma única lista
 * 4. **Filtros Avançados**: Substitui os "Filtros de Requisição" 
 * 5. **Paginação Client-side**: Ordenação por quantidade de pacotes
 */
@Component({
  selector: "app-mercado-live",
  standalone: true,
  imports: [CommonModule, TabSystemComponent],
  providers: [DatePipe],
  templateUrl: './mercado-livre.component.html',
  styleUrl: './mercado-livre.component.scss'
})
export class MercadoLiveComponent extends BaseDomainComponent<MercadoLiveRoute> {
  protected override logger = new Logger('MercadoLiveComponent');

  constructor(
    private mercadoLivreService: MercadoLivreService,
    titleService: TitleService,
    headerActionsService: HeaderActionsService,
    cdr: ChangeDetectorRef,
    private datePipe: DatePipe,
    private tabFormConfigService: TabFormConfigService
  ) {
    // ✅ Service adapter com lógica das 3 consultas específicas
    const serviceAdapter = {
      getEntities: (page: number, pageSize: number, filters: any) => {
        console.log('🔍 Filtros aplicados:', filters);
        return this.load3TypesOfRoutes(page, pageSize, filters);
      }
    };

    super(titleService, headerActionsService, cdr, serviceAdapter);
    
    this.registerMercadoLiveFormConfig();
  }

  // ========================================
  // 🎯 LÓGICA DAS 3 CONSULTAS ESPECÍFICAS
  // ========================================

  /**
   * 🚛 Carrega os 3 tipos de rotas: first_mile, line_haul, last_mile
   * Faz 3 consultas simultâneas, mapeia e unifica em uma lista
   */
  private load3TypesOfRoutes(page: number, pageSize: number, filters: any): Observable<{
    data: MercadoLiveRoute[];
    totalCount: number;
    pageCount: number;
    currentPage: number;
  }> {
    const types = ['last_mile', 'first_mile', 'line_haul'];
    
    // ✨ Fazer as 3 consultas simultaneamente usando forkJoin
    const requests = types.map(type => 
      this.mercadoLivreService.getMercadoLiveRoutes(1, 100, type, filters).pipe(
        map(response => {
          if (response.data[0]?.data_string) {
            const datapack = JSON.parse(response.data[0].data_string);
            const mappedRoutes = this.mapRoutesToInterface(datapack, type);
            this.logger.log(`🔄 Carregadas ${mappedRoutes.length} rotas do tipo ${type}`);
            return mappedRoutes;
          }
          return [];
        })
      )
    );

    return forkJoin(requests).pipe(
      map(allResults => {
        // 🔗 Unificar todos os resultados em uma única lista
        const allRoutes = allResults.flat();
        
        // 📊 Ordenar por estimatedPackages decrescente
        allRoutes.sort((a, b) => (b.estimatedPackages || 0) - (a.estimatedPackages || 0));
        
        // 📄 Aplicar paginação client-side
        const totalCount = allRoutes.length;
        const pageCount = Math.ceil(totalCount / pageSize);
        const startIndex = (page - 1) * pageSize;
        const endIndex = startIndex + pageSize;
        const data = allRoutes.slice(startIndex, endIndex);
        
        this.logger.log(`📋 Total: ${totalCount} rotas | Página ${page}: ${data.length} itens`);
        
        return {
          data,
          totalCount,
          pageCount,
          currentPage: page
        };
      })
    );
  }

  // ========================================
  // 🗺️ MAPEAMENTO ESPECÍFICO POR TIPO
  // ========================================

  /**
   * 🎯 Mapear diferentes tipos de rotas para interface padrão
   */
  private mapRoutesToInterface(datapack: MercadoLiveRouteRawType[], type: string): MercadoLiveRoute[] {
    return datapack.map(route => {
      switch (type) {
        case 'first_mile':
          return this.mapFirstMileRoute(route as FirstMileRouteType);
        case 'line_haul':
          return this.mapLineHaulRoute(route as LineHaulRouteType);
        case 'last_mile':
          return this.mapLastMileRoute(route as LastMileRouteType);
        default:
          return this.mapGenericRoute(route, type);
      }
    });
  }

  /**
   * 🚛 Mapear First Mile Route
   */
  private mapFirstMileRoute(route: FirstMileRouteType): MercadoLiveRoute {
    return {
      id: route.id.toString(),
      type: 'First Mile',
      customerName: route.carrierName,
      address: route.facilityName || route.facilityId,
      status: this.mapStatus(route.status),
      estimatedDelivery: this.convertToDate(route.plannedFinishTime),
      estimatedPackages: route.estimatedPackages,
      driverId: route.driverId?.toString(),
      driverName: route.driverName,
      vehiclePlate: route.vehicleName || route.vehicleLicensePlate,
      vehicleId: route.id.toString(),
      priority: route.warnings?.length > 0 ? 'high' : 
                route.performance === '0' ? 'medium' : 'low',
      vehicleType: route.vehicleType,
      locationName: route.facilityName,
      operationType: 'first_mile',
      DepartureDate: this.convertToDate(route.initDate),
      hasAmbulance: false,
      createdAt: this.convertToDate(route.initDate),
      updatedAt: new Date()
    };
  }

  /**
   * 🚚 Mapear Line Haul Route
   */
  private mapLineHaulRoute(route: LineHaulRouteType): MercadoLiveRoute {
    const facilityName = route.steps?.[0]?.origin?.facility || route.stops?.[0]?.facility || 'N/A';
    const destinationName = route.steps?.[0]?.destination?.facility || route.stops?.[1]?.facility || 'N/A';
    const address = `${facilityName} → ${destinationName}`;

    return {
      id: route.id?.toString() || `lh_${Date.now()}`,
      type: 'Line Haul',
      customerName: route.carrier || route.site_id,
      address: address,
      status: this.mapStatus(route.status || route.general_status),
      estimatedDelivery: this.convertToDate(route.finish_date),
      estimatedPackages: route.stops?.[0]?.total_packages || 0,
      driverId: route.driver_id?.toString() || route.drivers?.[0]?.id?.toString(),
      driverName: route.drivers?.[0]?.name || 'N/A',
      vehiclePlate: route.vehicle_license_plate || route.vehicles?.[0]?.license_plate,
      vehicleId: route.vehicle_id?.toString(),
      priority: route.substatus === 'delayed' || route.general_substatus === 'delayed' ? 'high' : 'medium',
      vehicleType: route.vehicle_type,
      locationName: route.site_id,
      operationType: 'line_haul',
      DepartureDate: this.convertToDate(route.departure_date),
      hasAmbulance: false,
      createdAt: this.convertToDate(route.date),
      updatedAt: new Date()
    };
  }

  /**
   * 📦 Mapear Last Mile Route
   */
  private mapLastMileRoute(route: LastMileRouteType): MercadoLiveRoute {
    return {
      id: route.id || `lm_${Date.now()}`,
      type: 'Last Mile',
      customerName: route.carrier,
      address: route.facilityId || route.cluster,
      status: this.mapStatus(route.status),
      estimatedDelivery: route.finalDate ? this.convertToDate(route.finalDate) : new Date(),
      estimatedPackages: route.counters?.total || route.shipmentData?.spr || 0,
      driverId: route.driver?.driverName,
      driverName: route.driver?.driverName,
      vehiclePlate: route.vehicle?.license,
      vehicleId: route.vehicle?.license || '',
      priority: route.routePerformanceScore === 'NOT_OK' ? 'high' : 
                route.claims?.length > 0 ? 'medium' : 'low',
      vehicleType: route.vehicle?.description,
      locationName: route.facilityId,
      operationType: 'last_mile',
      DepartureDate: this.convertToDate(route.initDate),
      hasAmbulance: route.hasAmbulance || false,
      createdAt: this.convertToDate(route.initDate),
      updatedAt: new Date()
    };
  }

  /**
   * 🔄 Mapear rota genérica
   */
  private mapGenericRoute(route: any, type: string): MercadoLiveRoute {
    return {
      id: route.id?.toString() || `gen_${Date.now()}`,
      type: type,
      customerName: route.customerName || route.carrier || route.carrierName || 'N/A',
      address: route.address || route.facility || route.facilityName || 'N/A',
      status: this.mapStatus(route.status),
      estimatedDelivery: this.convertToDate(route.estimatedDelivery || route.date),
      estimatedPackages: route.estimatedPackages || route.totalPackages || 0,
      driverId: route.driverId?.toString() || route.driver?.id?.toString(),
      driverName: route.driverName || route.drivers?.[0]?.name || route.driver?.driverName || 'N/A',
      vehiclePlate: route.vehiclePlate || route.vehicleName || route.vehicle?.license,
      vehicleId: route.vehicleId?.toString(),
      priority: 'medium',
      vehicleType: route.vehicleType || route.vehicle_type || route.vehicle?.description || 'N/A',
      locationName: route.locationName || route.facilityName || route.site_id || route.facilityId || 'N/A',
      operationType: type,
      DepartureDate: this.convertToDate(route.DepartureDate || route.departure_date || route.initDate),
      hasAmbulance: false,
      createdAt: new Date(),
      updatedAt: new Date()
    };
  }

  /**
   * 🎯 Mapear status para valores padronizados
   */
  private mapStatus(status: string): 'pending' | 'in_transit' | 'delivered' | 'cancelled' {
    if (!status) return 'pending';
    
    const statusMap: { [key: string]: 'pending' | 'in_transit' | 'delivered' | 'cancelled' } = {
      // First Mile
      'active': 'in_transit',
      'pending': 'pending',
      'finished': 'delivered',
      'closed': 'delivered',
      
      // Line Haul
      'in_progress': 'in_transit',
      'completed': 'delivered',
      'cancelled': 'cancelled',
      
      // Last Mile
      'started': 'in_transit',
      'delivered': 'delivered',
      
      // Genéricos
      'open': 'pending',
      'done': 'delivered'
    };

    return statusMap[status.toLowerCase()] || 'pending';
  }

  /**
   * 📅 Converter valor para Date
   */
  private convertToDate(dateValue: any): Date {
    if (!dateValue) {
      return new Date();
    }
    
    if (dateValue instanceof Date) {
      return dateValue;
    }
    
    if (typeof dateValue === 'string') {
      const parsed = new Date(dateValue);
      return isNaN(parsed.getTime()) ? new Date() : parsed;
    }
    
    if (typeof dateValue === 'number') {
      // Se for timestamp em segundos, converter para milissegundos
      const timestamp = dateValue < 10000000000 ? dateValue * 1000 : dateValue;
      return new Date(timestamp);
    }
    
    return new Date();
  }

  // ========================================
  // 🎯 CONFIGURAÇÃO DOS FILTROS AVANÇADOS
  // ========================================
  protected override getDomainConfig(): DomainConfig {
    return {
      domain: 'mercado-live',
      title: 'Rotas Mercado Livre - Filtros Avançados',
      entityName: 'rota',
      subTabs: ['dados'],
      pageSize: 500, // 🎯 Quantidade de itens por página
      
      // ✨ CONFIGURAÇÃO DE FILTROS AVANÇADOS (substitui "Filtros de Requisição")
      filterConfig: {
        specialFilters: [
          {
            id: 'id',
            label: 'ID da Rota',
            type: 'custom-select',
            config: {
              placeholder: 'Digite o ID da rota',
              allowFreeText: true,
              helpText: 'Digite ou selecione um ID de rota específico'
            }
          },
          {
            id: 'type',
            label: 'Tipo de Rota',
            type: 'custom-select',
            config: {
              options: [
                { value: 'first_mile', label: 'First Mile' },
                { value: 'line_haul', label: 'Line Haul' },
                { value: 'last_mile', label: 'Last Mile' }
              ],
              placeholder: 'Selecione o tipo',
              helpText: 'Filtre por tipo de operação logística'
            }
          },
          {
            id: 'status',
            label: 'Status',
            type: 'custom-select',
            config: {
              options: [
                { value: 'pending', label: 'Pendente' },
                { value: 'in_transit', label: 'Em Trânsito' },
                { value: 'delivered', label: 'Entregue' },
                { value: 'cancelled', label: 'Cancelado' }
              ],
              placeholder: 'Selecione o status',
              helpText: 'Filtre pelo status atual da rota'
            }
          },
          {
            id: 'estimatedDelivery',
            label: 'Data de Entrega',
            type: 'date-range',
            config: {
              placeholder: 'Selecione o período',
              helpText: 'Filtre por período de entrega estimado'
            }
          },
          {
            id: 'customerName',
            label: 'Cliente',
            type: 'multi-search',
            config: {
              placeholder: 'Digite o nome do cliente',
              minCharacters: 2,
              helpText: 'Busque por nome ou razão social do cliente'
            }
          },
          {
            id: 'driverName',
            label: 'Motorista',
            type: 'multi-search',
            config: {
              placeholder: 'Digite o nome do motorista',
              minCharacters: 2,
              helpText: 'Busque por nome do motorista responsável'
            }
          },
          {
            id: 'vehiclePlate',
            label: 'Placa do Veículo',
            type: 'multi-search',
            config: {
              placeholder: 'Digite a placa (ex: ABC-1234)',
              minCharacters: 3,
              helpText: 'Busque pela placa do veículo'
            }
          },
          {
            id: 'estimatedPackages',
            label: 'Quantidade de Pacotes',
            type: 'number-range',
            config: {
              placeholder: 'Faixa de pacotes',
              min: 0,
              max: 10000,
              helpText: 'Filtre por quantidade de pacotes na rota'
            }
          }
        ],
        companyFilter: true, // Manter filtro de empresa
        defaultFilters: [
          {
            field: 'status',
            operator: 'in',
            value: ['pending', 'in_transit'] // Padrão: mostrar apenas rotas ativas
          }
        ]
      },
      
      // ✨ Colunas da tabela
      columns: [
        { field: "id", header: "ID", sortable: true, filterable: true },
        { 
          field: "type", 
          header: "Tipo", 
          sortable: true, 
          filterable: true,
          label: (data: string) => {
            const typeMap: { [key: string]: string } = {
              'First Mile': '🚛 First Mile',
              'Line Haul': '🚚 Line Haul', 
              'Last Mile': '📦 Last Mile'
            };
            return typeMap[data] || data;
          }
        },
        { field: "customerName", header: "Cliente", sortable: true, filterable: true },
        { field: "locationName", header: "Localização", sortable: true, filterable: true },
        { 
          field: "estimatedPackages", 
          header: "Pacotes", 
          sortable: true, 
          filterable: true,
          label: (data: number) => data?.toLocaleString('pt-BR') || '0'
        },
        { 
          field: "status", 
          header: "Status", 
          sortable: true, 
          filterable: true,
          allowHtml: true,
          label: (status: string) => {
            if (!status) return '<span class="status-badge status-unknown">Não informado</span>';
            
            const statusConfig: { [key: string]: { label: string, class: string } } = {
              'pending': { label: 'Pendente', class: 'status-pending' },
              'in_transit': { label: 'Em Trânsito', class: 'status-in_transit' },
              'delivered': { label: 'Entregue', class: 'status-delivered' },
              'cancelled': { label: 'Cancelado', class: 'status-cancelled' },
              'delayed': { label: 'Atrasado', class: 'status-delayed' },
              'scheduled': { label: 'Agendado', class: 'status-scheduled' },
              'loading': { label: 'Carregando', class: 'status-loading' },
              'unloading': { label: 'Descarregando', class: 'status-unloading' },
              'on_route': { label: 'Em Rota', class: 'status-on_route' }
            };
            
            const config = statusConfig[status.toLowerCase()] || { label: status, class: 'status-unknown' };
            return `<span class="status-badge ${config.class}">${config.label}</span>`;
          }
        },
        {
          field: "DepartureDate",
          header: "Dt Início",
          sortable: true,
          filterable: true,
          label: (date: any) => this.datePipe.transform(date, "dd/MM/yyyy HH:mm") || "-"
        },
        { field: "driverName", header: "Motorista", sortable: true, filterable: true },
        { field: "vehiclePlate", header: "Placa", sortable: true, filterable: true },
        { field: "vehicleType", header: "Tipo Veículo", sortable: true, filterable: true },
        { 
          field: "hasAmbulance", 
          header: "Ambulância", 
          sortable: true, 
          filterable: true,
          label: (data: boolean) => data ? '🚑 Sim' : 'Não'
        }
      ],
      
      // ✨ Side Card com resumo da rota
      sideCard: {
        enabled: true,
        title: "Resumo da Rota",
        position: "right",
        width: "400px",
        component: "summary",
        data: {
          displayFields: [
            { 
              key: "type",
              label: "Tipo de Rota",
              type: "text",
              format: (data: string) => {
                const typeMap: { [key: string]: string } = {
                  'First Mile': '🚛 First Mile',
                  'Line Haul': '🚚 Line Haul', 
                  'Last Mile': '📦 Last Mile'
                };
                return typeMap[data] || data;
              }
            },
            {
              key: "status",
              label: "Status",
              type: "status"
            },
            {
              key: "customerName",
              label: "Cliente",
              type: "text"
            },
            {
              key: "estimatedPackages",
              label: "Total de Pacotes",
              type: "text"
            },
            {
              key: "driverName",
              label: "Motorista",
              type: "text"
            },
            {
              key: "vehiclePlate",
              label: "Veículo",
              type: "text"
            }
          ],
          statusField: "status",
          statusConfig: {
            // 🎯 Fallback para status vazios ou não informados
            "": {
              label: "Não informado",
              color: "#fff3cd",
              textColor: "#856404", 
              icon: "fa-exclamation-triangle"
            },
            "*": {
              label: "Status não definido",
              color: "#f5f5f5",
              textColor: "#666",
              icon: "fa-question-circle"
            },
            "pending": {
              label: "Pendente",
              color: "#fff3cd",
              textColor: "#856404",
              icon: "fa-clock"
            },
            "in_transit": {
              label: "Em Trânsito",
              color: "#cce7ff",
              textColor: "#004085",
              icon: "fa-shipping-fast"
            },
            "delivered": {
              label: "Entregue",
              color: "#d4edda",
              textColor: "#155724",
              icon: "fa-check-circle"
            },
            "cancelled": {
              label: "Cancelado",
              color: "#f8d7da",
              textColor: "#721c24",
              icon: "fa-times-circle"
            },
            "delayed": {
              label: "Atrasado",
              color: "#f5c6cb",
              textColor: "#721c24",
              icon: "fa-exclamation-triangle"
            },
            "scheduled": {
              label: "Agendado",
              color: "#b2ebf2",
              textColor: "#006064",
              icon: "fa-calendar"
            },
            "loading": {
              label: "Carregando",
              color: "#e1bee7",
              textColor: "#4a148c",
              icon: "fa-truck-loading"
            },
            "unloading": {
              label: "Descarregando",
              color: "#ffecb3",
              textColor: "#e65100",
              icon: "fa-dolly"
            },
            "on_route": {
              label: "Em Rota",
              color: "#dcedc8",
              textColor: "#33691e",
              icon: "fa-route"
            }
          }
        }
      }
    };
  }

  // ========================================
  // 🎯 EVENTOS DE FILTROS (DEMONSTRAÇÃO)
  // ========================================
  
  /**
   * 🔍 Override para capturar e logar filtros aplicados
   */
  override onAdvancedFiltersChanged(filters: any): void {
    console.log('🎯 FILTROS AVANÇADOS APLICADOS:');
    console.log('- Filtros simples:', filters.simple || {});
    console.log('- Filtros de intervalo:', filters.ranges || {});
    console.log('- Filtros de busca:', filters.searches || {});
    console.log('- Filtros de seleção:', filters.selects || {});
    
    // Chamar o método pai para aplicar os filtros
    super.onAdvancedFiltersChanged(filters);
  }

  /**
   * 📊 Override para demonstrar dados filtrados
   */
  override onFilter(filters: { [key: string]: string }) {
    console.log('📊 DADOS SENDO FILTRADOS:', filters);
    super.onFilter(filters);
  }

  // ========================================
  // 🎯 REGISTRY PATTERN - FORMULÁRIO ESPECÍFICO
  // ========================================
  
  /**
   * 🎯 Registra a configuração de formulário específica para mercado-live
   * Chamado no construtor para garantir que está disponível
   */
  private registerMercadoLiveFormConfig(): void {
    this.tabFormConfigService.registerFormConfig('mercado-live', () => this.getMercadoLiveFormConfig());
  }

  /**
   * 🎯 Configuração específica do formulário de rotas Mercado Live
   * 
   * ✅ RESPONSABILIDADE DO DOMÍNIO:
   * - Campos específicos da entidade
   * - Sub-abas e sua configuração
   * - Validações e comportamentos específicos
   */
  getMercadoLiveFormConfig(): TabFormConfig {
    return {
      title: 'Dados da Rota Mercado Live',
      entityType: 'mercado-live',
      fields: [],
      submitLabel: 'Salvar Rota',
      showCancelButton: true,
      subTabs: [
        {
          id: 'dados',
          label: 'Dados da Rota',
          icon: 'fa-route',
          enabled: true,
          order: 1,
          templateType: 'fields',
          requiredFields: ['type', 'customerName', 'status'],
          fields: [
            {
              key: 'type',
              label: 'Tipo de Rota',
              type: 'select',
              required: true,
              options: [
                { value: 'First Mile', label: '🚛 First Mile' },
                { value: 'Line Haul', label: '🚚 Line Haul' },
                { value: 'Last Mile', label: '📦 Last Mile' }
              ]
            },
            {
              key: 'customerName',
              label: 'Cliente/Transportadora',
              type: 'text',
              required: true,
              placeholder: 'Nome da transportadora ou cliente'
            },
            {
              key: 'address',
              label: 'Endereço/Local',
              type: 'text',
              required: false,
              placeholder: 'Endereço ou localização da rota'
            },
            {
              key: 'status',
              label: 'Status',
              type: 'select',
              required: true,
              options: [
                { value: 'pending', label: 'Pendente' },
                { value: 'in_transit', label: 'Em Trânsito' },
                { value: 'delivered', label: 'Entregue' },
                { value: 'cancelled', label: 'Cancelado' }
              ]
            },
            {
              key: 'priority',
              label: 'Prioridade',
              type: 'select',
              required: false,
              options: [
                { value: 'low', label: 'Baixa' },
                { value: 'medium', label: 'Média' },
                { value: 'high', label: 'Alta' }
              ],
              defaultValue: 'medium'
            },
            {
              key: 'estimatedDelivery',
              label: 'Entrega Estimada',
              type: 'date',
              required: false
            },
            {
              key: 'estimatedPackages',
              label: 'Pacotes Estimados',
              type: 'number',
              min: 0,
              placeholder: 'Quantidade de pacotes estimada'
            },
            {
              key: 'driverName',
              label: 'Motorista',
              type: 'text',
              required: false,
              placeholder: 'Nome do motorista'
            },
            {
              key: 'vehiclePlate',
              label: 'Placa do Veículo',
              type: 'text',
              required: false,
              placeholder: 'ABC-1234'
            },
            {
              key: 'vehicleType',
              label: 'Tipo de Veículo',
              type: 'select',
              options: [
                { value: 'Car', label: 'Carro' },
                { value: 'Truck', label: 'Caminhão' },
                { value: 'Van', label: 'Van' },
                { value: 'Motorcycle', label: 'Motocicleta' }
              ]
            },
            {
              key: 'DepartureDate',
              label: 'Data de Partida',
              type: 'date',
              required: false
            },
            {
              key: 'hasAmbulance',
              label: 'Possui Ambulância',
              type: 'checkbox',
              required: false
            }
          ]
        },
        {
          id: 'tracking',
          label: 'Rastreamento',
          icon: 'fa-map-marked-alt',
          enabled: true,
          order: 2,
          templateType: 'custom',
          comingSoon: true,
          requiredFields: []
        }
      ]
    };
  }
} 