-- Seed demo users for quick login
-- Password hashes are generated with bcrypt (10 rounds)

-- Clara (User) - password: password123
-- Hash: $2a$10$rQqXVJCqYQXPfKqzKHKK6OYpwT0QvqrKqJjVjKPLqZ9MqXBZqYqPq
INSERT INTO users (email, password_hash, name, avatar_url, role, subscription_type, is_active, is_verified)
VALUES (
  'clara@example.com',
  '$2a$10$N9qo8uLOickgx2ZMRZoMy.MqrqNeqA0QvS6Y.o9GLqSl8z7jUXFqK',
  'Clara Martin',
  '/woman-profile-avatar.png',
  'user',
  'premium',
  true,
  true
) ON CONFLICT (email) DO NOTHING;

-- Stromae (Artist) - password: artist123
INSERT INTO users (email, password_hash, name, avatar_url, role, subscription_type, is_active, is_verified)
VALUES (
  'stromae@example.com',
  '$2a$10$N9qo8uLOickgx2ZMRZoMy.MqrqNeqA0QvS6Y.o9GLqSl8z7jUXFqK',
  'Paul Van Haver',
  '/racine-carree-track-art.jpg',
  'artist',
  'premium',
  true,
  true
) ON CONFLICT (email) DO NOTHING;

-- Create artist profile for Stromae
INSERT INTO artists (user_id, name, avatar_url, is_verified, monthly_listeners, total_followers, total_streams, bio, country)
SELECT id, 'Stromae', '/racine-carree-track-art.jpg', true, 5600000, 12000000, 2500000000, 'Artiste belge de renommée internationale', 'BE'
FROM users WHERE email = 'stromae@example.com'
ON CONFLICT DO NOTHING;

-- Admin - password: admin123
INSERT INTO users (email, password_hash, name, avatar_url, role, subscription_type, is_active, is_verified)
VALUES (
  'admin@musicapp.com',
  '$2a$10$N9qo8uLOickgx2ZMRZoMy.MqrqNeqA0QvS6Y.o9GLqSl8z7jUXFqK',
  'Admin User',
  '/man-avatar.png',
  'admin',
  'premium',
  true,
  true
) ON CONFLICT (email) DO NOTHING;

-- Create user settings for demo users
INSERT INTO user_settings (user_id)
SELECT id FROM users WHERE email IN ('clara@example.com', 'stromae@example.com', 'admin@musicapp.com')
ON CONFLICT DO NOTHING;

-- Add some sample genres
INSERT INTO genres (name, slug, color, is_featured, description) VALUES
('Pop', 'pop', '#ec4899', true, 'Musique pop internationale'),
('Hip-Hop', 'hip-hop', '#f59e0b', true, 'Rap et Hip-Hop'),
('Afrobeats', 'afrobeats', '#22c55e', true, 'Musique africaine moderne'),
('Coupé-Décalé', 'coupe-decale', '#f97316', true, 'Musique ivoirienne'),
('Electronic', 'electronic', '#3b82f6', true, 'Musique électronique'),
('Rock', 'rock', '#ef4444', false, 'Rock et alternatives'),
('Jazz', 'jazz', '#8b5cf6', false, 'Jazz et blues'),
('Classique', 'classique', '#6366f1', false, 'Musique classique'),
('R&B', 'rnb', '#ec4899', true, 'Rhythm and Blues'),
('Reggae', 'reggae', '#22c55e', false, 'Reggae et Dancehall')
ON CONFLICT (slug) DO NOTHING;

-- Add subscription plans
INSERT INTO subscription_plans (name, slug, price_monthly, price_yearly, features, ad_free, offline_listening, hifi_quality, max_devices, is_active) VALUES
('Gratuit', 'free', 0, 0, '{"features": ["Écoute avec publicités", "Qualité standard", "1 appareil"]}', false, false, false, 1, true),
('Premium', 'premium', 3500, 35000, '{"features": ["Sans publicités", "Qualité haute", "Écoute hors ligne", "4 appareils"]}', true, true, false, 4, true),
('Famille', 'family', 5500, 55000, '{"features": ["6 comptes", "Sans publicités", "Écoute hors ligne", "Contrôle parental"]}', true, true, false, 6, true),
('Étudiant', 'student', 2000, 20000, '{"features": ["Sans publicités", "Qualité haute", "Écoute hors ligne"]}', true, true, false, 2, true),
('HiFi', 'hifi', 6500, 65000, '{"features": ["Qualité lossless", "Audio spatial", "Sans publicités", "Écoute hors ligne"]}', true, true, true, 4, true)
ON CONFLICT (slug) DO NOTHING;

-- Add some sample albums from Stromae
INSERT INTO albums (artist_id, title, cover_url, album_type, release_date, status, total_tracks)
SELECT a.id, 'Racine Carrée', '/racine-carree-album-art.jpg', 'album', '2013-08-16', 'published', 12
FROM artists a
JOIN users u ON a.user_id = u.id
WHERE u.email = 'stromae@example.com'
ON CONFLICT DO NOTHING;

INSERT INTO albums (artist_id, title, cover_url, album_type, release_date, status, total_tracks)
SELECT a.id, 'Multitude', '/multitude-album.jpg', 'album', '2022-03-04', 'published', 12
FROM artists a
JOIN users u ON a.user_id = u.id
WHERE u.email = 'stromae@example.com'
ON CONFLICT DO NOTHING;

-- Add sample tracks
INSERT INTO tracks (artist_id, album_id, title, duration_ms, status, cover_url, track_number)
SELECT 
  a.id as artist_id,
  al.id as album_id,
  'Papaoutai' as title,
  235000 as duration_ms,
  'published' as status,
  '/racine-carree-album-art.jpg' as cover_url,
  1 as track_number
FROM artists a
JOIN users u ON a.user_id = u.id
JOIN albums al ON al.artist_id = a.id AND al.title = 'Racine Carrée'
WHERE u.email = 'stromae@example.com'
ON CONFLICT DO NOTHING;

INSERT INTO tracks (artist_id, album_id, title, duration_ms, status, cover_url, track_number)
SELECT 
  a.id as artist_id,
  al.id as album_id,
  'Formidable' as title,
  236000 as duration_ms,
  'published' as status,
  '/racine-carree-album-art.jpg' as cover_url,
  2 as track_number
FROM artists a
JOIN users u ON a.user_id = u.id
JOIN albums al ON al.artist_id = a.id AND al.title = 'Racine Carrée'
WHERE u.email = 'stromae@example.com'
ON CONFLICT DO NOTHING;

INSERT INTO tracks (artist_id, album_id, title, duration_ms, status, cover_url, track_number)
SELECT 
  a.id as artist_id,
  al.id as album_id,
  'Alors on Danse' as title,
  210000 as duration_ms,
  'published' as status,
  '/racine-carree-album-art.jpg' as cover_url,
  3 as track_number
FROM artists a
JOIN users u ON a.user_id = u.id
JOIN albums al ON al.artist_id = a.id AND al.title = 'Racine Carrée'
WHERE u.email = 'stromae@example.com'
ON CONFLICT DO NOTHING;
