<?php
declare(strict_types=1);

function eaq_seed_mock_crm(): array {
  // Dados inspirados em Assets/Web/Application/MockWebDataService.cs (seedDemo).
  // Mantidos aqui para que o /app seja visível e funcional mesmo sem WebGL export.
  $now = gmdate('c'); // ISO8601
  $leads = [
    [
      'Id' => 'lead-1',
      'Name' => 'Maria Silva',
      'Email' => 'maria.silva@empresa.pt',
      'Phone' => '+351 912 000 001',
      'Company' => 'Empresa PT',
      'Status' => 'Qualified',
      'Source' => 'Website',
      'CreatedAt' => gmdate('c', time() - 14 * 86400),
      'Notes' => 'Interesse em evento corporativo 80 pax.',
    ],
    [
      'Id' => 'lead-2',
      'Name' => 'João Santos',
      'Email' => 'joao@eventos.pt',
      'Phone' => '+351 913 000 002',
      'Company' => 'Eventos & Cia',
      'Status' => 'Contacted',
      'Source' => 'Referral',
      'CreatedAt' => gmdate('c', time() - 7 * 86400),
      'Notes' => '',
    ],
    [
      'Id' => 'lead-3',
      'Name' => 'Ana Costa',
      'Email' => 'ana.costa@hotel.pt',
      'Phone' => '+351 914 000 003',
      'Company' => 'Hotel Vista',
      'Status' => 'New',
      'Source' => 'Inbound',
      'CreatedAt' => gmdate('c', time() - 2 * 86400),
      'Notes' => 'Pedido de proposta recebido.',
    ],
    [
      'Id' => 'lead-4',
      'Name' => 'Pedro Ferreira',
      'Email' => 'pedro@startup.pt',
      'Phone' => '+351 915 000 004',
      'Company' => 'Startup Labs',
      'Status' => 'New',
      'Source' => 'Website',
      'CreatedAt' => gmdate('c', time() - 1 * 86400),
      'Notes' => 'Evento tech 50 pax.',
    ],
  ];

  $proposals = [
    ['Id'=>'prop-1','OpportunityId'=>'opp-1','Name'=>'Proposta Premium - Empresa PT','Status'=>'Sent','SentAt'=>gmdate('c', time()-3*86400),'ViewedAt'=>gmdate('c', time()-2*86400),'AcceptedAt'=>null],
    ['Id'=>'prop-2','OpportunityId'=>'opp-2','Name'=>'Proposta Casamento 120 pax','Status'=>'Draft','SentAt'=>null,'ViewedAt'=>null,'AcceptedAt'=>null],
    ['Id'=>'prop-3','OpportunityId'=>'opp-3','Name'=>'Proposta Corporativo Ana Costa','Status'=>'Sent','SentAt'=>gmdate('c', time()-5*86400),'ViewedAt'=>null,'AcceptedAt'=>null],
    ['Id'=>'prop-4','OpportunityId'=>'opp-4','Name'=>'Proposta Startup Labs','Status'=>'Draft','SentAt'=>null,'ViewedAt'=>null,'AcceptedAt'=>null],
    ['Id'=>'prop-5','OpportunityId'=>'opp-5','Name'=>'Proposta Aniversário Eventos & Cia','Status'=>'Sent','SentAt'=>gmdate('c', time()-2*86400),'ViewedAt'=>null,'AcceptedAt'=>null],
  ];

  $sessions = [
    [
      'Id'=>'sess-1',
      'SessionId'=>'quest-session-001',
      'OpportunityId'=>'opp-1',
      'ProposalRecordId'=>'prop-1',
      'RecommendedProposalId'=>'proposal-guid-1',
      'SelectedProposalId'=>'proposal-guid-1',
      'FinalDecisionState'=>'Interested',
      'ConfirmedCTA'=>'Agendar reunião',
      'SuggestedNextAction'=>'Enviar detalhes do pacote premium',
      'FollowUpPriority'=>'High',
      'HasExportPayload'=>true,
      'HasHandoffReport'=>true,
      'HasShareableSummary'=>true,
      'HasQualityAssessment'=>true,
      'HasImprovementPlan'=>true,
      'LastSessionTimestamp'=>gmdate('c', time()-1*86400),
      'HeldAt'=>gmdate('c', time()-1*86400),
      'CreatedAt'=>gmdate('c', time()-1*86400),
    ],
    [
      'Id'=>'sess-2',
      'SessionId'=>null,
      'OpportunityId'=>'opp-2',
      'ProposalRecordId'=>null,
      'RecommendedProposalId'=>null,
      'SelectedProposalId'=>null,
      'FinalDecisionState'=>'Unknown',
      'ConfirmedCTA'=>null,
      'SuggestedNextAction'=>'Agendar sessão Quest',
      'FollowUpPriority'=>'Medium',
      'HasExportPayload'=>false,
      'HasHandoffReport'=>false,
      'HasShareableSummary'=>false,
      'HasQualityAssessment'=>false,
      'HasImprovementPlan'=>false,
      'LastSessionTimestamp'=>null,
      'HeldAt'=>null,
      'CreatedAt'=>gmdate('c', time()-4*86400),
    ],
    [
      'Id'=>'sess-3',
      'SessionId'=>'quest-session-003',
      'OpportunityId'=>'opp-3',
      'ProposalRecordId'=>'prop-3',
      'RecommendedProposalId'=>'proposal-guid-3',
      'SelectedProposalId'=>'proposal-guid-3',
      'FinalDecisionState'=>'ReadyToClose',
      'ConfirmedCTA'=>'Fechar contrato',
      'SuggestedNextAction'=>'Enviar minuta e agendar assinatura',
      'FollowUpPriority'=>'Urgent',
      'HasExportPayload'=>true,
      'HasHandoffReport'=>true,
      'HasShareableSummary'=>true,
      'HasQualityAssessment'=>true,
      'HasImprovementPlan'=>false,
      'LastSessionTimestamp'=>gmdate('c', time()-2*86400),
      'HeldAt'=>gmdate('c', time()-2*86400),
      'CreatedAt'=>gmdate('c', time()-2*86400),
    ],
  ];

  $opps = [
    ['Id'=>'opp-1','LeadId'=>'lead-1','Title'=>'Evento corporativo 80 pax - Empresa PT','Stage'=>'QuestSessionDone','Value'=>25000.0,'ProposalRecordId'=>'prop-1','SessionRecordId'=>'sess-1','CommercialPriority'=>'High','SuggestedNextAction'=>'Enviar detalhes do pacote premium','CreatedAt'=>gmdate('c', time()-10*86400),'UpdatedAt'=>gmdate('c', time()-1*86400)],
    ['Id'=>'opp-2','LeadId'=>'lead-2','Title'=>'Casamento 120 convidados','Stage'=>'Contacted','Value'=>35000.0,'ProposalRecordId'=>null,'SessionRecordId'=>null,'CommercialPriority'=>'Medium','SuggestedNextAction'=>'Enviar proposta e agendar visita','CreatedAt'=>gmdate('c', time()-5*86400),'UpdatedAt'=>gmdate('c', time()-2*86400)],
    ['Id'=>'opp-3','LeadId'=>'lead-3','Title'=>'Corporativo Ana Costa - Hotel Vista','Stage'=>'ReadyToClose','Value'=>18000.0,'ProposalRecordId'=>'prop-3','SessionRecordId'=>'sess-3','CommercialPriority'=>'Critical','SuggestedNextAction'=>'Enviar minuta e agendar assinatura','CreatedAt'=>gmdate('c', time()-8*86400),'UpdatedAt'=>gmdate('c', time()-2*86400)],
    ['Id'=>'opp-4','LeadId'=>'lead-4','Title'=>'Evento tech 50 pax - Startup Labs','Stage'=>'NewLead','Value'=>8000.0,'ProposalRecordId'=>null,'SessionRecordId'=>null,'CommercialPriority'=>'Low','SuggestedNextAction'=>'Qualificar e enviar proposta inicial','CreatedAt'=>gmdate('c', time()-1*86400),'UpdatedAt'=>gmdate('c', time()-0*86400)],
    ['Id'=>'opp-5','LeadId'=>'lead-2','Title'=>'Aniversário empresarial Eventos & Cia','Stage'=>'ProposalSent','Value'=>12000.0,'ProposalRecordId'=>'prop-5','SessionRecordId'=>null,'CommercialPriority'=>'Medium','SuggestedNextAction'=>'Aguardar feedback; sugerir sessão Quest','CreatedAt'=>gmdate('c', time()-4*86400),'UpdatedAt'=>gmdate('c', time()-1*86400)],
    ['Id'=>'opp-6','LeadId'=>'lead-1','Title'=>'Follow-up pós-sessão Empresa PT','Stage'=>'FollowUp','Value'=>25000.0,'ProposalRecordId'=>'prop-1','SessionRecordId'=>'sess-1','CommercialPriority'=>'High','SuggestedNextAction'=>'Ligar para confirmar reunião','CreatedAt'=>gmdate('c', time()-10*86400),'UpdatedAt'=>gmdate('c', time()-0*86400)],
    ['Id'=>'opp-7','LeadId'=>'lead-3','Title'=>'Evento fechado Q1 - Hotel Vista','Stage'=>'Won','Value'=>18000.0,'ProposalRecordId'=>'prop-3','SessionRecordId'=>'sess-3','CommercialPriority'=>'Low','SuggestedNextAction'=>'Entregar evento','CreatedAt'=>gmdate('c', time()-30*86400),'UpdatedAt'=>gmdate('c', time()-3*86400)],
  ];

  $followups = [
    ['Id'=>'fu-1','OpportunityId'=>'opp-1','SessionRecordId'=>'sess-1','Title'=>'Enviar detalhes do pacote premium','DueDate'=>gmdate('c', time()+2*86400),'Priority'=>'High','IsCompleted'=>false,'CreatedAt'=>gmdate('c', time()-1*86400)],
    ['Id'=>'fu-2','OpportunityId'=>'opp-2','SessionRecordId'=>null,'Title'=>'Agendar sessão Quest para apresentação','DueDate'=>gmdate('c', time()+5*86400),'Priority'=>'Medium','IsCompleted'=>false,'CreatedAt'=>gmdate('c', time()-2*86400)],
    ['Id'=>'fu-3','OpportunityId'=>'opp-3','SessionRecordId'=>'sess-3','Title'=>'Enviar minuta e agendar assinatura','DueDate'=>gmdate('c', time()+1*86400),'Priority'=>'Urgent','IsCompleted'=>false,'CreatedAt'=>gmdate('c', time()-2*86400)],
    ['Id'=>'fu-4','OpportunityId'=>'opp-1','SessionRecordId'=>'sess-1','Title'=>'Ligar para confirmar reunião','DueDate'=>gmdate('c', time()-1*86400),'Priority'=>'High','IsCompleted'=>true,'CreatedAt'=>gmdate('c', time()-3*86400)],
    ['Id'=>'fu-5','OpportunityId'=>'opp-4','SessionRecordId'=>null,'Title'=>'Qualificar lead e enviar proposta inicial','DueDate'=>gmdate('c', time()+7*86400),'Priority'=>'Low','IsCompleted'=>false,'CreatedAt'=>null],
  ];

  return [
    'leads' => $leads,
    'opportunities' => $opps,
    'proposals' => $proposals,
    'sessions' => $sessions,
    'followups' => $followups,
    'seededAt' => $now,
  ];
}

