@{
    Layout = "~/Views/Admin/Transport/SpjDriverUpst/Shared/_Layout.cshtml";
    ViewData["Title"] = "Detail Penjemputan";
}

<div class="w-full lg:max-w-sm mx-auto min-h-screen bg-gray-50 pb-24">
    <form id="upst-antiforgery" class="hidden" aria-hidden="true">
        @Html.AntiForgeryToken()
    </form>

    <div class="bg-upst text-white px-6 pt-8 pb-16 rounded-b-[40px] shadow-lg relative">
        <div class="flex items-center justify-between relative z-10">
            <a href="@Url.Action("Index", "Home")" class="w-10 h-10 flex items-center justify-center bg-white/10 rounded-xl backdrop-blur-md">
                <i class="w-5 h-5" data-lucide="chevron-left"></i>
            </a>
            <h1 class="text-lg font-black uppercase tracking-tight">Detail Lokasi</h1>
            <div class="w-10"></div>
        </div>
    </div>

    <div class="flex justify-center -mt-8 mb-6 px-6 relative z-20">
        <div class="bg-white border border-gray-100 px-6 py-3 rounded-2xl flex items-center gap-4 w-full justify-between">
            <div class="flex flex-col">
                <span class="text-[10px] font-black text-gray-400 uppercase tracking-widest">Plat Nomor</span>
                <span id="plat-nomor" class="text-green-700 font-black text-xl leading-none">B 9632 TOR</span>
            </div>
            <div class="h-8 w-[1px] bg-gray-100"></div>
            <div class="text-right">
                <span class="text-[10px] font-black text-gray-400 uppercase tracking-widest">No. Pintu</span>
                <p class="text-orange-500 font-bold text-sm">JRC 005</p>
            </div>
        </div>
    </div>

    <div class="px-6 space-y-6">
        <div class="bg-white rounded-[32px] p-6 border border-gray-100 relative overflow-hidden">
            <div class="absolute top-0 right-0 p-4">
                <span class="px-3 py-1 bg-green-500 text-white rounded-full text-[10px] font-black tracking-tighter uppercase">
                    PENGANGKUTAN
                </span>
            </div>

            <div class="space-y-4">
                <div>
                    <p class="text-[10px] text-gray-400 uppercase tracking-widest mb-1">Perusahaan</p>
                    <h2 class="text-xl font-black text-gray-800 leading-tight">CV Tri Berkah Sejahtera</h2>
                </div>

                <div class="flex items-center justify-center gap-2 bg-gray-50 p-2 rounded-xl">
                    <p class="text-gray-600 font-mono text-xl font-bold uppercase tracking-tighter">SPJ/07-2025/PKM/000476</p>
                </div>

                <div class="pt-2 border-t border-gray-50">
                    <div class="flex gap-2 items-start">
                        <p class="text-gray-500 text-xs font-medium leading-relaxed">
                            Kp. Pertanian II Rt.004 Rw.001 Kel. Klender Kec, Duren Sawit, Kota Adm. Jakarta Timur 13470
                        </p>
                    </div>
                </div>

                <div class="pt-4 border-t border-gray-100 mt-4 space-y-3">
                    <p class="text-[10px] text-gray-400 uppercase tracking-widest mb-2">Total Berat Semua TPS</p>
                    
                    <div class="grid grid-cols-3 gap-2">
                        <div class="bg-green-50 rounded-xl p-2">
                            <p class="text-[9px] text-green-600 font-bold uppercase tracking-wider">Organik</p>
                            <p class="text-sm font-black text-green-700"><span id="grand-total-organik">0,00</span> kg</p>
                        </div>
                        <div class="bg-blue-50 rounded-xl p-2">
                            <p class="text-[9px] text-blue-600 font-bold uppercase tracking-wider">Anorganik</p>
                            <p class="text-sm font-black text-blue-700"><span id="grand-total-anorganik">0,00</span> kg</p>
                        </div>
                        <div class="bg-red-50 rounded-xl p-2">
                            <p class="text-[9px] text-red-600 font-bold uppercase tracking-wider">Residu</p>
                            <p class="text-sm font-black text-red-700"><span id="grand-total-residu">0,00</span> kg</p>
                        </div>
                    </div>
                    
                    <div class="flex items-center justify-between pt-2 border-t border-gray-100">
                        <p class="text-xs font-bold text-gray-600">Total Keseluruhan</p>
                        <span class="text-2xl font-black text-upst"><span id="grand-total-timbangan">0,00</span> kg</span>
                    </div>
                </div>

            </div>
        </div>

        <div id="tps-selection-container" class="bg-white rounded-[32px] p-6 border border-gray-100" style="display: none;">
            <div class="flex items-center gap-2 mb-4">
                <div class="w-2 h-2 rounded-full bg-upst"></div>
                <h3 class="font-black text-gray-800">Pilih TPS yang Akan Diangkut</h3>
            </div>
            <div id="tps-checkboxes" class="space-y-2 mb-4">
            </div>
            <button type="button" id="btn-confirm-tps" class="w-full bg-upst text-white py-3 rounded-xl font-bold text-sm hover:brightness-110">
                Lanjutkan ke Form
            </button>
        </div>

        <div id="tps-tabs-container" class="bg-white rounded-[32px] p-6 border border-gray-100" style="display: none;">
            <div class="flex items-center gap-2 mb-4">
                <div class="w-2 h-2 rounded-full bg-upst"></div>
                <h3 class="font-black text-gray-800">Form Pengangkutan</h3>
            </div>
            <div id="tps-tabs" class="flex gap-2 overflow-x-auto pb-2 mb-4">
            </div>
            <div id="tps-content">
            </div>
        </div>

        @if (TempData["Success"] != null)
        {
            <div class="bg-green-50 border border-green-200 text-green-700 rounded-2xl p-3 text-sm font-medium">
                @TempData["Success"]
            </div>
        }

        @if (TempData["Error"] != null)
        {
            <div class="bg-red-50 border border-red-200 text-red-700 rounded-2xl p-3 text-sm font-medium">
                @TempData["Error"]
            </div>
        }
    </div>

    <partial name="~/Views/Admin/Transport/SpjDriverUpst/Shared/Components/_Navigation.cshtml" />
</div>

<!-- <register-block dynamic-section="scripts" key="jsDetailPenjemputan">
<script src="~/driver/js/detail-penjemputan.js"></script>
</register-block> -->

@section Scripts {
    <script src="~/driver/js/detail-penjemputan.js"></script>
}