<!DOCTYPE html>
<html lang="ar">
<head>
    <meta charset="UTF-8" />
    <style>
        body { font-family: DejaVu Sans, sans-serif; font-size: 12px; }
        .card {
            border: 1px solid #ccc;
            margin-bottom: 15px;
            padding: 10px;
            border-radius: 5px;
            direction: rtl;
        }
        .card h3 { margin: 0 0 10px; }
        .section-title { font-weight: bold; margin-top: 10px; }
        table { width: 100%; border-collapse: collapse; margin-top: 8px; }
        th, td { border: 1px solid #ccc; padding: 5px; text-align: right; }
    </style>
</head>
<body>
    <?php foreach ($trips_data as $trip) { ?>
    <div class="card">
        <h3>رحلة بتاريخ: <?= $trip['trip_date'] ?></h3>
        <p><strong>سائق:</strong> <?= $trip['driver_name'] ?></p>
        <p><strong>شركة النقل:</strong> <?= $trip['transport_company'] ?></p>

        <div class="section-title">المعتمرين</div>
        <table>
            <thead>
                <tr>
                    <th>اسم المعتمر</th>
                    <th>رقم الهوية</th>
                    <th>الجنسية</th>
                    <th>رقم الهاتف</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($trip['pilgrims'] as $p) { ?>
                <tr>
                    <td><?= $p['pilgrim_name'] ?></td>
                    <td><?= $p['id_number'] ?></td>
                    <td><?= $p['nationality'] ?></td>
                    <td><?= $p['phone'] ?></td>
                </tr>
                <?php } ?>
            </tbody>
        </table>

        <div class="section-title">التوريدات</div>
        <table>
            <thead>
                <tr>
                    <th>نوع التوريد</th>
                    <th>التفاصيل</th>
                    <th>الكمية</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($trip['supplies'] as $s) { ?>
                <tr>
                    <td><?= ucfirst($s['supply_type']) ?></td>
                    <td><?= $s['description'] ?></td>
                    <td><?= $s['quantity'] ?></td>
                </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
    <?php } ?>
</body>
</html>
