{{--
    Kolonları kullanıcı tarafından seçilen yolcu manifestosu PDF çıktısı.
    $headings / $rows  → PassengerManifestService::matrix()
    $numericKeys       → sağa yaslanacak kolon indeksleri (tutar alanları)
--}}
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="utf-8">
    <style>
        * { font-family: DejaVu Sans, sans-serif; }
        @page { margin: 22px 18px 34px; }
        body { margin: 0; color: #1e293b; }

        .head { border-bottom: 2px solid #1e293b; padding-bottom: 8px; margin-bottom: 10px; }
        .head h1 { font-size: 15px; margin: 0 0 3px; letter-spacing: -.2px; }
        .head .sub { font-size: 9.5px; color: #64748b; }
        .head .sub b { color: #334155; }
        .chip { display: inline-block; background: #eef2ff; color: #3730a3; font-size: 8px; font-weight: bold;
                padding: 2px 6px; border-radius: 7px; margin-left: 4px; }

        table { width: 100%; border-collapse: collapse; }
        th { background: #1e293b; color: #fff; font-size: {{ $fontSize ?? 8.5 }}px; text-align: left;
             padding: 5px 6px; text-transform: uppercase; letter-spacing: .2px; }
        td { font-size: {{ $fontSize ?? 8.5 }}px; padding: 4px 6px; border-bottom: 1px solid #e2e8f0; }
        tr:nth-child(even) td { background: #f8fafc; }
        .num { text-align: right; white-space: nowrap; }

        .foot { position: fixed; bottom: 10px; left: 0; right: 0; font-size: 7.5px; color: #94a3b8; }
        .foot .r { float: right; }
    </style>
</head>
<body>
    <div class="head">
        <h1>{{ $docTitle ?? 'Yolcu Listesi' }}</h1>
        <div class="sub">
            <b>{{ $title }}</b>
            <span class="chip">{{ count($rows) }} YOLCU</span>
            @if(!empty($presetLabel))<span class="chip">{{ mb_strtoupper($presetLabel) }}</span>@endif
        </div>
    </div>

    <table>
        <thead>
            <tr>@foreach($headings as $h)<th>{{ $h }}</th>@endforeach</tr>
        </thead>
        <tbody>
            @forelse($rows as $r)
                <tr>
                    @foreach($r as $ci => $cell)
                        @php $isNum = in_array($ci, $numericKeys ?? [], true); @endphp
                        <td class="{{ $isNum ? 'num' : '' }}">
                            {{ $isNum && is_numeric($cell) ? number_format((float) $cell, 2, ',', '.') : $cell }}
                        </td>
                    @endforeach
                </tr>
            @empty
                <tr><td colspan="{{ max(1, count($headings)) }}" style="text-align:center;color:#94a3b8;padding:18px;">Yolcu kaydı yok.</td></tr>
            @endforelse
        </tbody>
    </table>

    <div class="foot">
        {{ $agencyName ?? '' }}
        <span class="r">{{ now()->format('d.m.Y H:i') }}</span>
    </div>
</body>
</html>
