<!DOCTYPE html>
<html>
<head>
    <title>Task Report</title>
    <style>
        body { font-family: 'Helvetica', sans-serif; font-size: 12px; color: #334155; }
        .header { text-align: center; margin-bottom: 30px; }
        .header h1 { color: #4f46e5; margin: 0; }
        .task-card { border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; margin-bottom: 20px; }
        .priority { display: inline-block; padding: 2px 8px; border-radius: 4px; font-weight: bold; text-transform: uppercase; font-size: 10px; margin-bottom: 10px; }
        .priority-high { background: #fef2f2; color: #ef4444; }
        .priority-medium { background: #fffbeb; color: #f59e0b; }
        .priority-low { background: #f0fdf4; color: #22c55e; }
        .priority-urgent { background: #fef2f2; color: #b91c1c; border: 1px solid #ef4444; }
        .tag { background: #f1f5f9; padding: 2px 6px; border-radius: 100px; margin-right: 5px; font-size: 10px; border-left: 3px solid #ccc; }
        .subtasks { margin-top: 10px; padding-left: 20px; border-left: 2px solid #e2e8f0; }
        .subtask-item { margin-bottom: 5px; }
        .footer { position: fixed; bottom: 0; width: 100%; text-align: center; font-size: 10px; color: #94a3b8; }
    </style>
</head>
<body>
    <div class="header">
        <h1>Task Report</h1>
        <p>Generated on {{ now()->format('M d, Y H:i') }}</p>
    </div>

    @foreach($tasks as $task)
    <div class="task-card">
        <div class="priority priority-{{ $task->priority }}">{{ $task->priority }}</div>
        <h2 style="margin: 0 0 5px 0;">{{ $task->title }}</h2>
        <div style="font-size: 10px; color: #64748b; margin-bottom: 10px;">
            Workspace: {{ $task->workspace ? $task->workspace->name : 'None' }} | 
            Due: {{ $task->due_date ? $task->due_date->format('M d, Y') : 'No date' }}
        </div>
        
        @if($task->description)
        <div style="margin-bottom: 15px;">{!! $task->description !!}</div>
        @endif

        @if($task->tags->isNotEmpty())
        <div style="margin-bottom: 15px;">
            @foreach($task->tags as $tag)
            <span class="tag" style="border-left-color: {{ $tag->color }}">{{ $tag->name }}</span>
            @endforeach
        </div>
        @endif

        @if($task->subtasks->isNotEmpty())
        <div class="subtasks">
            <strong style="display: block; margin-bottom: 5px;">Subtasks:</strong>
            @foreach($task->subtasks as $sub)
            <div class="subtask-item">
                [{{ $sub->is_completed ? 'x' : ' ' }}] {{ $sub->title }}
            </div>
            @endforeach
        </div>
        @endif
    </div>
    @endforeach

    <div class="footer">
        Taskweb Portal &copy; {{ date('Y') }}
    </div>
</body>
</html>
