export interface ProductionChain {
  name: string;
  type: 'textile' | 'alimentaire' | 'metallurgie' | 'alcool';
  stages: ProductionStage[];
}

export interface ProductionStage {
  name: string;
  input: string;
  output: string;
  cost_per_unit: number;
  duration_hours: number;
  yield_rate: number; // 0-1
  description: string;
}

export const PRODUCTION_CHAINS: ProductionChain[] = [
  {
    name: 'Chaine Textile',
    type: 'textile',
    stages: [
      { name: 'Production', input: 'Champs coton', output: 'Coton brut', cost_per_unit: 15, duration_hours: 8, yield_rate: 1.0, description: '1 batch = 100 kg coton' },
      { name: 'Transformation', input: 'Coton brut', output: 'Tissus', cost_per_unit: 2, duration_hours: 4, yield_rate: 0.8, description: '100kg coton → 80kg tissus' },
      { name: 'Vente', input: 'Tissus', output: 'Vetements', cost_per_unit: 10, duration_hours: 0, yield_rate: 1.0, description: 'Achat 10 ∞, vente 30 ∞ retail (marge 3x)' },
    ],
  },
  {
    name: 'Chaine Alimentaire',
    type: 'alimentaire',
    stages: [
      { name: 'Production', input: 'Ferme', output: 'Legumes', cost_per_unit: 10, duration_hours: 6, yield_rate: 1.0, description: '1 batch = 50 kg legumes' },
      { name: 'Grossiste', input: 'Legumes', output: 'Produits marche', cost_per_unit: 0.5, duration_hours: 0, yield_rate: 1.0, description: 'Achat 0.5 ∞/kg, revente 1 ∞/kg (marge 2x)' },
      { name: 'Restaurant', input: 'Produits marche', output: 'Plats', cost_per_unit: 3, duration_hours: 0, yield_rate: 1.0, description: 'Achat 1 ∞/kg + prep 2 ∞, vente 5-10 ∞ (marge 5-10x)' },
    ],
  },
  {
    name: 'Chaine Metallique',
    type: 'metallurgie',
    stages: [
      { name: 'Extraction', input: 'Mine illegale', output: 'Minerai brut', cost_per_unit: 20, duration_hours: 10, yield_rate: 1.0, description: '1 batch = 200 kg, risque police 30%' },
      { name: 'Fonderie', input: 'Minerai brut', output: 'Acier', cost_per_unit: 3, duration_hours: 6, yield_rate: 0.7, description: '200kg minerai → 140kg acier' },
      { name: 'Manufacture', input: 'Acier', output: 'Produits finis', cost_per_unit: 5, duration_hours: 0, yield_rate: 1.0, description: 'Achat 5 ∞/kg, vente 15-30 ∞/unite (marge 3-6x)' },
    ],
  },
  // Phase 6 (2026-04-20) — production alcool (brasserie → bière pour bars/nightclubs/cavistes/biergartens)
  {
    name: 'Chaine Alcool',
    type: 'alcool',
    stages: [
      { name: 'Production', input: 'Brasserie', output: 'Biere brute', cost_per_unit: 5, duration_hours: 12, yield_rate: 1.0, description: '1 batch = 100 L bière' },
      { name: 'Conditionnement', input: 'Biere brute', output: 'Biere bouteille', cost_per_unit: 1, duration_hours: 2, yield_rate: 0.95, description: '100L → 95L en bouteilles' },
      { name: 'Vente Bar/Caviste', input: 'Biere bouteille', output: 'Pintes/Bouteilles', cost_per_unit: 2, duration_hours: 0, yield_rate: 1.0, description: 'Achat 2∞/L, vente 6∞/pinte au bar (×3)' },
    ],
  },
];

/** Universal cost ratio rules for legal goods */
export const COST_RATIOS = {
  production: 1,            // 1x baseline
  wholesale_white: 3,       // 3x production cost
  wholesale_black: 2,       // 2x production cost
  retail_markup: 3,         // 3x purchase price (= 9x production at retail)
  transport_cost_ratio: 0.1, // 10% of production cost
  storage_cost_ratio: 0.1,  // 10% of production cost per day
};
