@extends('layouts.app', ['title' => 'Admin Reports | Print Cards'])

@section('content')
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h1 class="h3 mb-1">Reports</h1>
            <p class="text-muted mb-0">Operational and revenue analytics for the card-printing platform.</p>
        </div>
        <a href="{{ route('admin.dashboard') }}" class="btn btn-outline-secondary">Back to Dashboard</a>
    </div>

    <div class="row g-4 mb-4">
        <div class="col-md-3"><div class="card card-soft h-100"><div class="card-body"><div class="text-muted small">Orders</div><div class="metric-number">{{ $summary['orders'] }}</div></div></div></div>
        <div class="col-md-3"><div class="card card-soft h-100"><div class="card-body"><div class="text-muted small">Customers</div><div class="metric-number">{{ $summary['customers'] }}</div></div></div></div>
        <div class="col-md-3"><div class="card card-soft h-100"><div class="card-body"><div class="text-muted small">Paid Revenue</div><div class="metric-number">Rs {{ number_format($summary['paid_revenue'], 2) }}</div></div></div></div>
        <div class="col-md-3"><div class="card card-soft h-100"><div class="card-body"><div class="text-muted small">Avg Order Value</div><div class="metric-number">Rs {{ number_format($summary['avg_order_value'], 2) }}</div></div></div></div>
    </div>

    <div class="row g-4">
        <div class="col-lg-6">
            <div class="card card-soft">
                <div class="card-body">
                    <h2 class="h5 mb-3">Order Status Breakdown</h2>
                    @foreach($statusCounts as $status => $count)
                        <div class="d-flex justify-content-between py-2 border-bottom">
                            <span>{{ ucfirst($status) }}</span>
                            <strong>{{ $count }}</strong>
                        </div>
                    @endforeach
                </div>
            </div>
        </div>
        <div class="col-lg-6">
            <div class="card card-soft">
                <div class="card-body">
                    <h2 class="h5 mb-3">Payment Status Breakdown</h2>
                    @foreach($paymentCounts as $status => $count)
                        <div class="d-flex justify-content-between py-2 border-bottom">
                            <span>{{ ucfirst($status) }}</span>
                            <strong>{{ $count }}</strong>
                        </div>
                    @endforeach
                </div>
            </div>
        </div>
    </div>

    <div class="card card-soft mt-4">
        <div class="card-body">
            <h2 class="h5 mb-3">Recent Notifications</h2>
            <div class="table-responsive">
                <table class="table align-middle">
                    <thead>
                        <tr>
                            <th>Channel</th>
                            <th>Recipient</th>
                            <th>Subject</th>
                            <th>Sent At</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($recentNotifications as $notification)
                            <tr>
                                <td>{{ $notification->channel }}</td>
                                <td>{{ $notification->recipient }}</td>
                                <td>{{ $notification->subject }}</td>
                                <td>{{ $notification->sent_at?->format('d M Y h:i A') }}</td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection
