<title>Maklumat Tuntutan (HR)</title>
@extends('ui::layouts.app')

@section('content')
<style>
    body { background-color: #f0f2f5; }
    .ui.container { max-width: 70% !important; margin-top: 2rem; }
    .ui.segment {
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        border-radius: 10px;
        background-color: #fff;
        padding: 2rem;
    }
    table.ui.definition.table td:first-child {
        width: 40%;
        font-weight: 600;
        background-color: #f9fafb;
    }
    .totals-row td {
        font-weight: 700;
        background: #f7f7f8;
    }
    .button-bar { margin-top: 2rem; display: flex; justify-content: space-between; }
</style>

<div class="ui container">
    <h2 class="ui header">Maklumat Tuntutan (HR)</h2>

    <div class="ui segment">
        <table class="ui definition table">
            <tr><td>Tarikh Tuntutan</td><td>{{ \Carbon\Carbon::parse($claim->claim_date)->format('d/m/Y') }}</td></tr>
            <tr><td>Jenis Kenderaan</td><td>{{ $claim->jenisKenderaan->keterangan ?? $claim->jenisKenderaan->name ?? '-' }}</td></tr>
            <tr><td>Nama Projek</td><td>{{ $claim->project->p_project_description ?? 'Tanpa Projek' }}</td></tr>
            <tr><td>Butiran</td><td>{{ $claim->description ?? '-' }}</td></tr>
            <tr><td>Jarak Dari</td><td>{{ $claim->distance_from ?? '-' }}</td></tr>
            <tr><td>Jarak Ke</td><td>{{ $claim->distance_to ?? '-' }}</td></tr>
            <tr><td>Jumlah Perbatuan</td><td>{{ number_format($claim->total_mileage, 2) }} km</td></tr>
            <tr><td>Toll</td><td>RM {{ number_format($claim->toll_amount ?? 0, 2) }}</td></tr>
            <tr><td>Lain-lain</td><td>RM {{ number_format($claim->others_amount ?? 0, 2) }}</td></tr>
            <tr><td>Butiran Lain-lain</td><td>{{ $claim->others_description ?? '-' }}</td></tr>
            <tr><td>Status</td><td><strong>{{ $claim->status }}</strong></td></tr>
            <tr class="totals-row"><td>Jumlah Akhir</td><td><strong>RM {{ number_format($claim->total_claim_amount, 2) }}</strong></td></tr>
        </table>
    </div>

    <div class="button-bar">
        <form action="{{ url()->previous() }}" method="GET" style="display:inline;">
            <button type="submit" class="ui grey button">
                <i class="arrow left icon"></i> Kembali
            </button>
        </form>

        @if(!in_array($claim->status, ['Ditolak', 'Diluluskan']))
            <form action="{{ route('mileage::HR.reject', $claim->id) }}" method="POST" style="display:inline;">
                @csrf
                <button type="submit" class="ui red button" onclick="return confirm('Tolak tuntutan ini?')">
                    <i class="times icon"></i> Tolak
                </button>
            </form>
        @endif
    </div>
</div>
@endsection
