-- Seed data: domains, default super-admin, badges, sample challenges.
-- IMPORTANT: replace the super-admin password hash by running:
--   node backend/utils/hash.js "YourStrongPassword"
-- and updating the value below before running this seed in production.

INSERT INTO domains (slug, name, emoji, description, sort_order) VALUES
 ('python',           'Python',           '🐍', 'Scripting, data, automation', 1),
 ('cpp',              'C++',              '💻', 'Systems & competitive programming', 2),
 ('frontend',         'Frontend',         '🎨', 'HTML, CSS, React, UX in code', 3),
 ('backend',          'Backend',          '⚙️', 'APIs, databases, services', 4),
 ('fullstack',        'Full Stack',       '🧱', 'End-to-end web engineering', 5),
 ('ai-ml',            'AI / ML',          '🤖', 'Models, data, prompts', 6),
 ('cyber-security',   'Cyber Security',   '🛡️', 'Offense, defense, recon', 7),
 ('uiux',             'UI / UX',          '✨', 'Interfaces & user journeys', 8),
 ('graphic-design',   'Graphic Design',   '🖌️', 'Visual identity & layout', 9),
 ('digital-marketing','Digital Marketing','📣', 'Funnels, ads, content', 10),
 ('seo',              'SEO',              '🔎', 'Search visibility & rankings', 11),
 ('video-editing',    'Video Editing',    '🎬', 'Cuts, color, motion', 12),
 ('content-writing',  'Content Writing',  '📝', 'Long-form & social copy', 13),
 ('mobile-dev',       'Mobile Dev',       '📱', 'iOS, Android, cross-platform', 14),
 ('devops',           'DevOps',           '🚀', 'CI/CD, infra, observability', 15),
 ('data-analytics',   'Data Analytics',   '📊', 'SQL, dashboards, insights', 16);

INSERT INTO badges (code, name, description, icon) VALUES
 ('first_blood',  'First Blood',      'Completed your first challenge',          '🩸'),
 ('streak_5',     '5-Streak',         '5 correct answers in a row',              '🔥'),
 ('top_10',       'Top 10',           'Reached the Top 10 in any domain',        '🏆'),
 ('top_3',        'Podium',           'Reached the Top 3 in any domain',         '🥇'),
 ('domain_pro',   'Domain Pro',       'Played 50+ challenges in one domain',     '🎯');

-- Default super-admin. Change this hash before production!
-- This hash is for password: "ChangeMe!123"
INSERT INTO users (email, password_hash, full_name, role, status, email_verified)
VALUES ('admin@prosensia.local',
        '$2b$10$wH3oYwQ3oQ8xQ2g8sQ8yJ.fEr9c5GZ0jKQp7dW0sJv7m6OQYJv8H6',
        'Prosensia Admin', 'superadmin', 'active', 1);

-- Sample MCQ for Python (id will be auto-assigned).
INSERT INTO challenges (domain_id, title, description, difficulty, type, points, time_limit_sec)
SELECT id, 'Python: list vs tuple', 'Which is immutable in Python?', 'easy', 'mcq', 10, 30
FROM domains WHERE slug = 'python';

SET @c := LAST_INSERT_ID();
INSERT INTO challenge_choices (challenge_id, body, is_correct, sort_order) VALUES
  (@c, 'list',     0, 1),
  (@c, 'tuple',    1, 2),
  (@c, 'dict',     0, 3),
  (@c, 'set',      0, 4);

INSERT INTO challenges (domain_id, title, description, difficulty, type, points, time_limit_sec)
SELECT id, 'Frontend: CSS specificity', 'Which selector has the HIGHEST specificity?', 'medium', 'mcq', 15, 45
FROM domains WHERE slug = 'frontend';

SET @c := LAST_INSERT_ID();
INSERT INTO challenge_choices (challenge_id, body, is_correct, sort_order) VALUES
  (@c, '.btn',                 0, 1),
  (@c, '#submit',              1, 2),
  (@c, 'button',               0, 3),
  (@c, 'button.btn',           0, 4);
