<?php

namespace Database\Seeders;

use App\Models\PointSetting;
use App\Models\RewardBadge;
use Illuminate\Database\Seeder;

class GamificationSeeder extends Seeder
{
    public function run(): void
    {
        $settings = [
            ['key' => 'task_completed_points', 'value' => 10, 'description' => 'Points for each completed task'],
            ['key' => 'daily_productivity_points', 'value' => 5, 'description' => 'Points for productive day'],
            ['key' => 'daily_productivity_threshold', 'value' => 80, 'description' => 'Minimum productivity score'],
            ['key' => 'qa_report_points', 'value' => 4, 'description' => 'Points for QA report submission'],
            ['key' => 'qa_penalty_multiplier', 'value' => 2, 'description' => 'Deduction multiplier for QA penalties'],
            ['key' => 'attendance_bonus', 'value' => 2, 'description' => 'Points for consistent attendance'],
            ['key' => 'deadline_bonus', 'value' => 15, 'description' => 'Bonus for early/on-time delivery'],
            ['key' => 'late_penalty', 'value' => 10, 'description' => 'Penalty for missed deadlines'],
        ];

        foreach ($settings as $setting) {
            PointSetting::updateOrCreate(['key' => $setting['key']], $setting);
        }

        $badges = [
            ['name' => 'Bronze Performer', 'slug' => 'bronze_performer', 'min_points' => 50, 'color' => '#CD7F32', 'rarity' => 'common', 'level' => 1, 'icon' => 'bi-trophy'],
            ['name' => 'Silver Performer', 'slug' => 'silver_performer', 'min_points' => 200, 'color' => '#C0C0C0', 'rarity' => 'rare', 'level' => 2, 'icon' => 'bi-award'],
            ['name' => 'Gold Performer', 'slug' => 'gold_performer', 'min_points' => 500, 'color' => '#FFD700', 'rarity' => 'epic', 'level' => 3, 'icon' => 'bi-gem'],
            ['name' => 'Architecture Lead', 'slug' => 'architecture_lead', 'min_points' => 1000, 'color' => '#00FF9D', 'rarity' => 'legendary', 'level' => 4, 'icon' => 'bi-cpu-fill'],
        ];

        foreach ($badges as $badge) {
            RewardBadge::updateOrCreate(['slug' => $badge['slug']], $badge);
        }
    }
}
