/**
 * ============================================
 * API TYPES
 * ============================================
 * 
 * Generic API request/response types
 * shared between frontend and backend
 */

// ============================================
// API RESPONSE
// ============================================

export interface ApiResponse<T = unknown> {
  success: boolean;
  data?: T;
  error?: ApiError;
  meta?: ApiMeta;
}

export interface ApiError {
  code: string;
  message: string;
  details?: unknown;
}

export interface ApiMeta {
  timestamp: string;
  requestId?: string;
  version?: string;
}

// ============================================
// PAGINATION
// ============================================

export interface PaginationParams {
  page?: number;
  limit?: number;
  sortBy?: string;
  sortOrder?: 'asc' | 'desc';
}

export interface PaginatedResponse<T> {
  data: T[];
  pagination: PaginationInfo;
}

export interface PaginationInfo {
  page: number;
  limit: number;
  total: number;
  totalPages: number;
  hasNext: boolean;
  hasPrev: boolean;
}

// ============================================
// FILTERS & SORTING
// ============================================

export interface FilterOptions {
  search?: string;
  difficulty?: string[];
  type?: string[];
  moduleId?: string[];
  topicId?: string[];
}

export interface SortOptions {
  field: 'createdAt' | 'points' | 'difficulty' | 'name';
  order: 'asc' | 'desc';
}
