<?php

namespace Database\Seeders;

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

class SettingsSeeder extends Seeder
{
    public function run(): void
    {
        $settings = [
            // Business Information
            [
                'key' => 'business_name',
                'value' => 'INVENTINO',
                'type' => 'string',
                'description' => 'Business name displayed on receipts and documents'
            ],
            [
                'key' => 'phone',
                'value' => '+234 800 000 0000',
                'type' => 'string',
                'description' => 'Business contact phone number'
            ],
            [
                'key' => 'email',
                'value' => 'info@inventino.shop',
                'type' => 'string',
                'description' => 'Business contact email'
            ],
            [
                'key' => 'website',
                'value' => 'https://inventino.shop',
                'type' => 'string',
                'description' => 'Business website URL'
            ],
            [
                'key' => 'address',
                'value' => 'Victoria Island, Lagos, Nigeria',
                'type' => 'string',
                'description' => 'Business physical address'
            ],

            // System Settings - Currency
            [
                'key' => 'currency_symbol',
                'value' => '₦',
                'type' => 'string',
                'description' => 'Currency symbol for display'
            ],
            [
                'key' => 'currency_code',
                'value' => 'NGN',
                'type' => 'string',
                'description' => 'ISO currency code'
            ],
            [
                'key' => 'currency_name',
                'value' => 'Nigerian Naira',
                'type' => 'string',
                'description' => 'Full currency name'
            ],

            // System Settings - Tax and Thresholds
            [
                'key' => 'tax_rate',
                'value' => '7.5',
                'type' => 'string',
                'description' => 'Default tax rate percentage (VAT for Nigeria is 7.5%)'
            ],
            [
                'key' => 'low_stock_threshold',
                'value' => '10',
                'type' => 'integer',
                'description' => 'Minimum quantity before low stock alert'
            ],

            // System Settings - Timezone and Format
            [
                'key' => 'timezone',
                'value' => 'Africa/Lagos',
                'type' => 'string',
                'description' => 'System timezone'
            ],
            [
                'key' => 'date_format',
                'value' => 'd/m/Y',
                'type' => 'string',
                'description' => 'Date display format'
            ],

            // Receipt Settings
            [
                'key' => 'receipt_header',
                'value' => 'Thank you for your purchase',
                'type' => 'string',
                'description' => 'Text displayed at the top of receipts'
            ],
            [
                'key' => 'receipt_footer',
                'value' => 'Please visit us again!',
                'type' => 'string',
                'description' => 'Text displayed at the bottom of receipts'
            ],
            [
                'key' => 'print_receipt_auto',
                'value' => '0',
                'type' => 'boolean',
                'description' => 'Automatically print receipts after sale'
            ],
            [
                'key' => 'email_receipt_enabled',
                'value' => '0',
                'type' => 'boolean',
                'description' => 'Enable email receipt functionality'
            ],

            // Inventory Settings
            [
                'key' => 'track_stock',
                'value' => '1',
                'type' => 'boolean',
                'description' => 'Enable inventory stock tracking'
            ],
            [
                'key' => 'allow_negative_stock',
                'value' => '0',
                'type' => 'boolean',
                'description' => 'Allow selling items with zero or negative stock'
            ],
            [
                'key' => 'low_stock_alert',
                'value' => '1',
                'type' => 'boolean',
                'description' => 'Show alerts when products reach low stock threshold'
            ],

            // Loyalty Program
            [
                'key' => 'loyalty_enabled',
                'value' => '0',
                'type' => 'boolean',
                'description' => 'Enable customer loyalty points program'
            ],
            [
                'key' => 'loyalty_points_per_dollar',
                'value' => '1',
                'type' => 'string',
                'description' => 'Points earned per currency unit spent'
            ],
            [
                'key' => 'loyalty_point_value',
                'value' => '0.01',
                'type' => 'string',
                'description' => 'Monetary value of each loyalty point'
            ],
        ];

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

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