-- Seed data — South Armz Global parent + 21 subsidiaries
-- Run after migrations/0001_init.sql

insert into public.organizations (slug, name, dba, tagline, blurb, industry, entity_type, status, state, emoji, primary_color)
values
  ('south-armz-global','South Armz Global','SAG','One family. Many ventures. Built in North Carolina.','South Armz Global is the parent holding company for a portfolio of operating businesses across food and beverage, hemp, technology, media, and recreation.','Holding','LLC','Active','NC','🏛️','#7a3e2e')
on conflict (slug) do update set
  name = excluded.name,
  tagline = excluded.tagline,
  blurb = excluded.blurb,
  updated_at = now();

-- Subsidiaries — parent_id linked via subquery
with parent as (select id from public.organizations where slug = 'south-armz-global')
insert into public.organizations (slug, name, dba, tagline, blurb, industry, entity_type, status, state, parent_id, website, emoji, primary_color)
select * from (values
  ('1nc-blockchain','1NC Blockchain',null,'Every county. One chain.','A North Carolina-first blockchain platform.','Blockchain & Finance','LLC','Active','NC',(select id from parent),'https://1ncblockchain.com','⛓️','#1e40af'),
  ('wccg-1045','WCCG 104.5 FM',null,'Sandhills sound. Carolina culture.','Independent FM broadcaster serving the Sandhills and Triangle.','Media & Broadcasting','LLC','Active','NC',(select id from parent),null,'📻','#dc2626'),
  ('koshu-sake','Koshu Aged American Sake','Koshu Sake Bar','American-aged sake. Slow brewed in North Carolina.','Aged-rice sake brewed locally. TTB winery permit application in progress.','Food & Beverage','LLC','Active','NC',(select id from parent),null,'🍶','#0f766e'),
  ('trap-sours','Trap Sours',null,'Bold flavors. Loud drops.','Sour beverages, candies, and limited drops.','Food & Beverage','LLC','Active','NC',(select id from parent),null,'🍬','#a21caf'),
  ('metal-brixx-cafe','Metal Brixx Cafe',null,'Coffee, comfort, community.','Neighborhood cafe and SAG anchor location.','Hospitality','LLC','Active','NC',(select id from parent),null,'☕','#92400e'),
  ('carolina-cannabar','Carolina Cannabar',null,'Bar-style hemp service.','Cannabar pour bar concept.','Hemp & Cannabis','LLC','Active','NC',(select id from parent),null,'🍃','#16a34a'),
  ('carolina-hemp-tours','Carolina Hemp Tours',null,'From farm to flight.','Guided tours of NC hemp farms.','Hemp & Cannabis','LLC','Active','NC',(select id from parent),null,'🌿','#15803d'),
  ('sandhills-hemp','Sandhills Hemp Company',null,'Hemp grown in the Sandhills.','Industrial hemp cultivation and processing.','Hemp & Cannabis','LLC','Active','NC',(select id from parent),null,'🌾','#65a30d'),
  ('chatham-axes','Chatham Axes',null,'Throw harder. Aim true.','Axe-throwing venue in Chatham County.','Recreation','LLC','Active','NC',(select id from parent),null,'🪓','#525252'),
  ('dj-ricoveli','DJ Ricoveli',null,'Live mixes. Original sets.','Master recording artist and live DJ.','Music & Entertainment','LLC','Active','NC',(select id from parent),null,'🎧','#7c3aed'),
  ('digital-gold','Digital Gold',null,'Premium digital products.','Digital goods and licensable IP.','Technology','LLC','Active','NC',(select id from parent),null,'🪙','#ca8a04'),
  ('gilmore-family-farms','Gilmore Family Farms',null,'Family roots. Carolina soil.','Family-owned working farm.','Agriculture','LLC','Active','NC',(select id from parent),null,'🚜','#15803d'),
  ('labor-yes','Labor Yes',null,'Labor on demand.','Labor placement and gig staffing.','Services','LLC','Active','NC',(select id from parent),null,'🛠️','#0369a1'),
  ('on-track-wellness','On Track Wellness and Recovery',null,'Forward, not back.','Outpatient wellness and recovery.','Health & Wellness','LLC','Active','NC',(select id from parent),null,'💚','#059669'),
  ('open-city-xr','Open City XR',null,'Extended-reality public spaces.','AR/VR/XR for civic and entertainment.','Technology','LLC','Active','NC',(select id from parent),null,'🕶️','#4338ca'),
  ('pittsboro-ebikes','Pittsboro eBikes',null,'Pedal-assist freedom.','eBike sales, service, rentals.','Retail','LLC','Active','NC',(select id from parent),null,'🚴','#0891b2'),
  ('sell-my-dog-network','Sell My Dog Network',null,'Find the right home, faster.','Marketplace for dog-rehoming and responsible breeders.','Technology','LLC','Active','NC',(select id from parent),null,'🐕','#b45309'),
  ('spectrum-recovery','Spectrum Recovery',null,'Recovery across the spectrum.','Specialty spectrum-disorder recovery services.','Health & Wellness','LLC','Active','NC',(select id from parent),null,'🩺','#0d9488'),
  ('tarheel-rewards','Tarheel Rewards',null,'Loyalty for Carolina.','Cross-portfolio loyalty rewards.','Technology','LLC','Active','NC',(select id from parent),null,'🎯','#0284c7'),
  ('the-plant','The Plant',null,'Where it all grows.','Multipurpose growing and R&D facility.','Agriculture','LLC','Active','NC',(select id from parent),null,'🪴','#65a30d'),
  ('the-virtual-muslim','The Virtual Muslim',null,'Faith, online and accessible.','Digital platform for Muslim community.','Technology','LLC','Active','NC',(select id from parent),null,'🕌','#1e7544'),
  ('transport-hub-logistics','Transport Hub Logistics',null,'Carolina freight, organized.','Logistics, dispatch, and freight brokerage.','Logistics','LLC','Active','NC',(select id from parent),null,'🚛','#1f2937')
) as v(slug,name,dba,tagline,blurb,industry,entity_type,status,state,parent_id,website,emoji,primary_color)
on conflict (slug) do update set
  name = excluded.name,
  tagline = excluded.tagline,
  blurb = excluded.blurb,
  updated_at = now();

-- Seed Koshu TTB application steps
with koshu as (select id from public.organizations where slug = 'koshu-sake')
insert into public.ttb_application_steps (organization_id, step_number, step_name, agency, form, description, estimated_duration_days)
select * from (values
  ((select id from koshu), 1, 'Qualify the bonded premises', 'Local zoning + landlord', null, 'Identify and secure physical location zoned for manufacturing/industrial use.', 14),
  ((select id from koshu), 2, 'Register on TTB Permits Online (PONL)', 'TTB', null, 'Create PONL account.', 2),
  ((select id from koshu), 3, 'File Application for Basic Permit (Wine Producer & Blender)', 'TTB', 'TTB F 5100.24', 'Federal Basic Permit application.', 7),
  ((select id from koshu), 4, 'Application to Establish and Operate Wine Premises', 'TTB', 'TTB F 5120.25', 'Companion to Basic Permit.', 7),
  ((select id from koshu), 5, 'File Wine Bond (or claim small-producer exemption)', 'TTB', 'TTB F 5120.36', 'Continuous penal-sum bond.', 14),
  ((select id from koshu), 6, 'Submit owner background documentation', 'TTB', null, 'EIN letter, articles, personnel questionnaires.', 7),
  ((select id from koshu), 7, 'TTB review and approval', 'TTB', null, 'TTB processes application incl. FBI background checks.', 75),
  ((select id from koshu), 8, 'Receive Federal Basic Permit', 'TTB', null, 'Permit delivered electronically.', 1),
  ((select id from koshu), 9, 'Apply for NC ABC Wine Manufacturer & Wholesaler permits', 'NC ABC Commission', null, 'State-level licenses required.', 45),
  ((select id from koshu), 10, 'Submit Certificate of Label Approval (COLA) per label', 'TTB', 'TTB F 5100.31', 'Every distinct sake label must be approved.', 45),
  ((select id from koshu), 11, 'Begin operations and file semi-monthly Excise Tax Returns', 'TTB', 'TTB F 5000.24', 'Federal excise tax filing.', null),
  ((select id from koshu), 12, 'File monthly Report of Wine Premises Operations', 'TTB', 'TTB F 5120.17', 'Monthly operational report.', null)
) as v(organization_id, step_number, step_name, agency, form, description, estimated_duration_days)
on conflict (organization_id, step_number) do nothing;
