<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Coupon;
use Carbon\Carbon;

class CouponSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $coupons = [
            [
                'code' => 'WELCOME10',
                'type' => 'percentage',
                'value' => 10.00,
                'min_purchase' => 500.00,
                'max_discount' => 200.00,
                'valid_from' => Carbon::now(),
                'valid_until' => Carbon::now()->addMonths(6),
                'max_uses' => 1000,
                'max_uses_per_customer' => 1,
                'current_uses' => 0,
                'description' => 'Desconto de 10% para novos clientes (compra mínima MT 500)',
                'status' => 'active',
            ],
            [
                'code' => 'VERAO2026',
                'type' => 'percentage',
                'value' => 15.00,
                'min_purchase' => 1000.00,
                'max_discount' => 500.00,
                'valid_from' => Carbon::now(),
                'valid_until' => Carbon::now()->addMonths(3),
                'max_uses' => 500,
                'max_uses_per_customer' => 2,
                'current_uses' => 0,
                'description' => 'Promoção de Verão 2026 - 15% de desconto (compra mínima MT 1000)',
                'status' => 'active',
            ],
            [
                'code' => 'FRETEGRATIS',
                'type' => 'fixed',
                'value' => 150.00,
                'min_purchase' => 800.00,
                'max_discount' => null,
                'valid_from' => Carbon::now(),
                'valid_until' => Carbon::now()->addMonths(12),
                'max_uses' => null,
                'max_uses_per_customer' => 5,
                'current_uses' => 0,
                'description' => 'Frete grátis para compras acima de MT 800',
                'status' => 'active',
            ],
            [
                'code' => 'BLACKFRIDAY',
                'type' => 'percentage',
                'value' => 25.00,
                'min_purchase' => 1500.00,
                'max_discount' => 1000.00,
                'valid_from' => Carbon::parse('2026-11-25'),
                'valid_until' => Carbon::parse('2026-11-30'),
                'max_uses' => 200,
                'max_uses_per_customer' => 1,
                'current_uses' => 0,
                'description' => 'Black Friday 2026 - 25% OFF em toda loja',
                'status' => 'active',
            ],
            [
                'code' => 'NATAL50',
                'type' => 'fixed',
                'value' => 50.00,
                'min_purchase' => 300.00,
                'max_discount' => null,
                'valid_from' => Carbon::parse('2026-12-15'),
                'valid_until' => Carbon::parse('2026-12-25'),
                'max_uses' => 1000,
                'max_uses_per_customer' => 1,
                'current_uses' => 0,
                'description' => 'Natal 2026 - MT 50 de desconto',
                'status' => 'active',
            ],
            [
                'code' => 'VIP20',
                'type' => 'percentage',
                'value' => 20.00,
                'min_purchase' => 2000.00,
                'max_discount' => 800.00,
                'valid_from' => Carbon::now(),
                'valid_until' => null,
                'max_uses' => null,
                'max_uses_per_customer' => 10,
                'current_uses' => 0,
                'description' => 'Desconto VIP de 20% para clientes especiais',
                'status' => 'active',
            ],
            [
                'code' => 'PRIMEIRACOMPRA',
                'type' => 'percentage',
                'value' => 12.00,
                'min_purchase' => 400.00,
                'max_discount' => 250.00,
                'valid_from' => Carbon::now(),
                'valid_until' => Carbon::now()->addYear(),
                'max_uses' => null,
                'max_uses_per_customer' => 1,
                'current_uses' => 0,
                'description' => 'Desconto especial para primeira compra na LK Fashion',
                'status' => 'active',
            ],
            [
                'code' => 'EXPIRADO',
                'type' => 'percentage',
                'value' => 30.00,
                'min_purchase' => 500.00,
                'max_discount' => 300.00,
                'valid_from' => Carbon::now()->subMonths(3),
                'valid_until' => Carbon::now()->subMonth(),
                'max_uses' => 100,
                'max_uses_per_customer' => 1,
                'current_uses' => 85,
                'description' => 'Cupom expirado - apenas para teste',
                'status' => 'expired',
            ],
            [
                'code' => 'TESTE100',
                'type' => 'fixed',
                'value' => 100.00,
                'min_purchase' => 500.00,
                'max_discount' => null,
                'valid_from' => Carbon::now(),
                'valid_until' => Carbon::now()->addMonths(6),
                'max_uses' => 10,
                'max_uses_per_customer' => 1,
                'current_uses' => 10,
                'description' => 'Cupom de teste com limite atingido',
                'status' => 'active',
            ],
            [
                'code' => 'DESATIVADO',
                'type' => 'percentage',
                'value' => 15.00,
                'min_purchase' => 300.00,
                'max_discount' => 200.00,
                'valid_from' => Carbon::now(),
                'valid_until' => Carbon::now()->addMonths(3),
                'max_uses' => 100,
                'max_uses_per_customer' => 1,
                'current_uses' => 0,
                'description' => 'Cupom desativado - apenas para teste',
                'status' => 'inactive',
            ],
        ];

        foreach ($coupons as $coupon) {
            Coupon::create($coupon);
        }

        $this->command->info('✅ 10 cupons criados com sucesso!');
    }
}
