import { z } from 'zod';

export const registrationSchema = z.object({
  fullName: z
    .string()
    .min(2, 'Full name must be at least 2 characters')
    .max(100, 'Full name must be less than 100 characters'),
  email: z.string().email('Please enter a valid email address'),
  phone: z
    .string()
    .min(10, 'Phone number must be at least 10 digits')
    .max(15, 'Phone number must be less than 15 digits')
    .regex(/^[0-9+\-\s()]+$/, 'Please enter a valid phone number'),
  gender: z.enum(['male', 'female', 'prefer_not_to_say'], {
    required_error: 'Please select your gender',
  }),
  ageRange: z.enum(['under_18', '18_25', '26_30', '31_35', '36_plus'], {
    required_error: 'Please select your age range',
  }),
  educationLevel: z.enum(
    ['secondary', 'undergraduate', 'graduate', 'postgraduate', 'other'],
    { required_error: 'Please select your education level' }
  ),
  institution: z
    .string()
    .min(2, 'Institution name must be at least 2 characters')
    .max(200, 'Institution name must be less than 200 characters'),
  stack: z.enum(
    [
      'data_analytics',
      'digital_marketing',
      'web_development',
      'product_design',
      'ai_automation',
    ],
    { required_error: 'Please select a track' }
  ),
  motivation: z
    .string()
    .min(50, 'Please write at least 50 characters')
    .max(1000, 'Motivation must be less than 1000 characters'),
  heardFrom: z.string().min(1, 'Please tell us how you heard about us'),
  // Referral code: optional, accepts any string (numbers, letters, mixed)
  referralCode: z
    .string()
    .max(100, 'Referral code must be less than 100 characters')
    .optional()
    .or(z.literal('')),
});

export type RegistrationFormData = z.infer<typeof registrationSchema>;