import { IsEmail, IsString, MinLength, IsOptional } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class RegisterDto {
  @ApiProperty({ 
    description: 'Full name of the passenger', 
    example: 'Kelemu Ketsela',
    minLength: 2,
    maxLength: 100
  }) 
  @IsString() 
  fullName: string;

  @ApiProperty({ 
    description: 'Email address (must be unique)', 
    example: 'kelemu@email.com',
    format: 'email'
  }) 
  @IsEmail() 
  email: string;

  @ApiProperty({ 
    description: 'Phone number with country code', 
    example: '+251912345678',
    pattern: '^\\+[1-9]\\d{1,14}$'
  }) 
  @IsString() 
  phone: string;

  @ApiProperty({ 
    description: 'Password (minimum 8 characters)', 
    example: 'SecurePass123',
    minLength: 8,
    format: 'password'
  }) 
  @IsString() 
  @MinLength(8) 
  password: string;

  @ApiPropertyOptional({ 
    description: 'Nationality of the passenger', 
    example: 'Ethiopian' 
  }) 
  @IsOptional() 
  @IsString() 
  nationality?: string;

  @ApiPropertyOptional({ 
    description: 'National ID number', 
    example: 'ET123456789' 
  }) 
  @IsOptional() 
  @IsString() 
  nationalId?: string;

  @ApiPropertyOptional({ 
    description: 'Passport number for international travelers', 
    example: 'P1234567' 
  }) 
  @IsOptional() 
  @IsString() 
  passportNumber?: string;
}

export class LoginDto {
  @ApiProperty({ 
    description: 'Registered email address', 
    example: 'kelemu@email.com',
    format: 'email'
  }) 
  @IsEmail() 
  email: string;

  @ApiProperty({ 
    description: 'Account password', 
    example: 'password123',
    format: 'password'
  }) 
  @IsString() 
  password: string;
}

export class RequestOtpDto {
  @ApiProperty({ 
    description: 'Email address to send OTP', 
    example: 'kelemu@email.com' 
  }) 
  @IsEmail() 
  email: string;

  @ApiProperty({ 
    description: 'Purpose of OTP (REGISTRATION, PASSWORD_RESET, VERIFICATION)', 
    example: 'REGISTRATION',
    enum: ['REGISTRATION', 'PASSWORD_RESET', 'VERIFICATION']
  }) 
  @IsString() 
  purpose: string;
}

export class VerifyOtpDto {
  @ApiProperty({ 
    description: 'Email address', 
    example: 'kelemu@email.com' 
  }) 
  @IsEmail() 
  email: string;

  @ApiProperty({ 
    description: '6-digit OTP code', 
    example: '123456',
    minLength: 6,
    maxLength: 6
  }) 
  @IsString() 
  code: string;

  @ApiProperty({ 
    description: 'Purpose of OTP verification', 
    example: 'REGISTRATION',
    enum: ['REGISTRATION', 'PASSWORD_RESET', 'VERIFICATION']
  }) 
  @IsString() 
  purpose: string;
}

export class RequestPasswordResetDto {
  @ApiProperty({ 
    description: 'Email address of the account', 
    example: 'kelemu@email.com' 
  }) 
  @IsEmail() 
  email: string;
}

export class ResetPasswordDto {
  @ApiProperty({ 
    description: 'Password reset token received via email', 
    example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' 
  }) 
  @IsString() 
  token: string;

  @ApiProperty({ 
    description: 'New password (minimum 8 characters)', 
    example: 'NewSecurePass123',
    minLength: 8,
    format: 'password'
  }) 
  @IsString() 
  @MinLength(8) 
  newPassword: string;
}
