<?= $this->extend('layouts/app') ?>

<?= $this->section('content') ?>
<div class="core-card p-4">
    <h2 class="h5 mb-3">Historique IA</h2>
    <div class="table-responsive">
        <table class="table align-middle">
            <thead><tr><th>Prompt</th><th>Modèle</th><th>Statut</th><th>Date</th></tr></thead>
            <tbody>
            <?php foreach ($requests as $request): ?>
                <tr>
                    <td><?= esc(mb_strimwidth($request['prompt'], 0, 90, '...')) ?></td>
                    <td><?= esc($request['model'] ?? '-') ?></td>
                    <td><span class="badge text-bg-secondary"><?= esc($request['status']) ?></span></td>
                    <td><?= esc($request['created_at']) ?></td>
                </tr>
            <?php endforeach; ?>
            <?php if ($requests === []): ?>
                <tr><td colspan="4" class="text-muted">Aucune demande IA enregistrée.</td></tr>
            <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?= $this->endSection() ?>
