@php $insights = is_array($insightCards ?? null) ? array_values(array_filter($insightCards, fn ($c) => is_array($c))) : []; $typeStyles = ['warning' => 'border-warning/20 bg-warning/5', 'success' => 'border-primary/20 bg-primary/5', 'info' => 'border-info/20 bg-info/5']; $iconStyles = ['warning' => 'text-warning bg-warning/10', 'success' => 'text-primary bg-primary/10', 'info' => 'text-info bg-info/10']; $warningInsights = collect($insights)->where('type', 'warning')->values()->all(); $successInsights = collect($insights)->where('type', 'success')->values()->all(); $infoInsights = collect($insights)->where('type', 'info')->values()->all(); $priorityActions = collect($insights) ->filter(fn ($ins) => in_array(($ins['type'] ?? 'info'), ['warning', 'info'], true)) ->take(3) ->values() ->all(); $health = is_array($health ?? null) ? $health : ['show' => false]; $score = $health['score'] ?? null; $dash = $score !== null ? min(100, max(0, (int) $score)) * 2.64 : 0; @endphp
@if (! ($health['show'] ?? false))

{{ __('budgets.insights_page.health_empty_title') }}

{{ __('budgets.insights_page.health_empty_body') }}

@else
{{ $score }}

{{ __('budgets.insights_page.health_title_live') }}

{{ __('budgets.insights_page.health_body_live') }}

{{ $health['savingsPct'] !== null ? number_format((float) $health['savingsPct'], 0).'%' : __('budgets.insights_page.metric_na') }}

{{ __('budgets.insights_page.metric_savings') }}

{{ $health['debtIncomePct'] !== null ? number_format((float) $health['debtIncomePct'], 0).'%' : __('budgets.insights_page.metric_na') }}

{{ __('budgets.insights_page.metric_debt_income') }}

@if (($health['subLoadLabelKey'] ?? null) !== null) {{ __('budgets.insights_page.metric_sub_load_'.$health['subLoadLabelKey']) }} @else {{ __('budgets.insights_page.metric_na') }} @endif

{{ __('budgets.insights_page.metric_sub_load_label') }}

@endif

{{ __('budgets.insights_page.priority_actions') }}

{{ count($priorityActions) }} {{ __('budgets.insights_page.priority_actions_count_suffix') }}
@if (count($priorityActions) === 0)

{{ __('budgets.insights_page.cards_empty_hint') }}

@else
@foreach ($priorityActions as $index => $ins) @php $t = $ins['type'] ?? 'info'; @endphp

{{ __('budgets.insights_page.action_prefix', ['number' => $index + 1]) }} ยท {{ $ins['title'] ?? '' }}

{{ $ins['text'] ?? '' }}

@endforeach
@endif
@if (count($insights) === 0)

{{ __('budgets.insights_page.cards_empty_title') }}

{{ __('budgets.insights_page.cards_empty_hint') }}

@else

{{ __('budgets.insights_page.section_watch') }}

@foreach ($warningInsights as $ins)

{{ $ins['title'] ?? '' }}

{{ $ins['text'] ?? '' }}

@endforeach

{{ __('budgets.insights_page.section_wins') }}

@foreach ($successInsights as $ins)

{{ $ins['title'] ?? '' }}

{{ $ins['text'] ?? '' }}

@endforeach

{{ __('budgets.insights_page.section_focus') }}

@foreach ($infoInsights as $ins)

{{ $ins['title'] ?? '' }}

{{ $ins['text'] ?? '' }}

@endforeach
@endif