// Template list item (GET /templates)
export interface Template {
  id: string;
  name: string;
  description: string;
  version: string;
  platforms: string[];
  assetCount: { required: number; optional: number };
}

// Template detail (GET /templates/:id — manifest fields spread at top level)
export interface TemplateDetail {
  id: string;
  name: string;
  description: string;
  version: string;
  assets: {
    uploadFormat: string;
    required: AssetDef[];
    optional: AssetDef[];
  };
  theme: {
    properties: ThemeProp[];
  };
  platforms: {
    available: string[];
    defaults?: string[];
  };
}

export interface AssetDef {
  key: string;
  file: string;
  label: string;
  accept: string;
}

export interface ThemeProp {
  key: string;
  label: string;
  type: "css-gradient" | "text" | "color";
  default: string;
  maxLength?: number;
}

export interface Creative {
  id: string;
  name: string;
  templateId: string;
  templateName?: string;
  template?: { id: string; name: string };
  status: "draft" | "assets_ready" | "building" | "built" | "failed";
  theme: Record<string, string>;
  assets?: CreativeAsset[];
  recentBuilds?: BuildSummary[];
  createdAt: string;
  updatedAt: string;
}

export interface CreativeAsset {
  key: string;
  fileName: string;
  fileSize: number;
  isRequired: boolean;
}

export interface BuildSummary {
  id: string;
  status: string;
  platforms: string[];
  previewUrl?: string;
  results?: BuildResult[];
  errorLog?: string;
  startedAt?: string;
  finishedAt?: string;
  createdAt: string;
}

export interface BuildResult {
  platform: string;
  fileSize: number;
}
