/**
 * Typer för AI-assisterad receptgenerering (docs/32).
 * Ingen PII. Alla receptkandidater passerar verifieringspipelinen.
 */

export interface RecipeCandidate {
  titleSv: string;
  descriptionSv: string;
  cuisine: string | null;
  mealTypes: string[];
  prepTimeMinutes: number;
  cookTimeMinutes: number;
  totalTimeMinutes: number;
  portions: number;
  spiceLevel: number;
  ingredients: RecipeCandidateIngredient[];
  steps: RecipeCandidateStep[];
  storageGuidanceSv: string | null;
  mealPrepFriendly: boolean;
  freezerFriendly: boolean;
  sourceType: "ai_generated";
  confidence: number;
  /** AI:s påstådda allergener — används aldrig som facit; alltid härledda ur ingredienser. */
  aiClaimedAllergens?: string[];
}

export interface RecipeCandidateIngredient {
  canonicalIngredientId: string;
  displayNameSv: string;
  quantity: number;
  unit: string;
  optional: boolean;
  note: string | null;
}

export interface RecipeCandidateStep {
  stepNumber: number;
  instructionSv: string;
  timerSeconds: number | null;
  temperatureC: number | null;
  tip: string | null;
}

export interface VerificationResult {
  candidate: RecipeCandidate;
  status: "verified" | "unverified" | "rejected";
  reasons: string[];
  nutritionPerPortion: import("@app/shared-types").NutritionValues | null;
  allergens: string[];
  canonicalIngredientIds: string[];
}

export interface GapReportEntry {
  searchQuery: string;
  missCount: number;
  lastMissedAt: Date;
  suggestedIngredientId: string | null;
  suggestedMealType: string | null;
  priority: "high" | "medium" | "low";
}

export interface GapReport {
  generatedAt: Date;
  entries: GapReportEntry[];
  topMissingIngredients: Array<{ canonicalIngredientId: string | null; count: number }>;
  topMissingMealTypes: Array<{ mealType: string | null; count: number }>;
}

export interface PilotBatchResult {
  batchId: string;
  generatedAt: Date;
  targetMatrix: Array<{
    mealType: string;
    mainIngredientId: string;
    dietVariant: string;
    count: number;
  }>;
  candidates: VerificationResult[];
  verifiedCount: number;
  unverifiedCount: number;
  rejectedCount: number;
  totalGeminiCostUsd: number;
}
