<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Work Report - {{ $report->user->name }}</title>
    <style>
        body {
            font-family: 'Helvetica', sans-serif;
            color: #333;
            line-height: 1.5;
        }

        .header {
            text-align: center;
            border-bottom: 2px solid #0d6efd;
            padding-bottom: 20px;
            margin-bottom: 30px;
        }

        .logo {
            font-size: 24px;
            font-weight: bold;
            color: #0d6efd;
        }

        .report-title {
            font-size: 20px;
            margin-top: 10px;
        }

        .meta-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 30px;
        }

        .meta-table td {
            padding: 8px;
            border: 1px solid #ddd;
        }

        .label {
            font-weight: bold;
            background: #f8f9fa;
            width: 30%;
        }

        .section-title {
            font-size: 16px;
            font-weight: bold;
            color: #0d6efd;
            border-bottom: 1px solid #ddd;
            padding-bottom: 5px;
            margin-bottom: 15px;
            margin-top: 30px;
        }

        .task-list {
            padding-left: 20px;
        }

        .task-item {
            margin-bottom: 10px;
        }

        .summary {
            background: #f8f9fa;
            padding: 15px;
            border-radius: 5px;
            border-left: 4px solid #0d6efd;
            white-space: pre-wrap;
        }

        .footer {
            position: fixed;
            bottom: 0;
            width: 100%;
            text-align: center;
            font-size: 10px;
            color: #999;
            border-top: 1px solid #ddd;
            padding-top: 10px;
        }

        .stats-box {
            display: inline-block;
            width: 23%;
            text-align: center;
            padding: 10px;
            border: 1px solid #eee;
            border-radius: 5px;
            margin-right: 1%;
        }

        .stats-val {
            display: block;
            font-weight: bold;
            font-size: 18px;
        }

        .stats-label {
            font-size: 10px;
            text-uppercase: true;
            color: #777;
        }
    </style>
</head>

<body>
    <div class="header">
        <div class="logo">{{ config('app.name', 'WorkFlow') }}</div>
        <div class="report-title">Work Report Details</div>
        <p style="margin: 0; font-size: 12px; color: #666;">Date: {{ $report->created_at->format('d M, Y') }}</p>
    </div>

    <table class="meta-table">
        <tr>
            <td class="label">Employee Name</td>
            <td>{{ $report->user->name }}</td>
            <td class="label">Department</td>
            <td>{{ $report->user->department->name ?? 'N/A' }}</td>
        </tr>
        <tr>
            <td class="label">Email</td>
            <td>{{ $report->user->email }}</td>
            <td class="label">Designation</td>
            <td>{{ $report->user->designation }}</td>
        </tr>
        <tr>
            <td class="label">Submission Time</td>
            <td colspan="3">{{ $report->submitted_at->format('h:i A, d M Y') }}</td>
        </tr>
    </table>

    <div>
        <div class="stats-box">
            <span
                class="stats-val">{{ $report->attendance->check_in ? $report->attendance->check_in->format('h:i A') : '-' }}</span>
            <span class="stats-label">Check In</span>
        </div>
        <div class="stats-box">
            <span
                class="stats-val">{{ $report->attendance->check_out ? $report->attendance->check_out->format('h:i A') : 'Active' }}</span>
            <span class="stats-label">Check Out</span>
        </div>
        <div class="stats-box">
            <span class="stats-val">{{ floor($report->attendance->total_break_minutes / 60) }}h
                {{ $report->attendance->total_break_minutes % 60 }}m</span>
            <span class="stats-label">Break Time</span>
        </div>
        <div class="stats-box">
            <span class="stats-val" style="color: #198754;">{{ floor($report->attendance->total_work_minutes / 60) }}h
                {{ $report->attendance->total_work_minutes % 60 }}m</span>
            <span class="stats-label">Net Work Time</span>
        </div>
    </div>

    <div class="section-title">Work Summary</div>
    <div class="summary">{{ $report->raw_summary }}</div>

    <div class="section-title">Tasks Executed ({{ $report->total_tasks }})</div>
    <ul class="task-list">
        @foreach ($report->tasks as $task)
            <li class="task-item">{{ $task->task_description }}</li>
        @endforeach
    </ul>

    <div class="footer">
        Generated by {{ config('app.name') }} on {{ date('d M, Y h:i A') }} | Page 1
    </div>
</body>

</html>
