export const MOCK_USER = {
  id: 'mock-1', email: 'admin@arpm.com',
  firstName: 'Admin', lastName: 'Sistema',
  role: 'SUPER_ADMIN', department: 'Dirección', jobTitle: 'Administrador',
};

// ── Resources — costType: 'HORA'|'DIA'|'SEMANA'|'MES'|'FIJO' ──────────────
export const MOCK_TEAM = [
  {
    id:'u1', resourceType:'HUMANO',
    firstName:'Álvaro', lastName:'Romero', role:'SUPER_ADMIN',
    dept:'Dirección', title:'Arquitecto de Software / CEO',
    email:'alro65@gmail.com', phone:'+1 555-0100',
    avatar:'AR', color:'#2563EB',
    costType:'MES', costRate:8000, currency:'USD',
    hoursPerDay:8, daysPerWeek:5, startTime:'09:00', endTime:'17:00',
    workDays:['Lun','Mar','Mié','Jue','Vie'], capacityHrsWeek:40,
    projects:['PRY-2026-004'],
    tasks:{ COMPLETADA:37, EN_PROCESO:1, PENDIENTE:5, BLOQUEADA:0 },
    allocatedHrs:{ 'PRY-2026-004':20 },
    skills:['React','Node.js','PostgreSQL','Prisma','Docker','Tailwind','AI/LLM'],
    status:'ACTIVO',
  },
  {
    id:'u2', resourceType:'HUMANO',
    firstName:'Paula', lastName:'Soto', role:'FINANCIERO',
    dept:'Finanzas', title:'Analista Financiero',
    email:'paula.soto@arelectronics.com', phone:'+1 555-0101',
    avatar:'PS', color:'#10B981',
    costType:'MES', costRate:4500, currency:'USD',
    hoursPerDay:8, daysPerWeek:5, startTime:'09:00', endTime:'17:00',
    workDays:['Lun','Mar','Mié','Jue','Vie'], capacityHrsWeek:40,
    projects:['PRY-2026-004'],
    tasks:{ COMPLETADA:2, EN_PROCESO:0, PENDIENTE:3, BLOQUEADA:0 },
    allocatedHrs:{ 'PRY-2026-004':24 },
    skills:['Excel','SAP','Presupuestos','EVM','Forecasting'],
    status:'ACTIVO',
  },
  {
    id:'u3', resourceType:'HUMANO',
    firstName:'Carlos', lastName:'Vega', role:'COLABORADOR',
    dept:'Tecnología', title:'Desarrollador Backend (futuro)',
    email:'carlos.vega@arelectronics.com', phone:'+1 555-0102',
    avatar:'CV', color:'#8B5CF6',
    costType:'HORA', costRate:55, currency:'USD',
    hoursPerDay:8, daysPerWeek:5, startTime:'09:00', endTime:'17:00',
    workDays:['Lun','Mar','Mié','Jue','Vie'], capacityHrsWeek:40,
    projects:['PRY-2026-004'],
    tasks:{ COMPLETADA:0, EN_PROCESO:0, PENDIENTE:5, BLOQUEADA:0 },
    allocatedHrs:{ 'PRY-2026-004':0 },
    skills:['Node.js','Express','PostgreSQL','Docker','AWS'],
    status:'ACTIVO',
  },
];

// ── Equipment, Materials & Subcontracts ───────────────────────────────────────
export const MOCK_EQUIPMENT = [
  { id:'eq1', resourceType:'EQUIPO',      name:'Servidor VPS — producción (4 vCPU / 16 GB)', category:'Infraestructura', costType:'MES',  costRate:80,    currency:'USD', project:'PRY-2026-004', status:'ACTIVO',   vendor:'Hetzner Cloud',       notes:'Ubuntu 24 LTS + Nginx + SSL' },
  { id:'eq2', resourceType:'EQUIPO',      name:'Servidor staging / CI',                       category:'Infraestructura', costType:'MES',  costRate:25,    currency:'USD', project:'PRY-2026-004', status:'ACTIVO',   vendor:'Hetzner Cloud',       notes:'2 vCPU / 4 GB — GitHub Actions runner' },
  { id:'eq3', resourceType:'EQUIPO',      name:'Licencia Claude API (Anthropic)',              category:'Software',        costType:'MES',  costRate:50,    currency:'USD', project:'PRY-2026-004', status:'ACTIVO',   vendor:'Anthropic',           notes:'Claude Sonnet — importador IA + asistente' },
  { id:'eq4', resourceType:'EQUIPO',      name:'Dominio arpm.arelectronics.com + SSL',        category:'Infraestructura', costType:'FIJO', costRate:15,    currency:'USD', project:'PRY-2026-004', status:'ACTIVO',   vendor:'Namecheap',           notes:'Renovación anual' },
  { id:'eq5', resourceType:'EQUIPO',      name:'Herramienta de diseño — Figma Pro',           category:'Software',        costType:'MES',  costRate:15,    currency:'USD', project:'PRY-2026-004', status:'ACTIVO',   vendor:'Figma',               notes:'1 editor + observadores ilimitados' },
  { id:'eq6', resourceType:'SUBCONTRATO', name:'QA externo — pruebas E2E y seguridad',        category:'Subcontrato',     costType:'FIJO', costRate:3500,  currency:'USD', project:'PRY-2026-004', status:'PENDIENTE', vendor:'Por definir',         notes:'Pendiente contratación — Fase 7' },
];

// ── Projects ──────────────────────────────────────────────────────────────────
export const MOCK_PROJECTS = [
  { id:'p4', code:'PRY-2026-004', name:'AR-ProjectManagement — Plataforma ERP',type:'Software', category:'Producto Interno', client:'AR Electronics', status:'ACTIVO', methodology:'Scrum', ragStatus:'VERDE', progressPct:75, budget:120000, baselineBudget:120000, startDate:'2026-06-01', plannedEndDate:'2026-12-31', baselineEndDate:'2026-12-31', description:'ERP de gestión de proyectos full-stack: React + Node.js + PostgreSQL + Prisma.' },
];

export const MOCK_KPIS = {
  projectsByStatus: { ACTIVO:1, EN_RIESGO:0, COMPLETADO:0, PAUSADO:0 },
  tasksByStatus: { PENDIENTE:7, EN_PROCESO:1, COMPLETADA:37, BLOQUEADA:0, EN_VERIFICACION:0 },
  activeUsers: 1,
  recentProjects: MOCK_PROJECTS,
};

const u = id => MOCK_TEAM.find(m => m.id === id) || null;

// ── Tasks — extra fields: progressPct, blockedReason, authorizedBy ────────────
export const MOCK_TASKS = {
  p4:[
    // ── Fase 1: Fundación & Arquitectura ────────────────────────────────────
    { id:'ar01',  wbsCode:'1.1', phase:'Fase 1 — Fundación & Arquitectura', title:'Setup React 18 + Tailwind + Router v6',       status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-02', progressPct:100, predecessors:[], isMilestone:false, isCritical:true,  estimatedHours:8,  actualHours:8,  plannedCost:1200, actualCost:1200, baselineStart:'2026-06-01', baselineEnd:'2026-06-02' },
    { id:'ar02',  wbsCode:'1.2', phase:'Fase 1 — Fundación & Arquitectura', title:'AuthContext + Login + RBAC (4 roles)',          status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-04', progressPct:100, predecessors:[{id:'ar01',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:16, actualHours:18, plannedCost:2400, actualCost:2700, baselineStart:'2026-06-02', baselineEnd:'2026-06-04' },
    { id:'ar03',  wbsCode:'1.3', phase:'Fase 1 — Fundación & Arquitectura', title:'Layout + Sidebar + Navbar + Dark Mode',        status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-06', progressPct:100, predecessors:[{id:'ar02',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:20, actualHours:22, plannedCost:3000, actualCost:3300, baselineStart:'2026-06-04', baselineEnd:'2026-06-06' },
    { id:'ar04',  wbsCode:'1.4', phase:'Fase 1 — Fundación & Arquitectura', title:'ProjectContext — filtro global de proyecto',   status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-07', progressPct:100, predecessors:[{id:'ar03',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:8,  actualHours:8,  plannedCost:1200, actualCost:1200, baselineStart:'2026-06-06', baselineEnd:'2026-06-07' },
    { id:'ar04',  wbsCode:'1.5', phase:'Fase 1 — Fundación & Arquitectura', title:'Mock data service (proyectos, tareas, equipo)', status:'COMPLETADA', priority:'ALTO',    assignee:u('u1'), dueDate:'2026-06-08', progressPct:100, predecessors:[{id:'ar04',type:'FS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:12, actualHours:14, plannedCost:1800, actualCost:2100, baselineStart:'2026-06-07', baselineEnd:'2026-06-08' },
    { id:'ar04m', wbsCode:'1.0', phase:'Fase 1 — Fundación & Arquitectura', title:'✦ Hito: Fundación lista',                      status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-08', progressPct:100, predecessors:[{id:'ar04',type:'FS',lag:0}], isMilestone:true,  isCritical:true,  estimatedHours:0,  actualHours:0,  plannedCost:0,    actualCost:0,    baselineStart:'2026-06-08', baselineEnd:'2026-06-08' },

    // ── Fase 2: Módulos Core PM ──────────────────────────────────────────────
    { id:'ar05',  wbsCode:'2.1', phase:'Fase 2 — Módulos Core PM', title:'Dashboard ejecutivo + KPIs + gráficas',       status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-10', progressPct:100, predecessors:[{id:'ar04m',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:24, actualHours:28, plannedCost:3600, actualCost:4200, baselineStart:'2026-06-09', baselineEnd:'2026-06-11' },
    { id:'ar06',  wbsCode:'2.2', phase:'Fase 2 — Módulos Core PM', title:'Projects CRUD + ProjectDetail + NewProjectForm', status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-12', progressPct:100, predecessors:[{id:'ar05',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:20, actualHours:22, plannedCost:3000, actualCost:3300, baselineStart:'2026-06-11', baselineEnd:'2026-06-13' },
    { id:'ar07',  wbsCode:'2.3', phase:'Fase 2 — Módulos Core PM', title:'Gantt interactivo con Critica Path + dependencias', status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-16', progressPct:100, predecessors:[{id:'ar06',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:32, actualHours:38, plannedCost:4800, actualCost:5700, baselineStart:'2026-06-13', baselineEnd:'2026-06-16' },
    { id:'ar08',  wbsCode:'2.4', phase:'Fase 2 — Módulos Core PM', title:'WBS / EDT jerárquico + importador CSV/Excel',    status:'COMPLETADA', priority:'ALTO',    assignee:u('u1'), dueDate:'2026-06-17', progressPct:100, predecessors:[{id:'ar07',type:'SS',lag:2}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:24, plannedCost:3000, actualCost:3600, baselineStart:'2026-06-14', baselineEnd:'2026-06-17' },
    { id:'ar09',  wbsCode:'2.5', phase:'Fase 2 — Módulos Core PM', title:'EVM — Valor Ganado + Curva S + Semáforo',        status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-18', progressPct:100, predecessors:[{id:'ar07',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:24, actualHours:26, plannedCost:3600, actualCost:3900, baselineStart:'2026-06-16', baselineEnd:'2026-06-18' },
    { id:'ar10',  wbsCode:'2.6', phase:'Fase 2 — Módulos Core PM', title:'Registro de Riesgos (matriz 5×5 + mapa calor)',   status:'COMPLETADA', priority:'ALTO',    assignee:u('u1'), dueDate:'2026-06-18', progressPct:100, predecessors:[{id:'ar06',type:'SS',lag:3}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:18, plannedCost:2400, actualCost:2700, baselineStart:'2026-06-15', baselineEnd:'2026-06-18' },
    { id:'ar10m', wbsCode:'2.0', phase:'Fase 2 — Módulos Core PM', title:'✦ Hito: Core PM entregado',                      status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-18', progressPct:100, predecessors:[{id:'ar09',type:'FS',lag:0},{id:'ar10',type:'FS',lag:0}], isMilestone:true, isCritical:true, estimatedHours:0, actualHours:0, plannedCost:0, actualCost:0, baselineStart:'2026-06-18', baselineEnd:'2026-06-18' },

    // ── Fase 3: Módulos Operativos ───────────────────────────────────────────
    { id:'ar11',  wbsCode:'3.1', phase:'Fase 3 — Módulos Operativos', title:'Team module + asignación de roles',           status:'COMPLETADA', priority:'ALTO',    assignee:u('u1'), dueDate:'2026-06-20', progressPct:100, predecessors:[{id:'ar10m',type:'FS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:16, plannedCost:2400, actualCost:2400, baselineStart:'2026-06-19', baselineEnd:'2026-06-20' },
    { id:'ar12',  wbsCode:'3.2', phase:'Fase 3 — Módulos Operativos', title:'Resources + Calendario + Matriz Habilidades + Tarifas', status:'COMPLETADA', priority:'ALTO', assignee:u('u1'), dueDate:'2026-06-21', progressPct:100, predecessors:[{id:'ar11',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:22, plannedCost:3000, actualCost:3300, baselineStart:'2026-06-19', baselineEnd:'2026-06-21' },
    { id:'ar13',  wbsCode:'3.3', phase:'Fase 3 — Módulos Operativos', title:'Budget module + control de costos',            status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-21', progressPct:100, predecessors:[{id:'ar10m',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:20, actualHours:20, plannedCost:3000, actualCost:3000, baselineStart:'2026-06-19', baselineEnd:'2026-06-21' },
    { id:'ar14',  wbsCode:'3.4', phase:'Fase 3 — Módulos Operativos', title:'Procurement — RFQs + POs + Juntas de comité',  status:'COMPLETADA', priority:'ALTO',    assignee:u('u1'), dueDate:'2026-06-22', progressPct:100, predecessors:[{id:'ar12',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:24, actualHours:26, plannedCost:3600, actualCost:3900, baselineStart:'2026-06-20', baselineEnd:'2026-06-22' },
    { id:'ar15',  wbsCode:'3.5', phase:'Fase 3 — Módulos Operativos', title:'Work Orders — órdenes por proyecto',           status:'COMPLETADA', priority:'MEDIO',   assignee:u('u1'), dueDate:'2026-06-22', progressPct:100, predecessors:[{id:'ar13',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:12, actualHours:12, plannedCost:1800, actualCost:1800, baselineStart:'2026-06-21', baselineEnd:'2026-06-22' },
    { id:'ar16',  wbsCode:'3.6', phase:'Fase 3 — Módulos Operativos', title:'Documents — gestión documental + versiones',   status:'COMPLETADA', priority:'MEDIO',   assignee:u('u1'), dueDate:'2026-06-22', progressPct:100, predecessors:[{id:'ar14',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:16, plannedCost:2400, actualCost:2400, baselineStart:'2026-06-21', baselineEnd:'2026-06-22' },
    { id:'ar17',  wbsCode:'3.7', phase:'Fase 3 — Módulos Operativos', title:'Accounting — pagos + conciliación + Balance',  status:'COMPLETADA', priority:'ALTO',    assignee:u('u1'), dueDate:'2026-06-23', progressPct:100, predecessors:[{id:'ar13',type:'FS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:22, plannedCost:3000, actualCost:3300, baselineStart:'2026-06-22', baselineEnd:'2026-06-23' },
    { id:'ar18',  wbsCode:'3.8', phase:'Fase 3 — Módulos Operativos', title:'Billing — facturas + cobros + pagos parciales', status:'COMPLETADA', priority:'ALTO',    assignee:u('u1'), dueDate:'2026-06-23', progressPct:100, predecessors:[{id:'ar17',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:22, plannedCost:3000, actualCost:3300, baselineStart:'2026-06-22', baselineEnd:'2026-06-23' },
    { id:'ar19',  wbsCode:'3.9', phase:'Fase 3 — Módulos Operativos', title:'Messages — mensajería interna con alertas',    status:'COMPLETADA', priority:'BAJO',    assignee:u('u1'), dueDate:'2026-06-23', progressPct:100, predecessors:[{id:'ar11',type:'FS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:12, actualHours:12, plannedCost:1800, actualCost:1800, baselineStart:'2026-06-22', baselineEnd:'2026-06-23' },
    { id:'ar19m', wbsCode:'3.0', phase:'Fase 3 — Módulos Operativos', title:'✦ Hito: Módulos operativos completos',         status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-23', progressPct:100, predecessors:[{id:'ar17',type:'FS',lag:0},{id:'ar18',type:'FS',lag:0},{id:'ar19',type:'FS',lag:0}], isMilestone:true, isCritical:true, estimatedHours:0, actualHours:0, plannedCost:0, actualCost:0, baselineStart:'2026-06-23', baselineEnd:'2026-06-23' },

    // ── Fase 4: Calidad, HSE y Contratos ────────────────────────────────────
    { id:'ar20',  wbsCode:'4.1', phase:'Fase 4 — Calidad, HSE y Contratos', title:'Quality — Inspecciones + NCR + Punch List + DoD + Auditorías', status:'COMPLETADA', priority:'ALTO', assignee:u('u1'), dueDate:'2026-06-24', progressPct:100, predecessors:[{id:'ar19m',type:'FS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:28, actualHours:30, plannedCost:4200, actualCost:4500, baselineStart:'2026-06-23', baselineEnd:'2026-06-24' },
    { id:'ar21',  wbsCode:'4.2', phase:'Fase 4 — Calidad, HSE y Contratos', title:'HSE — Incidentes + Inspecciones + CAPA + Pirámide Bird', status:'COMPLETADA', priority:'ALTO', assignee:u('u1'), dueDate:'2026-06-24', progressPct:100, predecessors:[{id:'ar20',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:24, actualHours:26, plannedCost:3600, actualCost:3900, baselineStart:'2026-06-23', baselineEnd:'2026-06-24' },
    { id:'ar22',  wbsCode:'4.3', phase:'Fase 4 — Calidad, HSE y Contratos', title:'Bids — Licitaciones + Análisis pérdidas + Convertir proyecto', status:'COMPLETADA', priority:'ALTO', assignee:u('u1'), dueDate:'2026-06-24', progressPct:100, predecessors:[{id:'ar20',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:22, plannedCost:3000, actualCost:3300, baselineStart:'2026-06-23', baselineEnd:'2026-06-24' },
    { id:'ar23',  wbsCode:'4.4', phase:'Fase 4 — Calidad, HSE y Contratos', title:'Contracts — contratos + adendas + hitos de pago',       status:'COMPLETADA', priority:'ALTO', assignee:u('u1'), dueDate:'2026-06-24', progressPct:100, predecessors:[{id:'ar22',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:20, plannedCost:3000, actualCost:3000, baselineStart:'2026-06-23', baselineEnd:'2026-06-24' },
    { id:'ar24',  wbsCode:'4.5', phase:'Fase 4 — Calidad, HSE y Contratos', title:'Vendors — homologación + score + evaluaciones',         status:'COMPLETADA', priority:'MEDIO', assignee:u('u1'), dueDate:'2026-06-25', progressPct:100, predecessors:[{id:'ar23',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:18, plannedCost:2400, actualCost:2700, baselineStart:'2026-06-24', baselineEnd:'2026-06-25' },
    { id:'ar25',  wbsCode:'4.6', phase:'Fase 4 — Calidad, HSE y Contratos', title:'Change Management — CRs + flujo aprobación + impacto',  status:'COMPLETADA', priority:'ALTO', assignee:u('u1'), dueDate:'2026-06-25', progressPct:100, predecessors:[{id:'ar23',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:22, plannedCost:3000, actualCost:3300, baselineStart:'2026-06-24', baselineEnd:'2026-06-25' },
    { id:'ar26',  wbsCode:'4.7', phase:'Fase 4 — Calidad, HSE y Contratos', title:'Reception + Project Closure + Client Portal',          status:'COMPLETADA', priority:'MEDIO', assignee:u('u1'), dueDate:'2026-06-25', progressPct:100, predecessors:[{id:'ar24',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:24, actualHours:24, plannedCost:3600, actualCost:3600, baselineStart:'2026-06-24', baselineEnd:'2026-06-25' },
    { id:'ar26m', wbsCode:'4.0', phase:'Fase 4 — Calidad, HSE y Contratos', title:'✦ Hito: Suite completa de módulos',                     status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-25', progressPct:100, predecessors:[{id:'ar25',type:'FS',lag:0},{id:'ar26',type:'FS',lag:0}], isMilestone:true, isCritical:true, estimatedHours:0, actualHours:0, plannedCost:0, actualCost:0, baselineStart:'2026-06-25', baselineEnd:'2026-06-25' },

    // ── Fase 5: Analytics & Reporting ───────────────────────────────────────
    { id:'ar27',  wbsCode:'5.1', phase:'Fase 5 — Analytics & Reporting', title:'Portfolio — RAG + comparativo + salud proyectos', status:'COMPLETADA', priority:'ALTO',   assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar26m',type:'FS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:16, plannedCost:2400, actualCost:2400, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar28',  wbsCode:'5.2', phase:'Fase 5 — Analytics & Reporting', title:'Burndown + Burnup + Velocidad & Predicción',      status:'COMPLETADA', priority:'ALTO',   assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar27',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:16, plannedCost:2400, actualCost:2400, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar29',  wbsCode:'5.3', phase:'Fase 5 — Analytics & Reporting', title:'Scenario Simulator — sliders + cashflow + saved', status:'COMPLETADA', priority:'MEDIO',  assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar27',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:22, plannedCost:3000, actualCost:3300, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar30',  wbsCode:'5.4', phase:'Fase 5 — Analytics & Reporting', title:'NPS — dashboard + encuestas + análisis',          status:'COMPLETADA', priority:'MEDIO',  assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar28',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:16, plannedCost:2400, actualCost:2400, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar31',  wbsCode:'5.5', phase:'Fase 5 — Analytics & Reporting', title:'PDF/CSV Export — 8 plantillas + modal progreso',  status:'COMPLETADA', priority:'MEDIO',  assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar29',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:20, plannedCost:3000, actualCost:3000, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar31m', wbsCode:'5.0', phase:'Fase 5 — Analytics & Reporting', title:'✦ Hito: Analytics completo',                      status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar30',type:'FS',lag:0},{id:'ar31',type:'FS',lag:0}], isMilestone:true, isCritical:true, estimatedHours:0, actualHours:0, plannedCost:0, actualCost:0, baselineStart:'2026-06-26', baselineEnd:'2026-06-26' },

    // ── Fase 6: Colaboración & Equipo ────────────────────────────────────────
    { id:'ar32',  wbsCode:'6.1', phase:'Fase 6 — Colaboración & Equipo', title:'Time Tracking — registro horas + resumen + reportes', status:'COMPLETADA', priority:'ALTO',  assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar31m',type:'FS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:20, plannedCost:3000, actualCost:3000, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar33',  wbsCode:'6.2', phase:'Fase 6 — Colaboración & Equipo', title:'Meetings — actas + compromisos + calendario',        status:'COMPLETADA', priority:'MEDIO', assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar32',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:16, plannedCost:2400, actualCost:2400, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar34',  wbsCode:'6.3', phase:'Fase 6 — Colaboración & Equipo', title:'Lessons Learned — base conocimiento + análisis',    status:'COMPLETADA', priority:'BAJO',  assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar33',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:16, plannedCost:2400, actualCost:2400, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar35',  wbsCode:'6.4', phase:'Fase 6 — Colaboración & Equipo', title:'Standup — daily + historial + bloqueadores kanban', status:'COMPLETADA', priority:'MEDIO', assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar33',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:18, plannedCost:2400, actualCost:2700, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar36',  wbsCode:'6.5', phase:'Fase 6 — Colaboración & Equipo', title:'Resource Calendar — semanal + heatmap + disponibilidad', status:'COMPLETADA', priority:'MEDIO', assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar32',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:20, actualHours:20, plannedCost:3000, actualCost:3000, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar37',  wbsCode:'6.6', phase:'Fase 6 — Colaboración & Equipo', title:'AI Chat — asistente flotante global con keywords',   status:'COMPLETADA', priority:'MEDIO', assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar34',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:12, actualHours:14, plannedCost:1800, actualCost:2100, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar37m', wbsCode:'6.0', phase:'Fase 6 — Colaboración & Equipo', title:'✦ Hito: Suite colaboración entregada',               status:'COMPLETADA', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar35',type:'FS',lag:0},{id:'ar36',type:'FS',lag:0},{id:'ar37',type:'FS',lag:0}], isMilestone:true, isCritical:true, estimatedHours:0, actualHours:0, plannedCost:0, actualCost:0, baselineStart:'2026-06-26', baselineEnd:'2026-06-26' },

    // ── Fase 7: QA, Bugs & Mejoras (en curso) ───────────────────────────────
    { id:'ar38',  wbsCode:'7.1', phase:'Fase 7 — QA, Bugs & Mejoras', title:'Auditoría filtro global proyecto (todos los módulos)', status:'COMPLETADA',  priority:'CRITICO', assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar37m',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:16, actualHours:20, plannedCost:2400, actualCost:3000, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar39',  wbsCode:'7.2', phase:'Fase 7 — QA, Bugs & Mejoras', title:'CSV Import para tareas (WBS drag & drop)',             status:'COMPLETADA',  priority:'ALTO',    assignee:u('u1'), dueDate:'2026-06-26', progressPct:100, predecessors:[{id:'ar38',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:12, actualHours:12, plannedCost:1800, actualCost:1800, baselineStart:'2026-06-25', baselineEnd:'2026-06-26' },
    { id:'ar40',  wbsCode:'7.3', phase:'Fase 7 — QA, Bugs & Mejoras', title:'Auditoría de seguridad (3 Guards: Injection, Net, Auth)', status:'EN_PROCESO', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-07-03', progressPct:10,  predecessors:[{id:'ar38',type:'FS',lag:0}], isMilestone:false, isCritical:true,  estimatedHours:20, actualHours:2,  plannedCost:3000, actualCost:300,  baselineStart:'2026-06-27', baselineEnd:'2026-07-03' },
    { id:'ar41',  wbsCode:'7.4', phase:'Fase 7 — QA, Bugs & Mejoras', title:'Tests E2E — flujos críticos con Playwright',           status:'PENDIENTE',   priority:'ALTO',    assignee:u('u1'), dueDate:'2026-07-10', progressPct:0,   predecessors:[{id:'ar40',type:'FS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:24, actualHours:0,  plannedCost:3600, actualCost:0,    baselineStart:'2026-07-04', baselineEnd:'2026-07-10' },
    { id:'ar42',  wbsCode:'7.5', phase:'Fase 7 — QA, Bugs & Mejoras', title:'Optimización performance + lazy loading + memoize',   status:'PENDIENTE',   priority:'MEDIO',   assignee:u('u1'), dueDate:'2026-07-15', progressPct:0,   predecessors:[{id:'ar41',type:'SS',lag:0}], isMilestone:false, isCritical:false, estimatedHours:16, actualHours:0,  plannedCost:2400, actualCost:0,    baselineStart:'2026-07-10', baselineEnd:'2026-07-15' },
    { id:'ar42m', wbsCode:'7.0', phase:'Fase 7 — QA, Bugs & Mejoras', title:'✦ Hito: QA & Seguridad aprobados',                    status:'PENDIENTE',   priority:'CRITICO', assignee:u('u1'), dueDate:'2026-07-15', progressPct:0,   predecessors:[{id:'ar41',type:'FS',lag:0},{id:'ar42',type:'FS',lag:0}], isMilestone:true, isCritical:true, estimatedHours:0, actualHours:0, plannedCost:0, actualCost:0, baselineStart:'2026-07-15', baselineEnd:'2026-07-15' },

    // ── Fase 8: Backend Real & Deploy ────────────────────────────────────────
    { id:'ar43',  wbsCode:'8.1', phase:'Fase 8 — Backend Real & Deploy', title:'API Node.js + Express + Prisma + PostgreSQL',     status:'PENDIENTE', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-09-15', progressPct:0, predecessors:[{id:'ar42m',type:'FS',lag:30}], isMilestone:false, isCritical:true,  estimatedHours:80, actualHours:0, plannedCost:12000, actualCost:0, baselineStart:'2026-08-01', baselineEnd:'2026-09-15' },
    { id:'ar44',  wbsCode:'8.2', phase:'Fase 8 — Backend Real & Deploy', title:'Migrar mockData → endpoints reales',              status:'PENDIENTE', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-10-01', progressPct:0, predecessors:[{id:'ar43',type:'FS',lag:0}],  isMilestone:false, isCritical:true,  estimatedHours:60, actualHours:0, plannedCost:9000,  actualCost:0, baselineStart:'2026-09-15', baselineEnd:'2026-10-01' },
    { id:'ar45',  wbsCode:'8.3', phase:'Fase 8 — Backend Real & Deploy', title:'Docker Compose frontend + backend + DB',          status:'PENDIENTE', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-10-15', progressPct:0, predecessors:[{id:'ar44',type:'FS',lag:0}],  isMilestone:false, isCritical:true,  estimatedHours:16, actualHours:0, plannedCost:2400,  actualCost:0, baselineStart:'2026-10-01', baselineEnd:'2026-10-15' },
    { id:'ar46',  wbsCode:'8.4', phase:'Fase 8 — Backend Real & Deploy', title:'CI/CD GitHub Actions + staging environment',      status:'PENDIENTE', priority:'ALTO',    assignee:u('u1'), dueDate:'2026-10-20', progressPct:0, predecessors:[{id:'ar45',type:'FS',lag:0}],  isMilestone:false, isCritical:false, estimatedHours:12, actualHours:0, plannedCost:1800,  actualCost:0, baselineStart:'2026-10-15', baselineEnd:'2026-10-20' },
    { id:'ar47',  wbsCode:'8.5', phase:'Fase 8 — Backend Real & Deploy', title:'Deploy VPS + Nginx + SSL + dominio',              status:'PENDIENTE', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-10-31', progressPct:0, predecessors:[{id:'ar45',type:'FS',lag:0},{id:'ar46',type:'FS',lag:0}], isMilestone:false, isCritical:true, estimatedHours:8, actualHours:0, plannedCost:1200, actualCost:0, baselineStart:'2026-10-20', baselineEnd:'2026-10-31' },
    { id:'ar47m', wbsCode:'8.0', phase:'Fase 8 — Backend Real & Deploy', title:'✦ Hito: AR-PM en producción',                     status:'PENDIENTE', priority:'CRITICO', assignee:u('u1'), dueDate:'2026-10-31', progressPct:0, predecessors:[{id:'ar47',type:'FS',lag:1}],  isMilestone:true,  isCritical:true,  estimatedHours:0,  actualHours:0, plannedCost:0,     actualCost:0, baselineStart:'2026-10-31', baselineEnd:'2026-10-31' },
  ],
};

// ── Risks ─────────────────────────────────────────────────────────────────────
export const MOCK_RISKS = {
  p4:[
    { id:'r6',  code:'R-001', title:'Scope creep — módulos sin terminar',    category:'Alcance',        probability:4, impact:4, status:'ACTIVO', owner:u('u1'), response:'Mitigar',  plan:'Priorización estricta por fases y backlog controlado', dueDate:'2026-07-01', residualProb:2, residualImpact:3 },
    { id:'r7',  code:'R-002', title:'Deuda técnica mockData vs BD real',     category:'Técnico',        probability:3, impact:4, status:'ACTIVO', owner:u('u1'), response:'Mitigar',  plan:'Migrar a backend real con Docker cuando esté disponible', dueDate:'2026-08-01', residualProb:2, residualImpact:2 },
    { id:'r8',  code:'R-003', title:'Performance con datasets grandes',      category:'Técnico',        probability:2, impact:3, status:'ACTIVO', owner:u('u1'), response:'Mitigar',  plan:'Paginación, virtualización, índices en BD', dueDate:'2026-09-01', residualProb:1, residualImpact:2 },
    { id:'r9',  code:'R-004', title:'Disponibilidad (solo 1 developer)',     category:'Recursos',       probability:3, impact:5, status:'ACTIVO', owner:u('u1'), response:'Aceptar',  plan:'Documentar arquitectura para onboarding rápido', dueDate:'2026-07-15', residualProb:3, residualImpact:5 },
    { id:'r10', code:'R-005', title:'Cambio de requerimientos del cliente',  category:'Organizacional', probability:3, impact:3, status:'ACTIVO', owner:u('u1'), response:'Mitigar',  plan:'Demo semanal + feedback estructurado por sprint', dueDate:'2026-12-31', residualProb:2, residualImpact:2 },
  ],
};

// ── EVM ────────────────────────────────────────────────────────────────────────
export const MOCK_EVM = {
  p4:[
    { date:'2026-06', pv:16500,  ev:20100, ac:20100 },
    { date:'2026-07', pv:45000,  ev:null,  ac:null  },
    { date:'2026-08', pv:75000,  ev:null,  ac:null  },
    { date:'2026-09', pv:95000,  ev:null,  ac:null  },
    { date:'2026-10', pv:108000, ev:null,  ac:null  },
    { date:'2026-12', pv:120000, ev:null,  ac:null  },
  ],
};

// ── Internal Messages ─────────────────────────────────────────────────────────
export const MOCK_MESSAGES = [
  {
    id:'msg1', type:'RECORDATORIO', priority:'ALTO',
    from: { id:'u1', name:'Admin Sistema', avatar:'AS', color:'#2563EB' },
    to:   { id:'u1', name:'Admin Sistema', avatar:'AS', color:'#2563EB' },
    subject:'Sprint 3 — Módulos pendientes de IA',
    body:'Recordatorio: los módulos de traducción IA y el importador de anteproyecto requieren pruebas finales esta semana. Revisar antes del demo del viernes.',
    projectId:'p4', projectCode:'PRY-2026-004',
    taskId:null, taskWbs:null, taskTitle:null,
    date:'2026-06-20T09:15:00', read: false,
  },
  {
    id:'msg2', type:'ALERTA', priority:'MEDIO',
    from: { id:'u1', name:'Admin Sistema', avatar:'AS', color:'#2563EB' },
    to:   { id:'u1', name:'Admin Sistema', avatar:'AS', color:'#2563EB' },
    subject:'Actualizar progreso real del proyecto',
    body:'El progreso registrado (75%) refleja los módulos entregados. Pendiente: backend real, autenticación JWT en producción y despliegue en servidor.',
    projectId:'p4', projectCode:'PRY-2026-004',
    taskId:null, taskWbs:null, taskTitle:null,
    date:'2026-06-19T14:30:00', read: true,
  },
];


// ── Dynamic helpers — merge mock + localStorage ───────────────────────────────
export function getAllProjects() {
  try {
    const extra = JSON.parse(localStorage.getItem('arpm_projects') || '[]');
    return [...MOCK_PROJECTS, ...extra];
  } catch { return MOCK_PROJECTS; }
}

export function getProjectById(id) {
  return getAllProjects().find(p => p.id === id) || MOCK_PROJECTS[0];
}

export function getTasksForProject(id) {
  try {
    const stored = JSON.parse(localStorage.getItem('arpm_tasks') || '{}');
    if (stored[id]) return stored[id];
  } catch {}
  return MOCK_TASKS[id] || [];
}

export function getAllTasks() {
  try {
    const stored = JSON.parse(localStorage.getItem('arpm_tasks') || '{}');
    const allIds = [...new Set([...Object.keys(MOCK_TASKS), ...Object.keys(stored)])];
    const result = {};
    allIds.forEach(id => { result[id] = stored[id] || MOCK_TASKS[id] || []; });
    return result;
  } catch { return MOCK_TASKS; }
}

export function getRisksForProject(id) {
  try {
    const stored = JSON.parse(localStorage.getItem('arpm_risks') || '{}');
    if (stored[id]) return stored[id];
  } catch {}
  return MOCK_RISKS[id] || [];
}

export function getEVMForProject(id) {
  try {
    const stored = JSON.parse(localStorage.getItem('arpm_evm') || '{}');
    if (stored[id]) return stored[id];
  } catch {}
  return MOCK_EVM[id] || [];
}
