<?php

namespace Database\Seeders;

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

class SystemSettingsSeeder extends Seeder
{
    public function run(): void
    {
        $settings = [
            // ── AI / OpenAI ──────────────────────────────────────────────────
            [
                'key'          => 'openai_api_key',
                'value'        => null,
                'group'        => 'ai',
                'label'        => 'OpenAI API Key',
                'description'  => 'Your OpenAI API key (sk-...). Stored encrypted. Required for AI document extraction and plot survey analysis.',
                'is_encrypted' => true,
            ],
            [
                'key'          => 'openai_model',
                'value'        => 'gpt-4o',
                'group'        => 'ai',
                'label'        => 'OpenAI Chat Model',
                'description'  => 'Model for text-based AI tasks (regulation extraction, analysis). Recommended: gpt-4o',
                'is_encrypted' => false,
            ],
            [
                'key'          => 'openai_vision_model',
                'value'        => 'gpt-4o',
                'group'        => 'ai',
                'label'        => 'OpenAI Vision Model',
                'description'  => 'Model for image/document OCR and plot survey analysis. Recommended: gpt-4o',
                'is_encrypted' => false,
            ],
            [
                'key'          => 'openai_max_tokens',
                'value'        => '4096',
                'group'        => 'ai',
                'label'        => 'Max Tokens per Request',
                'description'  => 'Maximum number of tokens to generate per AI call. Higher = more detail but higher cost.',
                'is_encrypted' => false,
            ],
            [
                'key'          => 'openai_enabled',
                'value'        => '0',
                'group'        => 'ai',
                'label'        => 'Enable AI Features',
                'description'  => 'Master switch for all AI-powered features. Set to 1 after entering your API key.',
                'is_encrypted' => false,
            ],
            // ── General ───────────────────────────────────────────────────────
            [
                'key'          => 'app_contact_email',
                'value'        => null,
                'group'        => 'general',
                'label'        => 'Contact Email',
                'description'  => 'Email address shown on the portal for user queries.',
                'is_encrypted' => false,
            ],
            [
                'key'          => 'bhulekh_enabled',
                'value'        => '0',
                'group'        => 'ai',
                'label'        => 'Enable Bhulekh Lookup',
                'description'  => 'Show Bhulekh land record portal links in survey analysis results.',
                'is_encrypted' => false,
            ],
        ];

        foreach ($settings as $data) {
            SystemSetting::firstOrCreate(
                ['key' => $data['key']],
                $data
            );
        }
    }
}
