<?php

namespace Database\Seeders;

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

class VipResellerFullCategorySeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $timestamp = now();

        echo "🚀 Starting FULL VIP Reseller category seeding...\n\n";

        // ========================================
        // 🎮 GAME CATEGORIES
        // ========================================
        $gameCategories = [
            // Mobile Legends Variants
            [
                'name' => 'Mobile Legends',
                'slug' => 'mobile-legends',
                'brand_code' => 'MOBILE LEGENDS A',
                'category_type' => 'game',
                'description' => 'Top up diamond Mobile Legends termurah dan tercepat. Proses otomatis 1-5 menit!',
                'icon' => 'fas fa-gamepad',
                'image' => 'https://i.imgur.com/wkxKGHT.png',
                'sort_order' => 1,
            ],
            // Free Fire
            [
                'name' => 'Free Fire',
                'slug' => 'free-fire',
                'brand_code' => 'FREE FIRE',
                'category_type' => 'game',
                'description' => 'Top up diamond Free Fire murah dan aman. Proses instant!',
                'icon' => 'fas fa-fire',
                'image' => 'https://i.imgur.com/9xvZJKm.png',
                'sort_order' => 2,
            ],
            // PUBG Mobile
            [
                'name' => 'PUBG Mobile',
                'slug' => 'pubg-mobile',
                'brand_code' => 'PUBG MOBILE (ID)',
                'category_type' => 'game',
                'description' => 'Top up UC PUBG Mobile termurah. Bonus langsung masuk!',
                'icon' => 'fas fa-crosshairs',
                'image' => 'https://i.imgur.com/xK8mL9P.png',
                'sort_order' => 3,
            ],
            // Genshin Impact
            [
                'name' => 'Genshin Impact',
                'slug' => 'genshin-impact',
                'brand_code' => 'GENSHIN IMPACT',
                'category_type' => 'game',
                'description' => 'Top up Genesis Crystal Genshin Impact. Proses cepat!',
                'icon' => 'fas fa-gem',
                'image' => 'https://i.imgur.com/2tY5xZm.png',
                'sort_order' => 4,
            ],
            // Honkai Star Rail
            [
                'name' => 'Honkai Star Rail',
                'slug' => 'honkai-star-rail',
                'brand_code' => 'HONKAI STAR RAIL',
                'category_type' => 'game',
                'description' => 'Top up Oneiric Shard Honkai Star Rail instant!',
                'icon' => 'fas fa-star',
                'image' => 'https://i.imgur.com/5xK3wYr.png',
                'sort_order' => 5,
            ],
            // Valorant
            [
                'name' => 'Valorant',
                'slug' => 'valorant',
                'brand_code' => 'VALORANT',
                'category_type' => 'game',
                'description' => 'Top up Valorant Points (VP) termurah!',
                'icon' => 'fas fa-bullseye',
                'image' => 'https://i.imgur.com/8xK5Zt9.png',
                'sort_order' => 6,
            ],
            // Call of Duty Mobile
            [
                'name' => 'Call of Duty Mobile',
                'slug' => 'call-of-duty-mobile',
                'brand_code' => 'CALL OF DUTY MOBILE (INDONESIA)',
                'category_type' => 'game',
                'description' => 'Top up CP Call of Duty Mobile instant!',
                'icon' => 'fas fa-crosshairs',
                'image' => 'https://i.imgur.com/7mK3wYr.png',
                'sort_order' => 7,
            ],
            // Roblox
            [
                'name' => 'Roblox',
                'slug' => 'roblox',
                'brand_code' => 'ROBLOX VIA LOGIN',
                'category_type' => 'game',
                'description' => 'Top up Robux termurah dan tercepat!',
                'icon' => 'fas fa-cube',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Roblox_Logo.svg/1200px-Roblox_Logo.svg.png',
                'sort_order' => 8,
            ],
            // League of Legends
            [
                'name' => 'League of Legends',
                'slug' => 'league-of-legends',
                'brand_code' => 'LEAGUE OF LEGENDS',
                'category_type' => 'game',
                'description' => 'Top up Riot Points (RP) League of Legends!',
                'icon' => 'fas fa-dragon',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/League_of_Legends_2019_vector.svg/1200px-League_of_Legends_2019_vector.svg.png',
                'sort_order' => 9,
            ],
            // Arena of Valor
            [
                'name' => 'Arena of Valor',
                'slug' => 'arena-of-valor',
                'brand_code' => 'ARENA OF VALOR',
                'category_type' => 'game',
                'description' => 'Top up Voucher Arena of Valor termurah!',
                'icon' => 'fas fa-shield-alt',
                'image' => 'https://upload.wikimedia.org/wikipedia/en/thumb/5/54/Arena_of_Valor_logo.png/220px-Arena_of_Valor_logo.png',
                'sort_order' => 10,
            ],
            // Blood Strike
            [
                'name' => 'Blood Strike',
                'slug' => 'blood-strike',
                'brand_code' => 'BLOOD STRIKE',
                'category_type' => 'game',
                'description' => 'Top up Gold Blood Strike termurah!',
                'icon' => 'fas fa-skull-crossbones',
                'image' => 'https://i.imgur.com/bloodstrike.png',
                'sort_order' => 11,
            ],
            // Marvel Rivals
            [
                'name' => 'Marvel Rivals',
                'slug' => 'marvel-rivals',
                'brand_code' => 'MARVEL RIVALS',
                'category_type' => 'game',
                'description' => 'Top up Lattice Marvel Rivals!',
                'icon' => 'fas fa-mask',
                'image' => 'https://i.imgur.com/marvelrivals.png',
                'sort_order' => 12,
            ],
            // Zenless Zone Zero
            [
                'name' => 'Zenless Zone Zero',
                'slug' => 'zenless-zone-zero',
                'brand_code' => 'ZENLESS ZONE ZERO (ZZZ)',
                'category_type' => 'game',
                'description' => 'Top up Monochrome Zenless Zone Zero!',
                'icon' => 'fas fa-bolt',
                'image' => 'https://i.imgur.com/zzz.png',
                'sort_order' => 13,
            ],
            // Delta Force
            [
                'name' => 'Delta Force',
                'slug' => 'delta-force',
                'brand_code' => 'DELTA FORCE',
                'category_type' => 'game',
                'description' => 'Top up Combat Cash Delta Force!',
                'icon' => 'fas fa-helicopter',
                'image' => 'https://i.imgur.com/deltaforce.png',
                'sort_order' => 14,
            ],
            // Sausage Man
            [
                'name' => 'Sausage Man',
                'slug' => 'sausage-man',
                'brand_code' => 'SAUSAGE MAN',
                'category_type' => 'game',
                'description' => 'Top up Candy Sausage Man termurah!',
                'icon' => 'fas fa-hotdog',
                'image' => 'https://i.imgur.com/sausageman.png',
                'sort_order' => 15,
            ],
            // Farlight 84
            [
                'name' => 'Farlight 84',
                'slug' => 'farlight-84',
                'brand_code' => 'FARLIGHT 84',
                'category_type' => 'game',
                'description' => 'Top up Diamond Farlight 84!',
                'icon' => 'fas fa-rocket',
                'image' => 'https://i.imgur.com/farlight84.png',
                'sort_order' => 16,
            ],
            // EA Sports FC Mobile
            [
                'name' => 'EA Sports FC Mobile',
                'slug' => 'ea-sports-fc-mobile',
                'brand_code' => 'EA SPORTS FC MOBILE',
                'category_type' => 'game',
                'description' => 'Top up FC Points EA Sports FC Mobile!',
                'icon' => 'fas fa-futbol',
                'image' => 'https://i.imgur.com/easportsfc.png',
                'sort_order' => 17,
            ],
            // Ragnarok Origin
            [
                'name' => 'Ragnarok Origin',
                'slug' => 'ragnarok-origin',
                'brand_code' => 'RAGNAROK ORIGIN',
                'category_type' => 'game',
                'description' => 'Top up Big Cat Coin Ragnarok Origin!',
                'icon' => 'fas fa-cat',
                'image' => 'https://i.imgur.com/ragnarokorigin.png',
                'sort_order' => 18,
            ],
            // LifeAfter
            [
                'name' => 'LifeAfter',
                'slug' => 'lifeafter',
                'brand_code' => 'LIFEAFTER',
                'category_type' => 'game',
                'description' => 'Top up Credit LifeAfter termurah!',
                'icon' => 'fas fa-biohazard',
                'image' => 'https://i.imgur.com/lifeafter.png',
                'sort_order' => 19,
            ],
            // Love and Deepspace
            [
                'name' => 'Love and Deepspace',
                'slug' => 'love-and-deepspace',
                'brand_code' => 'LOVE AND DEEPSPACE',
                'category_type' => 'game',
                'description' => 'Top up Diamond Love and Deepspace!',
                'icon' => 'fas fa-heart',
                'image' => 'https://i.imgur.com/lovedeepspace.png',
                'sort_order' => 20,
            ],
        ];

        // ========================================
        // 🎬 STREAMING CATEGORIES
        // ========================================
        $streamingCategories = [
            [
                'name' => 'Vidio Premier',
                'slug' => 'vidio-premier',
                'brand_code' => 'VIDIO PREMIER',
                'category_type' => 'streaming',
                'description' => 'Beli paket Vidio Premier termurah. Nonton streaming sepak bola, film, dan series!',
                'icon' => 'fas fa-play-circle',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/69/Vidio_logo_2023.svg/1200px-Vidio_logo_2023.svg.png',
                'sort_order' => 50,
            ],
            [
                'name' => 'Viu Premium',
                'slug' => 'viu-premium',
                'brand_code' => 'VIU PREMIUM',
                'category_type' => 'streaming',
                'description' => 'Beli paket Viu Premium termurah. Nonton drama Korea dan series Asia!',
                'icon' => 'fas fa-tv',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b9/Viu_logo.svg/1200px-Viu_logo.svg.png',
                'sort_order' => 51,
            ],
            [
                'name' => 'WeTV Premium',
                'slug' => 'wetv-premium',
                'brand_code' => 'WETV PREMIUM',
                'category_type' => 'streaming',
                'description' => 'Beli paket WeTV Premium termurah. Nonton drama China dan Asia!',
                'icon' => 'fas fa-film',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/WeTV_logo.svg/1200px-WeTV_logo.svg.png',
                'sort_order' => 52,
            ],
            [
                'name' => 'iQIYI Premium',
                'slug' => 'iqiyi-premium',
                'brand_code' => 'IQIYI PREMIUM',
                'category_type' => 'streaming',
                'description' => 'Beli paket iQIYI Premium termurah. Nonton drama dan variety show!',
                'icon' => 'fas fa-video',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/IQIYI_logo.svg/1200px-IQIYI_logo.svg.png',
                'sort_order' => 53,
            ],
            [
                'name' => 'Vision Plus',
                'slug' => 'vision-plus',
                'brand_code' => 'VISION PLUS',
                'category_type' => 'streaming',
                'description' => 'Beli paket Vision+ termurah. Nonton TV online dan on-demand!',
                'icon' => 'fas fa-broadcast-tower',
                'image' => 'https://i.imgur.com/visionplus.png',
                'sort_order' => 54,
            ],
            [
                'name' => 'Bstation Premium',
                'slug' => 'bstation-premium',
                'brand_code' => 'BSTATION PREMIUM',
                'category_type' => 'streaming',
                'description' => 'Beli paket Bstation Premium termurah!',
                'icon' => 'fas fa-play',
                'image' => 'https://i.imgur.com/bstation.png',
                'sort_order' => 55,
            ],
            [
                'name' => 'Amazon Prime Video',
                'slug' => 'amazon-prime-video',
                'brand_code' => 'AMAZON PRIME VIDEO',
                'category_type' => 'streaming',
                'description' => 'Beli akun Amazon Prime Video termurah!',
                'icon' => 'fas fa-amazon',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Amazon_Prime_Video_logo.svg/1200px-Amazon_Prime_Video_logo.svg.png',
                'sort_order' => 56,
            ],
        ];

        // ========================================
        // 🎟️ VOUCHER CATEGORIES
        // ========================================
        $voucherCategories = [
            [
                'name' => 'Steam Wallet',
                'slug' => 'steam-wallet',
                'brand_code' => 'STEAM WALLET CODE',
                'category_type' => 'voucher',
                'description' => 'Beli Steam Wallet Code termurah. Top up saldo Steam instant!',
                'icon' => 'fab fa-steam',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Steam_icon_logo.svg/1200px-Steam_icon_logo.svg.png',
                'sort_order' => 70,
            ],
            [
                'name' => 'Voucher Garena Shell',
                'slug' => 'voucher-garena-shell',
                'brand_code' => 'VOUCHER GARENA SHELL',
                'category_type' => 'voucher',
                'description' => 'Beli Voucher Garena Shell termurah!',
                'icon' => 'fas fa-ticket-alt',
                'image' => 'https://i.imgur.com/garenashell.png',
                'sort_order' => 71,
            ],
            [
                'name' => 'Voucher PSN',
                'slug' => 'voucher-psn',
                'brand_code' => 'VOUCHER PSN',
                'category_type' => 'voucher',
                'description' => 'Beli Voucher PlayStation Network (PSN) termurah!',
                'icon' => 'fab fa-playstation',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/PlayStation_logo.svg/1200px-PlayStation_logo.svg.png',
                'sort_order' => 72,
            ],
            [
                'name' => 'Voucher Razer Gold',
                'slug' => 'voucher-razer-gold',
                'brand_code' => 'VOUCHER RAZER GOLD',
                'category_type' => 'voucher',
                'description' => 'Beli Voucher Razer Gold termurah!',
                'icon' => 'fas fa-wallet',
                'image' => 'https://i.imgur.com/razergold.png',
                'sort_order' => 73,
            ],
            [
                'name' => 'Voucher Roblox',
                'slug' => 'voucher-roblox',
                'brand_code' => 'VOUCHER ROBLOX',
                'category_type' => 'voucher',
                'description' => 'Beli Voucher Roblox Gift Card termurah!',
                'icon' => 'fas fa-gift',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Roblox_Logo.svg/1200px-Roblox_Logo.svg.png',
                'sort_order' => 74,
            ],
            [
                'name' => 'Voucher Valorant',
                'slug' => 'voucher-valorant',
                'brand_code' => 'VOUCHER VALORANT',
                'category_type' => 'voucher',
                'description' => 'Beli Voucher Valorant Gift Card termurah!',
                'icon' => 'fas fa-gift-card',
                'image' => 'https://i.imgur.com/valorantvoucher.png',
                'sort_order' => 75,
            ],
        ];

        // ========================================
        // 💎 SUBSCRIPTION/TOOLS CATEGORIES
        // ========================================
        $subscriptionCategories = [
            [
                'name' => 'Canva Pro',
                'slug' => 'canva-pro',
                'brand_code' => 'CANVA PRO',
                'category_type' => 'subscription',
                'description' => 'Beli akun Canva Pro termurah. Design grafis profesional!',
                'icon' => 'fas fa-palette',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/Canva_icon_2021.svg/1200px-Canva_icon_2021.svg.png',
                'sort_order' => 90,
            ],
            [
                'name' => 'CapCut Pro',
                'slug' => 'capcut-pro',
                'brand_code' => 'CAPCUT PRO',
                'category_type' => 'subscription',
                'description' => 'Beli akun CapCut Pro termurah. Edit video profesional!',
                'icon' => 'fas fa-cut',
                'image' => 'https://i.imgur.com/capcut.png',
                'sort_order' => 91,
            ],
            [
                'name' => 'ChatGPT Plus',
                'slug' => 'chatgpt-plus',
                'brand_code' => 'CHATGPT',
                'category_type' => 'subscription',
                'description' => 'Beli akun ChatGPT Plus termurah. AI assistant terbaik!',
                'icon' => 'fas fa-robot',
                'image' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/ChatGPT_logo.svg/1200px-ChatGPT_logo.svg.png',
                'sort_order' => 92,
            ],
            [
                'name' => 'Alight Motion Pro',
                'slug' => 'alight-motion-pro',
                'brand_code' => 'ALIGHT MOTION',
                'category_type' => 'subscription',
                'description' => 'Beli akun Alight Motion Pro termurah!',
                'icon' => 'fas fa-magic',
                'image' => 'https://i.imgur.com/alightmotion.png',
                'sort_order' => 93,
            ],
        ];

        // Merge all categories
        $allCategories = array_merge(
            $gameCategories,
            $streamingCategories,
            $voucherCategories,
            $subscriptionCategories
        );

        // Insert categories
        $created = 0;
        $updated = 0;

        foreach ($allCategories as $category) {
            $category['is_active'] = true;
            $category['created_at'] = $timestamp;
            $category['updated_at'] = $timestamp;
            
            $exists = DB::table('categories')->where('slug', $category['slug'])->first();
            
            if (!$exists) {
                DB::table('categories')->insert($category);
                echo "✅ Created: {$category['name']}\n";
                $created++;
            } else {
                // Update brand_code if different
                if ($exists->brand_code !== $category['brand_code']) {
                    DB::table('categories')
                        ->where('slug', $category['slug'])
                        ->update([
                            'brand_code' => $category['brand_code'],
                            'updated_at' => $timestamp,
                        ]);
                    echo "🔄 Updated: {$category['name']}\n";
                    $updated++;
                } else {
                    echo "⏭️  Skipped: {$category['name']}\n";
                }
            }
        }

        echo "\n📊 Summary:\n";
        echo "✅ Created: $created\n";
        echo "🔄 Updated: $updated\n";
        echo "📦 Total categories: " . count($allCategories) . "\n\n";
        echo "🔥 Now run: php artisan vipreseller:sync\n\n";
    }
}
