<?php

namespace Database\Seeders;

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

class CountryPhoneCodeSeeder extends Seeder
{
    public function run(): void
    {
        $codes = [
            // Default first — Oman
            ['country_name' => 'Oman',            'country_code' => 'OM', 'dial_code' => '+968', 'flag_emoji' => '🇴🇲', 'sorting' => 1],

            // GCC
            ['country_name' => 'Saudi Arabia',    'country_code' => 'SA', 'dial_code' => '+966', 'flag_emoji' => '🇸🇦', 'sorting' => 2],
            ['country_name' => 'United Arab Emirates', 'country_code' => 'AE', 'dial_code' => '+971', 'flag_emoji' => '🇦🇪', 'sorting' => 3],
            ['country_name' => 'Kuwait',           'country_code' => 'KW', 'dial_code' => '+965', 'flag_emoji' => '🇰🇼', 'sorting' => 4],
            ['country_name' => 'Bahrain',          'country_code' => 'BH', 'dial_code' => '+973', 'flag_emoji' => '🇧🇭', 'sorting' => 5],
            ['country_name' => 'Qatar',            'country_code' => 'QA', 'dial_code' => '+974', 'flag_emoji' => '🇶🇦', 'sorting' => 6],

            // Middle East
            ['country_name' => 'Egypt',            'country_code' => 'EG', 'dial_code' => '+20',  'flag_emoji' => '🇪🇬', 'sorting' => 10],
            ['country_name' => 'Jordan',           'country_code' => 'JO', 'dial_code' => '+962', 'flag_emoji' => '🇯🇴', 'sorting' => 11],
            ['country_name' => 'Lebanon',          'country_code' => 'LB', 'dial_code' => '+961', 'flag_emoji' => '🇱🇧', 'sorting' => 12],
            ['country_name' => 'Turkey',           'country_code' => 'TR', 'dial_code' => '+90',  'flag_emoji' => '🇹🇷', 'sorting' => 13],

            // South / Southeast Asia
            ['country_name' => 'India',            'country_code' => 'IN', 'dial_code' => '+91',  'flag_emoji' => '🇮🇳', 'sorting' => 20],
            ['country_name' => 'Pakistan',         'country_code' => 'PK', 'dial_code' => '+92',  'flag_emoji' => '🇵🇰', 'sorting' => 21],
            ['country_name' => 'Bangladesh',       'country_code' => 'BD', 'dial_code' => '+880', 'flag_emoji' => '🇧🇩', 'sorting' => 22],
            ['country_name' => 'Sri Lanka',        'country_code' => 'LK', 'dial_code' => '+94',  'flag_emoji' => '🇱🇰', 'sorting' => 23],
            ['country_name' => 'Malaysia',         'country_code' => 'MY', 'dial_code' => '+60',  'flag_emoji' => '🇲🇾', 'sorting' => 24],
            ['country_name' => 'Singapore',        'country_code' => 'SG', 'dial_code' => '+65',  'flag_emoji' => '🇸🇬', 'sorting' => 25],
            ['country_name' => 'Indonesia',        'country_code' => 'ID', 'dial_code' => '+62',  'flag_emoji' => '🇮🇩', 'sorting' => 26],
            ['country_name' => 'Philippines',      'country_code' => 'PH', 'dial_code' => '+63',  'flag_emoji' => '🇵🇭', 'sorting' => 27],

            // International
            ['country_name' => 'United Kingdom',   'country_code' => 'GB', 'dial_code' => '+44',  'flag_emoji' => '🇬🇧', 'sorting' => 30],
            ['country_name' => 'United States',    'country_code' => 'US', 'dial_code' => '+1',   'flag_emoji' => '🇺🇸', 'sorting' => 31],
            ['country_name' => 'Australia',        'country_code' => 'AU', 'dial_code' => '+61',  'flag_emoji' => '🇦🇺', 'sorting' => 32],
        ];

        foreach ($codes as $code) {
            CountryPhoneCode::updateOrCreate(
                ['country_code' => $code['country_code']],
                array_merge($code, ['is_active' => true])
            );
        }
    }
}
