@php $total = (int) ($stats->total ?? 0); $delivered = (int) ($stats->delivered ?? 0); $bounced = (int) ($stats->bounced ?? 0); $failed = (int) ($stats->failed ?? 0); $deliveryRate = $total > 0 ? round(($delivered / $total) * 100, 1) : 0; $bounceRate = $total > 0 ? round(($bounced / $total) * 100, 1) : 0; $failRate = $total > 0 ? round(($failed / $total) * 100, 1) : 0; @endphp @if($total === 0) {{-- Empty state --}}

{{ __('No email data yet') }}

{{ __('Outbound email delivery metrics will appear here once emails are sent through the platform.') }}

@else {{-- Summary Cards --}}
@php $deliveryCards = [ ['label' => __('Total Emails Sent'), 'value' => number_format($total), 'icon' => 'M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z', 'color' => 'from-indigo-500 to-blue-600', 'shadow' => 'shadow-soft'], ['label' => __('Delivery Rate'), 'value' => $deliveryRate . '%', 'icon' => 'M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z', 'color' => 'from-green-500 to-emerald-600', 'shadow' => 'shadow-green-200'], ['label' => __('Bounce Rate'), 'value' => $bounceRate . '%', 'icon' => 'M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z', 'color' => 'from-amber-500 to-orange-600', 'shadow' => 'shadow-amber-200'], ['label' => __('Failure Rate'), 'value' => $failRate . '%', 'icon' => 'M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636', 'color' => 'from-red-500 to-rose-600', 'shadow' => 'shadow-red-200'], ]; @endphp @foreach($deliveryCards as $card)
{{ $card['label'] }}

{{ $card['value'] }}

@endforeach
{{-- Breakdown --}}

{{ __('Delivery Breakdown') }}

{{ __('All outbound messages by status') }}

{{ number_format($delivered) }}

{{ __('Delivered / Sent') }}

{{ number_format($bounced) }}

{{ __('Bounced') }}

{{ number_format($failed) }}

{{ __('Failed') }}

{{-- Recent Bounces --}}

{{ __('Recent Bounced Messages') }}

{{ __('Last') }} {{ $recentBounces->count() }} {{ __('bounced emails') }}

@if($recentBounces->count() > 0)
@foreach($recentBounces as $msg) @endforeach
{{ __('ID') }} {{ __('Subject') }} {{ __('Error') }} {{ __('Date') }}
#{{ $msg->id }} {{ $msg->subject ?? __('(no subject)') }} {{ $msg->delivery_error ?? __('Unknown error') }} {{ $msg->created_at?->format('M j, Y H:i') ?? '--' }}
@else

{{ __('No bounced messages found.') }}

@endif
@endif