@extends('layouts.app')

@section('title', 'Pembayaran QRIS')

@section('content')
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header bg-success text-white">
                <h5 class="mb-0"><i class="fas fa-qrcode me-2"></i>Pembayaran QRIS</h5>
            </div>
            <div class="card-body text-center">
                <div class="mb-4">
                    <h4>Total Pembayaran</h4>
                    <h2 class="text-success fw-bold">Rp {{ number_format($order->total_price, 0, ',', '.') }}</h2>
                </div>

                <div class="mb-4">
                    <p class="text-muted">Silakan scan QR Code di bawah untuk melakukan pembayaran</p>
                </div>

                <div class="border rounded p-4 bg-light mb-4">
                    @if($qris && $qris->image_path && file_exists(public_path('images/qris/' . $qris->image_path)))
                        <img src="{{ asset('images/qris/' . $qris->image_path) }}" 
                             alt="QRIS Payment" style="max-width: 300px; max-height: 300px;" class="img-fluid">
                    @else
                        <div class="text-muted py-5">
                            <i class="fas fa-image fa-4x mb-3"></i>
                            <p>QRIS belum tersedia</p>
                            <p class="small">Silakan hubungi admin untuk informasi lebih lanjut</p>
                        </div>
                    @endif
                </div>

                @if($qris)
                    <div class="mb-4">
                        <p class="fw-bold">{{ $qris->name }}</p>
                    </div>
                @endif

                <div class="alert alert-info">
                    <i class="fas fa-info-circle me-2"></i>
                    Setelah melakukan pembayaran, silakan tunggu konfirmasi dari admin.
                </div>

                <div class="d-grid gap-2">
                    <a href="{{ route('menu.orders') }}" class="btn btn-primary">
                        <i class="fas fa-list me-1"></i> Lihat Pesanan Saya
                    </a>
                    <a href="{{ route('menu.index') }}" class="btn btn-outline-secondary">
                        <i class="fas fa-home me-1"></i> Kembali ke Menu
                    </a>
                </div>
            </div>
        </div>

        <div class="card mt-3">
            <div class="card-body">
                <h6>Detail Pesanan</h6>
                <table class="table table-sm">
                    @foreach($order->orderItems as $item)
                    <tr>
                        <td>{{ $item->menu->name }} x {{ $item->quantity }}</td>
                        <td class="text-end">Rp {{ number_format($item->price * $item->quantity, 0, ',', '.') }}</td>
                    </tr>
                    @endforeach
                    <tr class="fw-bold">
                        <td>Total</td>
                        <td class="text-end">Rp {{ number_format($order->total_price, 0, ',', '.') }}</td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
@endsection
