{{-- ═══════════════════════════════════════════════ STAT CARDS — ROW 1 ═══════════════════════════════════════════════ --}} @php $statCards = [ ['label' => __('Total Users'), 'value' => number_format($totalUsers), 'sub' => number_format($activeUsers) . ' ' . __('Active'), 'badge' => ($userGrowth > 0 ? '+' : '') . $userGrowth . '%', 'badgeClass' => $userGrowth >= 0 ? 'badge-success' : 'badge-error', 'icon' => '', 'color' => 'text-blue-600', 'bg' => 'bg-blue-50 dark:bg-blue-900/20'], ['label' => __('Workspaces'), 'value' => number_format($totalWorkspaces ?? 0), 'sub' => __('Across all users'), 'badge' => null, 'icon' => '', 'color' => 'text-purple-600', 'bg' => 'bg-purple-50 dark:bg-purple-900/20'], ['label' => __('Active Subscriptions'), 'value' => number_format($payingUsers), 'sub' => number_format($totalUsers > 0 ? ($payingUsers / $totalUsers) * 100 : 0, 1) . '% ' . __('conversion'), 'badge' => __('Active'), 'badgeClass' => 'badge-primary', 'icon' => '', 'color' => 'text-emerald-600', 'bg' => 'bg-emerald-50 dark:bg-emerald-900/20'], ['label' => __('Open Tickets'), 'value' => number_format($openTicketsCount), 'sub' => __('Support queue'), 'badge' => $openTicketsCount > 0 ? $openTicketsCount . ' ' . __('Open') : __('Clear'), 'badgeClass' => $openTicketsCount > 0 ? 'badge-warning' : 'badge-success', 'icon' => '', 'color' => 'text-amber-600', 'bg' => 'bg-amber-50 dark:bg-amber-900/20'], ['label' => __('Total Revenue'), 'value' => \App\Helpers\CurrencyHelper::display($mrr * 12), 'sub' => __('All time'), 'badge' => null, 'icon' => '', 'color' => 'text-green-600', 'bg' => 'bg-green-50 dark:bg-green-900/20'], ['label' => __('This Month'), 'value' => \App\Helpers\CurrencyHelper::display($revenueThisMonth), 'sub' => __('Last') . ': ' . \App\Helpers\CurrencyHelper::display($revenueLastMonth), 'badge' => ($revenueGrowth > 0 ? '+' : '') . $revenueGrowth . '%', 'badgeClass' => $revenueGrowth >= 0 ? 'badge-success' : 'badge-error', 'icon' => '', 'color' => 'text-indigo-600', 'bg' => 'bg-indigo-50 dark:bg-indigo-900/20'], ['label' => __('Payments'), 'value' => number_format($recentPayments->count()), 'sub' => __('Processed'), 'badge' => null, 'icon' => '', 'color' => 'text-cyan-600', 'bg' => 'bg-cyan-50 dark:bg-cyan-900/20'], ['label' => __('AI Replies'), 'value' => number_format($aiUsageThisMonth->total_requests ?? 0), 'sub' => \App\Helpers\CurrencyHelper::display($aiUsageThisMonth->total_cost ?? 0) . ' ' . __('cost'), 'badge' => 'MTD', 'badgeClass' => 'badge-primary', 'icon' => '', 'color' => 'text-violet-600', 'bg' => 'bg-violet-50 dark:bg-violet-900/20'], ]; @endphp
@foreach(array_slice($statCards, 0, 4) as $card)
{!! $card['icon'] !!}
@if($card['badge'] ?? null) {{ $card['badge'] }} @endif

{{ $card['value'] }}

{{ $card['label'] }} · {{ $card['sub'] }}

@endforeach
@foreach(array_slice($statCards, 4) as $card)
{!! $card['icon'] !!}
@if($card['badge'] ?? null) {{ $card['badge'] }} @endif

{{ $card['value'] }}

{{ $card['label'] }} · {{ $card['sub'] }}

@endforeach
{{-- ═══════════════════════════════════════════════ CHARTS ═══════════════════════════════════════════════ --}}
{{-- Revenue Area Chart --}}

{{ __('Revenue Trend') }}

{{ __('Last 6 months performance') }}

@currency($arr)

{{ __('Projected ARR') }}

{{-- Plan Distribution Doughnut --}}

{{ __('Plan Distribution') }}

{{ __('Active subscription breakdown') }}

@if($planDistribution->isEmpty())

{{ __('No active subscriptions.') }}

@else
{{ number_format($planDistribution->sum()) }} {{ __('Active') }}
{{-- Plan breakdown --}}
@php $planColorsMap = [ 'Free' => 'bg-gray-400', 'Starter' => 'bg-blue-500', 'Pro' => 'bg-purple-500', 'Enterprise' => 'bg-amber-500', ]; @endphp @foreach($planDistribution as $plan => $count) @php $c = $planColorsMap[$plan] ?? 'bg-brand'; @endphp {{ $plan }} ({{ $count }}) @endforeach
@endif
{{-- ═══════════════════════════════════════════════ RECENT USERS TABLE ═══════════════════════════════════════════════ --}}

{{ __('Recent Users') }}

{{ __('View All') }}
@if($recentUsers->isEmpty())

{{ __('No users found.') }}

@else @php $avatarColors = ['#6366f1','#8b5cf6','#ec4899','#f43f5e','#f97316','#eab308','#22c55e','#14b8a6','#06b6d4','#3b82f6','#6d28d9','#db2777']; @endphp @foreach($recentUsers->take(8) as $user) @php $color = $avatarColors[crc32($user->name) % count($avatarColors)]; $planBadge = match($user->currentPlan->name ?? 'Free') { 'Free' => 'bg-gray-100 text-gray-600 dark:bg-gray-700/40 dark:text-gray-300', 'Starter' => 'bg-blue-50 text-blue-600 dark:bg-blue-500/10 dark:text-blue-400', 'Pro' => 'bg-purple-50 text-purple-600 dark:bg-purple-500/10 dark:text-purple-400', 'Enterprise' => 'bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-400', default => 'bg-gray-100 text-gray-600 dark:bg-gray-700/40 dark:text-gray-300', }; $statusDot = match($user->status) { 'active' => 'bg-emerald-500', 'suspended' => 'bg-red-500', 'pending_deletion' => 'bg-amber-500', default => 'bg-gray-500', }; @endphp @endforeach
{{ __('User') }} {{ __('Plan') }} {{ __('Status') }} {{ __('Joined') }}
{{ strtoupper(substr($user->name, 0, 1)) }}{{ strtoupper(substr(strstr($user->name . ' ', ' '), 1, 1)) }}
{{ $user->name }}

{{ $user->email }}

{{ $user->currentPlan->name ?? 'Free' }} {{ $user->status }} {{ \Carbon\Carbon::parse($user->created_at)->diffForHumans() }}
@endif
{{-- ═══════════════════════════════════════════════ RECENT PAYMENTS TABLE ═══════════════════════════════════════════════ --}}

{{ __('Recent Payments') }}

{{ __('Show More') }}
@if($recentPayments->isEmpty())

{{ __('No payments recorded.') }}

@else @foreach($recentPayments->take(6) as $payment) @php $paymentBadge = match($payment->status) { 'succeeded' => 'bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400', 'failed' => 'bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400', 'pending' => 'bg-amber-50 text-amber-600 dark:bg-amber-500/10 dark:text-amber-400', 'refunded' => 'bg-gray-100 text-gray-600 dark:bg-gray-700/40 dark:text-gray-300', default => 'bg-gray-100 text-gray-600 dark:bg-gray-700/40 dark:text-gray-300', }; @endphp @endforeach
{{ __('Invoice') }} {{ __('User') }} {{ __('Amount') }} {{ __('Status') }} {{ __('Date') }}
#{{ $payment->id }} {{ $payment->workspace?->name ?? __('Deleted Workspace') }} @currency($payment->amount) {{ ucfirst($payment->status) }} {{ \Carbon\Carbon::parse($payment->created_at)->format('M j, Y') }}
@endif
{{-- ═══════════════════════════════════════════════ ACTION CARDS — System Health, Pending Tickets, Updates ═══════════════════════════════════════════════ --}}
{{-- System Health --}}

{{ __('System Health') }}

@if(($systemSnapshot['failed_jobs'] ?? 0) == 0) @else @endif

{{ ($systemSnapshot['failed_jobs'] ?? 0) == 0 ? __('All systems operational') : __(':count failed jobs detected', ['count' => $systemSnapshot['failed_jobs'] ?? 0]) }}

{{ __('View Status') }}
{{-- Pending Tickets --}}

{{ __('Pending Tickets') }}

{{ $openTicketsCount ?? 0 }}

{{ __('Support tickets awaiting response') }}

{{ __('Review Tickets') }}
{{-- App Info / Updates --}}

{{ __('App Version') }}

v{{ app()->version() }}

{{ __('SaaS Core System Version') }}

{{ __('View Details') }}
{{-- ═══════════════════════════════════════════════ CHART.JS INITIALIZATION ═══════════════════════════════════════════════ --}}