<?php

namespace Database\Seeders;

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

class GeneralSettingsSeeder extends Seeder
{
    public function run()
    {
        $settings = [
            // General Settings
            ['key' => 'site_name', 'value' => 'The Mini Port', 'label' => 'Site Name', 'group' => 'general', 'type' => 'text'],
            ['key' => 'site_logo', 'value' => '', 'label' => 'Site Logo', 'group' => 'general', 'type' => 'image'],
            ['key' => 'site_favicon', 'value' => '', 'label' => 'Favicon', 'group' => 'general', 'type' => 'image'],
            ['key' => 'contact_email', 'value' => 'support@theminiport.com', 'label' => 'Contact Email', 'group' => 'general', 'type' => 'text'],
            ['key' => 'contact_phone', 'value' => '+91 98765 43210', 'label' => 'Contact Phone', 'group' => 'general', 'type' => 'text'],
            ['key' => 'contact_address', 'value' => '123, Business Park, Mumbai, India', 'label' => 'Contact Address', 'group' => 'general', 'type' => 'textarea'],

            // Home Page Settings
            ['key' => 'home_hero_title', 'value' => 'Find the Best Suppliers', 'label' => 'Hero Title', 'group' => 'home', 'type' => 'text'],
            ['key' => 'home_hero_subtitle', 'value' => 'Connect with verified manufacturers and suppliers globally.', 'label' => 'Hero Subtitle', 'group' => 'home', 'type' => 'text'],
            ['key' => 'show_featured_products', 'value' => '1', 'label' => 'Show Featured Products', 'group' => 'home', 'type' => 'boolean'],
            ['key' => 'show_latest_rfqs', 'value' => '1', 'label' => 'Show Latest RFQs', 'group' => 'home', 'type' => 'boolean'],

            // Social Media
            ['key' => 'social_facebook', 'value' => 'https://facebook.com', 'label' => 'Facebook URL', 'group' => 'social', 'type' => 'text'],
            ['key' => 'social_twitter', 'value' => 'https://twitter.com', 'label' => 'Twitter URL', 'group' => 'social', 'type' => 'text'],
            ['key' => 'social_linkedin', 'value' => 'https://linkedin.com', 'label' => 'LinkedIn URL', 'group' => 'social', 'type' => 'text'],
            ['key' => 'social_instagram', 'value' => 'https://instagram.com', 'label' => 'Instagram URL', 'group' => 'social', 'type' => 'text'],

            // SEO
            ['key' => 'meta_title', 'value' => 'The Mini Port - B2B Marketplace', 'label' => 'Default Meta Title', 'group' => 'seo', 'type' => 'text'],
            ['key' => 'meta_description', 'value' => 'Leading B2B marketplace for connecting buyers and sellers.', 'label' => 'Default Meta Description', 'group' => 'seo', 'type' => 'textarea'],
            ['key' => 'meta_keywords', 'value' => 'b2b, marketplace, suppliers, manufacturers', 'label' => 'Default Meta Keywords', 'group' => 'seo', 'type' => 'textarea'],

            // Scripts
            ['key' => 'header_scripts', 'value' => '', 'label' => 'Header Scripts (e.g., Analytics)', 'group' => 'scripts', 'type' => 'textarea'],
            ['key' => 'footer_scripts', 'value' => '', 'label' => 'Footer Scripts', 'group' => 'scripts', 'type' => 'textarea'],

            // Email Settings (Already seeded, but good to ensure)
            ['key' => 'mail_mailer', 'value' => 'smtp', 'label' => 'Mailer', 'group' => 'email', 'type' => 'text'],
            ['key' => 'mail_host', 'value' => 'smtp.mailtrap.io', 'label' => 'Mail Host', 'group' => 'email', 'type' => 'text'],
            ['key' => 'mail_port', 'value' => '2525', 'label' => 'Mail Port', 'group' => 'email', 'type' => 'text'],
            ['key' => 'mail_username', 'value' => '', 'label' => 'Mail Username', 'group' => 'email', 'type' => 'text'],
            ['key' => 'mail_password', 'value' => '', 'label' => 'Mail Password', 'group' => 'email', 'type' => 'text'],
            ['key' => 'mail_encryption', 'value' => 'tls', 'label' => 'Mail Encryption', 'group' => 'email', 'type' => 'text'],
            ['key' => 'mail_from_address', 'value' => 'hello@example.com', 'label' => 'From Address', 'group' => 'email', 'type' => 'text'],
            ['key' => 'mail_from_name', 'value' => 'The Mini Port', 'label' => 'From Name', 'group' => 'email', 'type' => 'text'],

            // Payment Settings
            ['key' => 'payment_gateway', 'value' => 'stripe', 'label' => 'Default Gateway', 'group' => 'payment', 'type' => 'text'],
            ['key' => 'stripe_key', 'value' => '', 'label' => 'Stripe Key', 'group' => 'payment', 'type' => 'text'],
            ['key' => 'stripe_secret', 'value' => '', 'label' => 'Stripe Secret', 'group' => 'payment', 'type' => 'text'],
            ['key' => 'payment_mode', 'value' => 'sandbox', 'label' => 'Payment Mode', 'group' => 'payment', 'type' => 'select'],
        ];

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