// INT-CLEANUP-002: Import shared types from @/types instead of duplicating
import type { User, AuthTokens } from '@/types';
// Action 1.1.3.13: Import generated types for auth responses
import type {
  VezaBackendApiInternalDtoTokenResponse,
  VezaBackendApiInternalDtoResendVerificationRequest,
} from '@/types/generated/api';

// Re-export for backward compatibility
export type { User, AuthTokens };

export interface LoginCredentials {
  email: string;
  password: string;
  remember_me?: boolean;
}

export interface RegisterCredentials {
  email: string;
  password: string;
  password_confirm: string;
  username?: string;
}

// INT-TYPE-008: AuthResponse aligned with backend LoginResponse (dto.LoginResponse)
// Backend format: { user: UserResponse, token: TokenResponse, requires_2fa?: boolean }
// INT-CLEANUP-002: Use User and AuthTokens from @/types
export interface AuthResponse {
  user: User; // Matches backend UserResponse (id, email, username)
  token: AuthTokens; // Matches backend TokenResponse (access_token, refresh_token, expires_in)
  requires_2fa?: boolean; // BE-API-001: Flag indicating 2FA is required
}

/**
 * RefreshResponse - Token refresh response
 * Action 1.1.3.13: Uses generated type from OpenAPI
 * Aligned with VezaBackendApiInternalDtoTokenResponse
 */
export type RefreshResponse = VezaBackendApiInternalDtoTokenResponse;

// Form Data Types (moved from types.ts)
export interface LoginFormData {
  email: string;
  password: string;
}

export interface RegisterFormData {
  email: string;
  password: string;
  password_confirm: string;
  username: string;
}

export interface ForgotPasswordFormData {
  email: string;
}

export interface ResetPasswordFormData {
  token: string;
  password: string;
  confirmPassword: string;
}

// API Request/Response Types
export interface VerifyEmailRequest {
  token: string;
}

/**
 * ResendVerificationRequest - Request to resend verification email
 * Action 1.1.3.13: Uses generated type from OpenAPI
 * Aligned with VezaBackendApiInternalDtoResendVerificationRequest
 */
export type ResendVerificationRequest = VezaBackendApiInternalDtoResendVerificationRequest;

export interface CheckUsernameRequest {
  username: string;
}

export interface RequestPasswordResetRequest {
  email: string;
}

export interface ResetPasswordRequest {
  token: string;
  new_password: string;
}

export interface MessageResponse {
  message: string;
}

export interface CheckUsernameResponse {
  available: boolean;
  username: string;
}

// OAuth Types
export interface OAuthProvider {
  id: string;
  name: string;
  auth_url: string;
}

export interface OAuthProvidersResponse {
  providers: OAuthProvider[];
}

// 2FA Types
export interface TwoFactorSetupResponse {
  secret: string;
  qr_code_url: string;
  recovery_codes: string[];
}

export interface TwoFactorVerifyRequest {
  code: string;
}

export interface TwoFactorStatusResponse {
  is_enabled: boolean;
  user_id: string;
}
