/**
 * ============================================
 * AUTHENTICATION TYPES
 * ============================================
 * 
 * Types for authentication requests and responses
 * shared between frontend and backend
 */

// ============================================
// REQUEST TYPES
// ============================================

export interface LoginRequest {
  email: string;
  password: string;
}

export interface RegisterRequest {
  email: string;
  username: string;
  password: string;
  confirmPassword?: string;
}

export interface RefreshTokenRequest {
  refreshToken: string;
}

export interface ChangePasswordRequest {
  currentPassword: string;
  newPassword: string;
}

// ============================================
// RESPONSE TYPES
// ============================================

export interface LoginResponse {
  token: string;
  refreshToken?: string;
  expiresIn?: number;
  user: User;
}

export interface RegisterResponse {
  token: string;
  user: User;
}

export interface RefreshTokenResponse {
  token: string;
  refreshToken: string;
  expiresIn: number;
}

// ============================================
// USER TYPE (Shared subset)
// ============================================

export interface User {
  id: string;
  email: string;
  username: string;
  role?: UserRole;
  createdAt: string;
  lastLoginAt?: string;
}

export type UserRole = 'STUDENT' | 'ADMIN' | 'INSTRUCTOR';

// ============================================
// JWT PAYLOAD (Backend usage mainly)
// ============================================

export interface JwtPayload {
  userId: string;
  email: string;
  username: string;
  role: string;
  iat?: number;
  exp?: number;
}

// ============================================
// AUTH TOKENS
// ============================================

export interface AuthTokens {
  accessToken: string;
  refreshToken: string;
  expiresIn: number;
}
