INSERT INTO users (name, email, password_hash, role, is_verified, verified_at, created_at, updated_at)
VALUES ('Platform Admin', 'admin@example.com', '$2y$12$mGqsnX2zSTxXcCJjBbUYser6rf6L/wM5CUekyxS5ftNuhfDI0EOge', 'super_admin', 1, NOW(), NOW(), NOW())
ON DUPLICATE KEY UPDATE email = email;

INSERT INTO user_profiles (user_id, display_name, favorite_sport, xp_points, created_at, updated_at)
SELECT id, 'Platform Admin', 'nba', 1000, NOW(), NOW() FROM users WHERE email = 'admin@example.com'
ON DUPLICATE KEY UPDATE display_name = display_name;

INSERT INTO teams (sport, name, city, abbr, created_at, updated_at) VALUES
('nba','Toronto Raptors','Toronto','TOR',NOW(),NOW()),
('nba','Los Angeles Lakers','Los Angeles','LAL',NOW(),NOW()),
('nba','Boston Celtics','Boston','BOS',NOW(),NOW()),
('nba','Golden State Warriors','Golden State','GSW',NOW(),NOW()),
('nhl','Vancouver Canucks','Vancouver','VAN',NOW(),NOW()),
('nhl','Toronto Maple Leafs','Toronto','TOR',NOW(),NOW()),
('nhl','Edmonton Oilers','Edmonton','EDM',NOW(),NOW()),
('nhl','Montreal Canadiens','Montreal','MTL',NOW(),NOW()),
('mlb','Toronto Blue Jays','Toronto','TOR',NOW(),NOW()),
('mlb','New York Yankees','New York','NYY',NOW(),NOW()),
('mlb','Los Angeles Dodgers','Los Angeles','LAD',NOW(),NOW()),
('mlb','Boston Red Sox','Boston','BOS',NOW(),NOW());

INSERT INTO players (sport, team_id, name, position, status, created_at, updated_at)
SELECT 'nba', id, CONCAT(name, ' Demo Guard'), 'G', 'active', NOW(), NOW() FROM teams WHERE sport = 'nba';
INSERT INTO players (sport, team_id, name, position, status, created_at, updated_at)
SELECT 'nba', id, CONCAT(name, ' Demo Forward'), 'F', 'active', NOW(), NOW() FROM teams WHERE sport = 'nba';
INSERT INTO players (sport, team_id, name, position, status, created_at, updated_at)
SELECT 'nhl', id, CONCAT(name, ' Demo Wing'), 'W', 'active', NOW(), NOW() FROM teams WHERE sport = 'nhl';
INSERT INTO players (sport, team_id, name, position, status, created_at, updated_at)
SELECT 'nhl', id, CONCAT(name, ' Demo Goalie'), 'G', 'active', NOW(), NOW() FROM teams WHERE sport = 'nhl';
INSERT INTO players (sport, team_id, name, position, status, created_at, updated_at)
SELECT 'mlb', id, CONCAT(name, ' Demo Pitcher'), 'P', 'active', NOW(), NOW() FROM teams WHERE sport = 'mlb';
INSERT INTO players (sport, team_id, name, position, status, created_at, updated_at)
SELECT 'mlb', id, CONCAT(name, ' Demo Slugger'), '1B', 'active', NOW(), NOW() FROM teams WHERE sport = 'mlb';

INSERT INTO community_rooms (sport, name, slug, description, is_active, created_at, updated_at) VALUES
('nba','NBA Main Court','nba-main-court','Basketball talk, lineups, trades, and weekly matchups.',1,NOW(),NOW()),
('nhl','Hockey Rival Room','hockey-rival-room','Goals, goalies, hits, blocks, and fan rivalries.',1,NOW(),NOW()),
('mlb','Baseball Clubhouse','baseball-clubhouse','Pitchers, sluggers, matchups, and season chatter.',1,NOW(),NOW());

INSERT INTO rewards (title, description, reward_type, points_cost, is_active, created_at, updated_at) VALUES
('Verified Founder Badge','Early member badge for verified launch users.','badge',250,1,NOW(),NOW()),
('Profile Spotlight','Feature your profile in the community sidebar.','feature',500,1,NOW(),NOW()),
('Private League Theme','Unlock a custom visual theme for one private league.','theme',750,1,NOW(),NOW()),
('Merch Discount Code','Admin-approved discount code for future merch campaigns.','discount',1000,1,NOW(),NOW());

INSERT INTO settings (setting_key, setting_value, created_at, updated_at) VALUES
('validation_only_mode','true',NOW(),NOW()),
('cash_prizes_enabled','false',NOW(),NOW()),
('paid_entry_enabled','false',NOW(),NOW()),
('material_prizes_enabled','false',NOW(),NOW())
ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value);


INSERT INTO news_sources (name, source_type, base_url, api_key_name, is_active, created_at, updated_at) VALUES
('Manual Editorial Desk','manual','#',NULL,1,NOW(),NOW()),
('Demo Sports Data Feed','api','#','SPORTS_API_KEY',1,NOW(),NOW())
ON DUPLICATE KEY UPDATE name = name;

INSERT INTO plans (name, slug, price_cents, currency, billing_interval, description, is_active, sort_order, created_at, updated_at) VALUES
('Free Fan','free-fan',0,'CAD','monthly','Public leagues, core community, basic news, and starter rewards.',1,10,NOW(),NOW()),
('Verified Fan','verified-fan',100,'CAD','one_time','One-time account validation layer for trust, verified badge, and rewards wallet access.',1,20,NOW(),NOW()),
('Fan Pro','fan-pro',499,'CAD','monthly','More leagues, advanced stats, alerts, trends, and fantasy-impact news.',1,30,NOW(),NOW()),
('Commissioner Pro','commissioner-pro',999,'CAD','monthly','Private league tools, custom scoring, draft controls, trade settings, and branded league features.',1,40,NOW(),NOW()),
('Club / Brand','club-brand',2999,'CAD','monthly','Branded rooms, sponsor placements, advanced moderation, and community growth tools.',1,50,NOW(),NOW())
ON DUPLICATE KEY UPDATE price_cents = VALUES(price_cents), description = VALUES(description), sort_order = VALUES(sort_order), updated_at = NOW();

INSERT INTO plan_features (plan_id, feature_key, feature_label, feature_value, created_at)
SELECT p.id, f.feature_key, f.feature_label, f.feature_value, NOW()
FROM plans p
JOIN (
    SELECT 'free-fan' slug, 'max_leagues' feature_key, 'Active Leagues' feature_label, '3' feature_value UNION ALL
    SELECT 'free-fan','can_view_basic_news','Basic News','true' UNION ALL
    SELECT 'verified-fan','verified_badge','Verified Badge','true' UNION ALL
    SELECT 'verified-fan','rewards_wallet','Rewards Wallet','true' UNION ALL
    SELECT 'verified-fan','max_leagues','Active Leagues','5' UNION ALL
    SELECT 'fan-pro','max_leagues','Active Leagues','25' UNION ALL
    SELECT 'fan-pro','can_access_advanced_stats','Advanced Stats','true' UNION ALL
    SELECT 'fan-pro','can_access_ai_fantasy_impact','Fantasy Impact Alerts','true' UNION ALL
    SELECT 'fan-pro','can_schedule_news_alerts','News Alerts','true' UNION ALL
    SELECT 'commissioner-pro','max_leagues','Active Leagues','50' UNION ALL
    SELECT 'commissioner-pro','can_create_private_leagues','Private Leagues','true' UNION ALL
    SELECT 'commissioner-pro','can_use_custom_scoring','Custom Scoring','true' UNION ALL
    SELECT 'commissioner-pro','can_use_draft_room','Draft Room','true' UNION ALL
    SELECT 'commissioner-pro','can_export_league_data','League Exports','true' UNION ALL
    SELECT 'club-brand','max_leagues','Active Leagues','unlimited' UNION ALL
    SELECT 'club-brand','can_brand_community_room','Branded Rooms','true' UNION ALL
    SELECT 'club-brand','sponsor_posts','Sponsor Posts','true' UNION ALL
    SELECT 'club-brand','advanced_moderation','Advanced Moderation','true'
) f ON f.slug = p.slug
WHERE NOT EXISTS (SELECT 1 FROM plan_features pf WHERE pf.plan_id = p.id AND pf.feature_key = f.feature_key);

INSERT INTO sports_news (sport, title, slug, excerpt, source_url, published_at, fantasy_impact_score, fantasy_summary, impact_tag, status, created_at, updated_at) VALUES
('nba','NBA injury watch: fantasy managers monitor late lineup changes','nba-injury-watch-fantasy-managers-monitor-late-lineup-changes','Daily injury reports can shift fantasy value quickly. Watch backup minutes, usage rate, and matchup pace before locking lineups.','#',NOW(),82,'If a high-usage player sits, monitor bench players with increased minutes and usage. Treat this as a start/sit watch item.','Start/Sit Watch','published',NOW(),NOW()),
('nba','NBA waiver radar: high-minutes role players gaining attention','nba-waiver-radar-high-minutes-role-players-gaining-attention','Players with steady minutes, rebounding chances, or increased assist usage can become useful weekly streamers.','#',NOW(),71,'Target short-term pickups with minutes security and a fantasy-friendly schedule.','Waiver Wire','published',NOW(),NOW()),
('nhl','NHL goalie starts remain key for weekly fantasy matchups','nhl-goalie-starts-remain-key-for-weekly-fantasy-matchups','Confirmed starters, back-to-back schedules, and team defensive form can change goalie value before puck drop.','#',NOW(),79,'Confirmed starters are high-impact alerts. Prioritize save volume, opponent quality, and win probability.','Goalie Watch','published',NOW(),NOW()),
('nhl','NHL power-play movement creates new fantasy value','nhl-power-play-movement-creates-new-fantasy-value','Second-unit players moving to top power-play groups can become short-term pickups in deeper leagues.','#',NOW(),68,'Power-play promotion can increase shots, assists, and goal exposure. Add to watchlist.','Power Play','published',NOW(),NOW()),
('mlb','MLB pitching matchups drive streamer decisions this week','mlb-pitching-matchups-drive-streamer-decisions-this-week','Projected starters, park factors, and opponent strikeout rates matter when choosing short-term pitching help.','#',NOW(),76,'Streamer pitchers should be judged by matchup, pitch count, park, and opponent strikeout tendency.','Pitching Edge','published',NOW(),NOW()),
('mlb','MLB hot bats trend upward after lineup promotion','mlb-hot-bats-trend-upward-after-lineup-promotion','Lineup spot changes can create more plate appearances, run opportunities, and RBI chances for fantasy users.','#',NOW(),73,'Lineup promotion creates more volume. Monitor batted-ball quality and schedule strength.','Hot Bats','published',NOW(),NOW())
ON DUPLICATE KEY UPDATE fantasy_impact_score = VALUES(fantasy_impact_score), fantasy_summary = VALUES(fantasy_summary), updated_at = NOW();

INSERT INTO trend_snapshots (sport, trend_type, title, summary, score, entity_name, entity_type, created_at, updated_at) VALUES
('nba','player','NBA Guard Usage Spike','A guard profile is trending because of extra minutes and increased ball-handling responsibility.',86,'Usage Guard','player',NOW(),NOW()),
('nba','injury','NBA Questionable Tags','Late status changes are driving start/sit discussion before tipoff.',81,'Injury Watch','player',NOW(),NOW()),
('nhl','goalie','NHL Confirmed Starters','Goalie-start confirmations are creating the strongest fantasy movement.',84,'Goalie Watch','player',NOW(),NOW()),
('nhl','player','NHL Power-Play Adds','Power-play movement is creating short-term value in deeper leagues.',73,'Power Play Skater','player',NOW(),NOW()),
('mlb','pitcher','MLB Streamer Arms','Pitching matchups are trending for weekly lineup construction.',79,'Streamer Pitcher','player',NOW(),NOW()),
('mlb','player','MLB Hot Bat Lineup Boost','A hitter moving higher in the lineup is gaining fantasy attention.',74,'Hot Bat','player',NOW(),NOW())
ON DUPLICATE KEY UPDATE summary = VALUES(summary), score = VALUES(score), updated_at = NOW();

-- v1.2 MLS teams, public scoreboard settings, and randomizer defaults.
INSERT INTO teams (sport, name, city, abbr, external_id, created_at, updated_at) VALUES
('mls','Vancouver Whitecaps FC','Vancouver','VAN','demo-mls-vancouver',NOW(),NOW()),
('mls','Toronto FC','Toronto','TOR','demo-mls-toronto',NOW(),NOW()),
('mls','CF Montréal','Montréal','MTL','demo-mls-montreal',NOW(),NOW()),
('mls','Seattle Sounders FC','Seattle','SEA','demo-mls-seattle',NOW(),NOW());

INSERT INTO players (sport, team_id, name, position, status, created_at, updated_at)
SELECT 'mls', id, CONCAT(name, ' Demo Striker'), 'F', 'active', NOW(), NOW() FROM teams WHERE sport = 'mls';
INSERT INTO players (sport, team_id, name, position, status, created_at, updated_at)
SELECT 'mls', id, CONCAT(name, ' Demo Keeper'), 'GK', 'active', NOW(), NOW() FROM teams WHERE sport = 'mls';

INSERT INTO community_rooms (sport, name, slug, description, is_active, created_at, updated_at) VALUES
('mls','MLS Matchday Hub','mls-matchday-hub','Soccer matchday talk, clean sheets, assists, goals, and fantasy-style lineup debates.',1,NOW(),NOW())
ON DUPLICATE KEY UPDATE description = VALUES(description), updated_at = NOW();

INSERT INTO sports_news (sport, title, slug, excerpt, source_url, published_at, fantasy_impact_score, fantasy_summary, impact_tag, status, created_at, updated_at) VALUES
('mls','MLS lineup watch: rotation can shift fantasy-style value before kickoff','mls-lineup-watch-rotation-can-shift-fantasy-style-value-before-kickoff','Monitor confirmed XI news, short rest, travel, and set-piece roles before locking soccer fantasy picks.','#',NOW(),74,'Set-piece takers, starting forwards, and clean-sheet defenders usually create the strongest short-term soccer value.','Lineup Watch','published',NOW(),NOW()),
('mls','MLS clean sheet and assist trends become weekly decision points','mls-clean-sheet-and-assist-trends-become-weekly-decision-points','Defenders with attacking roles and goalkeepers with high save volume can swing fantasy-style weekly contests.','#',NOW(),69,'Target defenders with crossing volume and keepers facing manageable shot volume for weekly upside.','Soccer Edge','published',NOW(),NOW())
ON DUPLICATE KEY UPDATE fantasy_impact_score = VALUES(fantasy_impact_score), fantasy_summary = VALUES(fantasy_summary), updated_at = NOW();

INSERT INTO trend_snapshots (sport, trend_type, title, summary, score, entity_name, entity_type, created_at, updated_at) VALUES
('mls','lineup','MLS Starting XI Watch','Starting XI confirmations and set-piece roles are driving soccer fantasy-style decisions.',77,'Starting XI','team',NOW(),NOW()),
('mls','player','MLS Striker Form','Goal involvement and expected minutes are creating short-term lineup movement.',72,'Form Striker','player',NOW(),NOW())
ON DUPLICATE KEY UPDATE summary = VALUES(summary), score = VALUES(score), updated_at = NOW();

INSERT INTO settings (setting_key, setting_value, created_at, updated_at) VALUES
('sports_provider','espn',NOW(),NOW()),
('validation_required_for_league_creation','true',NOW(),NOW()),
('randomizer_enabled','true',NOW(),NOW()),
('espn_scoreboard_notice','ESPN scoreboard endpoints are public/undocumented and should be monitored for availability before production scale.',NOW(),NOW())
ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value), updated_at = NOW();
