All files / components/layout DashboardNav.tsx

91.99% Statements 402/437
79.71% Branches 55/69
33.33% Functions 4/12
91.99% Lines 402/437

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 5891x                                                                                                               1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x     1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x   1x 57x 57x 57x 57x 57x 57x     57x           57x 24x 57x     57x 57x 8x 48x       57x 8x 48x     57x 8x 48x     57x 8x 48x     57x 57x 57x     57x 24x 57x     57x 25x 1x 25x 24x 24x 25x 25x 25x 57x   57x 3x 3x 3x 3x 3x   57x 57x   57x   57x 232x 232x 232x 232x 232x 232x 232x 232x 56x 176x 8x 168x 232x   232x 232x 232x 56x 56x 56x 56x 56x   232x   57x     57x 57x 57x 57x 57x 57x   56x 57x   57x   57x 57x 57x 57x 57x 57x 4x 4x 4x 4x 4x 4x   4x 4x 36x 36x 36x 8x 8x 8x 8x 8x   8x 8x   8x 8x 8x   28x 28x 28x 28x 28x   28x 28x   28x 28x 28x   4x 4x 4x   57x 57x     57x 56x 56x 56x 56x 56x 56x 56x 56x 384x 384x 384x 384x   384x 384x 384x 56x 56x 56x 56x       57x 57x 57x 57x 57x   57x 57x     57x                             57x 57x 57x 57x 57x 57x   57x 57x 57x 57x     57x 57x 57x 57x 57x 57x   57x 57x     57x 32x 32x 32x 1x   1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 13x 13x 13x 13x 13x 13x 1x 12x   12x 13x 13x 13x 13x 13x 13x 13x   13x 2x 2x 2x 2x   2x 2x 2x 2x 2x   11x 11x 11x 11x   11x 11x 11x 11x 11x   13x   1x     1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 7x 7x 7x 7x 7x   7x 7x 7x 1x 1x     1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x   1x   1x 1x     1x                                             1x 1x 1x 1x   1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x   32x 32x 32x 57x   57x  
'use client';
 
import { useState, useEffect } from 'react';
import { createPortal } from 'react-dom';
import Link from 'next/link';
import { usePathname, useRouter } from 'next/navigation';
import { motion, AnimatePresence } from 'framer-motion';
import {
  User,
  Briefcase,
  MessageSquare,
  Package,
  BarChart3,
  Settings,
  ExternalLink,
  LogOut,
  Menu,
  X,
  CreditCard,
  LineChart,
  GraduationCap,
  Code2,
  Palette,
  ChevronDown,
  MoreHorizontal,
  UserPlus,
  Gift,
  BookOpen,
  LayoutTemplate,
  Paintbrush,
  Stethoscope,
  Scale,
  Crown,
  Shield,
  type LucideIcon,
} from 'lucide-react';
import { Button } from '@/components/ui/button';
 
import { createClient } from '@/lib/supabase/client';
import type { ProfileType, AdminRole } from '@/types/database';
 
interface NavItem {
  href: string;
  label: string;
  icon: LucideIcon;
  color?: string;
}
 
interface DashboardNavProps {
  username: string;
  profileType?: ProfileType;
  isAdmin?: boolean;
  adminRole?: AdminRole | null;
}
 
// Primary nav items (always visible on desktop)
const primaryNavItems: NavItem[] = [
  { href: '/dashboard', label: 'Dashboard', icon: BarChart3 },
  { href: '/profile', label: 'Profile', icon: User },
  { href: '/samples', label: 'Samples', icon: Briefcase },
  { href: '/experience', label: 'Experience', icon: Briefcase },
];
 
// Secondary nav items (in "More" dropdown on desktop)
const secondaryNavItems: NavItem[] = [
  {
    href: '/testimonials',
    label: 'Testimonials',
    icon: MessageSquare,
  },
  { href: '/packages', label: 'Packages', icon: Package },
  { href: '/invites', label: 'Invites', icon: UserPlus },
  { href: '/referrals', label: 'Referrals', icon: Gift },
  { href: '/my-templates', label: 'Templates', icon: LayoutTemplate },
  { href: '/analytics', label: 'Analytics', icon: LineChart },
  { href: '/blog', label: 'Blog', icon: BookOpen },
  { href: '/subscription', label: 'Billing', icon: CreditCard },
  { href: '/settings', label: 'Settings', icon: Settings },
];
 
// Items that should force refresh on navigation (to get fresh data)
const forceRefreshItems = new Set(['/analytics', '/subscription']);
 
// All core items for mobile
const coreNavItems: NavItem[] = [...primaryNavItems, ...secondaryNavItems];
 
const verticalNavItems: Record<string, NavItem> = {
  tutor: {
    href: '/tutor',
    label: 'Tutor',
    icon: GraduationCap,
    color: 'text-blue-500',
  },
  developer: {
    href: '/developer',
    label: 'Developer',
    icon: Code2,
    color: 'text-green-500',
  },
  designer: {
    href: '/designer',
    label: 'Designer',
    icon: Palette,
    color: 'text-purple-500',
  },
  artist: {
    href: '/artist',
    label: 'Artist',
    icon: Paintbrush,
    color: 'text-pink-500',
  },
  doctor: {
    href: '/doctor',
    label: 'Doctor',
    icon: Stethoscope,
    color: 'text-red-500',
  },
  lawyer: {
    href: '/lawyer',
    label: 'Lawyer',
    icon: Scale,
    color: 'text-amber-600',
  },
  elite: {
    href: '/elite',
    label: 'Elite',
    icon: Crown,
    color: 'text-amber-500',
  },
};
 
// All verticals for the dropdown
const allVerticals: NavItem[] = [
  {
    href: '/tutor',
    label: 'Tutor Dashboard',
    icon: GraduationCap,
    color: 'text-blue-500',
  },
  {
    href: '/developer',
    label: 'Developer Dashboard',
    icon: Code2,
    color: 'text-green-500',
  },
  {
    href: '/designer',
    label: 'Designer Dashboard',
    icon: Palette,
    color: 'text-purple-500',
  },
  {
    href: '/artist',
    label: 'Artist Dashboard',
    icon: Paintbrush,
    color: 'text-pink-500',
  },
  {
    href: '/doctor',
    label: 'Doctor Dashboard',
    icon: Stethoscope,
    color: 'text-red-500',
  },
  {
    href: '/lawyer',
    label: 'Lawyer Dashboard',
    icon: Scale,
    color: 'text-amber-600',
  },
  {
    href: '/elite',
    label: 'Elite Dashboard',
    icon: Crown,
    color: 'text-amber-500',
  },
];
 
const adminRoleLabels: Record<string, string> = {
  super_admin: 'Super Admin',
  doctor_admin: 'Doctor Admin',
  lawyer_admin: 'Lawyer Admin',
  elite_admin: 'Elite Admin',
};
 
export function DashboardNav({ username, profileType, isAdmin, adminRole }: DashboardNavProps) {
  const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
  const [moreMenuOpen, setMoreMenuOpen] = useState(false);
  const [isSigningOut, setIsSigningOut] = useState(false);
  const [mounted, setMounted] = useState(false);
  const pathname = usePathname();
  const router = useRouter();
 
  // Get admin role label for display
  const getAdminRoleLabel = (role: AdminRole | null | undefined): string => {
    if (!role) return 'Admin';
    return adminRoleLabels[role] || 'Admin';
  };
 
  // Track mount state for portal (SSR safety)
  useEffect(() => {
    setMounted(true);
  }, []);
 
  // Get the vertical nav item if profile type is set
  const verticalItem =
    profileType && profileType !== 'general'
      ? verticalNavItems[profileType as keyof typeof verticalNavItems]
      : null;
 
  // Combine nav items - add vertical item after Dashboard if it exists
  // Also show other verticals that the user might want to explore
  const navItems = verticalItem
    ? [coreNavItems[0], verticalItem, ...coreNavItems.slice(1)]
    : coreNavItems;
 
  // Primary items for desktop (with vertical if set)
  const desktopPrimaryItems = verticalItem
    ? [primaryNavItems[0], verticalItem, ...primaryNavItems.slice(1)]
    : primaryNavItems;
 
  // Always show verticals for discovery - filter out current vertical if user has one
  const availableVerticals = verticalItem
    ? allVerticals.filter((v) => v.href !== verticalItem.href)
    : allVerticals;
 
  // Check if current path is in secondary items
  const isSecondaryActive = secondaryNavItems.some(
    (item) => pathname === item.href || pathname.startsWith(item.href + '/')
  );
 
  // Close mobile menu on route change
  useEffect(() => {
    setMobileMenuOpen(false);
  }, [pathname]);
 
  // Prevent body scroll when mobile menu is open
  useEffect(() => {
    if (mobileMenuOpen) {
      document.body.style.overflow = 'hidden';
    } else {
      document.body.style.overflow = 'unset';
    }
    return () => {
      document.body.style.overflow = 'unset';
    };
  }, [mobileMenuOpen]);
 
  const handleSignOut = async () => {
    setIsSigningOut(true);
    const supabase = createClient();
    await supabase.auth.signOut();
    router.push('/login');
  };
 
  return (
    <div className="flex items-center">
      {/* Desktop Navigation */}
      <nav className="hidden items-center gap-1 md:flex">
        {/* Primary Nav Items */}
        {desktopPrimaryItems.map((item) => {
          const isActive = pathname === item.href || pathname.startsWith(item.href + '/');
          const itemColor = item.color;
          return (
            <Link
              key={item.href}
              href={item.href}
              className={`relative flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-all duration-200 ${
                isActive
                  ? 'bg-muted text-foreground'
                  : itemColor
                    ? `${itemColor} hover:bg-muted`
                    : 'text-muted-foreground hover:bg-muted hover:text-foreground'
              }`}
            >
              <item.icon className={`h-4 w-4 ${isActive && itemColor ? itemColor : ''}`} />
              {item.label}
              {isActive && (
                <motion.div
                  layoutId="activeTab"
                  className="absolute inset-0 -z-10 rounded-md bg-muted"
                  transition={{ type: 'spring', duration: 0.5 }}
                />
              )}
            </Link>
          );
        })}
 
        {/* More Dropdown (Secondary Items) */}
        <div className="relative">
          <button
            onClick={() => setMoreMenuOpen(!moreMenuOpen)}
            onBlur={() => setTimeout(() => setMoreMenuOpen(false), 150)}
            className={`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-all duration-200 ${
              isSecondaryActive
                ? 'bg-muted text-foreground'
                : 'text-muted-foreground hover:bg-muted hover:text-foreground'
            }`}
          >
            <MoreHorizontal className="h-4 w-4" />
            More
            <ChevronDown
              className={`h-3 w-3 transition-transform duration-200 ${moreMenuOpen ? 'rotate-180' : ''}`}
            />
          </button>
          <AnimatePresence>
            {moreMenuOpen && (
              <motion.div
                initial={{ opacity: 0, y: -8, scale: 0.96 }}
                animate={{ opacity: 1, y: 0, scale: 1 }}
                exit={{ opacity: 0, y: -8, scale: 0.96 }}
                transition={{ duration: 0.15, ease: 'easeOut' }}
                className="absolute right-0 top-full z-50 mt-1 w-52 rounded-md border bg-background shadow-lg"
              >
                <div className="p-1">
                  {secondaryNavItems.map((item) => {
                    const isActive = pathname === item.href || pathname.startsWith(item.href + '/');
                    const shouldForceRefresh = forceRefreshItems.has(item.href);
                    return shouldForceRefresh ? (
                      <a
                        key={item.href}
                        href={item.href}
                        className={`flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors ${
                          isActive
                            ? 'bg-muted text-foreground'
                            : 'text-muted-foreground hover:bg-muted hover:text-foreground'
                        }`}
                      >
                        <item.icon className="h-4 w-4" />
                        {item.label}
                      </a>
                    ) : (
                      <Link
                        key={item.href}
                        href={item.href}
                        className={`flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors ${
                          isActive
                            ? 'bg-muted text-foreground'
                            : 'text-muted-foreground hover:bg-muted hover:text-foreground'
                        }`}
                      >
                        <item.icon className="h-4 w-4" />
                        {item.label}
                      </Link>
                    );
                  })}
                </div>
              </motion.div>
            )}
          </AnimatePresence>
        </div>
 
        {/* Verticals Dropdown (Desktop) - Always show to allow exploring other verticals */}
        {availableVerticals.length > 0 && (
          <div className="group relative">
            <button className="flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground">
              <Briefcase className="h-4 w-4" />
              {verticalItem ? 'Explore More' : 'Verticals'}
            </button>
            <div className="invisible absolute left-0 top-full z-50 mt-1 w-52 rounded-md border bg-background opacity-0 shadow-lg transition-all duration-200 group-hover:visible group-hover:opacity-100">
              <div className="p-1">
                {availableVerticals.map((item) => (
                  <Link
                    key={item.href}
                    href={item.href}
                    className={`flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium ${item.color} transition-colors hover:bg-muted`}
                  >
                    <item.icon className="h-4 w-4" />
                    {item.label}
                  </Link>
                ))}
              </div>
            </div>
          </div>
        )}
 
        {/* View Profile Link */}
        <Link
          href={`/${username}`}
          target="_blank"
          className="ml-2 flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium text-primary transition-colors duration-200 hover:bg-muted"
        >
          View Profile
          <ExternalLink className="h-3.5 w-3.5" />
        </Link>
 
        {/* Admin Link (Desktop) */}
        {isAdmin && (
          <Link
            href="/admin/applications"
            className={`ml-2 flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors duration-200 ${
              pathname.startsWith('/admin')
                ? 'bg-amber-500/10 text-amber-600 dark:text-amber-400'
                : 'text-amber-600 hover:bg-amber-500/10 dark:text-amber-400'
            }`}
          >
            <Shield className="h-4 w-4" />
            {getAdminRoleLabel(adminRole)}
          </Link>
        )}
 
        {/* Sign Out */}
        <Button
          variant="ghost"
          size="sm"
          onClick={handleSignOut}
          disabled={isSigningOut}
          className="ml-2 transition-all duration-200"
        >
          <LogOut className="mr-1.5 h-4 w-4" />
          {isSigningOut ? 'Signing out...' : 'Sign Out'}
        </Button>
      </nav>
 
      {/* Mobile Menu Button */}
      <Button
        variant="ghost"
        size="icon"
        className="relative z-50 shrink-0 select-none border-none outline-none ring-0 focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 active:border-none md:hidden"
        onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
        aria-label={mobileMenuOpen ? 'Close menu' : 'Open menu'}
      >
        {mobileMenuOpen ? <X className="h-5 w-5" /> : <Menu className="h-5 w-5" />}
      </Button>
 
      {/* Mobile Navigation Overlay - Rendered via Portal to escape header's backdrop-blur containing block */}
      {mounted &&
        createPortal(
          <AnimatePresence>
            {mobileMenuOpen && (
              <>
                {/* Backdrop */}
                <motion.div
                  initial={{ opacity: 0 }}
                  animate={{ opacity: 1 }}
                  exit={{ opacity: 0 }}
                  transition={{ duration: 0.2 }}
                  className="fixed inset-0 top-14 z-40 bg-background/80 backdrop-blur-sm md:hidden"
                  onClick={() => setMobileMenuOpen(false)}
                />
 
                {/* Menu Panel - Fixed with scroll */}
                <motion.div
                  initial={{ opacity: 0, x: -20 }}
                  animate={{ opacity: 1, x: 0 }}
                  exit={{ opacity: 0, x: -20 }}
                  transition={{ duration: 0.2, ease: 'easeOut' }}
                  className="fixed bottom-0 left-0 top-14 z-40 flex w-72 flex-col border-r bg-background shadow-xl md:hidden"
                >
                  {/* Scrollable content */}
                  <nav className="flex-1 space-y-1 overflow-y-auto p-4">
                    {navItems.map((item, index) => {
                      const isActive =
                        pathname === item.href || pathname.startsWith(item.href + '/');
                      const itemColor = item.color;
                      const shouldForceRefresh = forceRefreshItems.has(item.href);
                      const linkClassName = `flex items-center gap-3 rounded-md px-3 py-3 text-sm font-medium transition-all duration-200 ${
                        isActive
                          ? 'bg-primary text-primary-foreground'
                          : itemColor
                            ? `${itemColor} hover:bg-muted active:scale-[0.98]`
                            : 'text-muted-foreground hover:bg-muted hover:text-foreground active:scale-[0.98]'
                      }`;
                      return (
                        <motion.div
                          key={item.href}
                          initial={{ opacity: 0, x: -20 }}
                          animate={{ opacity: 1, x: 0 }}
                          transition={{ delay: index * 0.05 }}
                        >
                          {shouldForceRefresh ? (
                            <a
                              href={item.href}
                              onClick={() => setMobileMenuOpen(false)}
                              className={linkClassName}
                            >
                              <item.icon
                                className={`h-5 w-5 ${itemColor && !isActive ? itemColor : ''}`}
                              />
                              {item.label}
                            </a>
                          ) : (
                            <Link
                              href={item.href}
                              onClick={() => setMobileMenuOpen(false)}
                              className={linkClassName}
                            >
                              <item.icon
                                className={`h-5 w-5 ${itemColor && !isActive ? itemColor : ''}`}
                              />
                              {item.label}
                            </Link>
                          )}
                        </motion.div>
                      );
                    })}
 
                    {/* Verticals Section - Always show to allow exploring other verticals */}
                    {availableVerticals.length > 0 && (
                      <motion.div
                        initial={{ opacity: 0, x: -20 }}
                        animate={{ opacity: 1, x: 0 }}
                        transition={{ delay: navItems.length * 0.05 }}
                        className="mt-2 border-t pt-2"
                      >
                        <p className="px-3 py-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground">
                          {verticalItem ? 'Explore More Verticals' : 'Professional Verticals'}
                        </p>
                        {availableVerticals.map((item) => (
                          <Link
                            key={item.href}
                            href={item.href}
                            onClick={() => setMobileMenuOpen(false)}
                            className={`flex items-center gap-3 rounded-md px-3 py-2 text-sm font-medium ${item.color} transition-all duration-200 hover:bg-muted active:scale-[0.98]`}
                          >
                            <item.icon className="h-5 w-5" />
                            {item.label}
                          </Link>
                        ))}
                      </motion.div>
                    )}
 
                    <motion.div
                      initial={{ opacity: 0, x: -20 }}
                      animate={{ opacity: 1, x: 0 }}
                      transition={{
                        delay: (navItems.length + availableVerticals.length) * 0.05,
                      }}
                      className="mt-2 border-t pt-2"
                    >
                      <Link
                        href={`/${username}`}
                        target="_blank"
                        onClick={() => setMobileMenuOpen(false)}
                        className="flex items-center gap-3 rounded-md px-3 py-3 text-sm font-medium text-primary transition-all duration-200 hover:bg-muted active:scale-[0.98]"
                      >
                        <ExternalLink className="h-5 w-5" />
                        View Profile
                      </Link>
                    </motion.div>
 
                    {/* Admin Link (Mobile) */}
                    {isAdmin && (
                      <motion.div
                        initial={{ opacity: 0, x: -20 }}
                        animate={{ opacity: 1, x: 0 }}
                        transition={{
                          delay: (navItems.length + availableVerticals.length + 1) * 0.05,
                        }}
                      >
                        <Link
                          href="/admin/applications"
                          onClick={() => setMobileMenuOpen(false)}
                          className={`flex items-center gap-3 rounded-md px-3 py-3 text-sm font-medium transition-all duration-200 active:scale-[0.98] ${
                            pathname.startsWith('/admin')
                              ? 'bg-amber-500/10 text-amber-600 dark:text-amber-400'
                              : 'text-amber-600 hover:bg-amber-500/10 dark:text-amber-400'
                          }`}
                        >
                          <Shield className="h-5 w-5" />
                          {getAdminRoleLabel(adminRole)}
                        </Link>
                      </motion.div>
                    )}
 
                    <motion.div
                      initial={{ opacity: 0, x: -20 }}
                      animate={{ opacity: 1, x: 0 }}
                      transition={{ delay: (navItems.length + (isAdmin ? 2 : 1)) * 0.05 }}
                    >
                      <button
                        onClick={handleSignOut}
                        disabled={isSigningOut}
                        className="flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm font-medium text-destructive transition-all duration-200 hover:bg-destructive/10 active:scale-[0.98] disabled:opacity-50"
                      >
                        <LogOut className="h-5 w-5" />
                        {isSigningOut ? 'Signing out...' : 'Sign Out'}
                      </button>
                    </motion.div>
                  </nav>
                </motion.div>
              </>
            )}
          </AnimatePresence>,
          document.body
        )}
    </div>
  );
}