// User types
export interface User {
  id: string;
  email: string;
  name: string;
  avatar?: string;
  role: 'user' | 'admin' | 'moderator';
  subscription?: Subscription;
  createdAt: Date;
  updatedAt: Date;
}

export interface Subscription {
  id: string;
  plan: 'free' | 'basic' | 'pro' | 'enterprise';
  status: 'active' | 'inactive' | 'cancelled' | 'past_due';
  startDate: Date;
  endDate: Date;
  features: SubscriptionFeatures;
}

export interface SubscriptionFeatures {
  maxStreams: number;
  maxGuests: number;
  recordingHours: number;
  customBranding: boolean;
  multistream: boolean;
  analytics: boolean;
  priority_support: boolean;
}

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

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

export interface RegisterData {
  email: string;
  password: string;
  name: string;
  language?: string;
}

export interface AuthResponse {
  user: User;
  tokens: AuthTokens;
}

export interface AuthState {
  user: User | null;
  tokens: AuthTokens | null;
  isAuthenticated: boolean;
  isLoading: boolean;
}

// Language types
export type SupportedLanguage = 'es' | 'en' | 'pt' | 'fr';

export interface LanguageState {
  current: SupportedLanguage;
  available: SupportedLanguage[];
}

export interface Translation {
  [key: string]: string | Translation;
}

// API Response types
export interface ApiResponse<T = any> {
  success: boolean;
  data?: T;
  error?: ApiError;
  message?: string;
}

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

// Broadcast types
export interface Broadcast {
  id: string;
  title: string;
  description?: string;
  status: 'scheduled' | 'live' | 'ended' | 'recording';
  userId: string;
  destinations: StreamDestination[];
  startedAt?: Date;
  endedAt?: Date;
  createdAt: Date;
  updatedAt: Date;
}

export interface StreamDestination {
  id: string;
  platform: 'youtube' | 'facebook' | 'twitch' | 'linkedin' | 'custom';
  streamKey?: string;
  streamUrl?: string;
  enabled: boolean;
  status?: 'connected' | 'disconnected' | 'error';
}

// Studio types
export interface StudioScene {
  id: string;
  name: string;
  layout: 'single' | 'side-by-side' | 'pip' | 'grid';
  overlays: Overlay[];
  background?: BackgroundSource;
}

export interface Overlay {
  id: string;
  type: 'logo' | 'text' | 'image' | 'ticker';
  position: Position;
  size: Size;
  content: any;
  visible: boolean;
}

export interface Position {
  x: number;
  y: number;
}

export interface Size {
  width: number;
  height: number;
}

export interface BackgroundSource {
  type: 'color' | 'image' | 'video';
  value: string;
}

// Guest types
export interface Guest {
  id: string;
  name: string;
  email?: string;
  joinLink: string;
  status: 'invited' | 'joined' | 'disconnected';
  audioEnabled: boolean;
  videoEnabled: boolean;
  joinedAt?: Date;
}

// Analytics types
export interface AnalyticsData {
  broadcastId: string;
  viewers: ViewerStats;
  engagement: EngagementStats;
  platforms: PlatformStats[];
}

export interface ViewerStats {
  total: number;
  peak: number;
  average: number;
  current: number;
}

export interface EngagementStats {
  likes: number;
  comments: number;
  shares: number;
  chatMessages: number;
}

export interface PlatformStats {
  platform: string;
  viewers: number;
  engagement: number;
}

// Export all types
export * from './index';
