<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PROGRAM PERAWATAN KOMPUTER {{ strtoupper($type) }}</title>
    <style>
        body {
            font-family: "Arial", sans-serif;
            margin: 0;
            padding: 20px;
            font-size: 12px;
            -webkit-print-color-adjust: exact !important;
            print-color-adjust: exact !important;
        }
        @page {
            size: A4 landscape;
            margin: 1mm;
        }
        h1, h2, h3 {
            text-align: center;
            margin: 3px;
        }
        h1 {
            font-size: 20px;
            font-weight: bold;
        }
        h2 {
            font-size: 18px;
        }
        h3 {
            font-size: 16px;
            margin-bottom: 15px;
        }
        .check-table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
            table-layout: fixed;
        }
        .check-table td {
            border: 0.5px solid #000;
            padding: 6px;
            text-align: center;
        }
        .check-table th {
            background-color: #5fab62;
            color: white;
            font-weight: bold;
            font-family: "Arial", sans-serif;
            padding: 8px;
        }
        .check-table td:first-child {
            width: 4%;
        }
        .check-table td:nth-child(2) {
            text-align: left;
            width: 25%;
        }
        .month-col {
            width: 11.66%;
        }
        .week-numbers th {
            background-color: #5fab62;
            color: white;
            font-size: 12px;
            padding: 6px;
        }
        .week-col {
            width: 2.5%;
        }
        .week-label {
            font-weight: normal;
            font-size: 10px;
        }
        .checked {
            background-color: #cfffb8;
            color: #54c532;
            font-weight: bold;
        }
        .checked::after {
            content: "✓";
            font-size: 12px;
            font-family: "DejaVu Sans", sans-serif;
        }
        .signature-container {
            margin-top: 50px;
            width: 100%;
            page-break-inside: avoid;
        }
        .signature-table {
            width: 100%;
            border: none;
            border-collapse: collapse;
        }
        .signature-col {
            width: 50%;
            vertical-align: top;
            text-align: left;
            border: none;
        }
        .signature-col-left {
            padding-left: 5px;
        }
        .signature-col-right {
            padding-left: 322px;
        }
        .signature-title {
            margin-bottom: 5px;
        }
        .signature-department {
            font-weight: bold;
            margin-bottom: 80px;
        }
        .signature-date {
            margin-bottom: 5px;
        }
        .signature-position {
            font-weight: bold;
            margin-bottom: 80px;
        }
        .signature-name {
            margin-top: 40px;
            font-weight: bold;
            text-decoration: none;
        }
        .signature-nip {
            margin-top: 0;
        }
    </style>
</head>
<body>
    <h1>PROGRAM PERAWATAN KOMPUTER {{ strtoupper($type) }}</h1>
    <h2>SMKN 1 BONDOWOSO</h2>
    <h3>{{ $year }}</h3>

    <table class="check-table">
        <thead>
            <tr>
                <th rowspan="2">No</th>
                <th rowspan="2">Jenis Pengecekan</th>
                @foreach($months as $month)
                    <th colspan="4" class="month-col">
                        {{ ucfirst($month) }}
                        <br>
                        <span class="week-label">Minggu Ke-</span>
                    </th>
                @endforeach
            </tr>
            <tr class="week-numbers">
                @foreach($months as $month)
                    <th class="week-col">1</th>
                    <th class="week-col">2</th>
                    <th class="week-col">3</th>
                    <th class="week-col">4</th>
                @endforeach
            </tr>
        </thead>
        <tbody>
            @foreach($jadwalPerawatan as $index => $jadwal)
            <tr>
                <td>{{ $index + 1 }}</td>
                <td>
                    @if($type == 'software')
                        Aplikasi : {{ $jadwal->jenisPerawatan->nama }}
                    @else
                        {{ $jadwal->jenisPerawatan->nama }}
                    @endif
                </td>
                
                @foreach($months as $bulan)
                    @php
                        $mingguField = 'minggu_'.$bulan;
                        $mingguChecked = $jadwal->$mingguField ?? [];
                    @endphp
                    
                    @for($minggu = 1; $minggu <= 4; $minggu++)
                        <td class="{{ in_array($minggu, $mingguChecked) ? 'checked' : '' }}"></td>
                    @endfor
                @endforeach
            </tr>
            @endforeach
        </tbody>
    </table>

    <div class="signature-container">
        <table class="signature-table">
            <tr>
                <td class="signature-col signature-col-left">
                    <div class="signature-title">KETUA PAKET KEAHLIAN</div>
                    <div class="signature-department">{{ $kepemilikan['keahlian'] }}</div>
                    <div class="signature-name">{{ $kepemilikan['ketua'] }}</div>
                    <div class="signature-nip">{{ $kepemilikan['nip'] }}</div>
                </td>
                <td class="signature-col signature-col-right">
                    <div class="signature-date">Bondowoso, {{ now()->translatedFormat('d F Y') }}</div>
                    <div class="signature-position">{{ $kepemilikan['laboran'] }}</div>
                    <div class="signature-name">ABDUL MUID</div>
                </td>
            </tr>
        </table>
    </div>
</body>
</html>