<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Laporan Absensi</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <style>
        body {
            font-family: Arial, sans-serif;
            font-size: 14px;
        }
        h1, h3 {
            text-align: center;
            margin-top: 20px;
        }
        .report-container {
            padding: 20px;
        }
        .table {
            width: 100%;
            margin-bottom: 1rem;
            background-color: #fff;
            word-break: break-word;
        }
        .table th, .table td {
            vertical-align: top;
            padding: 8px;
        }
        .table thead th {
            background-color: #f2f2f2;
        }
        .table td, .table th {
            border: 1px solid #dee2e6;
        }
        @media print {
            body {
                font-size: 12px;
            }
            .table-responsive {
                overflow: visible;
            }
        }
    </style>
</head>
<body>

<div class="report-container">
    <h1>Laporan Absensi Karyawan</h1>
    <h3>Periode: {{ $start_date }} s/d {{ $end_date }}</h3>

    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th style="width: 30px;">No</th>
                    <th style="min-width: 100px;">Tanggal</th>
                    <th style="min-width: 150px;">Nama Karyawan</th>
                    <th style="min-width: 90px;">Waktu</th>
                    <th style="min-width: 70px;">Tipe</th>
                    <th style="min-width: 80px;">Status</th>
                    <th style="min-width: 120px;">Lokasi</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($attendances as $index => $attendance)
                    <tr>
                        <td>{{ $index + 1 }}</td>
                        <td>{{ \Carbon\Carbon::parse($attendance->date)->format('d-m-Y') }}</td>
                        <td>{{ $attendance->user->profile->name ?? $attendance->user->email }}</td>
                        <td>{{ \Carbon\Carbon::parse($attendance->time)->format('H:i:s') }}</td>
                        <td>{{ ucfirst($attendance->type) }}</td>
                        <td>{{ ucfirst($attendance->status) }}</td>
                        <td>{{ $attendance->location->name ?? '-' }}</td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    </div>
</div>

</body>
</html>
