import { z } from 'zod'

/**
 * Minimal signup schema — only asks for what's needed to create an identity.
 * See progressive-signup-plan.md Section 3.
 */
export const accountStartSchema = z.object({
  email: z.string().email(),
  password: z.string().min(8).max(128),
  preferredLanguage: z.enum(['en', 'fr', 'ar']).default('en'),
})

export const companyProfileSchema = z.object({
  firstName: z.string().min(1).max(80).optional(),
  lastName: z.string().min(1).max(80).optional(),
  firstNameAr: z.string().max(80).optional(),
  lastNameAr: z.string().max(80).optional(),
  companyName: z.string().min(2).max(120).optional(),
  companyNameAr: z.string().max(120).optional(),
  phone: z.string().min(1).max(80).optional(),
  companyEmail: z.string().email().optional(),
  streetAddress: z.string().min(1).max(200).optional(),
  streetAddressAr: z.string().max(200).optional(),
  city: z.string().min(1).max(120).optional(),
  cityAr: z.string().max(120).optional(),
  country: z.string().min(1).max(120).optional(),
  countryAr: z.string().max(120).optional(),
  zipCode: z.string().min(1).max(40).optional(),
  fax: z.string().max(80).optional(),
  yearsActive: z.string().max(80).optional(),
})

export const legalIdentitySchema = z.object({
  legalName: z.string().min(2).max(160),
  legalForm: z.string().min(1).max(80),
  registrationNumber: z.string().min(1).max(120),
  iceNumber: z.string().min(1).max(120),
  taxId: z.string().min(1).max(120),
  operatingLicenseNumber: z.string().min(1).max(120),
  operatingLicenseIssuedAt: z.string().min(1).max(40),
  operatingLicenseIssuedBy: z.string().min(1).max(160),
})

export const paymentSetupSchema = z.object({
  paymentProvider: z.enum(['AMANPAY', 'PAYPAL']),
  responsibleName: z.string().min(1).max(160),
  responsibleRole: z.string().min(1).max(120),
  responsibleIdentityNumber: z.string().min(1).max(120),
  responsibleQualification: z.string().max(200).optional(),
  responsiblePhone: z.string().min(1).max(80),
  responsibleEmail: z.string().email(),
  representativeName: z.string().max(160).optional(),
  representativeTitle: z.string().max(120).optional(),
})

export const planSchema = z.object({
  plan: z.enum(['STARTER', 'GROWTH', 'PRO']),
  billingPeriod: z.enum(['MONTHLY', 'ANNUAL']),
})
