<?php

namespace Database\Seeders;

use App\Contracts\SettingRepositoryContract;
use App\Support\NotificationSettings;
use Illuminate\Database\Seeder;

class SettingsSeeder extends Seeder
{
    public function run(): void
    {
        /** @var SettingRepositoryContract $settings */
        $settings = app(SettingRepositoryContract::class);

        $defaults = [
            'app.name' => ['value' => config('app.name'), 'category' => 'general', 'type' => 'string'],
            'app.timezone' => ['value' => 'UTC', 'category' => 'general', 'type' => 'string'],
            'app.locale' => ['value' => 'en', 'category' => 'general', 'type' => 'string'],
            'app.date_format' => ['value' => 'Y-m-d', 'category' => 'general', 'type' => 'string'],
            'company.name' => ['value' => config('app.name'), 'category' => 'company', 'type' => 'string'],
            'company.email' => ['value' => 'admin@example.com', 'category' => 'company', 'type' => 'string'],
            'company.phone' => ['value' => '', 'category' => 'company', 'type' => 'string'],
            'company.address' => ['value' => '', 'category' => 'company', 'type' => 'string'],
            'email.from_name' => ['value' => config('app.name'), 'category' => 'email', 'type' => 'string'],
            'email.from_address' => ['value' => 'hello@example.com', 'category' => 'email', 'type' => 'string'],
            'security.session_lifetime' => ['value' => '120', 'category' => 'security', 'type' => 'integer'],
            'security.two_factor_enabled' => ['value' => '0', 'category' => 'security', 'type' => 'boolean'],
            'security.password_expiry_days' => ['value' => '0', 'category' => 'security', 'type' => 'integer'],
            'auth.allow_registration' => ['value' => '0', 'category' => 'auth', 'type' => 'boolean'],
            'update.temp_path' => ['value' => storage_path('app/updates/tmp'), 'category' => 'update', 'type' => 'string'],
            'appearance.theme' => ['value' => 'light', 'category' => 'appearance', 'type' => 'string'],
            'appearance.primary_color' => ['value' => '#4f46e5', 'category' => 'appearance', 'type' => 'string'],
            'homepage.template' => ['value' => config('homepage.default_template', 'classic'), 'category' => 'homepage', 'type' => 'string'],
            'homepage.headline' => ['value' => 'Welcome to '.config('app.name'), 'category' => 'homepage', 'type' => 'string'],
            'homepage.subtitle' => ['value' => 'Manage your platform with confidence', 'category' => 'homepage', 'type' => 'string'],
            'homepage.description' => ['value' => 'Powerful admin tools to help you streamline operations, manage staff, and grow your business.', 'category' => 'homepage', 'type' => 'string'],
            'homepage.button_text' => ['value' => 'Admin Login', 'category' => 'homepage', 'type' => 'string'],
            'homepage.feature_1' => ['value' => 'Real-time analytics dashboard', 'category' => 'homepage', 'type' => 'string'],
            'homepage.feature_2' => ['value' => 'Team collaboration tools', 'category' => 'homepage', 'type' => 'string'],
            'homepage.feature_3' => ['value' => 'Advanced reporting & exports', 'category' => 'homepage', 'type' => 'string'],
            ...NotificationSettings::defaultSettingsPayload(),
        ];

        $settings->setMany($defaults);
    }
}
