<?php

namespace Database\Seeders;

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

class AppSettingsSeeder extends Seeder
{
    public function run(): void
    {
        $settings = [
            // General
            ['key' => 'app_name', 'value' => 'FIN-ANALYSIS PRO', 'type' => 'string', 'group' => 'general', 'label' => 'Nama Aplikasi', 'is_public' => true],
            ['key' => 'app_description', 'value' => 'Analisis Keuangan Z-Score untuk UMKM', 'type' => 'string', 'group' => 'general', 'label' => 'Deskripsi Aplikasi', 'is_public' => true],
            ['key' => 'maintenance_mode', 'value' => '0', 'type' => 'boolean', 'group' => 'general', 'label' => 'Mode Maintenance', 'is_public' => false],
            ['key' => 'allow_register', 'value' => '1', 'type' => 'boolean', 'group' => 'general', 'label' => 'Izinkan Registrasi Baru', 'is_public' => false],
            
            // Analysis
            ['key' => 'max_analyses_per_user', 'value' => '100', 'type' => 'integer', 'group' => 'analysis', 'label' => 'Maks Analisis per User', 'is_public' => false],
            ['key' => 'default_currency', 'value' => 'IDR', 'type' => 'string', 'group' => 'analysis', 'label' => 'Mata Uang Default', 'is_public' => true],
            
            // Notification
            ['key' => 'admin_email', 'value' => 'admin@analisisperusahaan.com', 'type' => 'string', 'group' => 'notification', 'label' => 'Email Admin', 'is_public' => false],
            ['key' => 'email_on_distress', 'value' => '0', 'type' => 'boolean', 'group' => 'notification', 'label' => 'Email saat Zona Berbahaya', 'is_public' => false],
        ];

        foreach ($settings as $setting) {
            AppSetting::updateOrCreate(
                ['key' => $setting['key']],
                $setting
            );
        }
    }
}
