from flask_wtf import FlaskForm
from wtforms import SelectField, StringField, TextAreaField, BooleanField
from wtforms.validators import DataRequired, Length, Email, Regexp


class PreDevForm(FlaskForm):
    """WTForm matching the Pre-Dev expression of interest fields."""
    
    name = StringField('Full Name', validators=[
        DataRequired(message="Please enter your full name."),
        Length(max=120, message="Name cannot exceed 120 characters.")
    ])
    
    email = StringField('Email Address', validators=[
        DataRequired(message="Please enter your email address."),
        Email(message="Please enter a valid email address."),
        Length(max=150, message="Email cannot exceed 150 characters.")
    ])
    
    whatsapp = StringField('WhatsApp Number', validators=[
        DataRequired(message="Please enter your WhatsApp number."),
        Regexp(r'^\+?[0-9\s\-]{7,30}$', message="Please enter a valid phone or WhatsApp number.")
    ])
    
    location = StringField('Current Location', validators=[
        DataRequired(message="Please enter your location."),
        Length(max=100, message="Location cannot exceed 100 characters.")
    ])
    
    current_status = SelectField('Current Status', choices=[
        ('', 'Select your current status'),
        ('student', 'Student'),
        ('graduate', 'Graduate'),
        ('self-taught-talent', 'Self-Taught Talent'),
        ('bootcamp-graduate', 'Bootcamp Graduate'),
        ('emerging-professional', 'Emerging Digital Professional'),
        ('employed', 'Employed Professional'),
        ('other', 'Other')
    ], validators=[
        DataRequired(message="Please select your current status.")
    ])
    
    primary_skill = SelectField('Primary Digital Skill or Area', choices=[
        ('', 'Select your main area'),
        ('web-development', 'Web Development'),
        ('software-development', 'Software Development'),
        ('graphic-design', 'Graphic Design'),
        ('video-editing', 'Video Editing & Motion Graphics'),
        ('digital-marketing', 'Digital Marketing & Growth'),
        ('data-ai', 'Data and Artificial Intelligence'),
        ('ui-ux', 'UI/UX Design'),
        ('content-media', 'Content and Digital Media'),
        ('other', 'Other')
    ], validators=[
        DataRequired(message="Please select your primary skill or interest.")
    ])
    
    experience_level = SelectField('Current Experience Level', choices=[
        ('', 'Select your level'),
        ('beginner', 'Beginner'),
        ('learning', 'Currently Learning'),
        ('some-projects', 'Completed Some Projects'),
        ('freelance-experience', 'Some Freelance Experience'),
        ('professional-experience', 'Some Professional Experience')
    ], validators=[
        DataRequired(message="Please select your experience level.")
    ])
    
    preferred_start_period = SelectField('Preferred Start Period', choices=[
        ('', 'Choose your preferred start period'),
        ('1-week', 'Within 1 Week'),
        ('2-weeks', 'Within 2 Weeks'),
        ('3-weeks', 'Within 3 Weeks'),
        ('4-weeks', 'Within 4 Weeks')
    ], validators=[
        DataRequired(message="Please select a preferred start period.")
    ])
    
    development_goal = TextAreaField('What do you hope to achieve through Pre-Dev?', validators=[
        DataRequired(message="Please provide your development goal."),
        Length(min=10, max=500, message="Development goal must be between 10 and 500 characters.")
    ])
    
    program_understanding = BooleanField('Program Understanding Acknowledgment', validators=[
        DataRequired(message="You must acknowledge the program guidelines to proceed.")
    ])