from django import forms
from django_recaptcha.fields import ReCaptchaField
from django_recaptcha.widgets import ReCaptchaV2Checkbox


class ContactForm(forms.Form):
    OPTIONS = [
        ('select', 'Select...'),
        ('info', 'General Information'),
        ('dynamics', 'Paragon Dynamics'),
        ('pixels', 'Paragon Pixels'),
    ]

    name = forms.CharField(label='Name', widget=forms.TextInput(attrs={
        'placeholder': 'First Name',
        'size': 40,
    }))

    surname = forms.CharField(label='Surname', widget=forms.TextInput(attrs={
        'placeholder': 'Surname',
    }))

    email = forms.EmailField(widget=forms.EmailInput(attrs={
        'placeholder': 'Email address',
    }))

    service = forms.ChoiceField(label='Select a Service', choices=OPTIONS, widget=forms.Select(attrs={
        'onchange': 'toggleForm(this.value)',
    }))

class InfoForm(forms.Form):
    message = forms.CharField(widget=forms.Textarea(attrs={
        'placeholder': 'Your Message'
    }))
    captcha = ReCaptchaField(widget=ReCaptchaV2Checkbox)

class DynamicsForm(forms.Form):
    OPTIONS = [
        ('program', 'Program Management Services'),
        ('project', 'Project Management Services'),
        ('consult', 'Business/Corporate Consultancy Services'),
    ]

    choices = forms.MultipleChoiceField(label='Select all that apply', choices=OPTIONS, widget=forms.CheckboxSelectMultiple(attrs={
        'class': 'form-check-input',
    }), required=True)
    
    def clean_choices(self):
        data = self.cleaned_data.get('choices')
        if not data:
            raise forms.ValidationError('You must select at least one option.')
        return data

class PixelsForm(forms.Form):
    OPTIONS = [
        ('design', 'Website Design'),
        ('dev', 'Website Development'),
        ('deploy', 'Website Deployment and Servers'),
    ]

    choices = forms.MultipleChoiceField(label='Select all that apply', choices=OPTIONS, widget=forms.CheckboxSelectMultiple())

class DirectForm(forms.Form):
    name = forms.CharField(label='Name', widget=forms.TextInput(attrs={
        'placeholder': 'First Name',
        'size': 40,
    }))

    surname = forms.CharField(label='Surname', widget=forms.TextInput(attrs={
        'placeholder': 'Surname',
    }))

    email = forms.EmailField(widget=forms.EmailInput(attrs={
        'placeholder': 'Email address',
    }))