<?php
$menus = [
 'patient'=>[
  ['Overview','/patient','layout-dashboard'],['My Care','#','heart-pulse'],['Upcoming Visits','/patient/visits','calendar-days'],['Request Care','/patient/request-care','circle-plus'],['Health Records','/patient/health','file-heart'],['Lab Results','/patient/labs','flask-conical'],['Pharmacy','/patient/pharmacy','pill'],['Video Care','/patient/telehealth','video'],['Care Packages','/patient/packages','package-check'],['Family','/patient/family','users'],['Payments','/patient/payments','credit-card'],['Messages','/patient/messages','message-square'],['Notifications','/patient/notifications','bell'],['Profile & Settings','/patient/profile','settings']
 ],
 'practitioner'=>[
  ['Dashboard','/practitioner','layout-dashboard'],['New Requests','/practitioner/requests','radio'],['Today’s Visits','/practitioner/visits','calendar-check'],['Patients','/practitioner/patients','users'],['Clinical Notes','/practitioner/records','notebook-pen'],['Prescriptions','/practitioner/prescriptions','pill'],['Lab Requests','/practitioner/labs','flask-conical'],['Video Care','/practitioner/telehealth','video'],['Earnings','/practitioner/earnings','wallet-cards'],['Availability','/practitioner/availability','clock-3'],['Professional Profile','/practitioner/profile','badge-check']
 ],
 'partner'=>[
  ['Partner Dashboard','/partner','layout-dashboard'],['Lab Requests','/partner/labs','flask-conical'],['Pharmacy Orders','/partner/pharmacy','pill'],['Referrals','/partner/referrals','git-branch'],['Payments','/partner/payments','credit-card'],['Settings','/partner/settings','settings']
 ],
 'admin'=>[
  ['Command Centre','/admin','layout-dashboard'],['Live Operations','/admin/requests','activity'],['Patients','/admin/patients','users'],['Practitioners','/admin/practitioners','stethoscope'],['Credentials','/admin/credentials','badge-check'],['Visits','/admin/visits','calendar-check'],['Clinical Oversight','/admin/clinical','shield-check'],['Payments','/admin/payments','credit-card'],['Payouts','/admin/payouts','wallet-cards'],['Partners','/admin/partners','network'],['Reviews','/admin/reviews','message-circle-more'],['Services & Pricing','/admin/services','badge-dollar-sign'],['Analytics','/admin/analytics','chart-no-axes-combined'],['Audit Logs','/admin/audit','scroll-text'],['Settings','/admin/settings','settings']
 ]
];
$menu=$menus[$area] ?? $menus['patient']; $current='/' . trim(uri_string(),'/'); if($current==='/')$current='/patient';
$areaLabel=$area==='admin'?'TibaLeta Admin':($area==='practitioner'?'TibaLeta Pro':($area==='partner'?'TibaLeta Partner':'TibaLeta')); 
?>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title><?= esc($title ?? 'TibaLeta') ?></title><meta name="theme-color" content="#087F75"><link rel="icon" href="/assets/images/tibaleta-mark.svg" type="image/svg+xml"><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap" rel="stylesheet"><?php if(is_file(FCPATH.'assets/css/tailwind.build.css')): ?><link rel="stylesheet" href="/assets/css/tailwind.build.css"><?php else: ?><script src="https://cdn.tailwindcss.com"></script><script>tailwind.config={theme:{extend:{colors:{teal:{50:'#E8F7F3',600:'#087F75',700:'#076B63'},navy:'#102A43',cream:'#FAFAF7',coral:'#FF766D'},fontFamily:{sans:['Inter','sans-serif'],display:['Manrope','sans-serif']}}}}</script><?php endif; ?><link rel="stylesheet" href="/assets/css/tibaleta.css"><script src="https://unpkg.com/lucide@0.468.0/dist/umd/lucide.min.js" defer></script><script src="/assets/js/tibaleta.js" defer></script></head>
<body class="bg-slate-50 antialiased"><div class="dashboard-grid min-h-screen">
<aside id="portal-sidebar" class="mobile-sidebar fixed inset-y-0 left-0 z-50 w-60 overflow-y-auto bg-navy text-white lg:sticky lg:top-0 lg:z-20 lg:h-screen lg:translate-x-0">
 <div class="flex h-20 items-center gap-2 border-b border-white/10 px-5"><img src="/assets/images/tibaleta-mark.svg" class="h-9 w-9" alt=""><div><div class="font-display text-lg font-extrabold"><?= $areaLabel ?></div><div class="text-[10px] text-white/50"><?= $area==='admin'?'Operations':($area==='practitioner'?'Healthcare professional':($area==='partner'?'Partner network':'Patient care')) ?></div></div><button class="ml-auto text-white/60 lg:hidden" onclick="TibaLeta.closeSidebar()">×</button></div>
 <?php if($area==='practitioner'): ?><div class="mx-3 mt-4 rounded-xl border border-white/10 bg-white/5 p-3"><div class="flex items-center gap-3"><span class="grid h-9 w-9 place-items-center rounded-full bg-teal-600 text-xs font-bold"><?= initials($authUser['full_name'] ?? '') ?></span><div class="min-w-0"><div class="truncate text-xs font-bold"><?= esc($authUser['full_name'] ?? '') ?></div><div class="text-[10px] text-white/50">Verified practitioner</div></div></div><form action="/practitioner/availability/toggle" method="post" class="mt-3"><?= csrf_field() ?><button class="flex w-full items-center justify-center gap-2 rounded-lg bg-teal-600 px-3 py-2 text-xs font-bold">Toggle availability</button></form></div><?php endif; ?>
 <nav class="space-y-1 p-3"><?php foreach($menu as $item): if($item[1]==='#'): ?><div class="px-3 pb-1 pt-4 text-[10px] font-bold uppercase tracking-[.16em] text-white/35"><?= esc($item[0]) ?></div><?php else: $active=$current===$item[1] || ($item[1]!=='/patient' && $item[1]!=='/practitioner' && $item[1]!=='/admin' && str_starts_with($current,$item[1])); ?><a href="<?= $item[1] ?>" class="<?= $active?'nav-active':'text-white/65 hover:bg-white/5 hover:text-white' ?> flex items-center gap-3 rounded-lg px-3 py-2.5 text-xs font-semibold"><i data-lucide="<?= $item[2] ?>" class="h-4 w-4"></i><span><?= esc($item[0]) ?></span></a><?php endif; endforeach; ?></nav>
 <div class="mt-auto p-3"><a href="/" class="flex items-center gap-3 rounded-lg px-3 py-2.5 text-xs font-semibold text-white/60 hover:bg-white/5 hover:text-white"><i data-lucide="external-link" class="h-4 w-4"></i>Public site</a><form action="/logout" method="post"><?= csrf_field() ?><button class="flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-xs font-semibold text-white/60 hover:bg-white/5 hover:text-white"><i data-lucide="log-out" class="h-4 w-4"></i>Log out</button></form></div>
</aside>
<div class="min-w-0"><header class="sticky top-0 z-30 flex h-20 items-center border-b border-slate-100 bg-white/95 px-4 backdrop-blur sm:px-6 lg:px-8"><button data-menu-toggle class="mr-3 grid h-10 w-10 place-items-center rounded-xl border border-slate-200 lg:hidden"><i data-lucide="menu" class="h-5 w-5"></i></button><div><p class="text-[10px] font-bold uppercase tracking-[.16em] text-teal-600"><?= $area==='admin'?'Operations':($area==='practitioner'?'Professional workspace':($area==='partner'?'Partner workspace':'My care')) ?></p><h1 class="font-display text-lg font-extrabold text-navy"><?= esc($title ?? 'Dashboard') ?></h1></div><div class="ml-auto flex items-center gap-3"><a href="<?= $area==='patient'?'/patient/notifications':'#' ?>" class="relative grid h-10 w-10 place-items-center rounded-xl border border-slate-200 bg-white text-slate-500"><i data-lucide="bell" class="h-4 w-4"></i></a><div class="hidden text-right sm:block"><div class="text-xs font-bold text-navy"><?= esc($authUser['full_name'] ?? '') ?></div><div class="text-[10px] capitalize text-slate-400"><?= esc($authUser['role'] ?? '') ?></div></div><span class="grid h-10 w-10 place-items-center rounded-full bg-teal-50 text-xs font-extrabold text-teal-700"><?= initials($authUser['full_name'] ?? '') ?></span></div></header>
<?php foreach(['success'=>'bg-emerald-50 text-emerald-800 border-emerald-200','warning'=>'bg-amber-50 text-amber-800 border-amber-200','error'=>'bg-rose-50 text-rose-800 border-rose-200'] as $type=>$classes): if(session()->getFlashdata($type)): ?><div role="alert" class="mx-4 mt-4 flex items-center justify-between rounded-xl border px-4 py-3 text-sm sm:mx-6 lg:mx-8 <?= $classes ?>"><span><?= esc(session()->getFlashdata($type)) ?></span><button data-dismiss>×</button></div><?php endif; endforeach; ?>
<main class="p-4 sm:p-6 lg:p-8"><?= view($view, get_defined_vars()) ?></main></div></div><script>window.addEventListener('DOMContentLoaded',()=>{if(window.lucide)lucide.createIcons()})</script></body></html>
