<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>

<div class="d-flex justify-content-between align-items-center mb-3">
    <h1 class="h3 mb-0">Event Clients</h1>
    <a href="<?= site_url('event-clients/new') ?>" class="btn btn-primary"><i class="bi bi-plus-lg"></i> New Client</a>
</div>

<form action="<?= site_url('event-clients') ?>" method="get" class="mb-3">
    <div class="input-group" style="max-width: 480px;">
        <input type="text" class="form-control" name="q" value="<?= esc($term) ?>" placeholder="Search by company, contact, or phone">
        <button type="submit" class="btn btn-outline-secondary">Search</button>
    </div>
</form>

<div class="card shadow-sm">
    <div class="table-scroll">
        <table class="table table-hover mb-0 align-middle">
            <thead class="table-light"><tr><th>Company</th><th>Contact</th><th>Phone</th><th>Email</th></tr></thead>
            <tbody>
                <?php if (empty($clients)): ?>
                    <tr><td colspan="4" class="text-center text-muted py-4">No event clients found.</td></tr>
                <?php endif; ?>
                <?php foreach ($clients as $client): ?>
                    <tr style="cursor:pointer" onclick="window.location='<?= site_url('event-clients/' . $client->id) ?>'">
                        <td class="fw-semibold"><?= esc($client->company_name) ?></td>
                        <td><?= esc($client->contact_name) ?></td>
                        <td><?= esc($client->phone) ?></td>
                        <td><?= esc($client->email) ?></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>

<?= $this->endSection() ?>
