<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Hasil SAW</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background: #f5f5f5;
        }        .print-info {
            background: #e3f2fd;
            border: 1px solid #2196f3;
            border-radius: 5px;
            padding: 15px;
            margin-bottom: 20px;
            text-align: center;
        }
        .print-info strong {
            color: #1976d2;
        }
        @media print {
            .print-info {
                display: none;
            }
            body {
                background: white;
                padding: 0;
            }
        }        .container {
            background: white;
            padding: 30px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .header {
            text-align: center;
            margin-bottom: 30px;
            border-bottom: 3px solid #667eea;
            padding-bottom: 20px;
        }
        .header h1 {
            color: #667eea;
            margin: 0 0 10px 0;
            font-size: 24px;
        }
        .header p {
            color: #666;
            margin: 5px 0;
            font-size: 12px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        table thead {
            background: #667eea;
            color: white;
        }
        table th {
            padding: 12px;
            text-align: left;
            font-weight: bold;
            font-size: 11px;
        }
        table td {
            padding: 10px 12px;
            border-bottom: 1px solid #ddd;
            font-size: 10px;
        }
        table tbody tr:nth-child(even) {
            background: #f9f9f9;
        }
        .rank-1 { background: #ffd700 !important; font-weight: bold; }
        .rank-2 { background: #c0c0c0 !important; font-weight: bold; }
        .rank-3 { background: #cd7f32 !important; font-weight: bold; color: white; }
        
        .footer {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #ddd;
            text-align: center;
            color: #666;
            font-size: 10px;
        }
    </style>
</head>
<body>
    <div class="print-info">
        <strong>📄 Cara Mengubah ke PDF:</strong> Tekan <kbd>Ctrl+P</kbd> atau klik Print, lalu pilih "Save as PDF" sebagai printer.
    </div>
    
    <div class="container">
        <div class="header">
            <h1>🏆 Hasil Analisis SAW</h1>
            <p><strong>Tipe:</strong> {{ ucfirst($tipe) }}</p>
            @if($jenisLayanan)
            <p><strong>Jenis Layanan:</strong> {{ $jenisLayanan }}</p>
            @endif
            <p>Dicetak pada: {{ now()->format('d M Y H:i:s') }}</p>
        </div>

        <table>
            <thead>
                <tr>
                    <th>Ranking</th>
                    <th>Nama {{ ucfirst($tipe) }}</th>
                    <th>Alamat</th>
                    <th>Nilai SAW</th>
                </tr>
            </thead>
            <tbody>
                @foreach($hasil as $key => $item)
                <tr @class(['rank-1' => $item['ranking'] == 1, 'rank-2' => $item['ranking'] == 2, 'rank-3' => $item['ranking'] == 3])>
                    <td>
                        @if($item['ranking'] == 1)
                            🥇 {{ $item['ranking'] }}
                        @elseif($item['ranking'] == 2)
                            🥈 {{ $item['ranking'] }}
                        @elseif($item['ranking'] == 3)
                            🥉 {{ $item['ranking'] }}
                        @else
                            {{ $item['ranking'] }}
                        @endif
                    </td>
                    <td><strong>{{ $item['nama'] ?? '-' }}</strong></td>
                    <td>{{ $item['alamat'] ?? '-' }}</td>
                    <td>{{ number_format($item['nilai'] ?? 0, 4) }}</td>
                </tr>
                @endforeach
            </tbody>
        </table>

        <div class="footer">
            <p>📊 Total Hasil: <strong>{{ count($hasil) }}</strong> {{ Str::plural($tipe, count($hasil)) }}</p>
            <p>Metode Analisis: Simple Additive Weighting (SAW)</p>
            <p>Generated by SPK Kontrakan System</p>
        </div>
    </div>
</body>
</html>
