@php
    $c = config('theme.colors');
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('admin.title'), 'url' => route('admin.dashboard')],
        ['label' => __('operations.business_metrics_title')],
    ];
@endphp

<x-ui.layout.page
    :title="__('operations.business_metrics_title')"
    :subtitle="__('operations.business_metrics_subtitle')"
    page-icon="fe fe-bar-chart-2"
    :breadcrumbs="$breadcrumbs"
>
    <div class="row row-cards">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header"><h3 class="card-title" style="color: {{ $c['text'] }}">Tenants</h3></div>
                <div class="card-body">
                    <p>Active: <strong>{{ (int) ($metrics['tenants_active'] ?? 0) }}</strong></p>
                    <ul class="mb-0 small">
                        @foreach ($metrics['tenants_by_lifecycle'] ?? [] as $k => $v)
                            <li><code>{{ $k }}</code>: {{ (int) $v }}</li>
                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card">
                <div class="card-header"><h3 class="card-title" style="color: {{ $c['text'] }}">Subscriptions</h3></div>
                <div class="card-body">
                    <ul class="mb-0 small">
                        @foreach ($metrics['subscriptions_by_status'] ?? [] as $k => $v)
                            <li><code>{{ $k }}</code>: {{ (int) $v }}</li>
                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-12">
            <div class="card">
                <div class="card-header"><h3 class="card-title" style="color: {{ $c['text'] }}">Volume (24h)</h3></div>
                <div class="card-body">
                    <span class="me-4">Exports: <strong>{{ (int) ($metrics['exports_last_24h'] ?? 0) }}</strong></span>
                    <span class="me-4">Webhook failures: <strong>{{ (int) ($metrics['webhook_failures_last_24h'] ?? 0) }}</strong></span>
                    <span>API audit rows: <strong>{{ (int) ($metrics['api_audit_events_last_24h'] ?? 0) }}</strong></span>
                </div>
            </div>
        </div>
    </div>
</x-ui.layout.page>
