<?php

namespace Database\Seeders;

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

class SettingsSeeder extends Seeder
{
    public function run(): void
    {
        $defaults = [
            // Site identity
            'site_name'              => 'LPTA - Lumbini Province Taekwondo Association',
            'site_tagline'           => 'Uniting Athletes Across Lumbini Province',
            'header_logo_text'       => 'LPTA',
            'header_logo_tagline'    => 'Lumbini Province Taekwondo Association',
            'header_logo_icon'       => '',
            'header_logo_img'        => '',
            // Contact info
            'contact_address'        => 'Butwal-11, Rupandehi, Lumbini Province, Nepal',
            'contact_phone'          => '+977-71-123456',
            'contact_email'          => 'info@lumbinitkd.org',
            // Social media
            'social_facebook'        => 'https://facebook.com/lumbinitkd',
            'social_youtube'         => 'https://youtube.com/lumbinitkd',
            'social_instagram'       => '',
            'social_tiktok'          => '',
            // Footer
            'footer_about'           => 'Lumbini Province Taekwondo Association (LPTA) is the governing body for Taekwondo in Lumbini Province, Nepal.',
            'footer_copyright'       => '2026 Lumbini Province Taekwondo Association. All rights reserved.',
            // Navigation menu — use 'route' key so links go through route() helper (absolute URLs)
            'nav_menu_json'          => json_encode([
                ['label' => 'Home',         'route' => 'home'],
                ['label' => 'About',        'route' => 'about'],
                ['label' => 'Events',       'route' => 'events'],
                ['label' => 'News',         'route' => 'news'],
                ['label' => 'Gallery',      'route' => 'gallery'],
                ['label' => 'Achievements', 'route' => 'achievements'],
                ['label' => 'Member',       'route' => 'tree'],
                ['label' => 'Contact',      'route' => 'contact'],
            ]),
            // Stats offsets
            'stats_members_offset'   => '140',
            'stats_clubs_offset'     => '0',
            'stats_coaches_offset'   => '0',
            'stats_referees_offset'  => '0',
            'stats_gold_offset'      => '12',
            'stats_silver_offset'    => '18',
            'stats_bronze_offset'    => '25',
            'stats_districts_offset' => '0',
        ];

        $now = now();
        foreach ($defaults as $key => $value) {
            DB::table('settings')->updateOrInsert(
                ['key' => $key],
                ['value' => $value, 'updated_at' => $now, 'created_at' => $now]
            );
        }

        $this->command->info('Settings seeded: ' . count($defaults) . ' rows.');
    }
}
