-- Create Admin User for the Music App
-- Password: admin123 (hashed with bcrypt)

INSERT INTO users (
  id,
  email,
  password_hash,
  name,
  role,
  is_active,
  is_verified,
  subscription_type,
  country,
  language,
  created_at,
  updated_at
) VALUES (
  'a0000000-0000-0000-0000-000000000001',
  'admin@musicapp.com',
  '$2a$10$rQEY7lSvBKAYqLf5HnV2NeOKLkGZ.T9ZqVjC5kj8nM3xfP1vYyXZS',
  'Admin Principal',
  'admin',
  true,
  true,
  'premium',
  'CI',
  'fr',
  NOW(),
  NOW()
) ON CONFLICT (email) DO UPDATE SET
  role = 'admin',
  is_active = true,
  is_verified = true,
  updated_at = NOW();

-- Create a demo artist user
INSERT INTO users (
  id,
  email,
  password_hash,
  name,
  role,
  is_active,
  is_verified,
  subscription_type,
  country,
  language,
  created_at,
  updated_at
) VALUES (
  'a0000000-0000-0000-0000-000000000002',
  'artist@musicapp.com',
  '$2a$10$rQEY7lSvBKAYqLf5HnV2NeOKLkGZ.T9ZqVjC5kj8nM3xfP1vYyXZS',
  'Artiste Demo',
  'artist',
  true,
  true,
  'premium',
  'CI',
  'fr',
  NOW(),
  NOW()
) ON CONFLICT (email) DO UPDATE SET
  role = 'artist',
  is_active = true,
  updated_at = NOW();

-- Create artist profile for demo artist
INSERT INTO artists (
  id,
  user_id,
  name,
  bio,
  country,
  genres,
  is_verified,
  monthly_listeners,
  total_followers,
  total_streams,
  created_at,
  updated_at
) VALUES (
  'b0000000-0000-0000-0000-000000000001',
  'a0000000-0000-0000-0000-000000000002',
  'Artiste Demo',
  'Artiste de demonstration pour la plateforme musicale.',
  'CI',
  ARRAY['Afrobeats', 'Coupe-Decale'],
  true,
  1500,
  500,
  25000,
  NOW(),
  NOW()
) ON CONFLICT (user_id) DO UPDATE SET
  name = EXCLUDED.name,
  updated_at = NOW();

-- Create a demo regular user
INSERT INTO users (
  id,
  email,
  password_hash,
  name,
  role,
  is_active,
  is_verified,
  subscription_type,
  country,
  language,
  created_at,
  updated_at
) VALUES (
  'a0000000-0000-0000-0000-000000000003',
  'user@musicapp.com',
  '$2a$10$rQEY7lSvBKAYqLf5HnV2NeOKLkGZ.T9ZqVjC5kj8nM3xfP1vYyXZS',
  'Utilisateur Demo',
  'user',
  true,
  true,
  'free',
  'CI',
  'fr',
  NOW(),
  NOW()
) ON CONFLICT (email) DO UPDATE SET
  role = 'user',
  is_active = true,
  updated_at = NOW();

-- Fixed UUIDs to use valid hex characters (replaced 'g' with 'c' and 'p' with 'd')
-- Add some sample genres if not exists
INSERT INTO genres (id, name, slug, description, color, is_featured, track_count) VALUES
  ('c0000000-0000-0000-0000-000000000001', 'Afrobeats', 'afrobeats', 'Musique afro contemporaine', '#FF6B35', true, 0),
  ('c0000000-0000-0000-0000-000000000002', 'Coupe-Decale', 'coupe-decale', 'Genre musical ivoirien', '#FFD700', true, 0),
  ('c0000000-0000-0000-0000-000000000003', 'Hip-Hop', 'hip-hop', 'Rap et Hip-Hop', '#9B59B6', true, 0),
  ('c0000000-0000-0000-0000-000000000004', 'R&B', 'rnb', 'Rhythm and Blues', '#E74C3C', true, 0),
  ('c0000000-0000-0000-0000-000000000005', 'Pop', 'pop', 'Musique populaire', '#3498DB', true, 0),
  ('c0000000-0000-0000-0000-000000000006', 'Reggae', 'reggae', 'Musique jamaicaine', '#27AE60', false, 0),
  ('c0000000-0000-0000-0000-000000000007', 'Jazz', 'jazz', 'Musique jazz', '#8E44AD', false, 0),
  ('c0000000-0000-0000-0000-000000000008', 'Gospel', 'gospel', 'Musique religieuse', '#F39C12', false, 0)
ON CONFLICT (slug) DO NOTHING;

-- Fixed UUIDs to use valid hex characters (replaced 'p' with 'd')
-- Add subscription plans if not exist
INSERT INTO subscription_plans (id, name, slug, description, price_monthly, price_yearly, features, max_devices, offline_listening, ad_free, hifi_quality, is_active) VALUES
  ('d0000000-0000-0000-0000-000000000001', 'Gratuit', 'free', 'Acces basique avec publicites', 0, 0, '["Streaming avec publicites", "Qualite audio standard", "1 appareil"]'::jsonb, 1, false, false, false, true),
  ('d0000000-0000-0000-0000-000000000002', 'Premium', 'premium', 'Experience sans publicite', 3500, 35000, '["Sans publicite", "Qualite audio haute", "3 appareils", "Ecoute hors ligne"]'::jsonb, 3, true, true, false, true),
  ('d0000000-0000-0000-0000-000000000003', 'Famille', 'family', 'Jusqu a 6 comptes', 5500, 55000, '["Sans publicite", "Qualite audio haute", "6 comptes", "Ecoute hors ligne"]'::jsonb, 6, true, true, false, true),
  ('d0000000-0000-0000-0000-000000000004', 'Etudiant', 'student', 'Tarif reduit pour etudiants', 1750, 17500, '["Sans publicite", "Qualite audio haute", "1 appareil", "Ecoute hors ligne"]'::jsonb, 1, true, true, false, true),
  ('d0000000-0000-0000-0000-000000000005', 'HiFi', 'hifi', 'Qualite audio lossless', 6500, 65000, '["Sans publicite", "Qualite lossless", "5 appareils", "Ecoute hors ligne", "Audio spatial"]'::jsonb, 5, true, true, true, true)
ON CONFLICT (slug) DO NOTHING;
