<?php

namespace App\Domain\Website\Blocks\Types;

use App\Domain\Website\Blocks\BlockField;
use App\Domain\Website\Blocks\BlockType;
use App\Domain\Website\Blocks\Concerns\HasSectionHeader;
use App\Domain\Website\Enums\BlockCategory;

/**
 * Contact form. Submissions land in the existing website_contact_submissions
 * table so the admin inbox keeps working unchanged.
 */
class ContactFormBlock extends BlockType
{
    use HasSectionHeader;

    public function key(): string
    {
        return 'contact_form';
    }

    public function label(): string
    {
        return 'نموذج تواصل';
    }

    public function icon(): string
    {
        return 'envelope';
    }

    public function category(): BlockCategory
    {
        return BlockCategory::Action;
    }

    public function variants(): array
    {
        return [
            'stacked' => 'عمودي',
            'split_info' => 'مع بيانات التواصل',
            'boxed' => 'صندوق',
            'inline' => 'مضغوط',
        ];
    }

    public function fields(): array
    {
        return [
            ...$this->sectionHeaderFields(),
            BlockField::textarea('description', 'الوصف'),
            BlockField::text('submit_label', 'نص زر الإرسال')
                ->default(['ar' => 'إرسال', 'en' => 'Send']),
            BlockField::textarea('success_message', 'رسالة النجاح'),
            BlockField::toggle('show_subject', 'إظهار حقل الموضوع')->default(true),
            BlockField::toggle('show_phone', 'إظهار حقل الهاتف')->default(true),
            BlockField::toggle('require_phone', 'الهاتف مطلوب'),
            BlockField::text('notify_email', 'إرسال إشعار إلى'),
        ];
    }
}
