<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Hasil Inspeksi</title>
    <style>
        * {

            font-size: 12px;
        }

        body {
            font-family: Arial, sans-serif;
        }

        /** Define the header rules **/
        @page {
            margin-top: 100px;
            margin-bottom: 50px;

        }

        #header {
            position: fixed;
            top: -80px;
            left: 0;
            right: 0;
            height: 50px;
            text-align: center;
            padding-bottom: 10px;
        }

        .header-logo {
            position: absolute;
            left: 20px;
            top: 10px;
            max-height: 80px;
            max-width: 150px;
        }

        .header-title {
            margin-top: 20px;
        }

        #footer {
            position: fixed;
            bottom: -50px;
            left: 0;
            right: 0;
            height: 50px;
            text-align: center;
            border-top: 1px solid #ddd;
            padding-top: 10px;
            font-size: 9px;
        }

        .page-number:after {
            content: counter(page) " dari " counter(pages);
        }

        .content {
            margin-top: 10px;
        }

        .page-break {
            page-break-after: always;
        }

        #footer {
            position: fixed;
            bottom: -50px;
            left: 0;
            right: 0;
            height: 50px;
            text-align: left;
            border-top: 1px solid #ddd;
            padding-top: 10px;
            font-size: 12px;
        }

        body {
            margin-top: 3cm;
            margin-bottom: 120px;
            position: relative;
            z-index: 1;
        }

        .border {
            border: 1px solid #000;
        }

        .no-break {
            page-break-inside: avoid;
            page-break-before: auto;
            page-break-after: auto;
        }

        .custom-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }

        .custom-table td {
            vertical-align: top;
        }

        .custom-table td:first-child {
            font-weight: bold;
            width: 30%;
            /* Sesuaikan lebar kolom keterangan */
        }

        table.checkbox-list {
            width: 100%;
            border-collapse: collapse;
        }

        td.checkbox-item {
            width: 33.33%;
            vertical-align: top;
            text-align: left;
        }

        label.checkbox-label {
            display: flex;
            align-items: center;
            font-size: 12px;
        }

        label.checkbox-label input[type="checkbox"] {
            margin-right: 6px;
            transform: scale(1.3);
            /* Memperkecil ukuran checkbox */
        }

        @media print {
        table {
            border-collapse: collapse;
        }
        tr {
            page-break-inside: avoid;
        }
        td, th {
            border: 1px solid #000;
        }

    }
    </style>

</head>

@php
    $data = '';
    $dokument = null;
    foreach ($permohonan->documents as $dokumen) {
        $data .= $dokumen->jenisJaminan->name . ', ';
        $dokument = $dokumen;
    }
    $data = rtrim($data, ', ');

    $senior_officer = null;
    if ($permohonan->debiture && $permohonan->documents) {
        foreach ($permohonan->documents as $dokumen) {
            $penilai = $permohonan->penilaian->userPenilai->where('role', 'penilai')->first();
            $teams = $permohonan->region->teams;

            if ($teams) {
                foreach ($teams as $team) {
                    $team_users = $team->teamsUsers;
                    // print_r($team_users);
                    if ($team_users) {
                        foreach ($team_users as $team_user) {
                            $user = $team_user->user;

                            if ($user && $user->hasRole('senior-officer')) {
                                $senior_officer = $user;
                                break 3;
                            }
                        }
                    }
                }
            }
        }
    }
@endphp

<body style="width: 90%; margin: auto">
    <header id="header">
        <table style="width: 100%; border: none;">
            <tr>
                <td style="width: 20%; text-align: left;" class="header-left">
                    @include('lpj::component.logo-bag', ['width' => 150, 'height' => 40])
                </td>
                <td style="text-align: right;">
                    <div style="">
                        <p style="margin: 0; padding:0; font-size:10px;">Tanggal: {{ date('Y-m-d') }}</p>
                        <p style="margin: 0; padding:0;  font-size:10px;">Waktu: {{ date('H:i:s') }}</p>
                        <p style="margin: 0; padding:0;  font-size:10px;">User: {{ Auth::user()->name }}</p>
                    </div>
                </td>
            </tr>
        </table>
    </header>
