{{-- Header --}}

{{ __('AI Performance') }}

{{ __('Track AI reply accuracy, confidence, and cost') }}

{{-- Date range selector --}}
@foreach(['today' => __('Today'), '7d' => __('7 days'), '30d' => __('30 days'), '90d' => __('90 days')] as $key => $label) @endforeach
{{-- Summary Cards --}}

{{ __('AI Replies Sent') }}

{{ number_format($aiRepliesSent) }}

{{ __('Accuracy') }}

{{ $accuracy }}%

{{ __('Avg Confidence') }}

{{ $avgConfidence }}%

{{ __('Escalation Rate') }}

{{ $escalationRate }}%

{{ __('Total Cost') }}

@currency($totalCost)

{{-- Topic Performance --}}

{{ __('Performance by Topic') }}

{{ __('AI accuracy grouped by conversation tags') }}

@if($topicPerformance->count() > 0)
@foreach($topicPerformance as $topic) @endforeach
{{ __('Topic') }} {{ __('Replies') }} {{ __('Accuracy') }} {{ __('Confidence') }}
{{ $topic['topic'] }} {{ $topic['total'] }}
{{ $topic['accuracy'] }}%
{{ $topic['avg_confidence'] }}%
@else
{{ __('No AI topic data available for this period.') }}
@endif
{{-- KB Gaps --}}

{{ __('Knowledge Base Gaps') }}

{{ __('Queries where AI confidence was below 50%') }}

@if($kbGaps->count() > 0)
@foreach($kbGaps as $gap)

{{ $gap['subject'] }}

{{ $gap['confidence'] }}% {{ __('confidence') }}

{{ $gap['date'] }}

@endforeach
@else
{{ __('No low-confidence queries found. AI is performing well.') }}
@endif
{{-- Cost Breakdown --}}

{{ __('Cost Breakdown by Provider & Model') }}

@if($costBreakdown->count() > 0)
@foreach($costBreakdown as $row) @endforeach
{{ __('Provider') }} {{ __('Model') }} {{ __('Requests') }} {{ __('Tokens In') }} {{ __('Tokens Out') }} {{ __('Total Cost') }}
{{ ucfirst($row->ai_provider ?? 'Unknown') }} {{ $row->ai_model ?? '--' }} {{ number_format($row->count) }} {{ number_format($row->total_tokens_in ?? 0) }} {{ number_format($row->total_tokens_out ?? 0) }} @currency($row->total_cost)
@else
{{ __('No AI cost data recorded for this period.') }}
@endif