<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Laporan Pensiun {{ $year }}</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            font-size: 11px;
            line-height: 1.4;
            color: #1f2937;
            background: white;
        }
        
        .container {
            max-width: 100%;
            padding: 20px;
        }
        
        /* Header */
        .header {
            text-align: center;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 3px solid #3b82f6;
        }
        
        .header h1 {
            font-size: 22px;
            font-weight: bold;
            color: #1f2937;
            margin-bottom: 5px;
        }
        
        .header p {
            font-size: 13px;
            color: #6b7280;
        }
        
        .header .meta {
            margin-top: 10px;
            font-size: 10px;
            color: #9ca3af;
        }
        
        /* Summary Cards */
        .summary-section {
            margin-bottom: 25px;
        }
        
        .summary-grid {
            display: table;
            width: 100%;
            border-collapse: separate;
            border-spacing: 8px;
            margin-bottom: 15px;
        }
        
        .summary-card {
            display: table-cell;
            width: 20%;
            padding: 12px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 6px;
            text-align: center;
            vertical-align: middle;
        }
        
        .summary-card.total {
            background: #eff6ff;
            border-color: #3b82f6;
        }
        
        .summary-card h3 {
            font-size: 24px;
            font-weight: bold;
            color: #3b82f6;
            margin-bottom: 3px;
        }
        
        .summary-card.total h3 {
            color: #1d4ed8;
        }
        
        .summary-card p {
            font-size: 9px;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        /* Chart Section */
        .chart-section {
            margin-bottom: 25px;
            page-break-inside: avoid;
        }
        
        .section-title {
            font-size: 14px;
            font-weight: bold;
            color: #1f2937;
            margin-bottom: 12px;
            padding-bottom: 6px;
            border-bottom: 2px solid #e5e7eb;
        }
        
        .chart-container {
            background: #f9fafb;
            border: 1px solid #e5e7eb;
            border-radius: 6px;
            padding: 15px;
            height: 220px;
            position: relative;
        }
        
        /* Simple Bar Chart for PDF */
        .bar-chart {
            display: flex;
            align-items: flex-end;
            justify-content: space-around;
            height: 180px;
            padding: 0 5px;
        }
        
        .bar-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            flex: 1;
            max-width: 50px;
            margin: 0 3px;
        }
        
        .bar {
            width: 100%;
            background: linear-gradient(to top, #3b82f6, #60a5fa);
            border-radius: 3px 3px 0 0;
            min-height: 15px;
            position: relative;
        }
        
        .bar-value {
            position: absolute;
            top: -16px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 9px;
            font-weight: bold;
            color: #3b82f6;
        }
        
        .bar-label {
            margin-top: 5px;
            font-size: 8px;
            color: #6b7280;
            text-align: center;
            white-space: nowrap;
        }
        
        /* Table Styles */
        .table-section {
            margin-top: 25px;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 10px;
        }
        
        thead {
            background: #f1f5f9;
        }
        
        th {
            padding: 10px 8px;
            text-align: left;
            font-weight: 600;
            color: #475569;
            text-transform: uppercase;
            font-size: 9px;
            letter-spacing: 0.5px;
            border-bottom: 2px solid #cbd5e1;
        }
        
        td {
            padding: 8px;
            border-bottom: 1px solid #e2e8f0;
            vertical-align: middle;
        }
        
        tr:nth-child(even) {
            background: #f8fafc;
        }
        
        /* Status Badges */
        .badge {
            display: inline-block;
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 9px;
            font-weight: 500;
        }
        
        .badge-retirement {
            background: #fee2e2;
            color: #991b1b;
        }
        
        .badge-type {
            background: #f3f4f6;
            color: #374151;
            text-transform: capitalize;
        }
        
        /* Employee Info */
        .employee-info {
            display: flex;
            align-items: center;
        }
        
        .avatar {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            background: linear-gradient(135deg, #3b82f6, #1d4ed8);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 9px;
            font-weight: bold;
            margin-right: 8px;
            flex-shrink: 0;
        }
        
        .employee-name {
            font-weight: 500;
            color: #1f2937;
        }
        
        .employee-position {
            font-size: 9px;
            color: #6b7280;
            display: block;
        }
        
        /* Empty State */
        .empty-state {
            text-align: center;
            padding: 30px;
            color: #9ca3af;
        }
        
        /* Footer */
        .footer {
            margin-top: 30px;
            padding-top: 15px;
            border-top: 1px solid #e5e7eb;
            text-align: center;
            font-size: 9px;
            color: #9ca3af;
        }
        
        /* Page Break */
        .page-break {
            page-break-before: always;
        }
        
        /* Print Optimizations */
        @media print {
            body {
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
            }
            
            .container {
                padding: 0;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- Header -->
        <div class="header">
            <h1>LAPORAN PENSIUN PEGAWAI</h1>
            <p>Tahun Anggaran {{ $year }}</p>
            <div class="meta">
                Dicetak pada: {{ now()->format('d F Y H:i') }} | 
                Total Data: {{ $summary['total'] }} Pegawai
            </div>
            <div class="table-section">
                 @if(count($data) > 0)
                <table>
                    <thead>
                        <tr>
                            <th style="width: 4%">No</th>
                            <th style="width: 10%">Bulan</th>
                            <th style="width: 11%">NIP</th>
                            <th style="width: 18%">Nama Pegawai</th>
                            <th style="width: 15%">Jabatan</th>
                            <th style="width: 14%">Departemen</th>
                            <th style="width: 12%">Tgl Pensiun</th>
                            <th style="width: 10%">Tipe</th>
                            <th style="width: 6%">Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($data as $index => $employee)
                            <tr>
                                <td>{{ $index + 1 }}</td>
                                <td>{{ $employee->retirement_date->format('M Y') }}</td>
                                <td>{{ $employee->nip }}</td>
                                <td>
                                    <div class="employee-info">
                                        <div class="avatar">
                                            {{ strtoupper(substr($employee->name, 0, 2)) }}
                                        </div>
                                        <div>
                                            <span class="employee-name">{{ $employee->name }}</span>
                                        </div>
                                    </div>
                                </td>
                                <td>{{ $employee->position ?? '-' }}</td>
                                <td>{{ $employee->department->name ?? '-' }}</td>
                                <td>
                                    <span class="badge badge-retirement">
                                        {{ $employee->retirement_date->format('d/m/Y') }}
                                    </span>
                                </td>
                                <td>
                                    <span class="badge badge-type">
                                        {{ str_replace(['_', '-'], ' ', $employee->retirement_type) }}
                                    </span>
                                </td>
                                <td>
                                    <span class="badge" style="background: #d1fae5; color: #065f46;">
                                        {{ $employee->employment_status }}
                                    </span>
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            @else
                <div class="empty-state">
                    <p>Tidak ada data pensiun untuk tahun {{ $year }}</p>
                </div>
            @endif
            </div>
           
        </div>
        <!-- Footer -->
        <div class="footer">
            <p>Laporan ini digenerate secara otomatis oleh sistem | © {{ date('Y') }} - Dokumen Rahasia</p>
        </div>
    </div>
</body>
</html>