<div class="row g-4">
    <div class="col-md-5">
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h5 class="mb-0"><?= e($pass['pass_number']) ?></h5>
                <?= status_badge($pass['status']) ?>
            </div>
            <div class="card-body">
                <table class="table table-sm">
                    <tr><th>Guest Name</th><td><?= e($pass['guest_name']) ?></td></tr>
                    <tr><th>Guest Phone</th><td><?= e($pass['guest_phone'] ?? '-') ?></td></tr>
                    <tr><th>National ID</th><td><?= e($pass['guest_national_id'] ?? '-') ?></td></tr>
                    <tr><th>Gender</th><td><?= e($pass['guest_gender'] ?? '-') ?></td></tr>
                    <tr><th>Pass Type</th><td><?= e($pass['type_name_en']) ?> / <?= e($pass['type_name_ar']) ?></td></tr>
                    <tr><th>Valid Date</th><td><?= e($pass['valid_date']) ?></td></tr>
                    <tr><th>Fee</th><td><?= money($pass['fee_amount']) ?></td></tr>
                    <tr><th>Host Member</th><td><a href="/members/show/<?= $pass['host_member_id'] ?>"><?= e($pass['host_name_en']) ?></a><br><small><?= e($pass['membership_number']) ?></small></td></tr>
                    <tr><th>Check In</th><td><?= e($pass['check_in_time'] ?? '-') ?></td></tr>
                    <tr><th>Check Out</th><td><?= e($pass['check_out_time'] ?? '-') ?></td></tr>
                </table>
                <div class="d-flex gap-2 mt-3">
                    <?php if ($pass['status'] === 'issued'): ?>
                    <form method="POST" action="/guests/<?= $pass['id'] ?>/checkin"><?= csrf_field() ?><button class="btn btn-success btn-sm"><i class="fas fa-sign-in-alt me-1"></i>Check In</button></form>
                    <?php endif; ?>
                    <?php if ($pass['status'] === 'active'): ?>
                    <form method="POST" action="/guests/<?= $pass['id'] ?>/checkout"><?= csrf_field() ?><button class="btn btn-info btn-sm"><i class="fas fa-sign-out-alt me-1"></i>Check Out</button></form>
                    <?php endif; ?>
                    <?php if (in_array($pass['status'], ['issued', 'active'])): ?>
                    <form method="POST" action="/guests/<?= $pass['id'] ?>/cancel"><?= csrf_field() ?><button class="btn btn-danger btn-sm"><i class="fas fa-times me-1"></i>Cancel</button></form>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-7">
        <div class="card"><div class="card-header"><h6 class="mb-0">Visit Log</h6></div><div class="card-body">
            <?php if (empty($visits)): ?>
                <p class="text-muted text-center py-3">No visits recorded</p>
            <?php else: ?>
            <table class="table table-sm"><thead><tr><th>Date</th><th>Check In</th><th>Check Out</th><th>Host Present</th></tr></thead><tbody>
            <?php foreach ($visits as $v): ?>
            <tr><td><?= e($v['visit_date']) ?></td><td><?= e($v['check_in']) ?></td><td><?= e($v['check_out'] ?? '-') ?></td><td><?= $v['host_present'] ? '<i class="fas fa-check text-success"></i>' : '<i class="fas fa-times text-danger"></i>' ?></td></tr>
            <?php endforeach; ?>
            </tbody></table>
            <?php endif; ?>
        </div></div>
    </div>
</div>