<div class="card">
    <div class="card-header"><h4 class="card-title mb-0">Meta Ads — Kampanya / Reklam Seti / Reklam</h4></div>
    <div class="card-body p-0">
        <div class="table-responsive">
            <table class="table table-striped mb-0"><thead><tr><th>Tip</th><th>Tarih</th><th>Ad</th><th>Harcama</th><th>Tıklama</th><th>Lead</th><th>Satın Alma</th></tr></thead><tbody>
            @foreach($latestMetaCampaigns as $row)
                <tr><td>Kampanya</td><td>{{ $row->date?->format('d.m.Y') }}</td><td>{{ $row->campaign_name }}</td><td>{{ number_format((float)$row->spend, 2, ',', '.') }}</td><td>{{ number_format($row->clicks, 0, ',', '.') }}</td><td>{{ number_format((float)$row->leads, 2, ',', '.') }}</td><td>{{ number_format((float)$row->purchases, 2, ',', '.') }}</td></tr>
            @endforeach
            @foreach($latestMetaAdsets as $row)
                <tr><td>Reklam Seti</td><td>{{ $row->date?->format('d.m.Y') }}</td><td>{{ $row->adset_name }}</td><td>{{ number_format((float)$row->spend, 2, ',', '.') }}</td><td>{{ number_format($row->clicks, 0, ',', '.') }}</td><td>{{ number_format((float)$row->leads, 2, ',', '.') }}</td><td>{{ number_format((float)$row->purchases, 2, ',', '.') }}</td></tr>
            @endforeach
            @foreach($latestMetaAds as $row)
                <tr><td>Reklam</td><td>{{ $row->date?->format('d.m.Y') }}</td><td>{{ $row->ad_name }}</td><td>{{ number_format((float)$row->spend, 2, ',', '.') }}</td><td>{{ number_format($row->clicks, 0, ',', '.') }}</td><td>{{ number_format((float)$row->leads, 2, ',', '.') }}</td><td>{{ number_format((float)$row->purchases, 2, ',', '.') }}</td></tr>
            @endforeach
            @if($latestMetaCampaigns->isEmpty() && $latestMetaAdsets->isEmpty() && $latestMetaAds->isEmpty())
                <tr><td colspan="7" class="text-center text-muted py-4">Henüz Meta snapshot yok.</td></tr>
            @endif
            </tbody></table>
        </div>
    </div>
</div>
