{{-- Flash Messages --}} @if(session()->has('success'))
{{ session('success') }}
@endif @if(session()->has('error'))
{{ session('error') }}
@endif {{-- Page Header --}}

{{ __('Workflow Automation') }}

{{ __('Automate repetitive tasks with visual, no-code workflows.') }}

{{-- Main Content Card --}}
{{-- Filters: Search + Status dropdown --}}
{{-- Status filter dropdown --}}
{{-- Workflows Table. Removed `overflow-hidden` from the outer card and made the horizontal scroll wrapper only apply below lg so the action-menu dropdown on the last column isn't clipped to the table bounds on desktop. --}} @if($workflows->count() > 0)

{{ __('Swipe to see more columns') }}

@foreach($workflows as $workflow) {{-- Name --}} {{-- Status badge: dot + label in colored pill --}} {{-- Trigger --}} {{-- Success Rate --}} {{-- Last Run --}} {{-- Created --}} {{-- Actions dropdown. Uses x-teleport="body" so the menu escapes the table's stacking context and can never be clipped by row borders, overflow, or the card rounding. Position is computed from the trigger button's rect on open and on scroll/resize so it stays anchored. --}} @endforeach
{{ __('Name') }} {{ __('Status') }} {{ __('Trigger') }} {{ __('Success Rate') }} {{ __('Last Run') }} {{ __('Created') }} {{ __('Actions') }}
{{ $workflow->name }} @if($workflow->description)

{{ $workflow->description }}

@endif
@php $statusConfig = [ 'active' => ['dot' => 'bg-success/100', 'text' => 'text-success', 'bg' => 'bg-success/10', 'label' => __('Active')], 'paused' => ['dot' => 'bg-warning/100', 'text' => 'text-warning', 'bg' => 'bg-warning/10', 'label' => __('Paused')], 'draft' => ['dot' => 'bg-gray-400', 'text' => 'text-muted ', 'bg' => 'bg-surface ', 'label' => __('Draft')], 'error' => ['dot' => 'bg-danger/100', 'text' => 'text-danger', 'bg' => 'bg-danger/10', 'label' => __('Error')], ]; $sc = $statusConfig[$workflow->status] ?? $statusConfig['draft']; @endphp {{ $sc['label'] }}
@php $triggerIcon = match($workflow->trigger_subtype) { 'email_received', 'new_email' => 'mail', 'contact_created', 'new_contact' => 'user-plus', 'webhook', 'webhook_received' => 'zap', 'deal_stage_changed' => 'trending-up', 'tag_added' => 'tag', 'schedule', 'scheduled' => 'clock', default => 'zap', }; @endphp {{ str_replace('_', ' ', ucfirst($workflow->trigger_subtype)) }}
{{ $workflow->success_rate }}% @if($workflow->last_run_at) {{ $workflow->last_run_at->diffForHumans() }} @else -- @endif {{ $workflow->created_at->format('M j, Y') }}
@else {{-- Empty state --}} @endif
{{-- end main content card --}}