/**
 * Represents an authenticated user.
 */
export interface User {
  id: string;
  email?: string;
  name?: string;
  avatarUrl?: string;
  emailVerified?: boolean;
  roles?: string[];
  scopes?: string[];
  metadata?: Record<string, unknown>;
}

/**
 * Authentication state.
 */
export interface AuthState {
  /** The authenticated user, or null if not authenticated */
  user: User | null;
  /** Whether authentication state is being loaded */
  isLoading: boolean;
  /** Whether the user is authenticated */
  isAuthenticated: boolean;
  /** Any authentication error */
  error: Error | null;
}

/**
 * Login credentials for username/password authentication.
 */
export interface LoginCredentials {
  email: string;
  password: string;
}

/**
 * Registration credentials.
 */
export interface RegisterCredentials {
  email: string;
  password: string;
  name?: string;
}

/**
 * OTP verification credentials.
 */
export interface OTPVerifyCredentials {
  email: string;
  code: string;
}

/**
 * Magic link verification credentials.
 */
export interface MagicLinkVerifyCredentials {
  email: string;
  token: string;
}

/**
 * A login session with device and location information.
 */
export interface Session {
  id: string;
  ipAddress: string;
  deviceLabel: string;
  lastActiveAt: string;
  createdAt: string;
  isCurrent: boolean;
}

/**
 * Token response from the authentication API.
 * Matches the backend LoginResponse shape: { token, user }.
 */
export interface TokenResponse {
  token: string;
  user: User;
}
