<div class="mx-auto max-w-4xl"><div class="mb-6"><p class="text-sm text-slate-500">Tell us what you need and TibaLeta will coordinate a suitable practitioner.</p></div>
<?php if($errors=session()->getFlashdata('errors')): ?><div class="mb-5 rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700"><?php foreach($errors as $e): ?><div><?= esc($e) ?></div><?php endforeach; ?></div><?php endif; ?>
<form method="post" action="/patient/request-care" class="space-y-6"><?= csrf_field() ?>
<section class="rounded-2xl border border-slate-100 bg-white p-6 shadow-card"><div class="flex items-center gap-3"><span class="grid h-10 w-10 place-items-center rounded-xl bg-teal-50 text-teal-600"><i data-lucide="stethoscope" class="h-5 w-5"></i></span><div><h2 class="font-display text-lg font-extrabold">1. What care do you need?</h2><p class="text-xs text-slate-400">Choose the service that best fits your request.</p></div></div><div class="mt-5 grid gap-3 sm:grid-cols-2 lg:grid-cols-4"><?php foreach($services as $s): ?><label class="group cursor-pointer"><input class="peer sr-only" type="radio" name="service_id" value="<?= $s['id'] ?>" <?= old('service_id')==$s['id']?'checked':'' ?> required><span class="block rounded-xl border border-slate-200 p-4 transition peer-checked:border-teal-600 peer-checked:bg-teal-50"><i data-lucide="<?= service_icon($s['slug']) ?>" class="h-5 w-5 text-teal-600"></i><span class="mt-3 block text-sm font-bold text-navy"><?= esc($s['name']) ?></span><span class="mt-1 block text-xs text-slate-400">From <?= money($s['base_price']) ?></span></span></label><?php endforeach; ?></div></section>
<section class="rounded-2xl border border-slate-100 bg-white p-6 shadow-card"><h2 class="font-display text-lg font-extrabold">2. Who needs care?</h2><div class="mt-4 grid gap-3 sm:grid-cols-2"><label class="rounded-xl border border-slate-200 p-4"><span class="flex items-center gap-3"><input type="radio" name="family_member_id" value="" checked><span><span class="block text-sm font-bold">Me</span><span class="text-xs text-slate-400"><?= esc($authUser['full_name']) ?></span></span></span></label><?php foreach($family as $f): ?><label class="rounded-xl border border-slate-200 p-4"><span class="flex items-center gap-3"><input type="radio" name="family_member_id" value="<?= $f['id'] ?>"><span><span class="block text-sm font-bold"><?= esc($f['full_name']) ?></span><span class="text-xs text-slate-400"><?= esc($f['relationship']) ?></span></span></span></label><?php endforeach; ?></div></section>
<section class="rounded-2xl border border-slate-100 bg-white p-6 shadow-card"><h2 class="font-display text-lg font-extrabold">3. Where and when?</h2><div class="mt-5 grid gap-4 sm:grid-cols-2"><div class="sm:col-span-2"><label class="mb-1.5 block text-xs font-bold text-slate-500">Home address</label><div class="flex gap-2"><input name="address_text" value="<?= esc(old('address_text')) ?>" required class="min-w-0 flex-1 rounded-xl border border-slate-200 px-4 py-3 text-sm focus:border-teal-500 focus:outline-none" placeholder="House, street, area, city"><button type="button" onclick="TibaLeta.geolocate()" class="rounded-xl border border-teal-200 bg-teal-50 px-4 text-xs font-bold text-teal-700">Use location</button></div><p id="location-status" class="mt-2 text-xs text-slate-400">Location is used only to match and coordinate the visit.</p><input type="hidden" id="latitude" name="latitude"><input type="hidden" id="longitude" name="longitude"></div><div><label class="mb-1.5 block text-xs font-bold text-slate-500">When?</label><select name="care_when" class="w-full rounded-xl border border-slate-200 px-4 py-3 text-sm"><option value="now">As soon as possible</option><option value="scheduled">Schedule for later</option></select></div><div><label class="mb-1.5 block text-xs font-bold text-slate-500">Scheduled time (optional)</label><input name="scheduled_for" type="datetime-local" class="w-full rounded-xl border border-slate-200 px-4 py-3 text-sm"></div><div><label class="mb-1.5 block text-xs font-bold text-slate-500">Priority</label><select name="urgency" class="w-full rounded-xl border border-slate-200 px-4 py-3 text-sm"><option value="routine">Routine</option><option value="priority">Priority home care</option></select></div><div class="sm:col-span-2"><label class="mb-1.5 block text-xs font-bold text-slate-500">What is happening?</label><textarea name="chief_complaint" required maxlength="1500" class="min-h-28 w-full rounded-xl border border-slate-200 px-4 py-3 text-sm focus:border-teal-500 focus:outline-none" placeholder="Briefly describe the symptoms or care needed."><?= esc(old('chief_complaint')) ?></textarea></div></div></section>
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"><p class="max-w-xl text-xs leading-5 text-slate-400">TibaLeta home care is not an emergency service. If the situation appears life-threatening, use the appropriate local emergency service.</p><button class="rounded-xl bg-teal-600 px-7 py-3 text-sm font-extrabold text-white hover:bg-teal-700">Find a practitioner</button></div>
</form></div>
