export type AdPlatform = 'AMAZON' | 'EBAY' | 'SHOPEE' | 'TIKTOK';
export type AdPlanStatus = 'DRAFT' | 'ACTIVE' | 'PAUSED' | 'COMPLETED' | 'PENDING_REVIEW';
export type CampaignStatus = 'PENDING' | 'RUNNING' | 'PAUSED' | 'COMPLETED' | 'FAILED';

export interface AdPlan {
  id?: string;
  tenant_id: string;
  shop_id: string;
  name: string;
  platform: AdPlatform;
  budget: number;
  daily_budget?: number;
  start_date?: Date;
  end_date?: Date;
  status: AdPlanStatus;
  target_audience?: string;
  keywords?: string[];
  trace_id?: string;
  task_id?: string;
  business_type?: 'TOC' | 'TOB';
  created_at?: Date;
  updated_at?: Date;
}

export interface AdCampaign {
  id?: string;
  ad_plan_id: string;
  tenant_id: string;
  product_id?: string;
  sku_id?: string;
  bid_amount: number;
  clicks: number;
  impressions: number;
  spend: number;
  sales: number;
  conversions: number;
  status: CampaignStatus;
  trace_id?: string;
  created_at?: Date;
  updated_at?: Date;
}

export interface CreateAdPlanParams {
  tenantId: string;
  shopId: string;
  name: string;
  platform: AdPlatform;
  budget: number;
  dailyBudget?: number;
  startDate?: Date;
  endDate?: Date;
  targetAudience?: string;
  keywords?: string[];
  taskId?: string;
  traceId: string;
  businessType: 'TOC' | 'TOB';
}

export interface ExecuteCampaignOptions {
  tenantId: string;
  shopId: string;
  adPlanId: string;
  productId?: string;
  skuId?: string;
  bidAmount: number;
  taskId?: string;
  traceId: string;
  businessType: 'TOC' | 'TOB';
}

export interface CampaignResult {
  campaignId: string;
  status: CampaignStatus;
  message: string;
}

export interface DateRange {
  startDate: Date;
  endDate: Date;
}

export interface ROIData {
  adPlanId: string;
  totalSpend: number;
  totalSales: number;
  totalConversions: number;
  roi: number;
  roas: number;
  ctr: number;
  cpc: number;
  acos: number;
  dateRange: DateRange;
}

export interface AdPerformanceMetrics {
  impressions: number;
  clicks: number;
  spend: number;
  sales: number;
  conversions: number;
}
