<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;

class SubscriptionPlanSeeder extends Seeder
{
    public function run(): void
    {
        $plans = [
            [
                'name' => 'Free',
                'slug' => 'free',
                'description' => 'Basic access for new users to explore PharmPrep NG before subscribing.',
                'price' => 0,
                'currency' => 'NGN',
                'features' => [
                    'Access to demo question test',
                    'View course list',
                    'View course material list only',
                    'View past question list only',
                    'AI descriptions for answers',
                    'No material download',
                    'No past question access',
                    'No randomized exam simulation',
                ],
                'sort_order' => 1,
            ],
            [
                'name' => 'Basic',
                'slug' => 'basic',
                'description' => 'Affordable exam preparation access for students who need structured CBT practice.',
                'price' => 5000,
                'currency' => 'NGN',
                'features' => [
                    'Access to demo question test',
                    'Course-based CBT practice',
                    'Limited randomized exam simulation',
                    'View and download selected course materials',
                    'View selected past questions',
                    'AI descriptions for answers',
                    'Exam attempt history',
                    'Performance analytics',
                ],
                'sort_order' => 2,
            ],
            [
                'name' => 'Premium',
                'slug' => 'premium',
                'description' => 'Full exam preparation access with all premium learning, revision, analytics, and group study features.',
                'price' => 8000,
                'currency' => 'NGN',
                'features' => [
                    'Everything in Basic',
                    'Full randomized pharmacy exam simulation',
                    'Access to all course materials',
                    'Download all available PDFs',
                    'Access to all past questions',
                    'Full AI descriptions for answers',
                    'Detailed answer revision',
                    'Group learning access',
                    'Create and join study groups',
                    'Take notes inside the app',
                    'Advanced performance analytics',
                    'Priority support',
                ],
                'sort_order' => 3,
            ],
        ];

        foreach ($plans as $plan) {
            DB::table('subscription_plans')->updateOrInsert(
                ['slug' => $plan['slug']],
                [
                    'name' => $plan['name'],
                    'description' => $plan['description'],
                    'price' => $plan['price'],
                    'currency' => $plan['currency'],
                    'features' => json_encode($plan['features']),
                    'is_active' => true,
                    'sort_order' => $plan['sort_order'],
                    'created_at' => now(),
                    'updated_at' => now(),
                ]
            );
        }
    }
}