// Extended per-industry onboarding details: certifications, insurance carriers,
// equipment, common objections + rebuttals, and local-market data.
// Keyed off cat, with a default fallback at the bottom.

const ONBOARDING_DETAIL = {

  roofing: {
    licenses: ['State contractor (GC / specialty)', 'Roofing contractor license', 'EPA RRP (lead-safe)', 'OSHA 10', 'OSHA 30', 'Fall protection certified'],
    certifications: [
      'GAF Master Elite', 'GAF Certified', 'CertainTeed Master Shingle Applicator', 'CertainTeed SELECT ShingleMaster',
      'Owens Corning Platinum Preferred', 'Owens Corning Preferred', 'Atlas Pro Plus', 'Tamko Pro Certified',
      'HAAG Certified Inspector', 'IICRC water mitigation', 'Drone pilot · FAA Part 107',
    ],
    carriers: ['State Farm','Allstate','USAA','Farmers','Liberty Mutual','Progressive','Nationwide','Travelers','Erie','American Family','Citizens','Florida Peninsula','Cincinnati Insurance'],
    equipment: [
      { id:'trucks',  name:'Trucks · pickup',          kind:'number', def:3 },
      { id:'dump',    name:'Dump trailers',            kind:'number', def:1 },
      { id:'liftgate',name:'Conveyor / lift to roof',  kind:'toggle', def:true },
      { id:'drone',   name:'Drone for inspections',    kind:'toggle', def:true },
      { id:'sat',     name:'Satellite report vendor',  kind:'select', opts:['EagleView','GAF QuickMeasure','RoofSnap','HOVER','None'], def:'EagleView' },
      { id:'photo',   name:'Field photo tool',         kind:'select', opts:['CompanyCam','iPhone only','ProjectPhotos','None'], def:'CompanyCam' },
    ],
    objections: [
      { o:"You're more expensive than the other quote.",            r:"Compare line items, not totals. We use synthetic underlayment, ice & water at every penetration, and we warranty the workmanship for 25 years." },
      { o:"I want to wait until next year.",                         r:"A leak that's not weather-tight by winter compounds — usually $4–6k in interior damage. Let's at least get a tarp on it this week, free." },
      { o:"My adjuster only approved replace of one slope.",        r:"Florida + ASTM standards require full-roof match if shingles are discontinued. Send me your scope sheet, I'll write a supplement." },
      { o:"Why can't you start tomorrow?",                           r:"Honestly because we don't rush re-roofs. We schedule a deck inspection day-1 so we don't hit surprise rot. You want this done right once." },
      { o:"What about 1099 crews?",                                  r:"All employees, all W-2, all background-checked. Our GL + WC insurance covers your home if anyone gets hurt — 1099 crews leave that on you." },
      { o:"How long will the warranty actually last?",               r:"GAF Golden Pledge on materials is 50 yrs (lifetime). Our workmanship is 25. Both are transferable when you sell." },
    ],
    localMarket: [
      { id:'hailcount',  q:'Hail events your zip averages per year?',      kind:'number', def:2 },
      { id:'avgclaim',   q:'Average insurance claim payout last 12 mo?',   kind:'number', prefix:'$', def:14200 },
      { id:'season',     q:'Your busiest months?',                          kind:'multi',  opts:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'], def:['May','Jun','Jul','Aug','Sep','Oct'] },
      { id:'avgcycle',   q:'Quote-to-signed cycle (days)?',                 kind:'number', def:7 },
      { id:'hoa',        q:'HOA-heavy neighborhoods you serve?',            kind:'text',   def:'Westchase, Heritage Harbor, Tampa Palms' },
    ],
  },

  hvac: {
    licenses: ['HVAC contractor license', 'EPA 608 Universal', 'NATE-certified techs on staff', 'OSHA 10', 'OSHA 30', 'Mechanical contractor license', 'Manufacturer warranty cert'],
    certifications: [
      'Carrier Factory Authorized Dealer', 'Trane Comfort Specialist', 'Lennox Premier Dealer', 'Mitsubishi Diamond Contractor',
      'Daikin Comfort Pro', 'Bryant Factory Authorized', 'Rheem Pro Partner', 'BPI Building Analyst',
      'ACCA member', 'RSES member', 'ENERGY STAR partner',
    ],
    carriers: ['Carrier','Trane','Lennox','Rheem','Goodman','Mitsubishi','Daikin','York','Bryant','American Standard','Amana'],
    equipment: [
      { id:'service-trucks', name:'Service trucks',      kind:'number', def:5 },
      { id:'install-trucks', name:'Install trucks',      kind:'number', def:2 },
      { id:'recovery',       name:'Refrigerant recovery machines', kind:'number', def:4 },
      { id:'megohmeter',     name:'Megohmeter / IR camera',         kind:'toggle', def:true },
      { id:'manualj',        name:'Manual J software',  kind:'select', opts:['Wrightsoft','RhVac','Cool Calc','Elite','None'], def:'Wrightsoft' },
      { id:'dispatch',       name:'Field dispatch tool',kind:'select', opts:['ServiceTitan','Housecall Pro','Jobber','Custom','None'], def:'ServiceTitan' },
    ],
    objections: [
      { o:"Window units have worked fine for years.",                  r:"They probably have. But a 16-SEER heat pump pays for itself in ~7 yrs on Tampa bills, and you stop melting in August. Let me run your kWh numbers." },
      { o:"$11k is way over budget.",                                  r:"I get it. Two paths — financing at 0%/60 mo brings monthly under your current bill, or we drop to a 14-SEER 2-stage for ~$7k." },
      { o:"Can't my buddy install it for less?",                       r:"Sure. But manufacturer warranty voids if it's not a licensed install + correct refrigerant charge. Sale day you'll regret it." },
      { o:"I just need it patched for now.",                           r:"On an 18-year-old R-22 system, patching is throwing money. R-22 is $200/lb and dropping production. Let's scope replace, you decide." },
      { o:"Sears quoted me $5k for the same thing.",                   r:"Different unit, different ductwork scope, different warranty. I'll write up side-by-side specs so you can actually compare." },
    ],
    localMarket: [
      { id:'avgton',    q:'Average tonnage you install?',              kind:'select', opts:['1.5','2','2.5','3','3.5','4','5'], def:'3' },
      { id:'avgseer',   q:'Average SEER customers pick?',              kind:'select', opts:['14','15','16','18','20+'], def:'16' },
      { id:'finratio',  q:'% of installs that finance?',               kind:'number', suffix:'%', def:55 },
      { id:'season',    q:'Your busiest months?',                       kind:'multi',  opts:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'], def:['May','Jun','Jul','Aug','Sep'] },
      { id:'commsplit', q:'% commercial vs residential?',              kind:'number', suffix:'% comm', def:15 },
    ],
  },

  plumbing: {
    licenses: ['Master plumber license', 'Journeyman plumber', 'Backflow certification', 'Medical gas certified', 'OSHA 10', 'Cross-connection control'],
    certifications: [
      'Bradford White certified installer', 'Rinnai certified', 'Navien certified', 'Pex Universe trained',
      'Watts backflow tester', 'IAPMO member', 'PHCC member',
    ],
    carriers: ['State Farm','Allstate','USAA','Farmers','Liberty Mutual','Progressive','Travelers','Citizens'],
    equipment: [
      { id:'service-trucks', name:'Service trucks',     kind:'number', def:4 },
      { id:'camera',         name:'Drain cameras',      kind:'number', def:2 },
      { id:'jetter',         name:'Hydro-jetter',       kind:'toggle', def:true },
      { id:'leakdetect',     name:'Leak detection equip', kind:'toggle', def:true },
      { id:'trenchless',     name:'Trenchless sewer rig', kind:'toggle', def:false },
      { id:'dispatch',       name:'Dispatch tool',      kind:'select', opts:['ServiceTitan','Housecall Pro','Jobber','None'], def:'ServiceTitan' },
    ],
    objections: [
      { o:"Can't I just snake it myself from Home Depot?",            r:"You can — for a soft clog. For a $.99 root in the line, the rental will jam and you'll pay for it twice. Camera scope first, then we know." },
      { o:"My neighbor's plumber was cheaper.",                       r:"Probably licensed differently. We pull permits, your home is up to code on resale, and our warranty is transferable. That's the gap." },
      { o:"Why pull a permit, it's just a water heater?",             r:"Because if it leaks or you sell, the city looks for it. We pull and pass inspection — included in the quote." },
      { o:"It's an emergency, why are you not here yet?",             r:"You're #2 in the queue. Tech is 23 min out. Shut your main + breaker if you haven't — text me a photo, I'll talk you through it." },
    ],
    localMarket: [
      { id:'wateragee', q:'Average water heater age in your service area?', kind:'number', suffix:'yrs', def:14 },
      { id:'pipe',      q:'Dominant pipe material in older homes?',         kind:'select', opts:['Galvanized','Copper','CPVC','PEX','PB (polybutylene)','Cast iron drains'], def:'Galvanized' },
      { id:'emergsplit',q:'% of calls that are emergencies?',                kind:'number', suffix:'%', def:30 },
      { id:'season',    q:'Your busiest months?',                            kind:'multi', opts:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'], def:['Dec','Jan','Feb'] },
    ],
  },

  electrical: {
    licenses: ['Master electrician', 'Journeyman electrician', 'Electrical contractor license', 'NFPA 70E arc-flash', 'OSHA 10', 'Generator install certified'],
    certifications: [
      'Tesla Wall Connector certified installer', 'ChargePoint certified', 'Generac Generator dealer',
      'Kohler dealer', 'Square D Schneider partner', 'Eaton Certified Contractor', 'IBEW signatory shop',
      'IES (Illuminating Engineering Society)',
    ],
    carriers: ['State Farm','Allstate','USAA','Liberty Mutual','Farmers','Travelers'],
    equipment: [
      { id:'service-trucks', name:'Service trucks',     kind:'number', def:4 },
      { id:'bucket',         name:'Bucket truck',       kind:'toggle', def:false },
      { id:'megger',         name:'Megger / IR thermography', kind:'toggle', def:true },
      { id:'genrental',      name:'Generator rental fleet', kind:'number', def:0 },
      { id:'evstock',        name:'EV chargers in stock',   kind:'number', def:12 },
      { id:'dispatch',       name:'Dispatch tool',      kind:'select', opts:['ServiceTitan','Housecall Pro','Jobber','None'], def:'ServiceTitan' },
    ],
    objections: [
      { o:"It's just a breaker, can't you replace it?",              r:"It's rarely just a breaker. If it's tripping with normal load, the panel is undersized. I'll prove it with a load reading on-site, you decide." },
      { o:"My handyman can do this.",                                  r:"Not legally. Permit + electrical inspection is required and a handyman can't pull either. Insurance won't cover an electrical fire on unpermitted work." },
      { o:"EV charger is just an outlet, right?",                      r:"That'd be a 14-50 NEMA — works for L1/L2 but you're running 80% of capacity. Hardwired is faster, safer, and qualifies for the federal tax credit." },
      { o:"The generator is overkill for our outages.",                r:"Until you lose power for 4 days. Whole-home auto-transfer is $14k installed, propane-fed runs ~17 days. Your call." },
    ],
    localMarket: [
      { id:'panelage',  q:'Average panel age in your service area?', kind:'number', suffix:'yrs', def:32 },
      { id:'evdemand',  q:'EV charger calls per month?',             kind:'number', def:18 },
      { id:'gendemand', q:'Generator installs per quarter?',         kind:'number', def:6 },
      { id:'outagerate', q:'Outages your area sees per year?',       kind:'number', def:4 },
    ],
  },

  solar: {
    licenses: ['Electrical contractor', 'Roofing endorsement', 'NABCEP installer', 'NABCEP designer', 'OSHA 10', 'Fall protection'],
    certifications: [
      'NABCEP PV Installation Professional', 'NABCEP PV Design Specialist', 'Tesla Powerwall Certified Installer',
      'Enphase Platinum Installer', 'SolarEdge Power Performer', 'SunPower Master Dealer', 'Sunnova certified',
      'Sunrun authorized installer', 'BPI Building Analyst',
    ],
    carriers: [],
    equipment: [
      { id:'install-trucks',  name:'Install trucks',          kind:'number', def:3 },
      { id:'aurora',          name:'Aurora Solar / OpenSolar', kind:'select', opts:['Aurora','OpenSolar','Helioscope','Other'], def:'Aurora' },
      { id:'flowmeter',       name:'Power Flow Meter on-truck', kind:'toggle', def:true },
      { id:'evstub',          name:'EV stub on every install',  kind:'toggle', def:true },
      { id:'monitoring',      name:'Monitoring platform',       kind:'select', opts:['Enphase Enlighten','SolarEdge','Tigo','None'], def:'Enphase Enlighten' },
    ],
    objections: [
      { o:"My utility company says solar isn't worth it.",            r:"They sell electricity, of course they say that. Let me pull your last 12 mo of bills and show the actual offset." },
      { o:"I don't want panels on my street-facing roof.",            r:"Totally fair. Production drops 8–14% on rear-only depending on shade. We can redesign to all-back or split. You'll know the trade-off in dollars before signing." },
      { o:"What happens when the company goes out of business?",       r:"Equipment warranty stays with the manufacturer (Enphase, Tesla — both publicly traded). Workmanship is 25 yrs and we self-insure." },
      { o:"Battery isn't worth the extra $11k.",                      r:"Worth it if your grid is brittle. Tampa Electric had 8 outages > 4 hrs last year. With Powerwall 3 you ride them out + arbitrage time-of-use rates. Math depends on your usage." },
      { o:"Aren't these things ugly?",                                r:"Aesthetic options have changed a lot — black-on-black panels disappear on dark shingles. Let me drop a 3D mockup of your house in 5 minutes." },
    ],
    localMarket: [
      { id:'avgbill',   q:'Average customer monthly electric bill?', kind:'number', prefix:'$', def:280 },
      { id:'batteryratio', q:'% of installs that add battery?',      kind:'number', suffix:'%', def:38 },
      { id:'roofnewratio', q:'% with roof replaced in last 5 yrs?',  kind:'number', suffix:'%', def:72 },
      { id:'avgsystem', q:'Average system size (kW)?',                kind:'number', suffix:'kW', def:9.6 },
    ],
  },

  pool: {
    licenses: ['Pool contractor license', 'CPO (Certified Pool Operator)', 'OSHA 10', 'Backflow certification'],
    certifications: ['Pentair certified', 'Hayward Pro Edge', 'Jandy / Zodiac certified', 'IPSSA member', 'APSP member', 'NPC startup certified'],
    carriers: [],
    equipment: [
      { id:'service-trucks', name:'Service trucks',  kind:'number', def:3 },
      { id:'equipment-truck', name:'Equipment install rig', kind:'toggle', def:true },
      { id:'crane',          name:'Crane rental access',   kind:'toggle', def:false },
      { id:'tile-saw',       name:'Tile saw on-site',     kind:'toggle', def:true },
      { id:'chem-software',  name:'Chemistry tracker',    kind:'select', opts:['PoolPro Office','Skimmer','Paythepoolman','None'], def:'Skimmer' },
    ],
    objections: [
      { o:"It's just an old pump, just replace it.",                  r:"Sure, but single-speed pumps are illegal to install new in FL/CA — energy code. VS pump qualifies for $300 utility rebate that pays you back in 14 months. We file the paperwork." },
      { o:"My buddy can pour concrete way cheaper.",                   r:"For the deck, yes. For a gunite shell, you need shotcrete + reinforced steel + plumbing pre-pour. Different trade." },
      { o:"Why does the heater cost more than the pump?",             r:"Heater + heat-pump combo is the most expensive piece of gear in your yard. Last 12 yrs if maintained. Cheap heater fails in 3." },
    ],
    localMarket: [
      { id:'seasonal', q:'Service-plan months per year?',             kind:'number', suffix:'mo', def:9 },
      { id:'avgsize',  q:'Average pool size you service (gallons)?',  kind:'number', def:22000 },
      { id:'gunite',   q:'% of builds gunite vs vinyl?',              kind:'number', suffix:'% gunite', def:72 },
    ],
  },

  tree: {
    licenses: ['Tree care license / ISA-certified arborist', 'TRAQ qualified', 'Electrical hazards awareness', 'OSHA 10', 'Pesticide license (if treating)'],
    certifications: ['ISA Certified Arborist', 'ISA Board-Certified Master Arborist', 'TCIA accredited', 'TRAQ qualified', 'CTSP (Certified Treecare Safety Professional)'],
    carriers: ['State Farm','Allstate','USAA','Farmers','Liberty Mutual'],
    equipment: [
      { id:'bucket',     name:'Bucket truck (height)',  kind:'select', opts:['No bucket','45 ft','55 ft','65 ft','75 ft+'], def:'55 ft' },
      { id:'crane',      name:'Crane (tonnage)',         kind:'select', opts:['None','15-ton','23-ton','40-ton+'], def:'23-ton' },
      { id:'chipper',    name:'Chipper capacity',        kind:'select', opts:['6"','9"','12"','18"','24"'], def:'12"' },
      { id:'stumpgrind', name:'Stump grinder',           kind:'toggle', def:true },
      { id:'climbers',   name:'Climbing arborists on staff', kind:'number', def:3 },
    ],
    objections: [
      { o:"Can't I just top the tree?",                                r:"Topping kills the tree in 3–5 yrs and creates more hazard (water sprouts). Proper crown reduction looks the same and the tree lives." },
      { o:"The other quote is half this.",                              r:"Two reasons that's suspicious: 1) they're unlicensed, your homeowner's won't cover damage. 2) cash-only no-receipts is a red flag at audit." },
      { o:"It's leaning, but it's fine.",                              r:"Maybe. TRAQ assessment is $185 and tells you risk class. If it's class 4, your insurance won't pay if it falls because they have notice now." },
    ],
    localMarket: [
      { id:'oakratio', q:'% of removals that are oak (>24" dbh)?',     kind:'number', suffix:'%', def:48 },
      { id:'stormcalls', q:'Storm cleanup calls per year?',            kind:'number', def:42 },
    ],
  },

  default: {
    licenses: ['State contractor license', 'OSHA 10'],
    certifications: [],
    carriers: [],
    equipment: [
      { id:'trucks', name:'Service trucks', kind:'number', def:2 },
      { id:'tools',  name:'Tool inventory tracker', kind:'toggle', def:false },
    ],
    objections: [
      { o:"You're more expensive than the other quote.", r:"Compare scope, not totals. We do X, Y, Z that they probably won't." },
      { o:"I want to think about it.", r:"Of course — anything specific that's unclear? Happy to break it down." },
    ],
    localMarket: [
      { id:'season', q:'Your busiest months?', kind:'multi', opts:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'], def:[] },
    ],
  },
};

const ONBOARDING_STEPS_V2 = [
  { id:'welcome',     title:'Welcome',      heading:'Tell us about the business.',         sub:'Five minutes to set the floor. We do the rest.' },
  { id:'certs',       title:'Licensing',    heading:'License, certs, and carriers.',       sub:"What you're allowed to install, and what manufacturers + carriers stand behind you." },
  { id:'services',    title:'Service mix',  heading:'What jobs do you take?',              sub:"Pick everything you'd quote on a normal week. We won't price what you don't sell." },
  { id:'equipment',   title:'Equipment',    heading:'Trucks, tools, fleet.',                sub:'What you own determines what we can dispatch fast.' },
  { id:'pricing',     title:'Price book',   heading:'Your labor, materials, margins.',     sub:'These set the floor. The engine flexes above them based on the world — never below.' },
  { id:'fields',      title:'Estimate form',heading:'Your fields.',                         sub:"We pre-loaded the defaults your trade actually uses. Drop what you don't need; add anything missing." },
  { id:'history',     title:'Job library',  heading:'Upload your last 50 jobs.',           sub:'This is how the AI learns your style. PDFs, photos, exports — anything goes.' },
  { id:'intake',      title:'Lead intake',  heading:'What should we ask leads?',           sub:'Toggle the questions your CSR asks. Reorder them. Add custom ones.' },
  { id:'voice',       title:'Voice',        heading:'How should the system sound?',        sub:"Real humans, not robots. Set the tone and the words it should — and shouldn't — say." },
  { id:'playbook',    title:'Playbook',     heading:'Common objections + your rebuttals.', sub:'These are the lines that win deals on the second call. The AI learns them and uses them on chat.' },
  { id:'connect',     title:'Connections',  heading:'Plug in your stack.',                 sub:"Calendar, CRM, payments, dispatch, suppliers. Skip whatever's not in your kit." },
  { id:'market',      title:'Local market', heading:'What does your zip act like?',         sub:"The ground truth nobody else gets right — storms, claim sizes, seasonality, the HOA-heavy neighborhoods." },
  { id:'review',      title:'Review',       heading:'Last look before we install.',         sub:'Five-minute review, then a real human reaches out to schedule install.' },
];

function getOnboardingDetail(cat) {
  return ONBOARDING_DETAIL[cat] || ONBOARDING_DETAIL.default;
}

Object.assign(window, { ONBOARDING_DETAIL, ONBOARDING_STEPS_V2, getOnboardingDetail });
