<?php
// api/portfolio.php  —  Portfolio generieren
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/ai_engine.php';
c2c_cors_headers();
require_api_token();

$clientId = (int)($_GET['client_id'] ?? 0);
if (!$clientId) json_response(['error' => 'client_id fehlt'], 422);

try {
    $portfolio = C2CAIEngine::generatePortfolio($clientId);
    json_response(['success' => true, 'sections' => array_keys($portfolio)]);
} catch (Exception $e) {
    error_log("Portfolio Error client $clientId: " . $e->getMessage());
    json_response(['error' => $e->getMessage()], 500);
}
