// DTO 任务/候选/审核/交付类型（按 API契约§3）

// 任务
export type TaskStatus =
  | 'pending' | 'generating' | 'pending_selection'
  | 'pending_review' | 'approved' | 'rejected' | 'archived';

export interface TaskListItem {
  id: number;
  product_id: number;
  theme: string;
  status: TaskStatus;
  created_at: string;
  text_count: number;
  image_count: number;
}

export interface CreateTaskRequest {
  product_id: number;
  benchmark_ids: number[];
  theme: string;
  text_count: number;
  image_count: number;
  track: 'ai' | 'import';
  need_product_image: boolean;  // 本次产品是否入镜：true=无图禁生成不降级
}

// 文案候选（含AI评委7维分）
export type BannedWordStatus = 'pass' | 'auto_fixed' | 'soft_warn' | 'hard_block';

export interface ScoreDim {
  item: string;
  score: number;
  max: number;
  note?: string;
}

export interface TextScore {
  title: number;
  emotion: number;
  selling: number;
  keyword: number;
  compliance: number;
  total: number;
  dims?: ScoreDim[];   // AI评委明细(7维含理由)，存在则优先按它渲染
}

export interface TextCandidate {
  candidate_id: number;
  angle_label: string;
  content: string;
  source: 'ai' | 'import';
  score: TextScore;
  banned_word_status: BannedWordStatus;
  verdict?: string;    // AI评委总评："优秀"|"合格"|"不合格"，旧数据为空字符串
  summary?: string;    // AI评委一句话总评(含改进点)，旧数据为空字符串
}

export interface SelectCandidateRequest { candidate_id: number; }

// 图片候选
export type ImageRole =
  | 'hook' | 'pain' | 'proof' | 'quality' | 'credit' | 'convert' | 'main';

export interface ImageCandidate {
  candidate_id: number;
  strategy: 'A' | 'B' | 'C';
  url: string;
  role: ImageRole;
}

// 审核
export interface ReviewQueueItem {
  task_id: number;
  product_name: string;
  theme: string;
  submitted_at: string;
  operator_name: string;
  selected_text: { candidate_id: number; angle_label: string; content: string; };
  selected_image: { candidate_id: number; strategy: 'A' | 'B' | 'C'; url: string; };
}

export interface RejectRequest { reason: string; }

// 飞轮偏好上下文
export interface PreferenceContext {
  recent_preference: string;
  reject_reasons: string[];
  injected_count: number;
}

// 交付包
export type DeliveryStatus = 'pending' | 'ready' | 'downloaded';

export interface DeliveryPackage {
  id: number;
  status: DeliveryStatus;
  download_url: string | null;
  expires_at: string | null;
}

// 统一响应包络
export interface ApiResponse<T> { code: number; data: T; }
export interface ApiError { code: number; message: string; }
export interface PaginatedResponse<T> {
  items: T[];
  total: number;
  page: number;
  page_size: number;
}
