<?php

namespace Database\Seeders;

use App\Domains\Subscription\Models\Plan;
use Illuminate\Database\Seeder;

class PlanSeeder extends Seeder
{
    public function run(): void
    {
        $plans = [
            [
                'name'                 => 'Free',
                'tier'                 => 'free',
                'stripe_price_id'      => null,
                'monthly_price_cents'  => 0,
                'workspace_limit'      => 1,
                'member_limit'         => 1,
                'custom_domain_limit'  => 0,
                'link_limit'           => 50,
                'click_limit_monthly'  => 1000,
                'bio_pages_limit'      => 1,
                'features'             => [
                    'workspace_subdomain' => false,
                    'pixel_injection'     => false,
                    'ai_suite'            => false,
                    'webhooks'            => false,
                    'api_tokens'          => false,
                    'agency_features'     => false,
                ],
            ],
            [
                'name'                 => 'Pro',
                'tier'                 => 'pro',
                'stripe_price_id'      => env('STRIPE_PRICE_PRO'),
                'monthly_price_cents'  => 1900,
                'workspace_limit'      => 1,
                'member_limit'         => 3,
                'custom_domain_limit'  => 1,
                'link_limit'           => 1000,
                'click_limit_monthly'  => 25000,
                'bio_pages_limit'      => 5,
                'features'             => [
                    'workspace_subdomain' => true,
                    'pixel_injection'     => true,
                    'ai_suite'            => true,
                    'webhooks'            => true,
                    'api_tokens'          => true,
                    'agency_features'     => false,
                ],
            ],
            [
                'name'                 => 'Business',
                'tier'                 => 'business',
                'stripe_price_id'      => env('STRIPE_PRICE_BUSINESS'),
                'monthly_price_cents'  => 7900,
                'workspace_limit'      => 3,
                'member_limit'         => 10,
                'custom_domain_limit'  => 5,
                'link_limit'           => 10000,
                'click_limit_monthly'  => 250000,
                'bio_pages_limit'      => 25,
                'features'             => [
                    'workspace_subdomain' => true,
                    'pixel_injection'     => true,
                    'ai_suite'            => true,
                    'webhooks'            => true,
                    'api_tokens'          => true,
                    'agency_features'     => true,
                ],
            ],
            [
                'name'                 => 'Agency',
                'tier'                 => 'agency',
                'stripe_price_id'      => env('STRIPE_PRICE_AGENCY'),
                'monthly_price_cents'  => 19900,
                'workspace_limit'      => null,
                'member_limit'         => null,
                'custom_domain_limit'  => null,
                'link_limit'           => null,
                'click_limit_monthly'  => 5000000,
                'bio_pages_limit'      => null,
                'features'             => [
                    'workspace_subdomain'  => true,
                    'pixel_injection'      => true,
                    'ai_suite'             => true,
                    'webhooks'             => true,
                    'api_tokens'           => true,
                    'agency_features'      => true,
                    'whitelabel_reseller'  => true,
                ],
            ],
        ];

        foreach ($plans as $p) {
            Plan::updateOrCreate(['tier' => $p['tier']], $p);
        }

        $this->command->info('✓ 4 Plans seeded (free/pro/business/agency)');
    }
}
