// Otto App · Sample data
// Multi-tenant CRM data James sees in his workspace.

const ME = { id: 'james', name: 'James Whitfield', email: 'james@ottokap.com', initials: 'JW', role: 'AE', territory: 'Midwest' };

const TEAMMATES = [
  { id: 'james',  name: 'James Whitfield', initials: 'JW', color: '#2B57E3' },
  { id: 'priya',  name: 'Priya Shah',      initials: 'PS', color: '#6B47E0' },
  { id: 'derek',  name: 'Derek Liang',     initials: 'DL', color: '#1F8A5B' },
  { id: 'morgan', name: 'Morgan Cole',     initials: 'MC', color: '#B33A3A' },
];

const ACCOUNTS = [
  { id: 'northwind', name: 'Northwind Industrial Supply', domain: 'northwind-supply.com', industry: 'Industrial distribution', employees: 240, location: 'Cleveland, OH', owner: 'james', territory: 'Midwest', health: 'good', arr: 51000, lastTouch: '2h ago' },
  { id: 'meridian',  name: 'Meridian Logistics', domain: 'meridianlog.com', industry: 'Freight & 3PL', employees: 480, location: 'Chicago, IL', owner: 'james', territory: 'Midwest', health: 'attention', arr: 84000, lastTouch: '1d ago' },
  { id: 'hartwell',  name: 'Hartwell Manufacturing', domain: 'hartwell.co', industry: 'Precision manufacturing', employees: 120, location: 'Toledo, OH', owner: 'james', territory: 'Midwest', health: 'good', arr: 42000, lastTouch: '3d ago' },
  { id: 'cardinal',  name: 'Cardinal Auto Parts', domain: 'cardinalap.com', industry: 'Auto parts distribution', employees: 95, location: 'Detroit, MI', owner: 'priya', territory: 'Midwest', health: 'risk', arr: 28000, lastTouch: '6d ago' },
];

const CONTACTS = {
  northwind: [
    { id: 'carla', name: 'Carla Reyes',   title: 'VP, Operations',         email: 'carla.reyes@northwind-supply.com', phone: '+1 (216) 555-0142', initials: 'CR', primary: true,  lastTouch: '2h ago',  byOtto: false },
    { id: 'sam',   name: 'Sam Patel',     title: 'Director, Sales Ops',    email: 'sam.patel@northwind-supply.com',    phone: '+1 (216) 555-0177', initials: 'SP', primary: false, lastTouch: '4d ago',  byOtto: false },
    { id: 'rita',  name: 'Rita Munoz',    title: 'Procurement Manager',    email: 'rita@northwind-supply.com',          phone: '+1 (216) 555-0188', initials: 'RM', primary: false, lastTouch: '9d ago',  byOtto: true  },
  ],
  meridian: [
    { id: 'eric',    name: 'Eric Tanaka',     title: 'COO',                email: 'eric.tanaka@meridianlog.com',    phone: '+1 (312) 555-0210', initials: 'ET', primary: true,  lastTouch: '1d ago',  byOtto: false },
    { id: 'helena',  name: 'Helena Barros',   title: 'Legal Counsel',      email: 'helena@meridianlog.com',          phone: '+1 (312) 555-0221', initials: 'HB', primary: false, lastTouch: '3d ago',  byOtto: true  },
    { id: 'tomas',   name: 'Tomás Aguilar',   title: 'IT Director',        email: 't.aguilar@meridianlog.com',       phone: '+1 (312) 555-0244', initials: 'TA', primary: false, lastTouch: '12d ago', byOtto: true  },
  ],
  hartwell: [
    { id: 'maya',    name: 'Maya Chen',       title: 'CTO',                email: 'maya.chen@hartwell.co',           phone: '+1 (419) 555-0301', initials: 'MC', primary: true,  lastTouch: '3d ago',  byOtto: false },
    { id: 'darnell', name: 'Darnell Brooks',  title: 'Plant Manager',      email: 'darnell.brooks@hartwell.co',      phone: '+1 (419) 555-0312', initials: 'DB', primary: false, lastTouch: '14d ago', byOtto: true  },
  ],
  cardinal: [
    { id: 'jared',   name: 'Jared Olsen',     title: 'General Manager',    email: 'jared.olsen@cardinalap.com',      phone: '+1 (313) 555-0405', initials: 'JO', primary: true,  lastTouch: '6d ago',  byOtto: false },
    { id: 'priscilla', name: 'Priscilla Vance', title: 'AP Lead',          email: 'p.vance@cardinalap.com',           phone: '+1 (313) 555-0418', initials: 'PV', primary: false, lastTouch: '34d ago', byOtto: true  },
  ],
};

const DEALS = [
  { id: 'Q-2041', account: 'northwind', name: 'Northwind · Otto rollout', stage: 'Closing',     amount: 51000, owner: 'james', closeDate: 'May 22', probability: 75, lastActivity: '2h ago' },
  { id: 'Q-2038', account: 'meridian',  name: 'Meridian · CRM + Service', stage: 'Negotiation', amount: 84000, owner: 'james', closeDate: 'May 30', probability: 60, lastActivity: '1d ago' },
  { id: 'Q-2032', account: 'hartwell',  name: 'Hartwell · CRM only',      stage: 'Proposal',    amount: 42000, owner: 'james', closeDate: 'Jun 12', probability: 45, lastActivity: '3d ago' },
  { id: 'Q-2029', account: 'cardinal',  name: 'Cardinal · Service expansion', stage: 'Qualification', amount: 28000, owner: 'priya', closeDate: 'Jun 28', probability: 25, lastActivity: '6d ago' },
  { id: 'Q-2025', account: 'northwind', name: 'Northwind · Phase 2 Inventory', stage: 'Discovery', amount: 32000, owner: 'james', closeDate: 'Aug 14', probability: 15, lastActivity: '4d ago' },
];

const ACTIVITIES = [
  { id: 'a1', type: 'call',  account: 'northwind', contact: 'carla', user: 'james', when: 'Today, 9:58 AM', topic: 'Pricing commitment', dur: '~15 min', auto: true },
  { id: 'a2', type: 'email', account: 'northwind', contact: 'carla', user: 'james', when: 'Today, 9:42 AM', subject: 'Re: Following up on the demo', dir: 'in' },
  { id: 'a3', type: 'email', account: 'northwind', contact: 'carla', user: 'james', when: 'Today, 9:35 AM', subject: 'Q-2041 finalized · 20% off + custom RMA', dir: 'out', byOtto: true },
  { id: 'a4', type: 'task',  account: 'northwind', contact: 'carla', user: 'james', when: 'Today, EOD',     subject: 'Send contract to Carla', status: 'open' },
  { id: 'a5', type: 'note',  account: 'northwind', user: 'james', when: 'Yesterday, 4:12 PM', subject: 'Carla confirmed verbal — wants 2-yr price-lock' },
  { id: 'a6', type: 'email', account: 'meridian', contact: 'eric',  user: 'james', when: 'Yesterday, 3:08 PM', subject: 'SOW redlines', dir: 'in' },
  { id: 'a7', type: 'call',  account: 'hartwell', contact: 'maya',  user: 'james', when: '3 days ago',     topic: 'Discovery call', dur: '~42 min' },
];

const TASKS = [
  { id: 't1', title: 'Send contract to Carla', account: 'northwind', due: 'Today, EOD', priority: 'high', status: 'open' },
  { id: 't2', title: 'Review Meridian SOW redlines', account: 'meridian', due: 'Tomorrow', priority: 'high', status: 'open' },
  { id: 't3', title: 'Follow up · Hartwell discovery', account: 'hartwell', due: 'Fri May 9', priority: 'med', status: 'open' },
  { id: 't4', title: 'Prep Q2 forecast review', due: 'Mon May 12', priority: 'med', status: 'open' },
];

const STAGES = ['Discovery', 'Qualification', 'Proposal', 'Negotiation', 'Closing', 'Closed Won'];

const accountById = (id) => ACCOUNTS.find(a => a.id === id);
const userById = (id) => TEAMMATES.find(u => u.id === id);

Object.assign(window, { ME, TEAMMATES, ACCOUNTS, CONTACTS, DEALS, ACTIVITIES, TASKS, STAGES, accountById, userById });
