<?php

namespace Database\Seeders;

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

class DynamicSettingsSeeder extends Seeder
{
    public function run(): void
    {
        $settings = [
            // ===== FEATURES GROUP =====
            
            // Social Login Settings
            [
                'key' => 'social_login_google_enabled',
                'value' => '1',
                'label' => 'Enable Google Login',
                'group' => 'features',
                'type' => 'boolean'
            ],
            [
                'key' => 'social_login_facebook_enabled',
                'value' => '1',
                'label' => 'Enable Facebook Login',
                'group' => 'features',
                'type' => 'boolean'
            ],
            [
                'key' => 'google_client_id',
                'value' => '',
                'label' => 'Google Client ID',
                'group' => 'features',
                'type' => 'text'
            ],
            [
                'key' => 'google_client_secret',
                'value' => '',
                'label' => 'Google Client Secret',
                'group' => 'features',
                'type' => 'password'
            ],
            [
                'key' => 'facebook_app_id',
                'value' => '',
                'label' => 'Facebook App ID',
                'group' => 'features',
                'type' => 'text'
            ],
            [
                'key' => 'facebook_app_secret',
                'value' => '',
                'label' => 'Facebook App Secret',
                'group' => 'features',
                'type' => 'password'
            ],
            
            // WhatsApp Settings
            [
                'key' => 'whatsapp_support_enabled',
                'value' => '1',
                'label' => 'Show WhatsApp Support Button',
                'group' => 'features',
                'type' => 'boolean'
            ],
            [
                'key' => 'whatsapp_support_number',
                'value' => '919876543210',
                'label' => 'WhatsApp Support Number',
                'group' => 'features',
                'type' => 'text'
            ],
            [
                'key' => 'whatsapp_support_message',
                'value' => 'Hi! I need help with The Mini Port platform.',
                'label' => 'Default WhatsApp Message',
                'group' => 'features',
                'type' => 'textarea'
            ],
            
            // SMS Settings
            [
                'key' => 'sms_enabled',
                'value' => '0',
                'label' => 'Enable SMS Notifications',
                'group' => 'features',
                'type' => 'boolean'
            ],
            [
                'key' => 'sms_provider',
                'value' => 'msg91',
                'label' => 'SMS Provider',
                'group' => 'features',
                'type' => 'select'
            ],
            [
                'key' => 'sms_otp_enabled',
                'value' => '0',
                'label' => 'Enable OTP Login for Sellers',
                'group' => 'features',
                'type' => 'boolean'
            ],
            
            // Product Settings
            [
                'key' => 'product_approval_required',
                'value' => '1',
                'label' => 'Require Admin Approval for New Products',
                'group' => 'features',
                'type' => 'boolean'
            ],
            [
                'key' => 'bulk_upload_enabled',
                'value' => '1',
                'label' => 'Enable Bulk Product Upload (CSV)',
                'group' => 'features',
                'type' => 'boolean'
            ],
            
            // Platform Limits
            [
                'key' => 'min_moq',
                'value' => '10',
                'label' => 'Minimum MOQ Allowed',
                'group' => 'features',
                'type' => 'text'
            ],
            [
                'key' => 'max_moq',
                'value' => '150',
                'label' => 'Maximum MOQ Allowed',
                'group' => 'features',
                'type' => 'text'
            ],
            
            // Help Page Settings
            [
                'key' => 'help_page_enabled',
                'value' => '1',
                'label' => 'Enable Help Page',
                'group' => 'features',
                'type' => 'boolean'
            ],
            [
                'key' => 'help_support_email',
                'value' => 'support@theminiport.com',
                'label' => 'Support Email for Help Page',
                'group' => 'features',
                'type' => 'text'
            ],
            
            // Newsletter Settings
            [
                'key' => 'newsletter_enabled',
                'value' => '1',
                'label' => 'Enable Newsletter Subscription',
                'group' => 'features',
                'type' => 'boolean'
            ],
            
            // Maintenance Mode
            [
                'key' => 'maintenance_mode',
                'value' => '0',
                'label' => 'Maintenance Mode',
                'group' => 'features',
                'type' => 'boolean'
            ],
            [
                'key' => 'maintenance_message',
                'value' => 'We are currently performing scheduled maintenance. Please check back soon.',
                'label' => 'Maintenance Message',
                'group' => 'features',
                'type' => 'textarea'
            ],
        ];

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

        $this->command->info('Dynamic settings seeded successfully!');
    }
}
