/**
 * Dashboard API Types - Mirror backend schemas
 */

export interface InventoryDashboardSummary {
  tenant_id: string;
  total_ingredients: number;
  total_stock_value: number;
  low_stock_count: number;
  out_of_stock_count: number;
  overstock_count: number;
  expiring_soon_count: number;
  expired_count: number;
  recent_movements: StockMovementSummary[];
  top_categories: CategorySummary[];
  alerts_summary: AlertSummary;
  last_updated: string;
}

export interface StockMovementSummary {
  id: string;
  ingredient_name: string;
  movement_type: 'in' | 'out' | 'adjustment' | 'transfer' | 'waste';
  quantity: number;
  created_at: string;
}

export interface CategorySummary {
  category: string;
  ingredient_count: number;
  total_value: number;
  low_stock_count: number;
}

export interface AlertSummary {
  total_alerts: number;
  critical_alerts: number;
  warning_alerts: number;
  info_alerts: number;
}

export interface StockStatusSummary {
  in_stock: number;
  low_stock: number;
  out_of_stock: number;
  overstock: number;
}

export interface InventoryAnalytics {
  tenant_id: string;
  period_start: string;
  period_end: string;
  stock_turnover_rate: number;
  average_days_to_consume: number;
  waste_percentage: number;
  cost_of_goods_sold: number;
  inventory_value_trend: Array<{
    date: string;
    value: number;
  }>;
  top_consuming_ingredients: Array<{
    ingredient_name: string;
    quantity_consumed: number;
    value_consumed: number;
  }>;
  seasonal_patterns: Record<string, any>;
}

export interface BusinessModelInsights {
  tenant_id: string;
  business_type: string;
  primary_categories: string[];
  seasonality_score: number;
  optimization_opportunities: Array<{
    type: 'stock_level' | 'supplier' | 'storage' | 'ordering';
    description: string;
    potential_savings: number;
    priority: 'high' | 'medium' | 'low';
  }>;
  benchmarking: {
    inventory_turnover_vs_industry: number;
    waste_percentage_vs_industry: number;
    storage_efficiency_score: number;
  };
}

export interface RecentActivity {
  id: string;
  type: 'stock_in' | 'stock_out' | 'ingredient_created' | 'alert_created';
  description: string;
  timestamp: string;
  user_name?: string;
}

export interface DashboardFilter {
  date_range?: {
    start: string;
    end: string;
  };
  categories?: string[];
  include_expired?: boolean;
  include_unavailable?: boolean;
}

export interface AlertsFilter {
  severity?: 'critical' | 'warning' | 'info';
  type?: 'expiry' | 'low_stock' | 'out_of_stock' | 'food_safety';
  resolved?: boolean;
  limit?: number;
  offset?: number;
}