@extends('layouts.app')
@section('content')
<main class="nxl-container"><div class="nxl-content"><div class="page-header"><h5>Related Activity — {{ ucfirst(rtrim($module,'s')) }} #{{ $record->id }}</h5></div><div class="main-content">
<div class="row mb-3"><div class="col-md-6"><div class="card"><div class="card-body"><small class="text-muted">Last interaction</small><div>{{ $lastInteraction?->title ?: 'None recorded' }}</div></div></div></div><div class="col-md-6"><div class="card"><div class="card-body"><small class="text-muted">Next interaction</small><div>{{ $nextCandidates['title'] ?? 'None scheduled' }}</div><small>{{ $nextCandidates['at'] ?? '' }}</small></div></div></div></div>
@foreach(['Activities'=>$activities,'Messages'=>$messages,'Notes'=>$notes,'Follow-ups'=>$followUps,'To-dos'=>$todos] as $title=>$items)
<div class="card mb-3"><div class="card-header"><h5>{{ $title }} <span class="badge bg-secondary">{{ $items->count() }}</span></h5></div>
<div class="card-body table-responsive"><table class="table"><thead><tr><th>Title</th><th>Status</th><th>Date</th><th>Description / Comments</th></tr></thead><tbody>
@forelse($items as $item)<tr><td>{{ $item->title ?? $item->subject ?? $item->content }}</td><td>{{ $item->lifecycle_status ?? $item->status ?? $item->email_status }}</td><td>{{ $item->follow_up_at ?? $item->due_at ?? $item->created_at }}</td><td>{{ $item->description }}@if($item->comments)<small class="d-block text-muted">Comments: {{ $item->comments }}</small>@endif</td></tr>
@empty<tr><td colspan="4">No related records.</td></tr>@endforelse
</tbody></table></div></div>@endforeach
</div></div></main>
@endsection
