<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <style>
        body { font-family: DejaVu Sans, sans-serif; font-size: 11px; color: #222; }
        h2 { margin: 0 0 8px 0; }
        .meta { margin-bottom: 12px; color: #666; font-size: 10px; }
        table { width: 100%; border-collapse: collapse; }
        th, td { border: 1px solid #ccc; padding: 5px; text-align: left; vertical-align: top; }
        th { background: #f2f2f2; }
    </style>
</head>
<body>
    <h2>Task Report</h2>
    <div class="meta">Generated: {{ now()->format('Y-m-d H:i:s') }}</div>

    <table>
        <thead>
            <tr>
                <th>Task ID</th>
                <th>Status</th>
                <th>Assigned User</th>
                <th>Assigned Role</th>
                <th>Workflow Instance</th>
                <th>Created At</th>
            </tr>
        </thead>
        <tbody>
            @forelse($tasks as $task)
                <tr>
                    <td>{{ $task->id }}</td>
                    <td>{{ ucfirst($task->status) }}</td>
                    <td>{{ $task->assignedUser->first_name ?? '-' }} {{ $task->assignedUser->last_name ?? '' }}</td>
                    <td>{{ $task->assignedRole->name ?? '-' }}</td>
                    <td>{{ $task->instance->id ?? '-' }}</td>
                    <td>{{ $task->created_at ? $task->created_at->format('Y-m-d H:i') : '-' }}</td>
                </tr>
            @empty
                <tr>
                    <td colspan="6">No tasks found</td>
                </tr>
            @endforelse
        </tbody>
    </table>
</body>
</html>
