<?php

namespace Database\Seeders;

use App\Models\Team;
use Illuminate\Database\Seeder;

class TeamSeeder extends Seeder
{
    public function run(): void
    {
        $teams = [
            // Group A — Host: Mexico
            ['name' => 'Mexico',        'code' => 'MEX', 'group_name' => 'A'],
            ['name' => 'South Africa',  'code' => 'RSA', 'group_name' => 'A'],
            ['name' => 'Korea Republic','code' => 'KOR', 'group_name' => 'A'],
            ['name' => 'Czechia',       'code' => 'CZE', 'group_name' => 'A'],

            // Group B — Host: Canada
            ['name' => 'Canada',             'code' => 'CAN', 'group_name' => 'B'],
            ['name' => 'Bosnia & Herzegovina','code' => 'BIH', 'group_name' => 'B'],
            ['name' => 'Qatar',              'code' => 'QAT', 'group_name' => 'B'],
            ['name' => 'Switzerland',        'code' => 'SUI', 'group_name' => 'B'],

            // Group C
            ['name' => 'Brazil',   'code' => 'BRA', 'group_name' => 'C'],
            ['name' => 'Morocco',  'code' => 'MAR', 'group_name' => 'C'],
            ['name' => 'Haiti',    'code' => 'HAI', 'group_name' => 'C'],
            ['name' => 'Scotland', 'code' => 'SCO', 'group_name' => 'C'],

            // Group D — Host: United States
            ['name' => 'United States', 'code' => 'USA', 'group_name' => 'D'],
            ['name' => 'Paraguay',      'code' => 'PAR', 'group_name' => 'D'],
            ['name' => 'Australia',     'code' => 'AUS', 'group_name' => 'D'],
            ['name' => 'Türkiye',       'code' => 'TUR', 'group_name' => 'D'],

            // Group E
            ['name' => 'Germany',     'code' => 'GER', 'group_name' => 'E'],
            ['name' => 'Curaçao',     'code' => 'CUW', 'group_name' => 'E'],
            ['name' => 'Ivory Coast', 'code' => 'CIV', 'group_name' => 'E'],
            ['name' => 'Ecuador',     'code' => 'ECU', 'group_name' => 'E'],

            // Group F
            ['name' => 'Netherlands', 'code' => 'NED', 'group_name' => 'F'],
            ['name' => 'Japan',       'code' => 'JPN', 'group_name' => 'F'],
            ['name' => 'Sweden',      'code' => 'SWE', 'group_name' => 'F'],
            ['name' => 'Tunisia',     'code' => 'TUN', 'group_name' => 'F'],

            // Group G
            ['name' => 'Belgium',     'code' => 'BEL', 'group_name' => 'G'],
            ['name' => 'Egypt',       'code' => 'EGY', 'group_name' => 'G'],
            ['name' => 'Iran',        'code' => 'IRN', 'group_name' => 'G'],
            ['name' => 'New Zealand', 'code' => 'NZL', 'group_name' => 'G'],

            // Group H
            ['name' => 'Spain',       'code' => 'ESP', 'group_name' => 'H'],
            ['name' => 'Cape Verde',  'code' => 'CPV', 'group_name' => 'H'],
            ['name' => 'Saudi Arabia','code' => 'KSA', 'group_name' => 'H'],
            ['name' => 'Uruguay',     'code' => 'URU', 'group_name' => 'H'],

            // Group I
            ['name' => 'France',  'code' => 'FRA', 'group_name' => 'I'],
            ['name' => 'Senegal', 'code' => 'SEN', 'group_name' => 'I'],
            ['name' => 'Iraq',    'code' => 'IRQ', 'group_name' => 'I'],
            ['name' => 'Norway',  'code' => 'NOR', 'group_name' => 'I'],

            // Group J
            ['name' => 'Argentina', 'code' => 'ARG', 'group_name' => 'J'],
            ['name' => 'Algeria',   'code' => 'ALG', 'group_name' => 'J'],
            ['name' => 'Austria',   'code' => 'AUT', 'group_name' => 'J'],
            ['name' => 'Jordan',    'code' => 'JOR', 'group_name' => 'J'],

            // Group K
            ['name' => 'Portugal',   'code' => 'POR', 'group_name' => 'K'],
            ['name' => 'DR Congo',   'code' => 'COD', 'group_name' => 'K'],
            ['name' => 'Uzbekistan', 'code' => 'UZB', 'group_name' => 'K'],
            ['name' => 'Colombia',   'code' => 'COL', 'group_name' => 'K'],

            // Group L
            ['name' => 'England', 'code' => 'ENG', 'group_name' => 'L'],
            ['name' => 'Croatia', 'code' => 'CRO', 'group_name' => 'L'],
            ['name' => 'Ghana',   'code' => 'GHA', 'group_name' => 'L'],
            ['name' => 'Panama',  'code' => 'PAN', 'group_name' => 'L'],
        ];

        foreach ($teams as $team) {
            Team::updateOrCreate(['code' => $team['code']], $team);
        }

        $this->command->info('✓ 48 World Cup 2026 teams seeded (Groups A–L)');
    }
}
