import { Loader2 } from 'lucide-react';
import { cn } from '@/lib/utils';

interface LoadingProps {
  className?: string;
  text?: string;
  size?: 'sm' | 'md' | 'lg';
}

export function Loading({ className, text, size = 'md' }: LoadingProps) {
  const sizeClasses = {
    sm: 'h-4 w-4',
    md: 'h-6 w-6',
    lg: 'h-8 w-8',
  };

  return (
    <div className={cn('flex items-center justify-center', className)}>
      <Loader2 className={cn(sizeClasses[size], 'animate-spin mr-2')} />
      {text && <span className="text-muted-foreground">{text}</span>}
    </div>
  );
}

// Full page loading component
export function LoadingPage({ text = 'Loading...' }: { text?: string }) {
  return (
    <div className="flex min-h-[400px] items-center justify-center">
      <Loading text={text} size="lg" />
    </div>
  );
}

// Inline loading for buttons or small areas
export function LoadingInline({ text }: { text?: string }) {
  return <Loading text={text} size="sm" />;
}
