// data.jsx — mock data for BIM Edge Solutions

const COMPANY = {
  name: "BIM Edge Solutions",
  tagline: "BIM Consulting & Modeling",
  address: "1820 Gateway Dr, Suite 410",
  city: "San Mateo, CA 94404",
  email: "billing@bimedge.io",
  phone: "+1 (415) 555-0184",
  ein: "EIN 87-2914037",
};

const CLIENTS = [
  { id: "c1", name: "Northstar Architects", contact: "Priya Anand", email: "priya@northstar-arch.com", city: "Seattle, WA", projects: 3, outstanding: 18450, ltv: 142800, color: "oklch(0.72 0.12 145)" },
  { id: "c2", name: "Meridian Construction Group", contact: "Daniel Cho", email: "dcho@meridiancg.com", city: "Austin, TX", projects: 2, outstanding: 9200, ltv: 98400, color: "oklch(0.72 0.12 220)" },
  { id: "c3", name: "Atlas Engineering", contact: "Rosa Vidal", email: "rvidal@atlas-eng.com", city: "Denver, CO", projects: 5, outstanding: 32600, ltv: 214500, color: "oklch(0.72 0.12 60)" },
  { id: "c4", name: "Helix Design Studio", contact: "Marcus Tran", email: "marcus@helixstudio.co", city: "Brooklyn, NY", projects: 1, outstanding: 0, ltv: 36400, color: "oklch(0.72 0.12 300)" },
  { id: "c5", name: "Cascade Civil Works", contact: "Hanna Liu", email: "hanna@cascadecw.com", city: "Portland, OR", projects: 2, outstanding: 14200, ltv: 76200, color: "oklch(0.72 0.12 25)" },
  { id: "c6", name: "Foundry Real Estate", contact: "Owen Park", email: "owen@foundryre.com", city: "Chicago, IL", projects: 1, outstanding: 4800, ltv: 22000, color: "oklch(0.72 0.12 175)" },
];

const SERVICES = [
  { id: "s1", code: "BIM-MOD-LOD350", name: "Revit Modeling — LOD 350", rate: 145, unit: "hr" },
  { id: "s2", code: "BIM-COORD", name: "BIM Coordination & Clash Detection", rate: 165, unit: "hr" },
  { id: "s3", code: "SCAN-TO-BIM", name: "Scan-to-BIM (Point cloud)", rate: 185, unit: "hr" },
  { id: "s4", code: "4D-SIM", name: "4D Construction Sequencing", rate: 195, unit: "hr" },
  { id: "s5", code: "BIM-MGT", name: "BIM Management Consulting", rate: 220, unit: "hr" },
  { id: "s6", code: "FAM-LIB", name: "Custom Family Library", rate: 1800, unit: "ea" },
  { id: "s7", code: "QTO", name: "Quantity Take-off Report", rate: 950, unit: "ea" },
];

const INVOICES = [
  {
    id: "inv-2026-0142", number: "BES-2026-0142", clientId: "c3", project: "Mountain View Civic Center — Phase 2",
    issued: "2026-04-15", due: "2026-05-15", status: "pending", period: "biweekly",
    items: [
      { desc: "BIM Coordination — Apr 1-15", qty: 64, rate: 165, type: "hr" },
      { desc: "Clash Detection Reports (3)", qty: 3, rate: 450, type: "ea" },
      { desc: "Scan-to-BIM — East Wing", qty: 38, rate: 185, type: "hr" },
    ],
    taxRate: 0, notes: "Net 30. Wire transfer preferred.",
  },
  {
    id: "inv-2026-0141", number: "BES-2026-0141", clientId: "c1", project: "Cedar Tower Residences",
    issued: "2026-04-10", due: "2026-04-25", status: "overdue", period: "monthly",
    items: [
      { desc: "Revit Modeling — LOD 350", qty: 96, rate: 145, type: "hr" },
      { desc: "Custom Family Library — Curtain Wall", qty: 1, rate: 1800, type: "ea" },
    ],
    taxRate: 0, notes: "",
  },
  {
    id: "inv-2026-0140", number: "BES-2026-0140", clientId: "c2", project: "Riverbend Logistics Hub",
    issued: "2026-04-08", due: "2026-05-08", status: "pending", period: "biweekly",
    items: [
      { desc: "4D Construction Sequencing", qty: 42, rate: 195, type: "hr" },
      { desc: "BIM Management Consulting", qty: 8, rate: 220, type: "hr" },
    ],
    taxRate: 0, notes: "",
  },
  {
    id: "inv-2026-0139", number: "BES-2026-0139", clientId: "c5", project: "Willamette Bridge Retrofit",
    issued: "2026-04-02", due: "2026-04-17", status: "paid", period: "biweekly",
    items: [
      { desc: "Scan-to-BIM — Underdeck", qty: 56, rate: 185, type: "hr" },
      { desc: "Quantity Take-off Report", qty: 1, rate: 950, type: "ea" },
    ],
    taxRate: 0, notes: "Paid via ACH 04/16",
  },
  {
    id: "inv-2026-0138", number: "BES-2026-0138", clientId: "c4", project: "Greenpoint Loft Conversion",
    issued: "2026-03-28", due: "2026-04-12", status: "paid", period: "monthly",
    items: [
      { desc: "Revit Modeling — LOD 300", qty: 48, rate: 145, type: "hr" },
    ],
    taxRate: 0, notes: "",
  },
  {
    id: "inv-2026-0137", number: "BES-2026-0137", clientId: "c3", project: "Mountain View Civic Center — Phase 2",
    issued: "2026-03-25", due: "2026-04-09", status: "paid", period: "biweekly",
    items: [
      { desc: "BIM Coordination — Mar 16-31", qty: 72, rate: 165, type: "hr" },
    ],
    taxRate: 0, notes: "",
  },
  {
    id: "inv-2026-0136", number: "BES-2026-0136", clientId: "c6", project: "Foundry HQ Renovation",
    issued: "2026-03-20", due: "2026-04-04", status: "pending", period: "monthly",
    items: [
      { desc: "BIM Management Consulting", qty: 22, rate: 220, type: "hr" },
    ],
    taxRate: 0, notes: "",
  },
  {
    id: "inv-2026-0135", number: "BES-2026-0135", clientId: "c1", project: "Cedar Tower Residences",
    issued: "2026-03-15", due: "2026-03-30", status: "draft", period: "monthly",
    items: [
      { desc: "Revit Modeling — LOD 350", qty: 0, rate: 145, type: "hr" },
    ],
    taxRate: 0, notes: "",
  },
];

// 12-week cashflow in $K
const CASHFLOW = [
  { week: "W1", paid: 18.4, outstanding: 6.2 },
  { week: "W2", paid: 22.1, outstanding: 4.8 },
  { week: "W3", paid: 14.6, outstanding: 9.4 },
  { week: "W4", paid: 28.9, outstanding: 3.2 },
  { week: "W5", paid: 19.3, outstanding: 7.1 },
  { week: "W6", paid: 24.7, outstanding: 5.6 },
  { week: "W7", paid: 31.2, outstanding: 2.4 },
  { week: "W8", paid: 26.4, outstanding: 6.9 },
  { week: "W9", paid: 21.8, outstanding: 11.3 },
  { week: "W10", paid: 33.6, outstanding: 4.1 },
  { week: "W11", paid: 27.4, outstanding: 18.6 },
  { week: "W12", paid: 12.9, outstanding: 22.4 },
];

const ACTIVITY = [
  { id: "a1", type: "paid", invoice: "BES-2026-0139", client: "Cascade Civil Works", amount: 11310, when: "2h ago", whenEs: "hace 2h" },
  { id: "a2", type: "sent", invoice: "BES-2026-0142", client: "Atlas Engineering", amount: 18650, when: "yesterday", whenEs: "ayer" },
  { id: "a3", type: "viewed", invoice: "BES-2026-0141", client: "Northstar Architects", amount: 15720, when: "yesterday", whenEs: "ayer" },
  { id: "a4", type: "reminder", invoice: "BES-2026-0136", client: "Foundry Real Estate", amount: 4840, when: "2d ago", whenEs: "hace 2d" },
  { id: "a5", type: "paid", invoice: "BES-2026-0138", client: "Helix Design Studio", amount: 6960, when: "3d ago", whenEs: "hace 3d" },
  { id: "a6", type: "created", invoice: "BES-2026-0140", client: "Meridian Construction Group", amount: 9950, when: "5d ago", whenEs: "hace 5d" },
];

function fmtMoney(n) {
  return "$" + n.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
}
function fmtMoneyShort(n) {
  if (n >= 1000) return "$" + (n / 1000).toFixed(1) + "K";
  return "$" + n.toFixed(0);
}
function calcInvoiceTotal(inv) {
  const sub = inv.items.reduce((s, it) => s + it.qty * it.rate, 0);
  const tax = sub * (inv.taxRate || 0);
  return { sub, tax, total: sub + tax };
}

Object.assign(window, { COMPANY, CLIENTS, SERVICES, INVOICES, CASHFLOW, ACTIVITY, fmtMoney, fmtMoneyShort, calcInvoiceTotal });
