<?php

namespace App\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;

class ContactType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('profile', ChoiceType::class, [
                'label' => 'Votre profil *',
                'choices' => [
                    'Particulier' => 'particulier',
                    'Investisseur' => 'investisseur',
                    'Professionnel' => 'professionnel',
                ],
                'placeholder' => 'Qui êtes-vous ?',
                'required' => true,
                'attr' => ['class' => 'form-control'],
            ])
            ->add('budget', ChoiceType::class, [
                'label' => 'Budget estimé',
                'choices' => [
                    'Moins de 100 000 €' => 'moins-100k',
                    '100 000 - 200 000 €' => '100-200k',
                    '200 000 - 500 000 €' => '200-500k',
                    'Plus de 500 000 €' => '500k+',
                ],
                'placeholder' => 'Sélectionnez votre budget',
                'required' => false,
                'attr' => ['class' => 'form-control'],
            ])
            ->add('project_type', ChoiceType::class, [
                'label' => 'Type de projet *',
                'choices' => [
                    'Recherche foncière' => 'recherche-fonciere',
                    'Construction neuve' => 'construction',
                    'Rénovation' => 'renovation',
                    'Agrandissement' => 'agrandissement',
                    'Transformation' => 'transformation',
                    'Valorisation patrimoniale' => 'valorisation',
                    'Projet de réhabilitation' => 'rehabilitation',
                    'Projet immobilier bloqué' => 'bloque',
                    'Autres' => 'autres',
                ],
                'expanded' => true,
                'multiple' => true,
                'required' => true,
                'attr' => ['class' => 'checkbox-group'],
            ])
            ->add('name', TextType::class, [
                'label' => 'Nom complet *',
                'required' => true,
                'attr' => ['class' => 'form-control'],
            ])
            ->add('email', EmailType::class, [
                'label' => 'Email',
                'required' => false,
                'attr' => ['class' => 'form-control'],
            ])
            ->add('phone', TelType::class, [
                'label' => 'Téléphone *',
                'required' => true,
                'attr' => [
                    'class' => 'form-control',
                    'placeholder' => '06 32 11 15 18',
                ],
            ])
            ->add('city', TextType::class, [
                'label' => 'Ville du projet',
                'required' => false,
                'attr' => ['class' => 'form-control'],
            ])
            ->add('description', TextareaType::class, [
                'label' => 'Décrivez votre projet',
                'required' => false,
                'attr' => [
                    'class' => 'form-control',
                    'rows' => 4,
                    'placeholder' => 'Décrivez-nous votre projet en quelques mots...',
                ],
            ])
            ->setMethod('POST');
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
         $resolver->setDefaults([
        'csrf_protection' => true,
        'csrf_field_name' => '_token',
        'csrf_token_id'   => 'contact_form',
    ]);
    }
}
