{{-- Subtle loading indicator for wire:poll refreshes --}}
{{-- Welcome banner --}}

{{ __('Welcome back, :name', ['name' => auth()->user()->name ?? __('there')]) }}

{{ __("Here's what's happening with your workspace.") }}

{{-- Plan usage warning --}} @if($usagePercent >= 80)

{{ $usagePercent >= 100 ? __('AI reply limit reached') : __('Approaching AI reply limit') }}

{{ number_format($aiRepliesUsed) }} / {{ number_format($aiRepliesLimit) }} {{ __('AI replies used this month') }} ({{ $usagePercent }}%)

{{ __('Upgrade Plan') }}
@endif {{-- AI spending cap warning --}} @if($aiCostLimit > 0 && $aiCostPercent >= 80)

{{ $aiCostPercent >= 100 ? __('AI spending cap reached - auto-replies paused') : __('Approaching AI spending cap') }}

@currency($aiMonthlyCost) / @currency($aiCostLimit) spent this month ({{ $aiCostPercent }}%)

{{ __('Adjust Limit') }}
@endif {{-- Range filter: Today / 7d / 30d / All. wire:click hits setRange() on the Livewire component which validates the value and re-runs render() with new date-bounded queries. Cache keys include the range so flipping it doesn't serve stale numbers from another window. Spacing: was `-mb-2` (negative bottom margin) which pulled the chips down into the metric cards row — visible overlap on narrower viewports. Swapped to `mb-4` so there's a real gap and the chips stop colliding with the cards. --}}
@foreach([ 'today' => __('Today'), '7d' => __('7 days'), '30d' => __('30 days'), 'all' => __('All time'), ] as $key => $label) @endforeach
{{-- Stats Cards with gradients and per-metric sparklines. Each card now pulls its own bar series from $sparklines[] (was sharing one array across all four, so every card showed the same shape). --}}
@php $stats = [ ['spark_key' => 'conversations', 'label' => __('Total Conversations'), 'value' => number_format($conversationCount), 'period' => $rangeLabel, 'icon' => 'inbox', 'gradient' => 'from-blue-50 to-indigo-50', 'gradient_dark' => 'dark:from-blue-900/20 dark:to-indigo-900/20', 'icon_bg' => 'bg-info/15', 'icon_bg_dark' => 'dark:bg-blue-900/40', 'icon_color' => 'text-blue-600', 'icon_color_dark' => 'dark:text-blue-400', 'bar_color' => 'bg-blue-200', 'bar_color_dark' => 'dark:bg-blue-800/60'], ['spark_key' => 'ai_replies', 'label' => __('AI Replies Sent'), 'value' => number_format($aiRepliesCount), 'period' => $rangeLabel, 'icon' => 'brain', 'gradient' => 'from-purple-50 to-violet-50', 'gradient_dark' => 'dark:from-purple-900/20 dark:to-violet-900/20','icon_bg' => 'bg-brand/15', 'icon_bg_dark' => 'dark:bg-purple-900/40', 'icon_color' => 'text-purple-600', 'icon_color_dark' => 'dark:text-purple-400', 'bar_color' => 'bg-purple-200', 'bar_color_dark' => 'dark:bg-purple-800/60'], ['spark_key' => 'avg_time', 'label' => __('Avg Response Time'), 'value' => $avgResponseTimeDisplay, 'period' => __('average'), 'icon' => 'clock', 'gradient' => 'from-cyan-50 to-teal-50', 'gradient_dark' => 'dark:from-cyan-900/20 dark:to-teal-900/20', 'icon_bg' => 'bg-cyan-100', 'icon_bg_dark' => 'dark:bg-cyan-900/40', 'icon_color' => 'text-cyan-600', 'icon_color_dark' => 'dark:text-cyan-400', 'bar_color' => 'bg-cyan-200', 'bar_color_dark' => 'dark:bg-cyan-800/60'], ['spark_key' => 'contacts', 'label' => __('Total Contacts'), 'value' => number_format($contactCount), 'period' => $rangeLabel, 'icon' => 'message-square', 'gradient' => 'from-amber-50 to-orange-50', 'gradient_dark' => 'dark:from-amber-900/20 dark:to-orange-900/20', 'icon_bg' => 'bg-warning/15','icon_bg_dark' => 'dark:bg-amber-900/40', 'icon_color' => 'text-amber-600', 'icon_color_dark' => 'dark:text-amber-400', 'bar_color' => 'bg-amber-200', 'bar_color_dark' => 'dark:bg-amber-800/60'], ]; @endphp @foreach($stats as $stat)
{{ $stat['label'] }}
{{ $stat['value'] }}
{{ $stat['period'] }}
@foreach($sparklines[$stat['spark_key']] ?? [] as $h)
@endforeach
@endforeach
{{-- Campaign metrics row — only renders for workspaces that have at least one campaign (otherwise a transactional/inbox-only user would just see a wall of zeros). Filtered by the same range as the cards above. --}} @if($hasCampaigns)

{{ __('Campaign Performance') }}

{{ $rangeLabel }}

{{ __('View All') }}

{{ __('Emails Sent') }}

{{ number_format($campaignStats['sent_count']) }}

{{ __('Open Rate') }}

{{ $campaignStats['open_rate'] }}%

{{ number_format($campaignStats['opened_count']) }} {{ __('opens') }}

{{ __('Click Rate') }}

{{ $campaignStats['click_rate'] }}%

{{ number_format($campaignStats['clicked_count']) }} {{ __('clicks') }}

{{ __('Active') }}

{{ number_format($campaignStats['active_campaigns']) }}

{{ __('sending / scheduled') }}

@endif {{-- Unlock more features suggestions --}} @if(!$hasKbDocs || !$hasSentAiReply || !$hasChannels) @endif {{-- Setup Guide + Connect Channels --}} @php $steps = [ ['done' => $hasEmailAccount, 'title' => __('Connect your email account'), 'desc' => __('Link Gmail, Outlook, or other email providers'), 'href' => url('/settings/email'), 'icon' => 'mail', 'iconBg' => 'bg-danger/15 text-danger', 'iconBgDark' => 'dark:bg-red-900/40 dark:text-red-400'], ['done' => $hasAiConfig, 'title' => __('Add your AI provider key'), 'desc' => __('Connect OpenAI, Claude, or Gemini'), 'href' => url('/settings/ai'), 'icon' => 'sparkles', 'iconBg' => 'bg-brand/15 text-purple-600', 'iconBgDark' => 'dark:bg-purple-900/40 dark:text-purple-400'], ['done' => $hasSentAiReply, 'title' => __('Send your first AI reply'), 'desc' => __('Open a conversation and let AI draft a response'), 'href' => url('/inbox'), 'icon' => 'bot', 'iconBg' => 'bg-brand/15 text-brand', 'iconBgDark' => 'dark:bg-indigo-900/40 dark:text-indigo-400'], ['done' => $hasKbDocs ?? false, 'title' => __('Train knowledge base'), 'desc' => __('Upload docs or scrape website'), 'href' => url('/knowledge-base'), 'icon' => 'book-open', 'iconBg' => 'bg-warning/15 text-amber-600', 'iconBgDark' => 'dark:bg-amber-900/40 dark:text-amber-400'], ['done' => $hasChannels, 'title' => __('Connect more channels'), 'desc' => __('WhatsApp, SMS, Telegram, Slack'), 'href' => url('/settings/channels'), 'icon' => 'globe', 'iconBg' => 'bg-cyan-100 text-cyan-600', 'iconBgDark' => 'dark:bg-cyan-900/40 dark:text-cyan-400'], ['done' => $hasTeamMembers, 'title' => __('Invite your team'), 'desc' => __('Add users and assignment rules'), 'href' => url('/settings/team'), 'icon' => 'users', 'iconBg' => 'bg-info/15 text-blue-600', 'iconBgDark' => 'dark:bg-blue-900/40 dark:text-blue-400'], ]; $completedCount = collect($steps)->where('done', true)->count(); $totalSteps = count($steps); @endphp
{{-- Getting Started Checklist — hidden once every step is complete so a fully-onboarded workspace isn't permanently staring at a giant "6/6 done" panel. Connect Channels stretches full-width below in that case. --}} @if($completedCount < $totalSteps)

{{ __('Getting Started') }}

{{ __('Complete these steps to get the most out of :brand', ['brand' => \App\Helpers\BrandingHelper::name()]) }}

{{ $completedCount }}/{{ $totalSteps }}
{{-- Progress bar --}}
{{ __(':completed of :total completed', ['completed' => $completedCount, 'total' => $totalSteps]) }} {{ round(($completedCount / $totalSteps) * 100) }}%
@endif {{-- Connect Channels (spans full width when the Getting Started panel is hidden, so the grid doesn't leave a 2/3 empty slot). --}}

{{ __('Connect Channels') }}

{{ __('Set up your communication channels') }}

@php // `key` matches what's stored in channel_integrations.channel // (and, for Email, the EmailAccount existence flag we already // have). Used to flip the "+" to a green check on rows that // are already configured. $channels = [ ['key' => 'email', 'connected' => $hasEmailAccount, 'name' => __('Email'), 'icon' => 'mail', 'href' => url('/settings/email'), 'color' => 'text-red-500 dark:text-red-400', 'bg' => 'bg-danger/10 dark:bg-red-900/20', 'hover' => 'hover:border-danger/20 dark:hover:border-red-900 hover:bg-danger/10/50 dark:hover:bg-red-900/10'], ['key' => 'whatsapp', 'connected' => in_array('whatsapp', $activeChannels, true), 'name' => __('WhatsApp'), 'icon' => 'message-circle', 'href' => url('/settings/channels'), 'color' => 'text-green-500 dark:text-green-400','bg' => 'bg-success/10 dark:bg-green-900/20', 'hover' => 'hover:border-success/20 dark:hover:border-green-900 hover:bg-success/10/50 dark:hover:bg-green-900/10'], ['key' => 'sms', 'connected' => in_array('sms', $activeChannels, true), 'name' => __('SMS'), 'icon' => 'phone', 'href' => url('/settings/channels'), 'color' => 'text-blue-500 dark:text-blue-400', 'bg' => 'bg-info/10 dark:bg-blue-900/20', 'hover' => 'hover:border-info/20 dark:hover:border-blue-900 hover:bg-info/10/50 dark:hover:bg-blue-900/10'], ['key' => 'telegram', 'connected' => in_array('telegram', $activeChannels, true), 'name' => __('Telegram'), 'icon' => 'send', 'href' => url('/settings/channels'), 'color' => 'text-sky-500 dark:text-sky-400', 'bg' => 'bg-sky-50 dark:bg-sky-900/20', 'hover' => 'hover:border-sky-200 dark:hover:border-sky-900 hover:bg-sky-50/50 dark:hover:bg-sky-900/10'], ['key' => 'slack', 'connected' => in_array('slack', $activeChannels, true), 'name' => __('Slack'), 'icon' => 'hash', 'href' => url('/settings/channels'), 'color' => 'text-purple-500 dark:text-purple-400','bg' => 'bg-brand/10 dark:bg-purple-900/20', 'hover' => 'hover:border-purple-200 dark:hover:border-purple-900 hover:bg-brand/10/50 dark:hover:bg-purple-900/10'], ['key' => 'chat', 'connected' => in_array('chat', $activeChannels, true) || in_array('live_chat', $activeChannels, true), 'name' => __('Live Chat'), 'icon' => 'message-square', 'href' => url('/settings/channels'), 'color' => 'text-orange-500 dark:text-orange-400', 'bg' => 'bg-orange-50 dark:bg-orange-900/20', 'hover' => 'hover:border-orange-200 dark:hover:border-orange-900 hover:bg-orange-50/50 dark:hover:bg-orange-900/10'], ]; @endphp @foreach($channels as $ch)

{{ $ch['name'] }}

@if($ch['connected'])

{{ __('Connected') }}

@endif
@if($ch['connected'])
@else
@endif
@endforeach
{{-- Recent Conversations --}}

{{ __('Recent Conversations') }}

{{ __('Your latest email and message threads') }}

{{ __('View All') }}