<?php

namespace Database\Seeders;

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

/**
 * Institutional configuration (PRD 54).
 *
 * Values here are King Ceasor University's real identity, taken from
 * kcu.ac.ug. Nothing in this list is hard-coded anywhere else in the
 * application, so another institution can be stood up by changing these rows.
 */
class SettingsSeeder extends Seeder
{
    /** key => [value, type, group, label, is_public] */
    protected function settings(): array
    {
        return [
            // ------------------------------------------------------- Identity
            'university_name' => ['King Ceasor University', 'string', 'identity', 'University name', true],
            'university_short_name' => ['KCU', 'string', 'identity', 'Short name', true],
            'university_tagline' => ['Celebrating Excellence', 'string', 'identity', 'Tagline', true],
            'university_motto' => ['Veritas', 'string', 'identity', 'Motto', true],
            'university_motto_meaning' => ['Truth', 'string', 'identity', 'Motto meaning', true],
            'university_established' => ['2011', 'string', 'identity', 'Year established', true],
            'university_chancellor' => ['King Ceasor Augustus Mulenga', 'string', 'identity', 'Chancellor', true],
            'university_vice_chancellor' => ['Dr. Charity Basaza Mulenga', 'string', 'identity', 'Vice Chancellor', true],
            'university_accreditation' => [
                'A Chartered institution accredited by the Uganda National Council for Higher Education (NCHE).',
                'string', 'identity', 'Accreditation statement', true,
            ],

            // -------------------------------------------------------- Contact
            'university_email' => ['info@kcu.ac.ug', 'string', 'contact', 'General email', true],
            'university_admissions_email' => ['admissions@kcu.ac.ug', 'string', 'contact', 'Admissions email', true],
            'university_phone' => ['+256 200 911 450', 'string', 'contact', 'Primary phone', true],
            'university_phone_alt' => ['+256 394 716 326', 'string', 'contact', 'Alternate phone', true],
            'university_address' => ['Plot 32 Ggaba Road, Bunga Hill', 'string', 'contact', 'Street address', true],
            'university_city' => ['Kampala', 'string', 'contact', 'City', true],
            'university_country' => ['Uganda', 'string', 'contact', 'Country', true],
            'university_postal' => ['P.O. Box 88, Kampala, Uganda', 'string', 'contact', 'Postal address', true],

            // --------------------------------------------------------- Social
            'social_facebook' => ['https://www.facebook.com/kcu.ac.ug/', 'string', 'social', 'Facebook', true],
            'social_twitter' => ['https://x.com/KingCeasorUni', 'string', 'social', 'X (Twitter)', true],
            'social_linkedin' => ['https://www.linkedin.com/school/king-ceasor-university/', 'string', 'social', 'LinkedIn', true],
            'social_youtube' => ['https://www.youtube.com/@kingceasoruniversitytv', 'string', 'social', 'YouTube', true],

            // --------------------------------------------------------- Brand
            'primary_color' => ['#0B6232', 'string', 'brand', 'Primary brand colour', true],
            'primary_color_dark' => ['#073F24', 'string', 'brand', 'Primary dark', true],
            'secondary_color' => ['#FFC66B', 'string', 'brand', 'Secondary brand colour', true],
            'logo' => ['images/kcu-logo.png', 'file', 'brand', 'Logo', true],
            'favicon' => ['images/favicon.png', 'file', 'brand', 'Favicon', true],

            // --------------------------------------------------- Applications
            'application_fee' => ['50000', 'decimal', 'admissions', 'Default application fee', true],
            'default_currency' => ['UGX', 'string', 'admissions', 'Currency', true],
            'application_number_prefix' => ['KCU', 'string', 'admissions', 'Application number prefix', false],
            'admission_number_prefix' => ['KCU', 'string', 'admissions', 'Admission number prefix', false],
            'max_programme_choices' => ['3', 'integer', 'admissions', 'Programme choices allowed', true],
            'admission_acceptance_days' => ['21', 'integer', 'admissions', 'Days an offer stays open', false],

            // ------------------------------------------------------- Payments
            'bank_name' => ['Stanbic Bank Uganda', 'string', 'payments', 'Bank name', true],
            'bank_account_name' => ['King Ceasor University', 'string', 'payments', 'Account name', true],
            'bank_account_number' => ['9030012345678', 'string', 'payments', 'Account number', true],
            'bank_branch' => ['Kampala Road', 'string', 'payments', 'Branch', true],
            'enabled_payment_providers' => [json_encode(['manual']), 'json', 'payments', 'Enabled providers', false],

            // -------------------------------------------------- Notifications
            'email_enabled' => ['1', 'boolean', 'notifications', 'Send email notifications', false],
            'sms_enabled' => ['0', 'boolean', 'notifications', 'Send SMS notifications', false],

            // ---------------------------------------------------------- Files
            'max_upload_size_kb' => ['5120', 'integer', 'documents', 'Maximum upload size (KB)', true],
        ];
    }

    public function run(): void
    {
        foreach ($this->settings() as $key => [$value, $type, $group, $label, $isPublic]) {
            Setting::updateOrCreate(['key' => $key], [
                'value' => $value,
                'type' => $type,
                'group' => $group,
                'label' => $label,
                'is_public' => $isPublic,
            ]);
        }

        Setting::flushCache();

        $this->command?->info('Seeded '.count($this->settings()).' institutional settings.');
    }
}
