export interface PriceData {
  time: number;
  open: number;
  high: number;
  low: number;
  close: number;
  volume?: number;
}

export interface Trade {
  id: string;
  timestamp: number;
  action: 'BUY' | 'SELL';
  quantity: number;
  price: number;
  total: number;
  pnl?: number;
}

export interface Position {
  symbol: string;
  quantity: number;
  avgPrice: number;
  currentPrice: number;
  unrealizedPnl: number;
  unrealizedPnlPercent: number;
}

export interface Portfolio {
  cash: number;
  initialCapital: number;
  totalValue: number;
  totalPnl: number;
  totalPnlPercent: number;
  position: Position | null;
  trades: Trade[];
}

export interface Indicator {
  name: string;
  enabled: boolean;
  params: Record<string, number>;
  data: { time: number; value: number }[];
}

export interface SimulationConfig {
  initialCapital: number;
  tradeFee: number;
  slippage: number;
}

export interface AIAnalysis {
  recommendation: 'BUY' | 'SELL' | 'HOLD';
  confidence: number;
  reasoning: string;
  supportResistance: {
    support: number[];
    resistance: number[];
  };
  riskLevel: 'LOW' | 'MEDIUM' | 'HIGH';
}

export interface MarketData {
  symbol: string;
  price: number;
  change: number;
  changePercent: number;
  high24h: number;
  low24h: number;
  volume: number;
}

// News and Sentiment Types
export type Sentiment = 'POSITIVE' | 'NEGATIVE' | 'NEUTRAL';

export interface NewsArticle {
  id: string;
  source: string;
  title: string;
  description?: string;
  url: string;
  published_at: string;
  sentiment: Sentiment;
  sentiment_score: number;
  impact_on_gold: 'HIGH' | 'MEDIUM' | 'LOW';
  relevance_score: number;
  category: string;
}

export interface NewsFeed {
  articles: NewsArticle[];
  total_count: number;
  bullish_count: number;
  bearish_count: number;
  neutral_count: number;
  overall_sentiment: Sentiment;
  avg_sentiment_score: number;
}

export interface EconomicEvent {
  id: string;
  title: string;
  country: string;
  currency: string;
  event_date: string;
  importance: 'HIGH' | 'MEDIUM' | 'LOW';
  forecast?: string;
  previous?: string;
  actual?: string;
  impact_on_gold: string;
}

export interface EconomicCalendar {
  events: EconomicEvent[];
  upcoming_high_impact: number;
}

// Alert Types
export type AlertType =
  | 'PRICE_SPIKE'
  | 'PRICE_DROP'
  | 'NEWS_BREAKING'
  | 'SUPPORT_BREACH'
  | 'RESISTANCE_BREACH'
  | 'HIGH_VOLATILITY'
  | 'ECONOMIC_EVENT';

export type AlertSeverity = 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW';

export interface Alert {
  id: string;
  type: AlertType;
  severity: AlertSeverity;
  title: string;
  message: string;
  price?: number;
  change_percent?: number;
  timestamp: string;
  related_news?: string[];
  action_required: boolean;
}

export interface AlertsData {
  alerts: Alert[];
  critical_count: number;
  unread_count: number;
}

// Dashboard Customization Types
export type TabId = 
  | 'chart'
  | 'portfolio'
  | 'trade-controls'
  | 'risk-management'
  | 'ai-analysis'
  | 'news'
  | 'alerts'
  | 'analytics'
  | 'daily-checklist'
  | 'daily-plan'
  | 'trading-journal'
  | 'market-summary';

export type LayoutMode = 'grid' | 'tabs' | 'split';
export type TabSize = 'small' | 'medium' | 'large' | 'full';
export type TabPosition = 'left' | 'center' | 'right' | 'top' | 'bottom';

export interface TabCustomization {
  refreshRate?: number; // in seconds
  autoRefresh?: boolean;
  displayMode?: string;
  filters?: Record<string, any>;
  theme?: 'default' | 'compact' | 'detailed';
}

export interface TabConfig {
  id: TabId;
  label: string;
  icon?: string;
  visible: boolean;
  order: number;
  size: TabSize;
  position?: TabPosition;
  group?: string; // for grouping related tabs
  customization?: TabCustomization;
  pinned?: boolean;
}

export interface LayoutPreset {
  id: string;
  name: string;
  description: string;
  mode: LayoutMode;
  tabs: TabConfig[];
}

export interface DashboardConfig {
  mode: LayoutMode;
  tabs: TabConfig[];
  activePreset?: string;
  customPresets: LayoutPreset[];
}
