@extends('layouts.admin') @section('title', ($country->name ?? 'Country') . ' — Risk Score') @section('page_title', ($country->name ?? 'Country') . ' — Risk Score') @section('content') {{-- ── Back ─────────────────────────────────────────────────────── --}}
← Back to Risk Scores
{{-- ── Hero card ────────────────────────────────────────────────── --}}
@if($country->flag_url) {{ $country->name }} flag @endif

{{ $country->name }}

{{ $country->iso2 }} / {{ $country->iso3 }} @if($latest) @include('partials.risk-badge', ['level' => $latest->risk_level]) @endif

{{ $country->region }}{{ $country->subregion ? ' · ' . $country->subregion : '' }} @if($country->capital) · 🏛 {{ $country->capital }} @endif

@if($latest)

{{ number_format($latest->total_score, 1) }}

Total Risk Score

Calculated {{ $latest->calculated_at?->diffForHumans() }}

@endif {{-- Recalculate button --}}
@csrf
@if($latest) {{-- ── Score breakdown ─────────────────────────────────────────── --}}
@php $components = [ ['label' => 'Currency', 'icon' => '💱', 'score' => $latest->currency_score, 'color' => 'sky'], ['label' => 'Weather', 'icon' => '🌩', 'score' => $latest->weather_score, 'color' => 'amber'], ['label' => 'Disaster', 'icon' => '🌋', 'score' => $latest->disaster_score, 'color' => 'orange'], ['label' => 'Political', 'icon' => '🏛', 'score' => $latest->political_score, 'color' => 'purple'], ['label' => 'Economy', 'icon' => '📈', 'score' => $latest->economy_score, 'color' => 'emerald'], ['label' => 'Inflation', 'icon' => '💸', 'score' => $latest->inflation_score, 'color' => 'yellow'], ['label' => 'Port', 'icon' => '⚓', 'score' => $latest->port_score, 'color' => 'blue'], ['label' => 'Supply Chain','icon'=> '🔗', 'score' => $latest->supply_chain_score, 'color' => 'teal'], ]; $colorMap = [ 'sky' => ['bar' => 'bg-sky-500', 'text' => 'text-sky-400'], 'amber' => ['bar' => 'bg-amber-500', 'text' => 'text-amber-400'], 'orange' => ['bar' => 'bg-orange-500', 'text' => 'text-orange-400'], 'purple' => ['bar' => 'bg-purple-500', 'text' => 'text-purple-400'], 'emerald' => ['bar' => 'bg-emerald-500', 'text' => 'text-emerald-400'], 'yellow' => ['bar' => 'bg-yellow-500', 'text' => 'text-yellow-400'], 'blue' => ['bar' => 'bg-blue-500', 'text' => 'text-blue-400'], 'teal' => ['bar' => 'bg-teal-500', 'text' => 'text-teal-400'], ]; @endphp @foreach($components as $c) @php $val = (float) ($c['score'] ?? 0); $cls = $colorMap[$c['color']]; @endphp
{{ $c['icon'] }} {{ $c['label'] }}
{{ number_format($val, 1) }}
@endforeach
{{-- ── Recommendation ───────────────────────────────────────────── --}} @if($latest->recommendation)
💡

Recommendation

{{ $latest->recommendation }}

@endif @else
No risk score calculated yet for {{ $country->name }}. Use the Recalculate button above to generate one.
@endif {{-- ── Score History ────────────────────────────────────────────── --}} @if($history->isNotEmpty())

Score History

@foreach($history as $h) @endforeach
Calculated Total Currency Weather Disaster Political Level
{{ $h->calculated_at?->format('Y-m-d H:i') }} @if($loop->first) ← latest @endif {{ number_format($h->total_score, 1) }} {{ number_format($h->currency_score ?? 0, 1) }} {{ number_format($h->weather_score ?? 0, 1) }} {{ number_format($h->disaster_score ?? 0, 1) }} {{ number_format($h->political_score ?? 0, 1) }} @include('partials.risk-badge', ['level' => $h->risk_level])
@endif @endsection