-- ============================================================================
-- 09 Seed data
-- NOTE: LGAs and towns are NOT seeded here. Import them from official INEC/NBS
-- data with `php artisan locations:import <csv>` (command included in Phase 1)
-- so the list is exact, not typed from memory.
-- ============================================================================

INSERT INTO states (name, slug, code, geopolitical_zone) VALUES
 ('Benue','benue','BE','North Central'), ('Kogi','kogi','KO','North Central'),
 ('Kwara','kwara','KW','North Central'), ('Nasarawa','nasarawa','NA','North Central'),
 ('Niger','niger','NI','North Central'), ('Plateau','plateau','PL','North Central'),
 ('Federal Capital Territory','fct','FC','North Central'),
 ('Adamawa','adamawa','AD','North East'), ('Bauchi','bauchi','BA','North East'),
 ('Borno','borno','BO','North East'), ('Gombe','gombe','GO','North East'),
 ('Taraba','taraba','TA','North East'), ('Yobe','yobe','YO','North East'),
 ('Jigawa','jigawa','JI','North West'), ('Kaduna','kaduna','KD','North West'),
 ('Kano','kano','KN','North West'), ('Katsina','katsina','KT','North West'),
 ('Kebbi','kebbi','KE','North West'), ('Sokoto','sokoto','SO','North West'),
 ('Zamfara','zamfara','ZA','North West'),
 ('Abia','abia','AB','South East'), ('Anambra','anambra','AN','South East'),
 ('Ebonyi','ebonyi','EB','South East'), ('Enugu','enugu','EN','South East'),
 ('Imo','imo','IM','South East'),
 ('Akwa Ibom','akwa-ibom','AK','South South'), ('Bayelsa','bayelsa','BY','South South'),
 ('Cross River','cross-river','CR','South South'), ('Delta','delta','DE','South South'),
 ('Edo','edo','ED','South South'), ('Rivers','rivers','RI','South South'),
 ('Ekiti','ekiti','EK','South West'), ('Lagos','lagos','LA','South West'),
 ('Ogun','ogun','OG','South West'), ('Ondo','ondo','ON','South West'),
 ('Osun','osun','OS','South West'), ('Oyo','oyo','OY','South West');

-- ----------------------------------------------------------------------------
-- Permission catalogue
-- ----------------------------------------------------------------------------
INSERT INTO permissions (code, area, description) VALUES
 ('users.view',                 'users',    'View member list and non-sensitive profile data'),
 ('users.view_pii',             'users',    'View contact details (email, phone); every view is logged'),
 ('users.create',               'users',    'Create regular member accounts'),
 ('users.update',               'users',    'Modify regular member accounts'),
 ('users.suspend',              'users',    'Suspend or ban a member on proven rule infringement'),
 ('users.delete',               'users',    'Delete a member account'),
 ('staff.view',                 'staff',    'View staff list'),
 ('staff.manage_admin',         'staff',    'Create, suspend or delete the second Admin (primary Admin only)'),
 ('staff.manage_manager',       'staff',    'Create, modify, suspend or delete Managers'),
 ('staff.manage_supervisor',    'staff',    'Create, modify, suspend or delete Supervisors'),
 ('staff.manage_specialist',    'staff',    'Create, modify, suspend or delete Finance, Ad Review and Legal officers'),
 ('posts.view_all',             'content',  'View all posts including pending and removed'),
 ('posts.moderate',             'content',  'Approve, reject or remove posts'),
 ('posts.delete',               'content',  'Delete posts'),
 ('posts.legal_hold',           'content',  'Place a post under legal hold and block syndication'),
 ('posts.request_anonymous_identity','content','Request disclosure of an anonymous author (needs Admin approval)'),
 ('posts.approve_anonymous_identity','content','Approve disclosure of an anonymous author'),
 ('comments.moderate',          'content',  'Hide or remove comments'),
 ('groups.manage',              'groups',   'Create, modify, enable, disable or delete groups'),
 ('groups.suspend',             'groups',   'Suspend groups'),
 ('champions.verify',           'champions','Verify officials and Champions and award badges'),
 ('champions.manage',           'champions','Manage Champion records'),
 ('pages.manage',               'cms',      'Create, modify, enable, disable and delete pages'),
 ('seo.manage',                 'cms',      'Edit title tags, meta text and headings'),
 ('menus.manage',               'cms',      'Edit navigation menus'),
 ('themes.manage',              'cms',      'Activate and deactivate themes'),
 ('settings.manage',            'system',   'Change general site settings'),
 ('features.toggle',            'system',   'Switch ads, profit sharing and shop on or off (needs 2FA re-confirmation)'),
 ('support.respond',            'support',  'Answer tickets and live chat'),
 ('support.user_summary',       'support',  'See the limited customer summary needed to help someone'),
 ('ads.review',                 'ads',      'Review and approve ad creatives and campaigns'),
 ('ads.providers',              'ads',      'Manage external ad providers and placements'),
 ('ads.reports',                'ads',      'View ad performance reports'),
 ('finance.view',               'finance',  'View financial records and the profit dashboard'),
 ('finance.payouts',            'finance',  'Approve creator payouts and advertiser refunds'),
 ('shop.manage',                'shop',     'Manage products, drops and inventory'),
 ('shop.orders',                'shop',     'Process orders and shipments'),
 ('shop.refunds',               'shop',     'Issue refunds'),
 ('legal.takedown',             'legal',    'Handle legal and takedown notices'),
 ('social.manage',              'social',   'Connect social accounts and manage auto-posting'),
 ('rss.manage',                 'social',   'Edit RSS ping provider list'),
 ('push.broadcast',             'system',   'Send targeted push notifications'),
 ('analytics.view',             'system',   'View platform analytics'),
 ('audit.view',                 'system',   'View audit logs'),
 ('trash.manage',               'system',   'Restore items from the trash and purge them early');

-- Admin: everything
INSERT INTO role_permissions (role, permission_code)
    SELECT 'admin', code FROM permissions;

-- Manager: runs people and content, cannot touch Admins, create/delete members, or switch money features
INSERT INTO role_permissions (role, permission_code)
    SELECT 'manager', code FROM permissions WHERE code IN (
     'users.view','users.view_pii','users.suspend',
     'staff.view','staff.manage_supervisor',
     'posts.view_all','posts.moderate','posts.delete','comments.moderate',
     'groups.manage','groups.suspend','champions.verify','champions.manage',
     'pages.manage','seo.manage','menus.manage',
     'support.respond','support.user_summary','push.broadcast',
     'finance.view','ads.reports','shop.orders','analytics.view','audit.view','trash.manage');

-- Supervisor: moderation and customer support only; limited record visibility
INSERT INTO role_permissions (role, permission_code)
    SELECT 'supervisor', code FROM permissions WHERE code IN (
     'users.view','posts.view_all','posts.moderate','comments.moderate',
     'support.respond','support.user_summary');

INSERT INTO role_permissions (role, permission_code)
    SELECT 'finance_officer', code FROM permissions WHERE code IN (
     'finance.view','finance.payouts','ads.reports','shop.orders','shop.refunds','analytics.view');

INSERT INTO role_permissions (role, permission_code)
    SELECT 'ad_reviewer', code FROM permissions WHERE code IN ('ads.review','ads.reports');

INSERT INTO role_permissions (role, permission_code)
    SELECT 'legal_officer', code FROM permissions WHERE code IN (
     'legal.takedown','posts.view_all','posts.legal_hold','posts.request_anonymous_identity','audit.view');

-- ----------------------------------------------------------------------------
-- Site settings. Anything that costs money or has legal weight starts OFF.
-- Anonymous posting is always available (no switch), by design.
-- ----------------------------------------------------------------------------
INSERT INTO site_settings (key, value, group_name, description, is_public) VALUES
 ('site_name',               '"Absurdities NG"',                  'general', 'Public site name', true),
 ('owner_name',              '"FlamyTech Computers Limited"',     'general', 'Legal owner and operator', true),
 ('owner_url',               '"https://www.flamytech.com"',       'general', 'Owner website', true),
 ('registration_open',       'true',                              'general', 'Allow new member sign-ups', true),
 ('ads_enabled',             'false',                             'features','Master ads switch; OFF at launch', false),
 ('profit_sharing_enabled',  'false',                             'features','Creator revenue sharing; independent of ads_enabled; OFF at launch', false),
 ('shop_enabled',            'false',                             'features','Shop at /shop; OFF at launch', true),
 ('social_autopost_enabled', 'false',                             'features','Auto-post approved posts to official social accounts', false),
 ('search_public',           'true',                              'features','Search open to logged-out visitors', true),
 ('push_enabled',            'true',                              'features','Push notifications', true),
 ('sniffer_enabled',         'true',                              'features','Sniffer AI Assistant', true),
 ('sniffer_daily_limit',     '10',                                'sniffer', 'Requests per member per day', false),
 ('max_admins',              '2',                                 'staff',   'Maximum number of Admins', false),
 ('two_factor_reminder_days','7',                                 'security','Days between 2FA reminders for members without it', false),
 ('two_factor_required_roles','["advertiser"]',                   'security','Member account types that must use 2FA', false),
 ('username_change_cooldown_days','30',                           'accounts','Days between username changes', false),
 ('username_redirect_days',  '90',                                'accounts','Days an old username keeps redirecting', false),
 ('trash_retention_days_member','30',                             'trash',   'Days a member can undo a delete', false),
 ('trash_retention_days_staff','90',                              'trash',   'Days staff-deleted items stay recoverable', false),
 ('undo_toast_seconds',      '10',                                'trash',   'Seconds the Undo button stays visible', true),
 ('rss_items_per_feed',      '50',                                'rss',     'Items per RSS/Atom feed', false),
 ('rss_full_text',           'false',                             'rss',     'Full post text in feeds instead of excerpts', false),
 ('share_networks',          '["whatsapp","facebook","instagram","x","telegram","linkedin","email","sms","copy_link"]','sharing','Enabled share targets', true),
 ('cookie_consent_required', 'true',                              'privacy', 'Block external ad and analytics scripts until consent', true),
 ('vetting_auto_publish',    'true',                              'moderation','Publish automatically when all instant checks pass', false);

INSERT INTO reserved_usernames (username, reason) VALUES
 ('admin','system'),('administrator','system'),('cytadel','system'),('support','system'),('help','system'),
 ('staff','system'),('moderator','system'),('system','system'),('root','system'),('api','system'),
 ('www','system'),('mail','system'),('login','system'),('logout','system'),('register','system'),
 ('users','system'),('user','system'),('shop','system'),('search','system'),('groups','system'),
 ('champions','system'),('official','system'),('verified','system'),('sniffer','system'),
 ('password','system'),('forgot-password','system'),('reset-password','system'),('two-factor','system'),
 ('settings','system'),('account','system'),('me','system'),('profile','system'),('check','system'),
 ('suggest','system'),('verify','system'),('email','system'),('notifications','system'),('feed','system'),
 ('explore','system'),('rss','system'),('sitemap','system'),('static','system'),('assets','system'),
 ('absurdities','brand'),('absurditiesng','brand'),('absurdities_ng','brand'),('flamytech','brand'),
 ('president','office'),('vicepresident','office'),('governor','office'),('senator','office'),
 ('minister','office'),('commissioner','office'),('speaker','office'),('chairman','office'),
 ('inec','office'),('efcc','office'),('police','office'),('nigeria','office'),('fgn','office');

INSERT INTO categories (name, slug, description, icon, sort_order) VALUES
 ('Roads & Infrastructure','roads-infrastructure','Potholes, bridges, abandoned projects','road',1),
 ('Power & Electricity','power-electricity','Outages, transformers, billing','bolt',2),
 ('Water & Sanitation','water-sanitation','Boreholes, drainage, waste','droplet',3),
 ('Health','health','Hospitals, clinics, drugs','heart-pulse',4),
 ('Education','education','Schools, classrooms, teachers','book',5),
 ('Transport','transport','Motor parks, rail, airports, fares','bus',6),
 ('Security','security','Checkpoints, safety','shield',7),
 ('Public Service Conduct','public-service-conduct','Bribery, delays, poor service','building-columns',8),
 ('Markets & Prices','markets-prices','Market conditions, price absurdities','store',9),
 ('Environment','environment','Erosion, pollution, flooding','leaf',10),
 ('Other','other','Anything else that needs fixing','circle-question',99);

INSERT INTO notification_types (code, label, default_push, default_email, default_in_app) VALUES
 ('post_approved','Your post was approved',true,false,true),
 ('post_rejected','Your post needs changes',true,true,true),
 ('claim_made','Someone claimed your absurdity',true,false,true),
 ('claim_update','Update on a claimed absurdity',true,false,true),
 ('claim_resolved','An absurdity you follow was resolved',true,false,true),
 ('comment_reply','Reply to your comment',true,false,true),
 ('post_comment','New comment on your post',true,false,true),
 ('post_confirmed','Someone confirmed your post',true,false,true),
 ('new_follower','New follower',false,false,true),
 ('followed_area_post','New post in a followed place',true,false,true),
 ('saved_search_match','New result for a saved search',true,true,true),
 ('group_invite','Group invitation',true,false,true),
 ('group_request','Join request for your group',true,false,true),
 ('sniffer_suggestion','Sniffer topic suggestion',true,false,true),
 ('security_alert','Security alert',true,true,true),
 ('two_factor_reminder','Turn on two-factor authentication',false,true,true),
 ('order_update','Order update',true,true,true),
 ('system_announcement','Announcement',true,false,true);

INSERT INTO home_sections (section_key, heading_h2, intro_text, columns_count, rows_count, sort_order) VALUES
 ('trending','Trending Absurdities in Nigeria','What Nigerians are talking about right now.',3,2,1),
 ('popular','Most Popular Absurdities in Nigeria','The issues that have rallied the most support.',3,2,2);

INSERT INTO menus (location, name) VALUES
 ('header','Header'),('footer','Footer'),('footer_legal','Legal links'),('mobile','Mobile bottom bar');

INSERT INTO menu_items (menu_id, label, url, requires_feature, sort_order)
    SELECT m.id, v.label, v.url, v.feature, v.sort_order FROM menus m JOIN (VALUES
      ('header','Home','/',NULL,1), ('header','Explore','/explore',NULL,2),
      ('header','Champions','/champions',NULL,3), ('header','Groups','/groups',NULL,4),
      ('header','Shop','/shop','shop_enabled',5),
      ('footer','About','/about',NULL,1), ('footer','How it works','/how-it-works',NULL,2),
      ('footer','Contact','/contact',NULL,3),
      ('footer_legal','Terms of Service','/terms',NULL,1), ('footer_legal','Privacy Policy','/privacy',NULL,2),
      ('footer_legal','Community Guidelines','/community-guidelines',NULL,3)
    ) AS v(location, label, url, feature, sort_order) ON v.location = m.location;

INSERT INTO pages (slug, template, is_system, status, title_tag, meta_description, h1_text, hero_headline, hero_subline,
                   hero_cta_primary_label, hero_cta_primary_url, hero_cta_secondary_label, hero_cta_secondary_url) VALUES
 ('home','home',true,'enabled','Absurdities NG | Expose What Needs Fixing in Nigeria',
  'Film it, post it, get it fixed. Absurdities NG puts everyday absurdities in front of the people who can fix them.',
  'Absurdities NG','See it. Film it. Get it fixed.',
  'Nigeria''s home for everyday absurdities and the Champions who fix them.',
  'Post an Absurdity','/users/register','Explore Trending','/explore'),
 ('about','default',false,'enabled','About Absurdities NG','Why Absurdities NG exists and who is behind it.','About Absurdities NG',NULL,NULL,NULL,NULL,NULL,NULL),
 ('how-it-works','default',false,'enabled','How Absurdities NG Works','Post an absurdity, find a Champion, track the fix.','How it works',NULL,NULL,NULL,NULL,NULL,NULL),
 ('terms','default',false,'draft','Terms of Service','Terms of service for Absurdities NG.','Terms of Service',NULL,NULL,NULL,NULL,NULL,NULL),
 ('privacy','default',false,'draft','Privacy Policy','How Absurdities NG handles your data under the NDPA.','Privacy Policy',NULL,NULL,NULL,NULL,NULL,NULL),
 ('community-guidelines','default',false,'draft','Community Guidelines','What you can and cannot post.','Community Guidelines',NULL,NULL,NULL,NULL,NULL,NULL),
 ('contact','default',false,'enabled','Contact Absurdities NG','Reach the Absurdities NG team.','Contact us',NULL,NULL,NULL,NULL,NULL,NULL),
 ('shop','shop',true,'disabled','Absurdities NG Shop','Official Absurdities NG merchandise.','Shop',NULL,NULL,NULL,NULL,NULL,NULL),
 ('search','search',true,'enabled','Search Absurdities NG','Search posts, Champions, groups and places.','Search',NULL,NULL,NULL,NULL,NULL,NULL);
UPDATE pages SET robots = 'noindex,follow' WHERE slug = 'search';

-- Ad slots (inert until ads_enabled is switched on)
INSERT INTO ad_placements (code, name, page_type, width, height, device, sort_order) VALUES
 ('home_below_hero','Home: below hero','home',970,250,'all',1),
 ('home_between_sections','Home: between sections','home',728,90,'desktop',2),
 ('home_mobile_between','Home: mobile between sections','home',320,100,'mobile',3),
 ('feed_in_stream_1','Feed: after 3rd card','post',NULL,NULL,'all',4),
 ('feed_in_stream_2','Feed: after 9th card','post',NULL,NULL,'all',5),
 ('post_below_title','Post: below title','post',728,90,'all',6),
 ('post_mid_content','Post: in content','post',336,280,'all',7),
 ('post_sidebar_top','Post: sidebar top','post',300,250,'desktop',8),
 ('post_footer','Post: after comments','post',728,90,'all',9),
 ('search_top','Search: above results','search',728,90,'all',10),
 ('profile_sidebar','Profile: sidebar','profile',300,250,'desktop',11);

INSERT INTO product_categories (name, slug, sort_order) VALUES
 ('T-Shirts & Hoodies','apparel',1),('Caps & Hats','headwear',2),('Stickers & Pins','stickers-pins',3),
 ('Mugs & Bottles','drinkware',4),('Bags','bags',5),('Notebooks & Stationery','stationery',6);

INSERT INTO social_caption_templates (platform, name, template, is_default) VALUES
 ('x','Default','{title} - {state}, {lga}. {officials} {hashtags} {link}',true),
 ('facebook','Default','{title}\n\nWhere: {town}, {lga}, {state}\n{officials}\n\nSee the full story and how to help: {link}\n{hashtags}',true),
 ('instagram','Default','{title}\n\n{town}, {lga}, {state}\n\nLink in bio. {hashtags}',true),
 ('youtube','Default','{title} | {town}, {state}\n\n{summary}\n\nFull story: {link}\n{hashtags}',true),
 ('tiktok','Default','{title} - {state} {hashtags}',true);

INSERT INTO search_stop_words (word) VALUES ('the'),('and'),('of'),('in'),('at'),('to'),('a'),('is');
INSERT INTO search_synonyms (term, synonym) VALUES
 ('nepa','phcn'),('nepa','disco'),('nepa','electricity'),('light','electricity'),
 ('road','pothole'),('road','highway'),('hospital','clinic'),('okada','motorcycle');
