// Tipos base de la aplicación
export interface BaseEntity {
  id: number;
  createdAt: Date;
  updatedAt: Date;
}

// Tipos de Juego
export interface Game extends BaseEntity {
  title: string;
  description?: string;
  platformId: number;
  platform?: Platform;
  releaseYear?: number;
  rating?: number;
  tags: Tag[];
  romFile?: RomFile;
  metadataSource?: 'igdb' | 'rawg' | 'thegamesdb' | 'manual';
  igdbId?: string;
  rawgId?: string;
  thegamesdbId?: string;
}

// Tipos de Plataforma
export interface Platform extends BaseEntity {
  name: string;
  description?: string;
  manufacturer?: string;
  releaseYear?: number;
  romExtension?: string;
  games: Game[];
}

// Tipos de ROM
export interface RomFile extends BaseEntity {
  filename: string;
  path: string;
  size: number;
  checksum: string;
  gameId: number;
  game?: Game;
}

// Tipos de Etiqueta
export interface Tag extends BaseEntity {
  name: string;
  color: string;
  description?: string;
  games: Game[];
}

// Tipos de Compra
export interface Purchase extends BaseEntity {
  gameId: number;
  game?: Game;
  price: number;
  currency: string;
  purchaseDate: Date;
  store?: string;
  notes?: string;
}

// Tipos de Historial de Precios
export interface PriceHistory extends BaseEntity {
  gameId: number;
  game?: Game;
  price: number;
  currency: string;
  date: Date;
}

// Tipos de Arte
export interface Artwork extends BaseEntity {
  gameId: number;
  game?: Game;
  type: 'cover' | 'screenshot' | 'logo' | 'banner';
  url: string;
  width?: number;
  height?: number;
}

// Tipos de Configuración
export interface Settings {
  igdbApiKey?: string;
  rawgApiKey?: string;
  thegamesdbApiKey?: string;
  defaultRomDirectory?: string;
  autoImportEnabled: boolean;
  metadataSourcePriority: ('igdb' | 'rawg' | 'thegamesdb')[];
}

// Tipos de API Response
export interface ApiResponse<T> {
  data: T;
  message?: string;
  error?: string;
}

export interface PaginatedResponse<T> {
  data: T[];
  pagination: {
    page: number;
    limit: number;
    total: number;
    totalPages: number;
  };
}

// Tipos de Filtros
export interface GameFilters {
  search?: string;
  platformId?: number;
  tags?: number[];
  rating?: number;
  releaseYear?: number;
  metadataSource?: string;
  hasRom?: boolean;
}

export interface PlatformFilters {
  search?: string;
  manufacturer?: string;
  releaseYear?: number;
}

export interface TagFilters {
  search?: string;
  color?: string;
}

// Tipos de Formularios
export interface GameFormData {
  title: string;
  description?: string;
  platformId: number;
  releaseYear?: number;
  rating?: number;
  tags?: number[];
  romFile?: File;
  metadataSource?: 'igdb' | 'rawg' | 'thegamesdb' | 'manual';
}

export interface PlatformFormData {
  name: string;
  description?: string;
  manufacturer?: string;
  releaseYear?: number;
  romExtension?: string;
}

export interface TagFormData {
  name: string;
  color: string;
  description?: string;
}

export interface ImportRomFormData {
  romPath: string;
  platformId: number;
  autoScan: boolean;
}

export interface SettingsFormData {
  igdbApiKey?: string;
  rawgApiKey?: string;
  thegamesdbApiKey?: string;
  defaultRomDirectory?: string;
  autoImportEnabled: boolean;
  metadataSourcePriority: ('igdb' | 'rawg' | 'thegamesdb')[];
}

// Tipos de Metadata
export interface GameMetadata {
  title: string;
  description?: string;
  releaseDate?: string;
  rating?: number;
  genres?: string[];
  platforms?: string[];
  coverUrl?: string;
  screenshots?: string[];
  developer?: string;
  publisher?: string;
  region?: string;
  language?: string;
}

// Tipos de Errores
export interface ApiError {
  message: string;
  code?: string;
  details?: Record<string, string[]>;
}

export interface ValidationError {
  field: string;
  message: string;
}

// Tipos de UI
export interface MenuItem {
  label: string;
  href: string;
  icon?: string;
  children?: MenuItem[];
}

export interface BreadcrumbItem {
  label: string;
  href?: string;
}

export interface TableColumn<T> {
  key: keyof T;
  label: string;
  sortable?: boolean;
  render?: (value: any, record: T) => React.ReactNode;
}

// Tipos de Hooks
export interface UseQueryOptions<T> {
  enabled?: boolean;
  refetchOnWindowFocus?: boolean;
  refetchOnMount?: boolean;
  refetchOnReconnect?: boolean;
  staleTime?: number;
  cacheTime?: number;
  retry?: number;
  retryDelay?: number;
}

export interface UseMutationOptions<T> {
  onSuccess?: (data: T) => void;
  onError?: (error: Error) => void;
  onSettled?: () => void;
  retry?: number;
  retryDelay?: number;
}
