import { RefreshCw } from 'lucide-react';
import { RefreshButton } from '@/components/ui/refresh-button';
import { ThemeToggle } from '@/components/theme/ThemeToggle';
import { AuthButtons } from '@/components/auth/AuthButtons';
import { NotificationCenter } from '@/components/notifications/NotificationCenter';
import { SidebarTrigger } from '@/components/ui/sidebar';
import { useAuth } from '@/hooks/useAuth';

interface AdminTopBarProps {
  onRefresh?: () => void;
  refreshMode?: 'auto' | 'manual';
  pollInterval?: number;
  lastUpdated?: Date;
  isRefreshing?: boolean;
}

export function AdminTopBar({ 
  onRefresh, 
  refreshMode, 
  pollInterval, 
  lastUpdated,
  isRefreshing 
}: AdminTopBarProps) {
  const { user } = useAuth();

  return (
    <header className="sticky top-0 z-40 w-full border-b border-border/40 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
      <div className="flex h-14 items-center justify-between px-4 gap-4">
        {/* Left Section */}
        <div className="flex items-center gap-3">
          <SidebarTrigger className="-ml-1" />
          
          {refreshMode && (
            <div className="hidden sm:flex items-center gap-2 text-xs text-muted-foreground">
              <RefreshCw className="w-3 h-3" />
              {refreshMode === 'auto' ? (
                <span>Auto: {pollInterval ? pollInterval / 1000 : 30}s</span>
              ) : (
                <span>Manual</span>
              )}
              {lastUpdated && (
                <span className="hidden md:inline">
                  • {lastUpdated.toLocaleTimeString()}
                </span>
              )}
            </div>
          )}
        </div>

        {/* Right Section */}
        <div className="flex items-center gap-2">
          {onRefresh && (
            <RefreshButton
              onRefresh={onRefresh}
              isLoading={isRefreshing}
              variant="ghost"
              size="sm"
            />
          )}
          <ThemeToggle />
          {user && <NotificationCenter />}
          <AuthButtons />
        </div>
      </div>
    </header>
  );
}
