@extends('layouts.app')

@section('title', 'Detail Pemesanan - INUFA')

@section('header', 'Detail Pemesanan')

@section('content')
<div class="bg-white rounded-lg shadow-lg overflow-hidden">
    <!-- Header Detail -->
    <div class="bg-blue-800 text-white p-4">
        <div class="flex justify-between items-center">
            <h2 class="text-lg font-bold">Kode Pemesanan: #{{ $sewa->id }}</h2>
            <span class="px-3 py-1 rounded-full text-sm font-semibold 
                {{ $sewa->status == 'pending' ? 'bg-yellow-200 text-yellow-800' : 
                   ($sewa->status == 'confirmed' ? 'bg-blue-200 text-blue-800' : 
                   ($sewa->status == 'ongoing' ? 'bg-purple-200 text-purple-800' : 
                   ($sewa->status == 'completed' ? 'bg-green-200 text-green-800' : 
                   'bg-red-200 text-red-800'))) }}">
                {{ ucfirst($sewa->status) }}
            </span>
        </div>
        <p class="text-sm opacity-80 mt-1">Tanggal Pemesanan: {{ $sewa->created_at->format('d F Y, H:i') }}</p>
    </div>

    <!-- Detail Informasi -->
    <div class="p-6 grid grid-cols-1 md:grid-cols-2 gap-6">
        <!-- Informasi Paket -->
        <div class="space-y-4">
            <h3 class="text-lg font-semibold">Informasi Paket</h3>
            <div class="bg-gray-50 p-4 rounded-lg">
                <div class="space-y-2">
                    <div class="flex justify-between">
                        <span class="text-gray-600">Nama Paket:</span>
                        <span class="font-medium">{{ $sewa->paket->nama_paket }}</span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-gray-600">Harga per Hari:</span>
                        <span class="font-medium">Rp {{ number_format($sewa->paket->harga, 0, ',', '.') }}</span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-gray-600">Durasi Sewa:</span>
                        <span class="font-medium">{{ $sewa->durasi_sewa }} hari</span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-gray-600">Total Harga:</span>
                        <span class="font-medium text-blue-600">Rp {{ number_format($sewa->total_harga, 0, ',', '.') }}</span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Informasi Pembayaran -->
        <div class="space-y-4">
            <h3 class="text-lg font-semibold">Informasi Pembayaran</h3>
            <div class="bg-gray-50 p-4 rounded-lg">
                <div class="space-y-2">
                    <div class="flex justify-between">
                        <span class="text-gray-600">Nominal Pembayaran:</span>
                        <span class="font-medium">
                            @if($sewa->nominal_pembayaran)
                                Rp {{ number_format($sewa->nominal_pembayaran, 0, ',', '.') }}
                            @else
                                <span class="text-gray-500">-</span>
                            @endif
                        </span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-gray-600">Status Pembayaran:</span>
                        <span>
                            @if($sewa->nominal_pembayaran)
                                @if($sewa->nominal_pembayaran >= $sewa->total_harga)
                                    <span class="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs font-semibold">
                                        Lunas
                                    </span>
                                @else
                                    <span class="px-2 py-1 bg-yellow-100 text-yellow-800 rounded-full text-xs font-semibold">
                                        DP {{ number_format(($sewa->nominal_pembayaran / $sewa->total_harga) * 100, 0) }}%
                                    </span>
                                @endif
                            @else
                                <span class="px-2 py-1 bg-red-100 text-red-800 rounded-full text-xs font-semibold">
                                    Belum Bayar
                                </span>
                            @endif
                        </span>
                    </div>
                    @if($sewa->tanggal_pembayaran)
                    <div class="flex justify-between">
                        <span class="text-gray-600">Tanggal Pembayaran:</span>
                        <span class="font-medium">{{ $sewa->tanggal_pembayaran->format('d/m/Y H:i') }}</span>
                    </div>
                    @endif
                    @if($sewa->bukti_pembayaran)
                    <div class="flex justify-between items-center">
                        <span class="text-gray-600">Bukti Pembayaran:</span>
                        <a href="{{ Storage::url($sewa->bukti_pembayaran) }}" target="_blank" 
                           class="text-blue-600 hover:text-blue-800 font-medium">
                            Lihat Bukti
                        </a>
                    </div>
                    @endif
                </div>
            </div>
        </div>

        <!-- Informasi Pengiriman -->
        <div class="space-y-4">
            <h3 class="text-lg font-semibold">Informasi Pengiriman</h3>
            <div class="bg-gray-50 p-4 rounded-lg">
                <div class="space-y-2">
                    <div class="flex justify-between">
                        <span class="text-gray-600">Kota Tujuan:</span>
                        <span class="font-medium">{{ $sewa->kota->nama_kota }}</span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-gray-600">Biaya Ongkir:</span>
                        <span class="font-medium">Rp {{ number_format($sewa->ongkir, 0, ',', '.') }}</span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-gray-600">Alamat:</span>
                        <span class="font-medium">{{ $sewa->lokasi }}</span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Informasi Jaminan -->
        <div class="space-y-4">
            <h3 class="text-lg font-semibold">Informasi Jaminan</h3>
            <div class="bg-gray-50 p-4 rounded-lg">
                <div class="space-y-2">
                    @if($sewa->foto_jaminan)
                    <div class="flex justify-between">
                        <span class="text-gray-600">Jenis Jaminan:</span>
                        <span class="font-medium">{{ strtoupper($sewa->jenis_jaminan) }}</span>
                    </div>
                    <div class="flex justify-between items-center">
                        <span class="text-gray-600">Foto Jaminan:</span>
                        <a href="{{ Storage::url($sewa->foto_jaminan) }}" target="_blank" 
                           class="text-blue-600 hover:text-blue-800 font-medium">
                            Lihat Jaminan
                        </a>
                    </div>
                    @else
                    <p class="text-gray-500 text-center">Belum ada jaminan yang diupload</p>
                    @endif
                </div>
            </div>
        </div>
    </div>

    <!-- Tombol Kembali -->
    <div class="p-6 border-t border-gray-200">
        <a href="{{ route('riwayat') }}" 
           class="inline-block bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition-colors">
            Kembali ke Riwayat
        </a>
    </div>
</div>
@endsection 