@extends('layouts.admin')

@section('title', 'Dashboard')
@section('heading', 'Dashboard')

@section('content')
<div class="kpis">
    <div class="kpi"><span>Shipments</span><b>{{ $shipmentCount }}</b></div>
    <div class="kpi"><span>In transit</span><b>{{ $inTransit }}</b></div>
    <div class="kpi"><span>Delivered</span><b>{{ $delivered }}</b></div>
    <div class="kpi"><span>Unread messages</span><b>{{ $unreadMessages }}</b></div>
</div>

<div class="grid-2">
    <div class="panel">
        <h3>Recent shipments</h3>
        <table>
            <thead><tr><th>Tracking</th><th>Status</th><th>Route</th></tr></thead>
            <tbody>
                @forelse($recentShipments as $shipment)
                    <tr>
                        <td><a href="{{ route('admin.shipments.show', $shipment) }}">{{ $shipment->tracking_number }}</a></td>
                        <td><span class="badge {{ $shipment->status }}">{{ $shipment->statusLabel() }}</span></td>
                        <td>{{ $shipment->origin_city }} → {{ $shipment->destination_city }}</td>
                    </tr>
                @empty
                    <tr><td colspan="3">No shipments yet.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
    <div class="panel">
        <h3>Latest messages</h3>
        @forelse($recentMessages as $message)
            <p><a href="{{ route('admin.messages.show', $message) }}"><strong>{{ $message->name }}</strong></a> — {{ $message->subject ?: 'No subject' }}</p>
        @empty
            <p>No messages yet.</p>
        @endforelse
    </div>
</div>
@endsection
