<?php
function getBusinessInfoForPDF($pdo) {
    try {
        $stmt = $pdo->prepare("SELECT company_name, logo_url, branding_color_primary, branding_color_secondary, phone_primary FROM business_info WHERE id = ? LIMIT 1");
        $stmt->execute([1]);
        $generalData = $stmt->fetch(PDO::FETCH_ASSOC);

        $logo_url = $generalData['logo_url'] ?? 'https://i.imgur.com/83D4Z58.png';
        if ($logo_url && !filter_var($logo_url, FILTER_VALIDATE_URL)) {
             $cleaned_path = ltrim(str_replace('../', '', $logo_url), '/');
             $logo_url = dirname(__DIR__) . '/' . $cleaned_path;
             if (!file_exists($logo_url)) {
                 error_log("Advertencia PDF: El archivo de logo no se encontró en: " . $logo_url);
                 $logo_url = 'https://i.imgur.com/83D4Z58.png';
             }
        }

        return [
            'company_name' => $generalData['company_name'] ?? 'FlowClean Cleaning LLC',
            'logo_url' => $logo_url,
            'primary_color' => $generalData['branding_color_primary'] ?? '#92A3D3',
            'secondary_color' => $generalData['branding_color_secondary'] ?? '#991B1B',
            'phone_primary' => $generalData['phone_primary'] ?? '(425) 555-1234'
        ];

    } catch (PDOException $e) {
        error_log("Error al leer business_info para PDF: " . $e->getMessage());
        return [
            'company_name' => 'Error de Carga (FlowClean)',
            'logo_url' => 'https://i.imgur.com/83D4Z58.png',
            'primary_color' => '#07162d',
            'secondary_color' => '#9e1428',
            'phone_primary' => '(425) 555-0000'
        ];
    }
}
?>