export interface Project {
    id: string;
    name: string;
    client: string;
    startDate?: Date | string | null;
    endDate?: Date | string | null;
    technician?: string | null;
    environment?: string | null;
    createdAt: Date | string;
    updatedAt: Date | string;
    parts?: Part[];
    paintingSchemes?: PaintingScheme[];
    applicationRecords?: ApplicationRecord[];
    inspections?: Inspection[];
}

export interface Part {
    id: string;
    projectId: string;
    description: string;
    dimensions?: string | null;
    weight?: number | null;
    type?: string | null;
    area?: number | null;
    complexity?: number | null;
    quantity: number;
    notes?: string | null;
}

export interface PaintingScheme {
    id: string;
    projectId: string;
    name: string;
    type?: string | null;
    solidsVolume?: number | null;
    yieldTheoretical?: number | null;
    epsMin?: number | null;
    epsMax?: number | null;
    dilution?: number | null;
    manufacturer?: string | null;
    color?: string | null;
    notes?: string | null;
}

export interface ApplicationRecord {
    id: string;
    projectId: string;
    coatStage: string;
    pieceDescription?: string | null;
    date?: Date | string | null;
    operator?: string | null;
    realWeight?: number | null; // Peso Real (kg)
    volumeUsed?: number | null; // Volume Utilizado (L)
    areaPainted?: number | null; // Área Pintada (m²)
    wetThicknessAvg?: number | null; // Espessura Úmida Média (µm)
    dryThicknessCalc?: number | null; // Espessura Seca Calculada (µm)
    method?: string | null;
    realYield?: number | null; // Rendimento Real (m²/L)
    diluentUsed?: number | null; // Consumo estimado de Diluente (L)
    notes?: string | null;
}

export interface Inspection {
    id: string;
    projectId: string;
    date?: Date | string | null;
    inspector?: string | null;
    pieceDescription?: string | null;
    epsPoints?: (number | null)[];
    adhesionTest?: string | null; // Teste de Aderência
    appearance?: string | null; // Aspecto Visual
    defects?: string | null;
}

export interface TechnicalDataSheet {
    id: string;
    name: string;
    manufacturer?: string;
    type?: string; // 'epoxi', 'pu', 'diluent', etc
    fileUrl: string; // Path or URL to PDF
    uploadDate: Date | string;

    // Technical Properties for Analysis
    solidsVolume?: number; // %
    density?: number; // g/cm3
    mixingRatio?: string;
    mixingRatioWeight?: string;
    mixingRatioVolume?: string;
    wftMin?: number;
    wftMax?: number;
    dftMin?: number;
    dftMax?: number;
    reducer?: string;
    yieldTheoretical?: number; // m2/L
    dftReference?: number; // µm (Espessura de camada seca de referência para o rendimento teórico)
    yieldFactor?: number; // Razão m²/L por µm (Calculado como rendimento * espessura / 1 ou simplesmente sólidos * 10)
    dilution?: number; // % sugerida
    notes?: string;
}

export interface PieceCategory {
    id: string;
    name: string;
    weight: number; // Total weight in Kg
    historicalYield: number; // L/Kg (Historical consumption)
    historicalDft: number; // µm (Reference DFT for the historical yield)
    efficiency: number; // % (Expected application efficiency)
}

export interface YieldStudy {
    id: string;
    name: string;
    dataSheetId: string; // Ficha Técnica selecionada
    targetDft: number; // µm (Desired dry thickness)
    dilutionPercent: number; // % (Expected dilution)
    categories: PieceCategory[];
    createdAt: Date | string;
    updatedAt: Date | string;

    // Results (Calculated)
    totalWeight: number;
    estimatedPaintVolume: number; // Liters
    estimatedReducerVolume: number; // Liters
    averageComplexity: number;
}
