<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Laporan Perpanjangan Akses <?php echo e($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 #10b981;
        }
        
        .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: 15px;
            background: #f0fdf4;
            border: 1px solid #bbf7d0;
            border-radius: 8px;
            text-align: center;
            vertical-align: middle;
        }
        
        .summary-card.total {
            background: #ecfdf5;
            border-color: #10b981;
        }
        
        .summary-card.approved {
            background: #d1fae5;
            border-color: #34d399;
        }
        
        .summary-card.rejected {
            background: #fee2e2;
            border-color: #f87171;
        }
        
        .summary-card.pending {
            background: #fef3c7;
            border-color: #fbbf24;
        }
        
        .summary-card.rate {
            background: #eff6ff;
            border-color: #3b82f6;
        }
        
        .summary-card h3 {
            font-size: 26px;
            font-weight: bold;
            margin-bottom: 5px;
        }
        
        .summary-card.total h3 { color: #059669; }
        .summary-card.approved h3 { color: #059669; }
        .summary-card.rejected h3 { color: #dc2626; }
        .summary-card.pending h3 { color: #d97706; }
        .summary-card.rate h3 { color: #2563eb; }
        
        .summary-card p {
            font-size: 10px;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .summary-card .sub {
            font-size: 9px;
            color: #9ca3af;
            margin-top: 3px;
        }
        
        /* Progress Bar */
        .progress-section {
            margin-bottom: 25px;
            padding: 15px;
            background: #f9fafb;
            border-radius: 8px;
            border: 1px solid #e5e7eb;
        }
        
        .progress-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        
        .progress-title {
            font-size: 12px;
            font-weight: 600;
            color: #374151;
        }
        
        .progress-value {
            font-size: 18px;
            font-weight: bold;
            color: #059669;
        }
        
        .progress-bar {
            width: 100%;
            height: 20px;
            background: #e5e7eb;
            border-radius: 10px;
            overflow: hidden;
        }
        
        .progress-fill {
            height: 100%;
            background: linear-gradient(to right, #34d399, #059669);
            border-radius: 10px;
            transition: width 0.3s;
        }
        
        /* Section Title */
        .section-title {
            font-size: 14px;
            font-weight: bold;
            color: #1f2937;
            margin-bottom: 12px;
            padding-bottom: 6px;
            border-bottom: 2px solid #e5e7eb;
        }
        
        /* Table Styles */
        .table-section {
            margin-top: 25px;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 10px;
        }
        
        thead {
            background: #ecfdf5;
        }
        
        th {
            padding: 12px 8px;
            text-align: left;
            font-weight: 600;
            color: #065f46;
            text-transform: uppercase;
            font-size: 9px;
            letter-spacing: 0.5px;
            border-bottom: 2px solid #10b981;
        }
        
        td {
            padding: 10px 8px;
            border-bottom: 1px solid #e5e7eb;
            vertical-align: middle;
        }
        
        tr:nth-child(even) {
            background: #f9fafb;
        }
        
        /* Status Badges */
        .badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 9px;
            font-weight: 600;
            text-transform: capitalize;
        }
        
        .badge-approved {
            background: #d1fae5;
            color: #065f46;
        }
        
        .badge-rejected {
            background: #fee2e2;
            color: #991b1b;
        }
        
        .badge-pending {
            background: #fef3c7;
            color: #92400e;
        }
        
        /* Employee Info */
        .employee-info {
            display: flex;
            align-items: center;
        }
        
        .avatar {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            background: linear-gradient(135deg, #10b981, #059669);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            font-weight: bold;
            margin-right: 10px;
            flex-shrink: 0;
        }
        
        .employee-name {
            font-weight: 600;
            color: #1f2937;
        }
        
        .employee-nip {
            font-size: 9px;
            color: #6b7280;
        }
        
        /* Access Info */
        .access-name {
            font-weight: 500;
            color: #1f2937;
        }
        
        .access-detail {
            font-size: 9px;
            color: #6b7280;
        }
        
        /* Duration Badge */
        .duration-badge {
            display: inline-block;
            padding: 3px 8px;
            background: #dbeafe;
            color: #1e40af;
            border-radius: 4px;
            font-size: 9px;
            font-weight: 600;
        }
        
        /* Approved By */
        .approver {
            font-size: 10px;
            color: #374151;
        }
        
        .approval-date {
            font-size: 8px;
            color: #9ca3af;
        }
        
        /* Empty State */
        .empty-state {
            text-align: center;
            padding: 40px;
            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 PERPANJANGAN AKSES</h1>
            <p>Tahun Anggaran <?php echo e($year); ?></p>
            <div class="meta">
                Dicetak pada: <?php echo e(now()->format('d F Y H:i')); ?> | 
                Total Data: <?php echo e($summary['total']); ?> Request
            </div>
        </div>

        <!-- Summary Section -->
        <div class="summary-section">
            <h2 class="section-title">Ringkasan Statistik</h2>
            <div class="summary-grid">
                <div class="summary-card total">
                    <h3><?php echo e($summary['total']); ?></h3>
                    <p>Total Request</p>
                </div>
                <div class="summary-card approved">
                    <h3><?php echo e($summary['approved']); ?></h3>
                    <p>Disetujui</p>
                    <?php if($summary['total'] > 0): ?>
                        <div class="sub"><?php echo e(round(($summary['approved'] / $summary['total']) * 100)); ?>% dari total</div>
                    <?php endif; ?>
                </div>
                <div class="summary-card rejected">
                    <h3><?php echo e($summary['rejected']); ?></h3>
                    <p>Ditolak</p>
                </div>
                <div class="summary-card pending">
                    <h3><?php echo e($summary['pending']); ?></h3>
                    <p>Pending</p>
                </div>
                <div class="summary-card rate">
                    <h3><?php echo e($summary['approval_rate']); ?>%</h3>
                    <p>Approval Rate</p>
                    <div class="sub"><?php echo e($summary['total_days_extended']); ?> hari diperpanjang</div>
                </div>
            </div>
        </div>

        <!-- Progress Bar -->
        <div class="progress-section">
            <div class="progress-header">
                <span class="progress-title">Tingkat Persetujuan Perpanjangan</span>
                <span class="progress-value"><?php echo e($summary['approval_rate']); ?>%</span>
            </div>
            <div class="progress-bar">
                <div class="progress-fill" style="width: <?php echo e(min($summary['approval_rate'], 100)); ?>%"></div>
            </div>
        </div>

        <!-- Table Section -->
        <div class="table-section">
            <h2 class="section-title">Detail Request Perpanjangan <?php echo e($year); ?></h2>
            
            <?php if(count($data) > 0): ?>
                <table>
                    <thead>
                        <tr>
                            <th style="width: 4%">No</th>
                            <th style="width: 12%">Tanggal Request</th>
                            <th style="width: 20%">Pegawai</th>
                            <th style="width: 20%">Akses</th>
                            <th style="width: 10%">Durasi</th>
                            <th style="width: 10%">Status</th>
                            <th style="width: 14%">Approved By</th>
                            <th style="width: 10%">Tgl Approval</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $request): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td style="text-align: center;"><?php echo e($index + 1); ?></td>
                                <td><?php echo e($request->created_at->format('d M Y')); ?></td>
                                <td>
                                    <div class="employee-info">
                                        <div class="avatar">
                                            <?php echo e(strtoupper(substr($request->employeeAccessDetail->employee->name ?? 'UN', 0, 2))); ?>

                                        </div>
                                        <div>
                                            <div class="employee-name">
                                                <?php echo e($request->employeeAccessDetail->employee->name ?? 'Unknown'); ?>

                                            </div>
                                            <div class="employee-nip">
                                                NIP: <?php echo e($request->employeeAccessDetail->employee->nip ?? '-'); ?>

                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <div class="access-name">
                                        <?php echo e($request->employeeAccessDetail->accessCatalog->name ?? 'Unknown'); ?>

                                    </div>
                                    <div class="access-detail">
                                        ID: <?php echo e($request->employeeAccessDetail->id ?? '-'); ?>

                                    </div>
                                </td>
                                <td>
                                    <span class="duration-badge">
                                        <?php echo e($request->requested_duration_days); ?> hari
                                    </span>
                                </td>
                                <td>
                                    <?php
                                        $statusClass = match($request->approval_status) {
                                            'approved' => 'badge-approved',
                                            'rejected' => 'badge-rejected',
                                            'pending' => 'badge-pending',
                                            default => 'badge-pending'
                                        };
                                    ?>
                                    <span class="badge <?php echo e($statusClass); ?>">
                                        <?php echo e(ucfirst($request->approval_status)); ?>

                                    </span>
                                </td>
                                <td>
                                    <div class="approver">
                                        <?php echo e($request->approvedBy->name ?? ($request->approval_status === 'pending' ? '-' : 'System')); ?>

                                    </div>
                                    <?php if($request->approved_at): ?>
                                        <div class="approval-date">
                                            <?php echo e($request->approved_at->format('d/m/Y H:i')); ?>

                                        </div>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <?php if($request->approved_at): ?>
                                        <?php echo e($request->approved_at->format('d M Y')); ?>

                                    <?php else: ?>
                                        <span style="color: #9ca3af;">-</span>
                                    <?php endif; ?>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            <?php else: ?>
                <div class="empty-state">
                    <p>Tidak ada data perpanjangan untuk tahun <?php echo e($year); ?></p>
                </div>
            <?php endif; ?>
        </div>

        <!-- Summary Days Extended -->
        <?php if($summary['total_days_extended'] > 0): ?>
        <div style="margin-top: 20px; padding: 15px; background: #f0fdf4; border-radius: 8px; border-left: 4px solid #10b981;">
            <h4 style="font-size: 12px; color: #065f46; margin-bottom: 5px;">Total Hari Perpanjangan yang Disetujui</h4>
            <p style="font-size: 18px; font-weight: bold; color: #059669;">
                <?php echo e(number_format($summary['total_days_extended'])); ?> hari
            </p>
            <p style="font-size: 10px; color: #6b7280; margin-top: 5px;">
                Dari <?php echo e($summary['approved']); ?> request yang disetujui
            </p>
        </div>
        <?php endif; ?>

        <!-- Footer -->
        <div class="footer">
            <p>Laporan ini digenerate secara otomatis oleh sistem | © <?php echo e(date('Y')); ?> - Dokumen Rahasia</p>
        </div>
    </div>
</body>
</html><?php /**PATH C:\codingan\access-control-management\resources\views/reports/pdf/extension.blade.php ENDPATH**/ ?>