<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>باسات الحجز #<?= e($booking['booking_number'] ?? '') ?><?php $__template->endSection(); ?>

<?php $__template->section('page_actions'); ?>
<a href="/sa/bookings/<?= (int) $booking['id'] ?>" class="btn btn-outline"><i data-lucide="arrow-right" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> تفاصيل الحجز</a>
<button onclick="window.print()" class="btn btn-primary"><i data-lucide="printer" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> طباعة</button>
<?php $__template->endSection(); ?>

<?php $__template->section('content'); ?>

<!-- Booking Info -->
<div class="card" style="margin-bottom:20px;padding:15px;">
    <div style="display:grid;grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));gap:10px;font-size:13px;">
        <div><strong>الحاجز:</strong> <?= e($booking['booker_name'] ?? '') ?></div>
        <div><strong>المرفق:</strong> <?= e($booking['facility_name'] ?? '') ?> - <?= e($booking['unit_name'] ?? '') ?></div>
        <div><strong>التاريخ:</strong> <?= e($booking['booking_date'] ?? '') ?></div>
        <div><strong>الوقت:</strong> <?= e($booking['start_time'] ?? '') ?> - <?= e($booking['end_time'] ?? '') ?></div>
        <div><strong>نظام المشاركين:</strong>
            <?php
            $modeLabels = ['full' => 'تسجيل كامل', 'partial' => 'أسماء فقط', 'passes' => 'باسات'];
            echo e($modeLabels[$booking['participant_mode'] ?? 'passes'] ?? 'باسات');
            ?>
        </div>
        <div><strong>الاستخدام:</strong> <?= (int) ($booking['passes_used'] ?? 0) ?> / <?= (int) ($booking['passes_total'] ?? 0) ?></div>
    </div>
</div>

<!-- Passes List -->
<div class="card">
    <div style="padding:12px 15px;border-bottom:1px solid #E5E7EB;display:flex;justify-content:space-between;align-items:center;">
        <span style="font-weight:700;">الباسات (<?= count($passes) ?>)</span>
    </div>
    <table style="width:100%;border-collapse:collapse;font-size:13px;">
        <thead>
            <tr style="background:#F9FAFB;">
                <th style="padding:10px;border-bottom:1px solid #E5E7EB;text-align:right;">#</th>
                <th style="padding:10px;border-bottom:1px solid #E5E7EB;text-align:right;">رقم الباس</th>
                <th style="padding:10px;border-bottom:1px solid #E5E7EB;text-align:center;">الحالة</th>
                <th style="padding:10px;border-bottom:1px solid #E5E7EB;text-align:right;">تم الاستخدام</th>
                <th style="padding:10px;border-bottom:1px solid #E5E7EB;text-align:right;">بواسطة</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($passes as $i => $pass): ?>
            <?php
                $statusColors = ['issued' => '#ECFDF5', 'used' => '#FEF3C7', 'expired' => '#FEE2E2', 'cancelled' => '#F3F4F6'];
                $statusLabels = ['issued' => 'متاح', 'used' => 'مستخدم', 'expired' => 'منتهي', 'cancelled' => 'ملغي'];
                $statusColor = $statusColors[$pass['status']] ?? '#F3F4F6';
                $statusLabel = $statusLabels[$pass['status']] ?? $pass['status'];
            ?>
            <tr style="border-bottom:1px solid #F3F4F6;">
                <td style="padding:10px;"><?= $i + 1 ?></td>
                <td style="padding:10px;font-family:monospace;font-weight:600;"><?= e($pass['pass_number']) ?></td>
                <td style="padding:10px;text-align:center;">
                    <span style="background:<?= $statusColor ?>;padding:2px 8px;border-radius:8px;font-size:11px;font-weight:600;"><?= e($statusLabel) ?></span>
                </td>
                <td style="padding:10px;font-size:12px;color:#6B7280;"><?= e($pass['used_at'] ?? '-') ?></td>
                <td style="padding:10px;font-size:12px;"><?= e($pass['used_by_name'] ?? '-') ?></td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
    if (typeof lucide !== 'undefined') { lucide.createIcons(); }
});
</script>
<?php $__template->endSection(); ?>
