from django import forms
from .models import ContactMessage, Application


class ContactForm(forms.ModelForm):
    class Meta:
        model = ContactMessage
        fields = (
            "name",
            "email",
            "phone",
            "subject",
            "message",
        )

        widgets = {

            "name": forms.TextInput(
                attrs={
                    "class": "w-full h-10 rounded-lg border border-gray-300 px-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-blue-600",
                    "placeholder": "Full Name",
                    "autocomplete": "name",
                }
            ),

            "email": forms.EmailInput(
                attrs={
                    "class": "w-full h-10 rounded-lg border border-gray-300 px-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-blue-600",
                    "placeholder": "Email Address",
                    "autocomplete": "email",
                }
            ),

            "phone": forms.TextInput(
                attrs={
                    "class": "w-full h-10 rounded-lg border border-gray-300 px-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-blue-600",
                    "placeholder": "Phone Number",
                    "autocomplete": "tel",
                }
            ),

            "subject": forms.TextInput(
                attrs={
                    "class": "w-full h-10 rounded-lg border border-gray-300 px-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-blue-600",
                    "placeholder": "Subject",
                }
            ),

            "message": forms.Textarea(
                attrs={
                    "class": "w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-blue-600",
                    "placeholder": "Type your message here...",
                    "rows": 6,
                }
            ),

        }

        labels = {
            "name": "Full Name",
            "email": "Email Address",
            "phone": "Phone Number",
            "subject": "Subject",
            "message": "Message",
        }

        help_texts = {
            "phone": "Include your country code if applicable.",
        }


class ApplicationForm(forms.ModelForm):

    class Meta:
        model = Application

        fields = (
            "surname",
            "first_name",
            "other_name",
            "email",
            "phone",
            "address",
            "photo",
            "course",
        )

        widgets = {

            "surname": forms.TextInput(attrs={
                # "class": "w-full rounded-lg border border-gray-300 px-3 py-2",
                "class": "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
                "placeholder": "Surname"
            }),

            "first_name": forms.TextInput(attrs={
                # "class": "w-full rounded-lg border border-gray-300 px-3 py-2",
                "class": "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
                "placeholder": "First Name"
            }),

            "other_name": forms.TextInput(attrs={
                # "class": "w-full rounded-lg border border-gray-300 px-3 py-2",
                "class": "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
                "placeholder": "Other Name"
            }),

            "email": forms.EmailInput(attrs={
                # "class": "w-full rounded-lg border border-gray-300 px-3 py-2",
                "class": "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
                "placeholder": "Email Address"
            }),

            "phone": forms.TextInput(attrs={
                # "class": "w-full rounded-lg border border-gray-300 px-3 py-2",
                "class": "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
                "placeholder": "Phone Number"
            }),

            "address": forms.Textarea(attrs={
                "rows": 2,
                # "class": "w-full rounded-lg border border-gray-300 px-3 py-2",
                "class": "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
                "placeholder": "Residential Address"
            }),

            "photo": forms.ClearableFileInput(attrs={
                # "class": "w-full rounded-lg border border-gray-300 px-3 py-2"
                "class": "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
            }),

            "course": forms.Select(attrs={
                # "class": "w-full rounded-lg border border-gray-300 px-3 py-2"
                "class": "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
            }),
        }


class ApplicantProfileForm(forms.ModelForm):
    class Meta:
        model = Application
        fields = [
            "surname",
            "first_name",
            "other_name",
            "phone",
            "address",
            "photo",
        ]

        widgets = {
            "surname": forms.TextInput(attrs={
                "class": "w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500"
            }),
            "first_name": forms.TextInput(attrs={
                "class": "w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500"
            }),
            "other_name": forms.TextInput(attrs={
                "class": "w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500"
            }),
            "phone": forms.TextInput(attrs={
                "class": "w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500"
            }),
            "address": forms.Textarea(attrs={
                "rows": 2,
                "class": "w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500"
            }),
            "photo": forms.ClearableFileInput(attrs={
                "class": "w-full border rounded-lg px-3 py-2"
            }),
        }


