@extends('layouts.app')
@section('title', 'Dashboard — No Lead Left Behind')
@section('content')
{{-- ═══════════════════════════════════════════════════════════════
PAGE HEADER — Greeting + Attention Summary
═══════════════════════════════════════════════════════════════ --}}
{{ $greeting }}.
@if($summary['attention_count'] > 0)
{{ $summary['attention_count'] }} lead{{ $summary['attention_count'] !== 1 ? 's' : '' }} need{{ $summary['attention_count'] === 1 ? 's' : '' }} attention
— review your action items below.
@else
You're all caught up. No leads need attention right now.
@endif
{{-- Onboarding Checklist --}}
@include('dashboard.partials.onboarding_checklist')
{{-- ═══════════════════════════════════════════════════════════════
KPI STRIP
═══════════════════════════════════════════════════════════════ --}}
@php
$kpis = [
['label' => 'New Leads', 'value' => $summary['new_leads'], 'color' => 'text-blue-600', 'bg' => 'bg-blue-50', 'icon' => 'M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z'],
['label' => 'Needs Response', 'value' => $summary['needs_response'], 'color' => $summary['needs_response'] > 0 ? 'text-red-600' : 'text-slate-400', 'bg' => $summary['needs_response'] > 0 ? 'bg-red-50' : 'bg-slate-50', 'icon' => 'M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z'],
['label' => 'Follow-ups Due', 'value' => $summary['followups_due'], 'color' => $summary['followups_due'] > 0 ? 'text-amber-600' : 'text-slate-400', 'bg' => $summary['followups_due'] > 0 ? 'bg-amber-50' : 'bg-slate-50', 'icon' => 'M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z'],
['label' => 'Hot Leads', 'value' => $summary['hot_leads'], 'color' => 'text-orange-600', 'bg' => 'bg-orange-50', 'icon' => 'M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c0-2 .5-5 2.986-7C14 5 16.09 5.777 17.656 7.343A7.975 7.975 0 0120 13a7.975 7.975 0 01-2.343 5.657z'],
['label' => 'Won', 'value' => $summary['won_leads'], 'color' => 'text-emerald-600', 'bg' => 'bg-emerald-50', 'icon' => 'M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'],
['label' => 'Automation Failed', 'value' => $summary['automation_failed'], 'color' => $summary['automation_failed'] > 0 ? 'text-red-600' : 'text-slate-400', 'bg' => $summary['automation_failed'] > 0 ? 'bg-red-50' : 'bg-slate-50', 'icon' => 'M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z'],
];
@endphp
@foreach($kpis as $kpi)
{{ number_format($kpi['value']) }}
{{ $kpi['label'] }}
@endforeach
{{-- Secondary KPIs Row --}}
Conversion Rate
{{ $summary['conversion_rate'] !== null ? $summary['conversion_rate'] . '%' : '—' }}
Won ÷ (Won + Lost)
Revenue Attributed
@if($summary['revenue_attributed'] > 0)
{{ \App\Domains\Core\Services\CurrencyService::format($summary['revenue_attributed'], auth()->user()->currentWorkspace->currency ?? 'USD') }}
@else
—
@endif
From won leads with deal value
Recovered Leads
{{ $summary['recovered_leads'] }}
Re-engaged after going stale
Lost Leads
{{ $summary['lost_leads'] }}
During this period
{{-- ═══════════════════════════════════════════════════════════════
ATTENTION CENTER
═══════════════════════════════════════════════════════════════ --}}
@if($attentionItems->isEmpty())
All caught up!
No leads need attention right now. Check back after your next enquiry arrives.
@else
{{-- Critical Items First --}}
@foreach($groupedAttention['critical'] as $item)
@include('dashboard.partials.attention-card', ['item' => $item, 'badgeClass' => 'bg-red-100 text-red-700 border border-red-200', 'badgeLabel' => 'CRITICAL'])
@endforeach
{{-- High Priority --}}
@foreach($groupedAttention['high'] as $item)
@include('dashboard.partials.attention-card', ['item' => $item, 'badgeClass' => 'bg-orange-100 text-orange-700 border border-orange-200', 'badgeLabel' => 'HIGH'])
@endforeach
{{-- Medium — show first 5 --}}
@foreach($groupedAttention['medium']->take(5) as $item)
@include('dashboard.partials.attention-card', ['item' => $item, 'badgeClass' => 'bg-amber-100 text-amber-700 border border-amber-200', 'badgeLabel' => 'MEDIUM'])
@endforeach
@if($groupedAttention['medium']->count() > 5)
+ {{ $groupedAttention['medium']->count() - 5 }} more items — view all leads
@endif
@endif
{{-- ═══════════════════════════════════════════════════════════════
PIPELINE SNAPSHOT + RECENT ACTIVITY (2-column on desktop)
═══════════════════════════════════════════════════════════════ --}}
{{-- Pipeline Snapshot --}}
@if(empty($pipelineSnapshot))
No pipeline stages found. Set up your pipeline to begin tracking leads.
@else
@endif
{{-- Recent Activity --}}
Recent Activity
@if($recentActivity->isEmpty())
No activity yet. Create your first lead to get started.
Add a lead →
@else
@foreach($recentActivity as $activity)
@php
$icons = [
'lead_created' => ['M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z', 'text-blue-500'],
'stage_changed' => ['M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4', 'text-indigo-500'],
'followup_sent' => ['M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z', 'text-emerald-500'],
'followup_failed' => ['M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z', 'text-red-500'],
'sequence_completed' => ['M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z', 'text-emerald-500'],
'lead_contacted' => ['M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z', 'text-blue-400'],
];
$iconData = $icons[$activity->event_type] ?? ['M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z', 'text-slate-400'];
@endphp
{{ $activity->description }}
@if($activity->lead)
{{ $activity->lead->full_name }}
@if($activity->created_at) · {{ $activity->created_at->diffForHumans() }}@endif
@endif
@endforeach
@endif
@endsection