<?php
/**
 * Agentic Square - Client Portal Navigation Control Sidebar
 * Path: client/client-sidebar.php
 */
$currentPage = basename($_SERVER['PHP_SELF']);
$siteIdentity = function_exists('get_site_identity') ? get_site_identity() : ['business_name' => APP_NAME, 'logo_url' => ''];
$siteName = $siteIdentity['business_name'] ?? APP_NAME;
$siteLogoUrl = $siteIdentity['logo_url'] ?? '';
?>
<button data-drawer-target="client-sidebar" data-drawer-toggle="client-sidebar" aria-controls="client-sidebar" type="button" class="inline-flex items-center p-2 mt-2 ms-3 text-sm text-slate-400 rounded-lg lg:hidden hover:bg-slate-900 focus:outline-none focus:ring-2 focus:ring-slate-800 absolute top-4 left-4 z-50">
    <span class="sr-only">Open Menu</span>
    <i class="fa-solid fa-bars text-xl"></i>
</button>

<aside id="client-sidebar" class="fixed top-0 left-0 z-40 w-64 h-screen transition-transform -translate-x-full lg:translate-x-0 border-r border-slate-900/80 bg-slate-950/40 backdrop-blur-xl" aria-label="Sidebar">
    <div class="h-full px-4 py-6 overflow-y-auto flex flex-col justify-between">
        <div class="space-y-6">
            <div class="flex items-center gap-3 px-2 mb-8">
                <?php if (!empty($siteLogoUrl)): ?>
                    <div class="w-9 h-9 rounded-lg bg-slate-950 border border-slate-800 overflow-hidden flex items-center justify-center shadow-md">
                        <img src="<?php echo htmlspecialchars($siteLogoUrl, ENT_QUOTES, 'UTF-8'); ?>" alt="<?php echo htmlspecialchars($siteName, ENT_QUOTES, 'UTF-8'); ?> Logo" class="max-h-full max-w-full object-contain">
                    </div>
                <?php else: ?>
                    <div class="w-8 h-8 rounded-lg bg-gradient-to-tr from-nftAccentCyan to-nftAccentPurple flex items-center justify-center shadow-md">
                        <span class="text-white font-black text-sm"><?php echo htmlspecialchars(strtoupper(substr($siteName, 0, 1)), ENT_QUOTES, 'UTF-8'); ?></span>
                    </div>
                <?php endif; ?>
                <div class="min-w-0">
                    <h4 class="text-sm font-black tracking-tight text-white max-w-[160px] truncate"><?php echo htmlspecialchars($siteName, ENT_QUOTES, 'UTF-8'); ?></h4>
                    <span class="text-[10px] font-bold text-nftAccentCyan tracking-widest uppercase">// Client Panel</span>
                </div>
            </div>

            <nav class="space-y-1.5">
                <a href="client-dashboard.php" class="flex items-center gap-3 px-4 py-3 rounded-xl text-xs font-bold uppercase tracking-wider transition-all group <?php echo ($currentPage === 'client-dashboard.php') ? 'bg-gradient-to-r from-nftAccentCyan/10 to-nftAccentPurple/10 border border-nftAccentCyan/20 text-white' : 'text-nftTextGray hover:text-white hover:bg-slate-900/50'; ?>">
                    <i class="fa-solid fa-chart-pie text-sm transition-colors <?php echo ($currentPage === 'client-dashboard.php') ? 'text-nftAccentCyan' : 'text-slate-500 group-hover:text-nftAccentCyan'; ?>"></i>
                    Dashboard
                </a>
                
                <a href="downloads.php" class="flex items-center gap-3 px-4 py-3 rounded-xl text-xs font-bold uppercase tracking-wider transition-all group <?php echo ($currentPage === 'downloads.php') ? 'bg-gradient-to-r from-nftAccentCyan/10 to-nftAccentPurple/10 border border-nftAccentCyan/20 text-white' : 'text-nftTextGray hover:text-white hover:bg-slate-900/50'; ?>">
                    <i class="fa-solid fa-cloud-arrow-down text-sm transition-colors <?php echo ($currentPage === 'downloads.php') ? 'text-nftAccentCyan' : 'text-slate-500 group-hover:text-nftAccentCyan'; ?>"></i>
                    Downloads
                </a>

                <a href="update-profile.php" class="flex items-center gap-3 px-4 py-3 rounded-xl text-xs font-bold uppercase tracking-wider transition-all group <?php echo ($currentPage === 'update-profile.php') ? 'bg-gradient-to-r from-nftAccentCyan/10 to-nftAccentPurple/10 border border-nftAccentCyan/20 text-white' : 'text-nftTextGray hover:text-white hover:bg-slate-900/50'; ?>">
                    <i class="fa-solid fa-user-gear text-sm transition-colors <?php echo ($currentPage === 'update-profile.php') ? 'text-nftAccentCyan' : 'text-slate-500 group-hover:text-nftAccentCyan'; ?>"></i>
                    Update Profile
                </a>

                <a href="support-tickets.php" class="flex items-center gap-3 px-4 py-3 rounded-xl text-xs font-bold uppercase tracking-wider transition-all group <?php echo (in_array($currentPage, ['support-tickets.php', 'create-ticket.php', 'ticket-details.php'], true)) ? 'bg-gradient-to-r from-nftAccentCyan/10 to-nftAccentPurple/10 border border-nftAccentCyan/20 text-white' : 'text-nftTextGray hover:text-white hover:bg-slate-900/50'; ?>">
                    <i class="fa-solid fa-headset text-sm transition-colors <?php echo (in_array($currentPage, ['support-tickets.php', 'create-ticket.php', 'ticket-details.php'], true)) ? 'text-nftAccentCyan' : 'text-slate-500 group-hover:text-nftAccentCyan'; ?>"></i>
                    Support
                </a>
                <a href="contact-us.php" class="flex items-center gap-3 px-4 py-3 rounded-xl text-xs font-bold uppercase tracking-wider transition-all group <?php echo ($currentPage === 'contact-us.php') ? 'bg-gradient-to-r from-nftAccentCyan/10 to-nftAccentPurple/10 border border-nftAccentCyan/20 text-white' : 'text-nftTextGray hover:text-white hover:bg-slate-900/50'; ?>">
    <i class="fa-solid fa-envelope text-sm transition-colors <?php echo ($currentPage === 'contact-us.php') ? 'text-nftAccentCyan' : 'text-slate-500 group-hover:text-nftAccentCyan'; ?>"></i>
    Contact Us
</a>
            </nav>
        </div>

        <div>
            <a href="../logout.php" class="flex items-center gap-3 px-4 py-3 rounded-xl text-xs font-bold uppercase tracking-wider text-rose-400 hover:bg-rose-500/10 transition-all">
                <i class="fa-solid fa-right-from-bracket text-sm"></i>
                Logout Interface
            </a>
        </div>
    </div>
</aside>
