<?php

namespace Database\Seeders;

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

class SupportSettingsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $settings = [
            // Ticket numaralandırma (no UI, kept for future)
            'ticket_number_prefix' => 'TKT',
            'ticket_number_format' => '{prefix}{number}',
            'ticket_number_padding' => 6,
            'ticket_number_counter' => 1000,

            // Ticket atama (no UI, kept for future)
            'auto_assign_tickets' => true,
            'auto_assign_department_based' => true,
            'auto_assign_load_balancing' => true,
            'notify_assigned_staff' => true,

            // Ticket bildirimleri (canonical keys)
            'notify_client_on_ticket_reply' => true,
            'notify_client_on_status_change' => true,
            'notify_staff_on_new_ticket' => true,
            'notify_staff_on_client_reply' => true,

            // Çalışma saatleri (canonical keys)
            'business_hours_enabled' => true,
            'business_hours' => json_encode([
                'work_days' => ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'],
                'start' => '09:00',
                'end' => '18:00',
            ]),
            'support_timezone' => 'Europe/Istanbul',

            // Otomatik yanıtlar
            'auto_response_on_new_ticket' => true,
            'auto_response_on_ticket_close' => true,

            // Otomatik kapatma (canonical keys)
            'auto_close_inactive_tickets' => true,
            'auto_close_inactive_days' => 7,

            // Ticket değerlendirme (canonical keys — no duplicate of support_ticket_rating)
            // PRC-340 — ticket_rating_required kaldırıldı (rating gönüllü).
            'ticket_rating_reminder_days' => 3,

            // SLA ayarları (canonical keys)
            'sla_enabled' => true,
            'sla_default_response_hours' => 24,
            'sla_default_resolution_hours' => 72,
            'sla_business_hours_only' => true,

            // Müşteri izinleri
            'allow_client_ticket_attachments' => true,

            // PRC-788 — müşteri ticket açarken öncelik seçimi (required|optional|hidden)
            'ticket_client_priority_mode' => 'required',

            // Canlı destek (PRC-349/606/608/609) — dev'de reset sonrası hazır gelsin diye açık.
            // Prod fresh install için kapatmak istersen chat_enabled/chat_guest_enabled=false yap.
            'chat_enabled' => true,
            'chat_position' => 'bottom-right',
            'chat_guest_enabled' => true,
            'chat_rating_enabled' => true,
            'chat_agent_display_name' => 'Destek',
        ];

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