<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Detail Layanan #{{ $service->id }}</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            color: #333;
        }
        .header {
            text-align: center;
            margin-bottom: 20px;
            border-bottom: 1px solid #ddd;
            padding-bottom: 10px;
        }
        .logo {
            max-width: 150px;
            margin-bottom: 10px;
        }
        h1 {
            font-size: 20px;
            margin-bottom: 5px;
        }
        .info-section {
            margin-bottom: 20px;
        }
        .info-section h2 {
            font-size: 16px;
            margin-bottom: 10px;
            border-bottom: 1px solid #eee;
            padding-bottom: 5px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 10px;
        }
        table td {
            padding: 5px;
            vertical-align: top;
        }
        .label {
            font-weight: bold;
            width: 40%;
        }
        .status {
            display: inline-block;
            padding: 3px 8px;
            border-radius: 3px;
            font-size: 12px;
            color: white;
            background-color: #777;
        }
        .status-menunggu { background-color: #f0ad4e; }
        .status-diterima { background-color: #5bc0de; }
        .status-diproses { background-color: #0275d8; }
        .status-selesai { background-color: #5cb85c; }
        .status-ditolak { background-color: #d9534f; }
        .footer {
            margin-top: 30px;
            text-align: center;
            font-size: 12px;
            color: #777;
            border-top: 1px solid #ddd;
            padding-top: 10px;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>LAYANAN PENGUJIAN AIR #{{ $service->id }} 
            @if($service->status == 'Ditolak')
            <span style="color: #d9534f;">(DITOLAK)</span>
            @elseif($service->status == 'Selesai')
            <span style="color: #5cb85c;">(SELESAI)</span>
            @elseif($service->status == 'Diproses')
            <span style="color: #0275d8;">(DIPROSES)</span>
            @elseif($service->status == 'Diterima')
            <span style="color: #5bc0de;">(DITERIMA)</span>
            @endif
        </h1>
        <p>Dicetak pada: {{ date('d-m-Y H:i:s') }}</p>
    </div>

    <div class="info-section">
        <h2>Informasi Pelanggan</h2>
        <table>
            <tr>
                <td class="label">Nama</td>
                <td>{{ $service->user->name }}</td>
            </tr>
            <tr>
                <td class="label">Email</td>
                <td>{{ $service->user->email }}</td>
            </tr>
            <tr>
                <td class="label">No. HP</td>
                <td>{{ $service->user->phone ?? '-' }}</td>
            </tr>
            <tr>
                <td class="label">Nama Badan Usaha</td>
                <td>{{ $service->user->business_name ?? '-' }}</td>
            </tr>
            <tr>
                <td class="label">Alamat Badan Usaha</td>
                <td>{{ $service->user->business_address ?? '-' }}</td>
            </tr>
        </table>
    </div>

    <div class="info-section">
        <h2>Informasi Permintaan</h2>
        <table>
            <tr>
                <td class="label">Status</td>
                <td>
                    <span class="status status-{{ strtolower($service->status) }}">{{ $service->status }}</span>
                </td>
            </tr>
            @if($service->keterangan && ($service->status == 'Diterima' || $service->status == 'Ditolak'))
            <tr>
                <td class="label">Keterangan Status</td>
                <td style="color: {{ $service->status == 'Ditolak' ? '#d9534f' : '#5bc0de' }};">
                    <strong>{{ $service->keterangan }}</strong>
                </td>
            </tr>
            @endif
            <tr>
                <td class="label">Jenis Permintaan</td>
                <td>{{ $service->jenis_permintaan }}</td>
            </tr>
            <tr>
                <td class="label">Tanggal Uji</td>
                <td>{{ \Carbon\Carbon::parse($service->tanggal_uji)->format('d F Y') }}</td>
            </tr>
            <tr>
                <td class="label">Parameter</td>
                <td>{{ $service->parameter }}</td>
            </tr>
            <tr>
                <td class="label">Waktu Pendaftaran</td>
                <td>{{ $service->created_at->format('d F Y, H:i') }}</td>
            </tr>
        </table>
    </div>

    <div class="info-section">
        <h2>Detail Pengujian</h2>
        <table>
            <tr>
                <td class="label">Pengujian Kualitas Air</td>
                <td>{{ $service->pengujian_kualitas_air }}</td>
            </tr>
            <tr>
                <td class="label">Total Sampel</td>
                <td>{{ $service->total_sampel }} sampel</td>
            </tr>
            <tr>
                <td class="label">Jarak Pengambilan Sampel</td>
                <td>{{ $service->jarak_pengambilan_sampel }}</td>
            </tr>
            <tr>
                <td class="label">Tanggal Selesai Uji</td>
                <td>
                    @if($service->tanggal_selesai_uji)
                        {{ \Carbon\Carbon::parse($service->tanggal_selesai_uji)->format('d F Y') }}
                    @elseif($service->status == 'Ditolak')
                        <span style="color: #d9534f; font-weight: bold;">Ditolak</span>
                    @else
                        Menunggu
                    @endif
                </td>
            </tr>
        </table>
    </div>

    <div class="info-section">
        <h2>Informasi Biaya</h2>
        <table>
            <tr>
                <td class="label">Biaya Retribusi Parameter</td>
                <td>
                    @if($service->biaya_retribusi_parameter)
                        Rp {{ number_format($service->biaya_retribusi_parameter, 0, ',', '.') }}
                    @elseif($service->status == 'Ditolak')
                        <span style="color: #d9534f; font-weight: bold;">Ditolak</span>
                    @else
                        Menunggu
                    @endif
                </td>
            </tr>
            <tr>
                <td class="label">Biaya Retribusi Jarak</td>
                <td>
                    @if($service->biaya_retribusi_jarak)
                        Rp {{ number_format($service->biaya_retribusi_jarak, 0, ',', '.') }}
                    @elseif($service->status == 'Ditolak')
                        <span style="color: #d9534f; font-weight: bold;">Ditolak</span>
                    @else
                        Menunggu
                    @endif
                </td>
            </tr>
            <tr>
                <td class="label">Total Biaya Retribusi</td>
                <td>
                    @if($service->biaya_retribusi)
                        <strong>Rp {{ number_format($service->biaya_retribusi, 0, ',', '.') }}</strong>
                    @elseif($service->status == 'Ditolak')
                        <span style="color: #d9534f; font-weight: bold;">Ditolak</span>
                    @else
                        Menunggu
                    @endif
                </td>
            </tr>
        </table>
    </div>

    @if($service->status == 'Ditolak' && $service->keterangan)
    <div class="info-section" style="border: 1px solid #d9534f; padding: 10px; background-color: #fdf7f7;">
        <h2 style="color: #d9534f;">Alasan Penolakan</h2>
        <p>{{ $service->keterangan }}</p>
    </div>
    @endif

    <div class="footer">
        <p>Dokumen ini diterbitkan secara elektronik dan tidak memerlukan tanda tangan.</p>
        <p>© {{ date('Y') }} UPTD Laboratorium Lingkungan Pada Dinas Lingkungan Hidup Kota Probolinggo - Dokumen Layanan Pengujian Air</p>
    </div>
</body>
</html> 