<?php

namespace Database\Seeders;

use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    use WithoutModelEvents;

    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        // User::factory(10)->create();

        $user = User::factory()->create([
            'name' => 'Admin User',
            'email' => 'admin@metrix.com',
            'password' => 'admin123',
            'is_admin' => true,
            'daily_banker_ends_at' => now()->addDays(15),
            'vip_master_ends_at' => now()->subDays(5),
            'ht_draw_ends_at' => null,
        ]);


        $this->call(VipPackageSeeder::class);
        $this->call(MatchPredictionSeeder::class);

        // Seed Support Channels
        \App\Models\SupportChannel::create([
            'name' => 'Email Support',
            'type' => 'email',
            'value' => 'support@matchmetrix.com',
            'description' => 'Response within 2 hours',
        ]);
        \App\Models\SupportChannel::create([
            'name' => 'Telegram Community',
            'type' => 'telegram',
            'value' => 'https://t.me/matchmetrix_predictions',
            'description' => 'Join our active community chat',
        ]);
        \App\Models\SupportChannel::create([
            'name' => 'WhatsApp Hotline',
            'type' => 'whatsapp',
            'value' => 'https://wa.me/256772123456',
            'description' => 'Instant chat with support agent',
        ]);
        \App\Models\SupportChannel::create([
            'name' => 'Phone Call Support',
            'type' => 'phone',
            'value' => '+256782998877',
            'description' => 'Available Mon-Fri 9AM - 5PM',
        ]);

        // Seed Support Tickets
        \App\Models\SupportTicket::create([
            'user_id' => $user->id,
            'subject' => 'Subscription not activated after Payment',
            'message' => 'I paid via Mobile Money but VIP is still locked',
            'reply' => 'We have activated your plan. Sorry for the delay!',
            'status' => 'resolved',
            'priority' => 'high',
        ]);
        \App\Models\SupportTicket::create([
            'user_id' => $user->id,
            'subject' => 'Request for HT Draw tips historical stats',
            'message' => 'Do you have a sheet showing all past HT draw wins?',
            'reply' => null,
            'status' => 'open',
            'priority' => 'low',
        ]);

        // Seed Terms & Privacy Settings
        \App\Models\Setting::create([
            'key' => 'terms_and_conditions',
            'value' => "### Match Metrix Terms & Conditions\n\nWelcome to Match Metrix Predictions. By using our platform, you agree to these terms.\n\n1. **Use of Predictions**: The tips provided are for informational and entertainment purposes only. We do not guarantee outcomes.\n2. **Responsible Gaming**: Please bet responsibly. You must be over 18 (or the legal age in your jurisdiction) to participate.\n3. **Subscriptions**: Subscription renewals are billed periodically. Subscriptions can be canceled at any time.\n4. **No Refunds**: Due to the nature of digital predictions and analytics services, all subscription payments are non-refundable.\n\nThank you for choosing Match Metrix!",
        ]);

        \App\Models\Setting::create([
            'key' => 'privacy_policy',
            'value' => "### Match Metrix Privacy Policy\n\nYour privacy is important to us. This policy details how we handle your personal data.\n\n1. **Information Collected**: We collect your name, email address, profile picture (if uploaded), and active subscription status to provide our prediction services.\n2. **Data Storage**: Your information is stored securely on our encrypted servers. We do not share your private data with third parties.\n3. **Analytics**: We use aggregated traffic data to analyze and improve application performance.\n4. **Security**: We implement industry-standard encryption and security updates to protect your data from unauthorized access.\n\nFor questions, please contact our support department.",
        ]);

        \App\Models\Setting::create([
            'key' => 'ugx_to_usd',
            'value' => '0.00027',
        ]);

        \App\Models\Setting::create([
            'key' => 'usd_to_ugx',
            'value' => '3700',
        ]);

        \App\Models\Setting::create([
            'key' => 'relworx_api_key',
            'value' => 'placeholder_key',
        ]);

        \App\Models\Setting::create([
            'key' => 'relworx_account_no',
            'value' => 'RELJH012BV45P',
        ]);
    }

}
