{{-- Header with date range --}}

{{ __('Analytics') }}

{{ __('Monitor performance metrics across your workspace') }}

{{-- Date range selector --}}
@foreach(['today' => __('Today'), '7d' => __('7 days'), '30d' => __('30 days'), '90d' => __('90 days')] as $key => $label) @endforeach
{{-- Summary stat cards with gradients & sparklines --}}
@php $summaryCards = [ ['label' => __('Total Conversations'), 'value' => number_format($totalConversations), 'icon' => 'inbox', 'gradient' => 'from-blue-500/10 to-indigo-500/10', 'icon_bg' => 'bg-blue-500/15', 'icon_color' => 'text-blue-400', 'bar_color' => 'bg-blue-500/30'], ['label' => __('New Conversations'), 'value' => number_format($newConversations), 'icon' => 'plus-circle', 'gradient' => 'from-green-500/10 to-emerald-500/10', 'icon_bg' => 'bg-green-500/15', 'icon_color' => 'text-green-400', 'bar_color' => 'bg-green-500/30'], ['label' => __('Resolved'), 'value' => number_format($resolvedConversations), 'icon' => 'check-circle', 'gradient' => 'from-emerald-500/10 to-teal-500/10', 'icon_bg' => 'bg-emerald-500/15', 'icon_color' => 'text-emerald-400', 'bar_color' => 'bg-emerald-500/30'], ['label' => __('Avg First Response'), 'value' => $avgFirstResponse, 'icon' => 'clock', 'gradient' => 'from-amber-500/10 to-orange-500/10', 'icon_bg' => 'bg-amber-500/15', 'icon_color' => 'text-amber-400', 'bar_color' => 'bg-amber-500/30'], ['label' => __('Avg Resolution'), 'value' => $avgResolution, 'icon' => 'trending-down', 'gradient' => 'from-purple-500/10 to-violet-500/10', 'icon_bg' => 'bg-purple-500/15', 'icon_color' => 'text-purple-400', 'bar_color' => 'bg-purple-500/30'], ['label' => __('CSAT Score'), 'value' => $csatScore, 'icon' => 'star', 'gradient' => 'from-yellow-500/10 to-amber-500/10', 'icon_bg' => 'bg-yellow-500/15', 'icon_color' => 'text-yellow-400', 'bar_color' => 'bg-yellow-500/30'], ]; @endphp @foreach($summaryCards as $stat)
@switch($stat['icon']) @case('inbox') @break @case('plus-circle') @break @case('check-circle') @break @case('clock') @break @case('trending-down') @break @case('star') @break @endswitch

{{ $stat['value'] }}

{{ $stat['label'] }}

{{-- Mini sparkline bars --}}
@for($i = 0; $i < 8; $i++) @php $h = rand(20, 100); @endphp
@endfor
@endforeach
{{-- Charts row --}}
{{-- Channel Breakdown --}}

{{ __('Channel Breakdown') }}

@if($channelData->count() > 0)
@foreach($channelData as $ch)
{{ $ch['name'] }}
{{ $ch['pct'] }}% ({{ number_format($ch['count']) }})
@endforeach
@else

{{ __('No data for this period') }}

@endif
{{-- Response by Type --}}

{{ __('Messages by Sender Type') }}

@if($senderData->count() > 0)
@foreach($senderData as $s)
{{ $s['name'] }}
{{ $s['pct'] }}% ({{ number_format($s['count']) }})
@endforeach
@else

{{ __('No data for this period') }}

@endif
{{-- Recent Activity --}}

{{ __('Recent Activity') }}

@if($recentActivity->count() > 0)
@foreach($recentActivity as $activity) @php $activityIcon = match(true) { str_contains(strtolower($activity['event'] ?? ''), 'resolved') || str_contains(strtolower($activity['event'] ?? ''), 'closed') => ['bg' => 'bg-success/15', 'color' => 'text-success', 'icon' => ''], str_contains(strtolower($activity['event'] ?? ''), 'new') || str_contains(strtolower($activity['event'] ?? ''), 'created') => ['bg' => 'bg-info/15', 'color' => 'text-blue-600', 'icon' => ''], str_contains(strtolower($activity['event'] ?? ''), 'ai') || str_contains(strtolower($activity['event'] ?? ''), 'auto') => ['bg' => 'bg-brand/15', 'color' => 'text-purple-600', 'icon' => ''], str_contains(strtolower($activity['event'] ?? ''), 'assign') => ['bg' => 'bg-warning/15', 'color' => 'text-amber-600', 'icon' => ''], default => ['bg' => 'bg-surface ', 'color' => 'text-muted', 'icon' => ''], }; @endphp
@safeSvg($activityIcon['icon'])

{{ $activity['actor'] }} {{ $activity['event'] }} @if($activity['type']) {{ __('on') }} {{ $activity['type'] }} @endif

{{ $activity['time'] }}

@endforeach
@else

{{ __('No recent activity found.') }}

@endif