<?php

namespace Database\Seeders;

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

class SettingSeeder extends Seeder
{
    public function run(): void
    {
        $defaults = [
            // ── General ─────────────────────────────────────────────────────────
            ['key' => 'site_name',           'group' => 'general',  'type' => 'string',  'value' => 'VVmj8 Casino',    'label' => 'Site Name'],
            ['key' => 'site_tagline',        'group' => 'general',  'type' => 'string',  'value' => 'The Ultimate Casino & Sports Betting Platform', 'label' => 'Tagline'],
            ['key' => 'site_logo',           'group' => 'general',  'type' => 'string',  'value' => '',                 'label' => 'Logo URL'],
            ['key' => 'site_favicon',        'group' => 'general',  'type' => 'string',  'value' => '',                 'label' => 'Favicon URL'],
            ['key' => 'site_description',    'group' => 'general',  'type' => 'string',  'value' => 'The ultimate destination for online casino games and sports betting.', 'label' => 'Meta Description'],
            ['key' => 'support_email',       'group' => 'general',  'type' => 'string',  'value' => 'support@vvmj8.com', 'label' => 'Support Email'],
            ['key' => 'support_phone',       'group' => 'general',  'type' => 'string',  'value' => '+1 800 VVMJ8',     'label' => 'Support Phone'],
            ['key' => 'maintenance_mode',    'group' => 'general',  'type' => 'boolean', 'value' => '0',                'label' => 'Maintenance Mode'],
            ['key' => 'maintenance_message', 'group' => 'general',  'type' => 'string',  'value' => 'We are currently undergoing maintenance. Please check back soon.', 'label' => 'Maintenance Message'],

            // ── API Integrations ─────────────────────────────────────────────────
            ['key' => 'odds_api_key',          'group' => 'api',  'type' => 'string',  'value' => env('ODDS_API_KEY', ''),  'label' => 'TheOddsAPI Key'],
            ['key' => 'odds_api_enabled',      'group' => 'api',  'type' => 'boolean', 'value' => '1',                       'label' => 'TheOddsAPI Enabled'],
            ['key' => 'odds_api_base_url',     'group' => 'api',  'type' => 'string',  'value' => 'https://api.the-odds-api.com/v4', 'label' => 'TheOddsAPI Base URL'],
            ['key' => 'odds_api_regions',      'group' => 'api',  'type' => 'string',  'value' => 'eu,uk',                  'label' => 'TheOddsAPI Regions'],
            ['key' => 'odds_api_markets',      'group' => 'api',  'type' => 'string',  'value' => 'h2h',                    'label' => 'TheOddsAPI Markets'],
            ['key' => 'odds_api_odds_format',  'group' => 'api',  'type' => 'string',  'value' => 'decimal',                'label' => 'TheOddsAPI Odds Format'],
            ['key' => 'google_analytics_id',   'group' => 'api',  'type' => 'string',  'value' => '',                       'label' => 'Google Analytics ID'],
            ['key' => 'recaptcha_site_key',    'group' => 'api',  'type' => 'string',  'value' => '',                       'label' => 'reCAPTCHA Site Key'],
            ['key' => 'recaptcha_secret_key',  'group' => 'api',  'type' => 'string',  'value' => '',                       'label' => 'reCAPTCHA Secret Key'],
            ['key' => 'recaptcha_enabled',     'group' => 'api',  'type' => 'boolean', 'value' => '0',                      'label' => 'reCAPTCHA Enabled'],
            ['key' => 'smtp_host',             'group' => 'api',  'type' => 'string',  'value' => '',                       'label' => 'SMTP Host'],
            ['key' => 'smtp_port',             'group' => 'api',  'type' => 'integer', 'value' => '587',                    'label' => 'SMTP Port'],
            ['key' => 'smtp_username',         'group' => 'api',  'type' => 'string',  'value' => '',                       'label' => 'SMTP Username'],
            ['key' => 'smtp_password',         'group' => 'api',  'type' => 'string',  'value' => '',                       'label' => 'SMTP Password'],
            ['key' => 'smtp_from_name',        'group' => 'api',  'type' => 'string',  'value' => 'VVmj8 Casino',           'label' => 'Email From Name'],
            ['key' => 'smtp_from_email',       'group' => 'api',  'type' => 'string',  'value' => 'noreply@vvmj8.com',      'label' => 'Email From Address'],

            // ── Finance ──────────────────────────────────────────────────────────
            ['key' => 'default_currency',        'group' => 'finance', 'type' => 'string',  'value' => 'USD',    'label' => 'Default Currency'],
            ['key' => 'currency_symbol',         'group' => 'finance', 'type' => 'string',  'value' => '$',      'label' => 'Currency Symbol'],
            ['key' => 'welcome_balance',         'group' => 'finance', 'type' => 'float',   'value' => '500.00', 'label' => 'Welcome Balance ($)'],
            ['key' => 'welcome_balance_enabled', 'group' => 'finance', 'type' => 'boolean', 'value' => '1',      'label' => 'Give Welcome Balance on Register'],
            ['key' => 'global_min_deposit',      'group' => 'finance', 'type' => 'float',   'value' => '10',     'label' => 'Global Min Deposit ($)'],
            ['key' => 'global_max_deposit',      'group' => 'finance', 'type' => 'float',   'value' => '50000',  'label' => 'Global Max Deposit ($)'],
            ['key' => 'global_min_withdrawal',   'group' => 'finance', 'type' => 'float',   'value' => '20',     'label' => 'Global Min Withdrawal ($)'],
            ['key' => 'global_max_withdrawal',   'group' => 'finance', 'type' => 'float',   'value' => '10000',  'label' => 'Global Max Withdrawal ($)'],
            ['key' => 'deposit_fee_percent',     'group' => 'finance', 'type' => 'float',   'value' => '0',      'label' => 'Deposit Fee (%)'],
            ['key' => 'withdrawal_fee_percent',  'group' => 'finance', 'type' => 'float',   'value' => '0',      'label' => 'Withdrawal Fee (%)'],
            ['key' => 'auto_approve_withdrawal', 'group' => 'finance', 'type' => 'boolean', 'value' => '1',      'label' => 'Auto-Approve Withdrawals'],

            // POS
            ['key' => 'pos_enabled',          'group' => 'pos', 'type' => 'boolean', 'value' => '1',   'label' => 'POS Enabled'],
            ['key' => 'pos_max_terminals',    'group' => 'pos', 'type' => 'integer', 'value' => '0',   'label' => 'Maximum POS Terminals'],
            ['key' => 'pos_receipt_prefix',   'group' => 'pos', 'type' => 'string',  'value' => 'POS', 'label' => 'Receipt Prefix'],
            ['key' => 'pos_default_location', 'group' => 'pos', 'type' => 'string',  'value' => '',    'label' => 'Default POS Location'],
            ['key' => 'pos_print_footer',     'group' => 'pos', 'type' => 'string',  'value' => 'Thank you for using VVmj8 Casino.', 'label' => 'Receipt Footer'],

            // ── Betting ───────────────────────────────────────────────────────────
            ['key' => 'min_bet',             'group' => 'betting', 'type' => 'float',   'value' => '0.10',   'label' => 'Minimum Bet ($)'],
            ['key' => 'max_bet',             'group' => 'betting', 'type' => 'float',   'value' => '10000',  'label' => 'Maximum Bet ($)'],
            ['key' => 'max_parlay_legs',     'group' => 'betting', 'type' => 'integer', 'value' => '10',     'label' => 'Max Parlay Legs'],
            ['key' => 'max_parlay_payout',   'group' => 'betting', 'type' => 'float',   'value' => '100000', 'label' => 'Max Parlay Payout ($)'],
            ['key' => 'house_win_rate',      'group' => 'betting', 'type' => 'integer', 'value' => '45',     'label' => 'House Win Rate (%) — player loses this % of bets'],
            ['key' => 'settlement_mode',     'group' => 'betting', 'type' => 'string',  'value' => 'instant','label' => 'Settlement Mode (instant / manual)'],
            ['key' => 'sports_betting_enabled', 'group' => 'betting', 'type' => 'boolean', 'value' => '1',  'label' => 'Sports Betting Enabled'],
            ['key' => 'casino_games_enabled',   'group' => 'betting', 'type' => 'boolean', 'value' => '1',  'label' => 'Casino Games Enabled'],
            ['key' => 'vip_points_per_dollar',  'group' => 'betting', 'type' => 'integer', 'value' => '10', 'label' => 'VIP Points per $1 Staked'],

            // ── Registration & Security ───────────────────────────────────────────
            ['key' => 'registration_enabled',       'group' => 'registration', 'type' => 'boolean', 'value' => '1',  'label' => 'Allow New Registrations'],
            ['key' => 'email_verification_required', 'group' => 'registration', 'type' => 'boolean', 'value' => '0', 'label' => 'Require Email Verification'],
            ['key' => 'kyc_required',               'group' => 'registration', 'type' => 'boolean', 'value' => '0',  'label' => 'Require KYC Verification'],
            ['key' => 'minimum_age',                'group' => 'registration', 'type' => 'integer', 'value' => '18', 'label' => 'Minimum Age'],
            ['key' => 'max_login_attempts',         'group' => 'registration', 'type' => 'integer', 'value' => '5',  'label' => 'Max Login Attempts Before Lock'],
            ['key' => 'session_lifetime_minutes',   'group' => 'registration', 'type' => 'integer', 'value' => '120','label' => 'Session Lifetime (minutes)'],
            ['key' => 'two_factor_enabled',         'group' => 'registration', 'type' => 'boolean', 'value' => '0',  'label' => '2FA Available for Players'],

            // ── Legal & Social ────────────────────────────────────────────────────
            ['key' => 'license_number',    'group' => 'legal', 'type' => 'string', 'value' => 'GLH-OCCHKTW0700781-2025', 'label' => 'License Number'],
            ['key' => 'license_authority', 'group' => 'legal', 'type' => 'string', 'value' => 'Curacao eGaming',         'label' => 'Licensing Authority'],
            ['key' => 'company_name',      'group' => 'legal', 'type' => 'string', 'value' => 'VVmj8 Limited',           'label' => 'Company Name'],
            ['key' => 'company_address',   'group' => 'legal', 'type' => 'string', 'value' => 'Willemstad, Curaçao',     'label' => 'Company Address'],
            ['key' => 'terms_url',         'group' => 'legal', 'type' => 'string', 'value' => '',                        'label' => 'Terms & Conditions URL'],
            ['key' => 'privacy_url',       'group' => 'legal', 'type' => 'string', 'value' => '',                        'label' => 'Privacy Policy URL'],
            ['key' => 'responsible_gaming_url', 'group' => 'legal', 'type' => 'string', 'value' => '',                   'label' => 'Responsible Gaming URL'],
            ['key' => 'facebook_url',      'group' => 'legal', 'type' => 'string', 'value' => '',                        'label' => 'Facebook URL'],
            ['key' => 'twitter_url',       'group' => 'legal', 'type' => 'string', 'value' => '',                        'label' => 'Twitter / X URL'],
            ['key' => 'instagram_url',     'group' => 'legal', 'type' => 'string', 'value' => '',                        'label' => 'Instagram URL'],
            ['key' => 'telegram_url',      'group' => 'legal', 'type' => 'string', 'value' => '',                        'label' => 'Telegram URL'],

            // ── Responsible Gaming ────────────────────────────────────────────────
            ['key' => 'rg_enabled',                    'group' => 'responsible_gaming', 'type' => 'boolean', 'value' => '1',   'label' => 'Responsible Gaming Enabled'],
            ['key' => 'self_exclusion_enabled',        'group' => 'responsible_gaming', 'type' => 'boolean', 'value' => '1',   'label' => 'Self-Exclusion Enabled'],
            ['key' => 'deposit_limits_enabled',        'group' => 'responsible_gaming', 'type' => 'boolean', 'value' => '1',   'label' => 'Deposit Limits Enabled'],
            ['key' => 'loss_limits_enabled',           'group' => 'responsible_gaming', 'type' => 'boolean', 'value' => '1',   'label' => 'Loss Limits Enabled'],
            ['key' => 'session_limits_enabled',        'group' => 'responsible_gaming', 'type' => 'boolean', 'value' => '1',   'label' => 'Session Limits Enabled'],
            ['key' => 'reality_check_enabled',         'group' => 'responsible_gaming', 'type' => 'boolean', 'value' => '1',   'label' => 'Reality Check Enabled'],
            ['key' => 'reality_check_interval',        'group' => 'responsible_gaming', 'type' => 'integer', 'value' => '30',  'label' => 'Reality Check Interval (minutes)'],
            ['key' => 'cool_off_enabled',              'group' => 'responsible_gaming', 'type' => 'boolean', 'value' => '1',   'label' => 'Cool-Off Period Enabled'],
            ['key' => 'max_session_hours',             'group' => 'responsible_gaming', 'type' => 'integer', 'value' => '8',   'label' => 'Max Session Hours'],
            ['key' => 'rg_helpline',                   'group' => 'responsible_gaming', 'type' => 'string',  'value' => 'https://www.gamblingtherapy.org', 'label' => 'Gambling Help URL'],

            // ── KYC ──────────────────────────────────────────────────────────────
            ['key' => 'kyc_required_for_withdrawal',   'group' => 'kyc', 'type' => 'boolean', 'value' => '1',       'label' => 'KYC Required for Withdrawal'],
            ['key' => 'kyc_required_above_amount',     'group' => 'kyc', 'type' => 'float',   'value' => '2000',    'label' => 'KYC Required Above ($)'],
            ['key' => 'kyc_auto_approve',              'group' => 'kyc', 'type' => 'boolean', 'value' => '0',       'label' => 'Auto-Approve KYC Documents'],
            ['key' => 'kyc_allowed_types',             'group' => 'kyc', 'type' => 'string',  'value' => 'passport,drivers_license,national_id,utility_bill,bank_statement', 'label' => 'Allowed Document Types (comma-separated)'],
            ['key' => 'kyc_max_file_size_mb',          'group' => 'kyc', 'type' => 'integer', 'value' => '10',      'label' => 'Max Document File Size (MB)'],

            // ── Affiliate ─────────────────────────────────────────────────────────
            ['key' => 'affiliate_system_enabled',      'group' => 'affiliate', 'type' => 'boolean', 'value' => '1',   'label' => 'Affiliate System Enabled'],
            ['key' => 'affiliate_registration_open',   'group' => 'affiliate', 'type' => 'boolean', 'value' => '1',   'label' => 'Open Affiliate Registration'],
            ['key' => 'affiliate_default_rev_share',   'group' => 'affiliate', 'type' => 'float',   'value' => '25',  'label' => 'Default Revenue Share (%)'],
            ['key' => 'affiliate_default_cpa',         'group' => 'affiliate', 'type' => 'float',   'value' => '50',  'label' => 'Default CPA Amount ($)'],
            ['key' => 'affiliate_min_withdrawal',      'group' => 'affiliate', 'type' => 'float',   'value' => '100', 'label' => 'Affiliate Min Withdrawal ($)'],
            ['key' => 'affiliate_cookie_days',         'group' => 'affiliate', 'type' => 'integer', 'value' => '30',  'label' => 'Affiliate Cookie Duration (days)'],

            // ── Bonus ─────────────────────────────────────────────────────────────
            ['key' => 'bonus_system_enabled',          'group' => 'bonus', 'type' => 'boolean', 'value' => '1',   'label' => 'Bonus System Enabled'],
            ['key' => 'bonus_default_wagering',        'group' => 'bonus', 'type' => 'integer', 'value' => '35',  'label' => 'Default Wagering Multiplier (x)'],
            ['key' => 'bonus_max_bet_while_wagering',  'group' => 'bonus', 'type' => 'float',   'value' => '5',   'label' => 'Max Bet While Wagering ($)'],
            ['key' => 'bonus_expiry_days',             'group' => 'bonus', 'type' => 'integer', 'value' => '30',  'label' => 'Bonus Expiry (days)'],
            ['key' => 'welcome_bonus_enabled',         'group' => 'bonus', 'type' => 'boolean', 'value' => '1',   'label' => 'Welcome Bonus Enabled'],
            ['key' => 'welcome_bonus_amount',          'group' => 'bonus', 'type' => 'float',   'value' => '100', 'label' => 'Welcome Bonus Amount ($)'],
            ['key' => 'welcome_bonus_percent',         'group' => 'bonus', 'type' => 'integer', 'value' => '100', 'label' => 'Welcome Bonus Match (%)'],

            // ── Fraud & Security ──────────────────────────────────────────────────
            ['key' => 'fraud_detection_enabled',       'group' => 'fraud', 'type' => 'boolean', 'value' => '1',     'label' => 'Fraud Detection Enabled'],
            ['key' => 'fraud_max_deposits_per_hour',   'group' => 'fraud', 'type' => 'integer', 'value' => '5',     'label' => 'Max Deposits Per Hour'],
            ['key' => 'fraud_suspicious_amount',       'group' => 'fraud', 'type' => 'float',   'value' => '10000', 'label' => 'Suspicious Deposit Amount ($)'],
            ['key' => 'withdrawal_review_threshold',   'group' => 'fraud', 'type' => 'float',   'value' => '5000',  'label' => 'Withdrawal Review Threshold ($)'],
            ['key' => 'max_accounts_per_ip',           'group' => 'fraud', 'type' => 'integer', 'value' => '3',     'label' => 'Max Accounts Per IP'],
            ['key' => 'ip_block_enabled',              'group' => 'fraud', 'type' => 'boolean', 'value' => '0',     'label' => 'IP Blocking Enabled'],

            // ── Social Login ──────────────────────────────────────────────────────
            ['key' => 'google_login_enabled',    'group' => 'social', 'type' => 'boolean', 'value' => '0', 'label' => 'Google Login Enabled'],
            ['key' => 'google_client_id',        'group' => 'social', 'type' => 'string',  'value' => '',  'label' => 'Google Client ID'],
            ['key' => 'google_client_secret',    'group' => 'social', 'type' => 'string',  'value' => '',  'label' => 'Google Client Secret'],
            ['key' => 'facebook_login_enabled',  'group' => 'social', 'type' => 'boolean', 'value' => '0', 'label' => 'Facebook Login Enabled'],
            ['key' => 'facebook_client_id',      'group' => 'social', 'type' => 'string',  'value' => '',  'label' => 'Facebook App ID'],
            ['key' => 'facebook_client_secret',  'group' => 'social', 'type' => 'string',  'value' => '',  'label' => 'Facebook App Secret'],
            ['key' => 'github_login_enabled',    'group' => 'social', 'type' => 'boolean', 'value' => '0', 'label' => 'GitHub Login Enabled'],
            ['key' => 'github_client_id',        'group' => 'social', 'type' => 'string',  'value' => '',  'label' => 'GitHub Client ID'],
            ['key' => 'github_client_secret',    'group' => 'social', 'type' => 'string',  'value' => '',  'label' => 'GitHub Client Secret'],
        ];

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