<div class="mx-auto max-w-6xl"><?php if(!$visit): ?><div class="rounded-2xl border border-slate-100 bg-white px-6 py-16 text-center shadow-card"><span class="mx-auto grid h-12 w-12 place-items-center rounded-2xl bg-teal-50 text-teal-600"><i data-lucide="house-heart" class="h-5 w-5"></i></span><h2 class="mt-4 font-display text-xl font-extrabold">No active visit</h2><p class="mt-2 text-sm text-slate-500">When a practitioner accepts your request, live visit status will appear here.</p><a href="/patient/request-care" class="mt-6 inline-flex rounded-xl bg-teal-600 px-5 py-3 text-sm font-bold text-white">Request Care</a></div><?php else: ?>
<div class="mb-6"><p class="text-sm text-slate-500">Your practitioner and care status in one view.</p></div><div class="grid gap-6 lg:grid-cols-[1fr_320px]"><section class="overflow-hidden rounded-2xl border border-slate-100 bg-white shadow-card"><div class="border-b border-slate-100 p-5"><div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between"><div><p class="text-xs font-bold uppercase tracking-[.15em] text-teal-600"><?= esc(ucwords(str_replace('_',' ',$visit['status']))) ?></p><h2 class="mt-1 font-display text-2xl font-extrabold"><?= in_array($visit['status'],['en_route'])?'Your practitioner is on the way':(in_array($visit['status'],['arrived','in_progress'])?'Your home visit is underway':'Your practitioner is confirmed') ?></h2></div><div class="rounded-xl bg-teal-50 px-4 py-3 text-center"><div class="font-display text-xl font-extrabold text-teal-700"><?= $visit['status']==='en_route'?'~18 min':'Confirmed' ?></div><div class="text-[10px] font-semibold text-slate-400"><?= $visit['status']==='en_route'?'Estimated arrival':'Visit status' ?></div></div></div></div><div class="relative h-[470px] map-grid"><div class="absolute left-[8%] top-[20%] w-[80%] map-road rotate-6"></div><div class="absolute left-[16%] top-[55%] w-[70%] map-road -rotate-12"></div><div class="absolute left-[62%] top-[18%] h-[65%] w-[7px] map-road rotate-12"></div><div class="pin" style="left:24%;top:29%"><span>DR</span></div><div class="absolute right-[18%] bottom-[23%] grid h-14 w-14 place-items-center rounded-full bg-coral text-white shadow-soft"><i data-lucide="house" class="h-6 w-6"></i></div><svg class="absolute inset-0 h-full w-full" viewBox="0 0 800 470" preserveAspectRatio="none"><path d="M230 155 C360 170, 390 250, 620 340" fill="none" stroke="#087F75" stroke-width="4" stroke-dasharray="10 8"/></svg></div><div class="flex flex-wrap gap-2 border-t border-slate-100 p-4"><a href="tel:<?= esc($visit['practitioner_phone'] ?? '') ?>" class="rounded-xl border border-slate-200 px-4 py-2.5 text-xs font-bold">Call</a><a href="/patient/messages" class="rounded-xl border border-slate-200 px-4 py-2.5 text-xs font-bold">Message</a><span class="rounded-xl bg-slate-50 px-4 py-2.5 text-xs text-slate-400">Location updates are shared only during an active visit.</span></div></section>
<aside class="space-y-5"><div class="rounded-2xl border border-slate-100 bg-white p-5 shadow-card"><div class="flex items-center gap-3"><span class="grid h-12 w-12 place-items-center rounded-full bg-teal-50 text-xs font-extrabold text-teal-700"><?= initials($visit['practitioner_name']) ?></span><div><h3 class="font-display font-extrabold"><?= esc($visit['practitioner_name'] ?: 'Assigned practitioner') ?></h3><p class="text-xs text-slate-400"><?= esc($visit['profession'] ?: '') ?></p></div></div><div class="mt-5 space-y-3 border-t border-slate-100 pt-4 text-xs"><div class="flex justify-between"><span class="text-slate-400">Service</span><strong><?= esc($visit['service_name']) ?></strong></div><div class="flex justify-between"><span class="text-slate-400">Address</span><strong class="max-w-[160px] text-right"><?= esc($visit['address_text']) ?></strong></div><div class="flex justify-between"><span class="text-slate-400">Amount</span><strong><?= money($visit['estimated_amount']) ?></strong></div></div></div><div class="rounded-2xl border border-slate-100 bg-white p-5 shadow-card"><h3 class="font-display font-extrabold">Visit progress</h3><div class="mt-4 space-y-3"><?php $steps=['accepted'=>'Confirmed','en_route'=>'On the way','arrived'=>'Arrived','in_progress'=>'Visit in progress','completed'=>'Completed'];$order=array_keys($steps);$current=array_search($visit['status'],$order,true);foreach($steps as $key=>$label):$idx=array_search($key,$order,true);?><div class="flex items-center gap-3 text-xs"><span class="grid h-6 w-6 place-items-center rounded-full <?= $idx<=$current?'bg-teal-600 text-white':'bg-slate-100 text-slate-300' ?>"><?= $idx<$current?'✓':$idx+1 ?></span><span class="<?= $idx<=$current?'font-semibold text-navy':'text-slate-400' ?>"><?= $label ?></span></div><?php endforeach; ?></div></div></aside></div><?php endif; ?></div>
