<?php

namespace Database\Seeders;

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

class MobileSettingSeeder extends Seeder
{
    public function run(): void
    {
        $settings = [
            // --- ASSETS ---
            ['key' => 'theme_color_secondary', 'value' => '#1a1a1a',  'group' => 'assets', 'type' => 'string'],
            ['key' => 'theme_color_primary',   'value' => '#c6f135',  'group' => 'assets', 'type' => 'string'],
            ['key' => 'primary_font_family',   'value' => 'Outfit',   'group' => 'assets', 'type' => 'string'],
            ['key' => 'logo_url',              'value' => '/storage/mobile-assets/logo_url_1777816317.png',   'group' => 'assets', 'type' => 'image_path'],
            ['key' => 'splash_image_url',      'value' => '/storage/mobile-assets/splash_image_url_1777816317.png', 'group' => 'assets', 'type' => 'image_path'],

            // --- GENERAL ---
            ['key' => 'brand_color',           'value' => '#c6f135',                         'group' => 'general', 'type' => 'string'],
            ['key' => 'app_name',              'value' => 'biiproject',                       'group' => 'general', 'type' => 'string'],
            ['key' => 'app_version',           'value' => '2.0.0',                            'group' => 'general', 'type' => 'string'],
            ['key' => 'app_icon_url',          'value' => '/storage/mobile-assets/app_icon_url_1777816326.png', 'group' => 'general', 'type' => 'image_path'],
            ['key' => 'store_url_android',     'value' => 'https://play.google.com/store/apps/details?id=com.biiproject', 'group' => 'general', 'type' => 'string'],
            ['key' => 'store_url_ios',         'value' => 'https://apps.apple.com/app/biiproject', 'group' => 'general', 'type' => 'string'],

            // --- FLAGS ---
            ['key' => 'enable_registration',       'value' => 'true',  'group' => 'flags', 'type' => 'boolean'],
            ['key' => 'enable_remember_me',        'value' => 'true',  'group' => 'flags', 'type' => 'boolean'],
            ['key' => 'kill_switch_active',        'value' => 'false', 'group' => 'flags', 'type' => 'boolean'],
            ['key' => 'require_otp_registration',  'value' => 'false', 'group' => 'flags', 'type' => 'boolean'],
            ['key' => 'enable_biometrics',         'value' => 'false', 'group' => 'flags', 'type' => 'boolean'],
            ['key' => 'enable_push_notifications', 'value' => 'true',  'group' => 'flags', 'type' => 'boolean'],

            // --- NETWORK ---
            ['key' => 'api_base_url',          'value' => 'http://192.168.8.129:8000', 'group' => 'network', 'type' => 'string'],
            ['key' => 'api_timeout_ms',        'value' => '30000',                    'group' => 'network', 'type' => 'integer'],
            ['key' => 'api_retry_count',       'value' => '3',                        'group' => 'network', 'type' => 'integer'],
            ['key' => 'enable_ssl_pinning',    'value' => 'false',                    'group' => 'network', 'type' => 'boolean'],
            ['key' => 'environment_selector',  'value' => 'development',              'group' => 'network', 'type' => 'string'],
            ['key' => 'api_version',           'value' => 'v1',                       'group' => 'network', 'type' => 'string'],
            ['key' => 'request_cache_ttl',     'value' => '3600',                     'group' => 'network', 'type' => 'integer'],

            // --- AUTH ---
            ['key' => 'token_ttl_minutes',     'value' => '43200',       'group' => 'auth', 'type' => 'integer'],
            ['key' => 'session_max_age',        'value' => '86400',       'group' => 'auth', 'type' => 'integer'],
            ['key' => 'biometric_auth_type',    'value' => 'fingerprint', 'group' => 'auth', 'type' => 'string'],
            ['key' => 'oauth_google_enabled',   'value' => 'false',       'group' => 'auth', 'type' => 'boolean'],
            ['key' => 'oauth_apple_enabled',    'value' => 'false',       'group' => 'auth', 'type' => 'boolean'],
            ['key' => 'login_max_attempts',     'value' => '5',           'group' => 'auth', 'type' => 'integer'],

            // --- NOTIFICATION ---
            ['key' => 'fcm_topic_default',           'value' => 'all_users', 'group' => 'notification', 'type' => 'string'],
            ['key' => 'default_channel_id',          'value' => 'general',   'group' => 'notification', 'type' => 'string'],
            ['key' => 'notification_sound_enabled',  'value' => 'true',      'group' => 'notification', 'type' => 'boolean'],
            ['key' => 'badge_count_enabled',         'value' => 'true',      'group' => 'notification', 'type' => 'boolean'],
            ['key' => 'priority_level',              'value' => 'high',      'group' => 'notification', 'type' => 'string'],

            // --- SYSTEM ---
            ['key' => 'sync_interval_ms',     'value' => '10000',         'group' => 'system', 'type' => 'integer'],
            ['key' => 'min_app_version',      'value' => '1.0.0',         'group' => 'system', 'type' => 'string'],
            ['key' => 'target_sdk_version',   'value' => '34',            'group' => 'system', 'type' => 'string'],
            ['key' => 'system_timezone',      'value' => 'Asia/Jakarta',  'group' => 'system', 'type' => 'string'],
            ['key' => 'google_analytics_id',  'value' => 'G-BII-2026-X', 'group' => 'system', 'type' => 'string'],
            ['key' => 'default_locale',       'value' => 'en',            'group' => 'system', 'type' => 'string'],
            ['key' => 'privacy_policy_url',   'value' => 'https://biiproject.com/privacy', 'group' => 'system', 'type' => 'string'],
            ['key' => 'region_lock_enabled',  'value' => 'false',         'group' => 'system', 'type' => 'boolean'],
            ['key' => 'min_sdk_version',      'value' => '21',            'group' => 'system', 'type' => 'string'],

            // --- SUPPORT ---
            ['key' => 'social_instagram_url', 'value' => '', 'group' => 'support', 'type' => 'string'],
            ['key' => 'social_twitter_url',   'value' => '', 'group' => 'support', 'type' => 'string'],
            ['key' => 'support_email',        'value' => 'support@biiproject.com', 'group' => 'support', 'type' => 'string'],
            ['key' => 'support_whatsapp',     'value' => '628123456789',           'group' => 'support', 'type' => 'string'],
            ['key' => 'live_chat_url',        'value' => '', 'group' => 'support', 'type' => 'string'],
            ['key' => 'faq_url',              'value' => '', 'group' => 'support', 'type' => 'string'],

            // --- ANALYTICS ---
            ['key' => 'crashlytics_enabled',     'value' => 'true',  'group' => 'analytics', 'type' => 'boolean'],
            ['key' => 'log_level',               'value' => 'error', 'group' => 'analytics', 'type' => 'string'],
            ['key' => 'event_sampling_rate',     'value' => '1.0',   'group' => 'analytics', 'type' => 'string'],
            ['key' => 'gdpr_compliance_enabled', 'value' => 'false', 'group' => 'analytics', 'type' => 'boolean'],
        ];

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