<?php

namespace App\PageBuilder\Components\Marketing;

use App\PageBuilder\PageComponent;

class ContactFormComponent extends PageComponent
{
    public function key(): string { return 'contact_form'; }
    public function category(): string { return 'marketing'; }
    public function label(): string { return 'Contact Form'; }
    public function icon(): string { return 'fas fa-envelope'; }

    public function schema(): array
    {
        return [
            'title' => ['type' => 'text'],
            'subtitle' => ['type' => 'textarea'],
            'submit_text' => ['type' => 'text'],
            'success_message' => ['type' => 'textarea'],
            'options' => [
                'color' => ['type' => 'color_token', 'default' => 'transparent'],
                'padding' => ['type' => 'padding_token', 'default' => 'lg'],
                'show_phone' => ['type' => 'boolean', 'label' => __('admin/pages.cf_show_phone'), 'default' => false],
                'show_subject' => ['type' => 'boolean', 'label' => __('admin/pages.cf_show_subject'), 'default' => true],
                'show_departments' => ['type' => 'boolean', 'label' => __('admin/pages.cf_show_departments'), 'default' => true],
                'layout' => ['type' => 'select', 'label' => __('admin/pages.cf_layout'), 'options' => ['stacked', 'split'], 'default' => 'stacked'],
            ],
        ];
    }

    public function defaults(): array
    {
        return [
            // Boş bırakılınca render'da __('store.contact_*') fallback'i kullanılır
            'title' => __('store.contact_title'),
            'subtitle' => null,
            'submit_text' => '',
            'success_message' => '',
            'options' => [
                'color' => 'transparent', 'padding' => 'lg',
                'show_phone' => false, 'show_subject' => true,
                'show_departments' => true, 'layout' => 'stacked',
            ],
        ];
    }

    public function render(array $data, array $options): string
    {
        return view('page-builder.components.contact_form', compact('data', 'options'))->render();
    }
}
