<?php

namespace Database\Seeders;

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

class CategorySeeder extends Seeder
{
    public function run(): void
    {
        $categories = [
            [
                'id'         => 1,
                'name'       => 'Breaking News',
                'slug'       => 'breaking-news',
                'description'=> 'Latest breaking news from around the world.',
                'color'      => 'text-red-400',
                'bg_color'   => 'bg-red-500',
                'icon'       => 'zap',
                'sort_order' => 1,
            ],
            [
                'id'         => 2,
                'name'       => 'Sports',
                'slug'       => 'sports',
                'description'=> 'Football, basketball, cricket, tennis and more.',
                'color'      => 'text-orange-400',
                'bg_color'   => 'bg-orange-500',
                'icon'       => 'trophy',
                'sort_order' => 2,
            ],
            [
                'id'         => 3,
                'name'       => 'Entertainment',
                'slug'       => 'entertainment',
                'description'=> 'Movies, music, celebrity news and pop culture.',
                'color'      => 'text-purple-400',
                'bg_color'   => 'bg-purple-500',
                'icon'       => 'star',
                'sort_order' => 3,
            ],
            [
                'id'         => 4,
                'name'       => 'Technology',
                'slug'       => 'technology',
                'description'=> 'Tech news, startups, AI, gadgets and innovation.',
                'color'      => 'text-cyan-400',
                'bg_color'   => 'bg-cyan-500',
                'icon'       => 'cpu',
                'sort_order' => 4,
            ],
            [
                'id'         => 5,
                'name'       => 'Politics',
                'slug'       => 'politics',
                'description'=> 'Political news, elections, policy and world affairs.',
                'color'      => 'text-emerald-400',
                'bg_color'   => 'bg-emerald-500',
                'icon'       => 'landmark',
                'sort_order' => 5,
            ],
        ];

        foreach ($categories as $category) {
            DB::table('categories')->updateOrInsert(
                ['id' => $category['id']],
                array_merge($category, [
                    'posts_count' => 0,
                    'created_at'  => now(),
                    'updated_at'  => now(),
                ])
            );
        }

        $this->command->info('✓ Categories seeded (' . count($categories) . ')');
    }
}
