{{-- Flash messages --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- ── Header ─────────────────────────────────────────────────── --}}
{{-- Top row: title + pipeline selector + add deal --}}

{{ __('Deals') }}

@if($totalValue > 0) @currency($totalValue) {{ __('total pipeline value') }} @else {{ __('Manage your sales pipeline') }} @endif

{{-- Pipeline selector --}}
{{-- Status filter tabs --}}
@php $filters = [ 'open' => ['label' => __('Open'), 'count' => $statusCounts->open_count ?? 0], 'won' => ['label' => __('Won'), 'count' => $statusCounts->won_count ?? 0], 'lost' => ['label' => __('Lost'), 'count' => $statusCounts->lost_count ?? 0], 'all' => ['label' => __('All'), 'count' => $statusCounts->total ?? 0], ]; @endphp @foreach($filters as $filterKey => $filter) @endforeach
{{-- ── Revenue Forecast Bar ──────────────────────────────────── --}} @if($stages->isNotEmpty())
{{ __('Pipeline Value') }}

@currency($pipelineForecast['total'])

{{ __('Weighted Forecast') }}

@currency($pipelineForecast['weighted'])

{{ __('Open Deals') }}

{{ $pipelineForecast['open_deals'] }}

@endif {{-- ── Stage summary ──────────────────────────────────────────── --}}
@foreach($stages as $stage) @php $stageDeals = $deals->get($stage->id, collect()); $stageTotal = $stageDeals->sum('value'); $stageCount = $stageDeals->count(); @endphp
{{ $stage->name }}

@currency($stageTotal)

{{ $stageCount }} {{ $stageCount === 1 ? __('deal') : __('deals') }}

@endforeach
{{-- ── Mobile: Stacked list view ──────────────────────────────── --}}
{{-- Status filter is already shown above --}} @foreach($stages as $stage) @php $stageDeals = $deals->get($stage->id, collect()); @endphp

{{ $stage->name }}

{{ $stageDeals->count() }}
@currency($stageDeals->sum('value'))
@forelse($stageDeals as $deal)
@if($deal->status === 'won') @elseif($deal->status === 'lost') @endif

{{ $deal->title }}

{{ $deal->contact?->company ?? $deal->contact?->full_name ?? __('No contact') }}

@currency($deal->value)

@if($deal->expected_close_date) @php $dl = intval(now()->diffInDays($deal->expected_close_date, false)); @endphp

{{ $dl < 0 ? abs($dl).'d overdue' : ($dl === 0 ? 'Today' : $dl.'d left') }}

@endif
@empty

{{ __('No deals in this stage') }}

@endforelse
{{-- Add deal to stage (mobile) --}}
@endforeach
{{-- Deal move loading indicator --}}
{{ __('Moving deal...') }}
{{-- ── Desktop: Kanban board with drag & drop ────────────────── --}} @if($stages->isEmpty()) @endif {{-- ── Pipeline Create Modal ──────────────────────────────────── --}} @if($showPipelineForm) @endif {{-- ── Deal Form Modal ────────────────────────────────────────── --}} @if($showDealForm) @endif