import { cn } from '../lib/utils';
import { Spinner } from './spinner';

interface TableLoadingOverlayProps {
  isLoading: boolean;
  message?: string;
  className?: string;
}

export default function TableLoadingOverlay({
  isLoading,
  message = 'Загрузка данных...',
  className,
}: TableLoadingOverlayProps) {
  if (!isLoading) return null;

  return (
    <div
      className={cn(
        'absolute inset-0 z-10 flex flex-col items-center justify-center bg-white/80 backdrop-blur-[1px] transition-opacity duration-200',
        className,
      )}
    >
      <Spinner size='lg' className='mb-2 text-red-600' />
      <p className='font-medium text-gray-700'>{message}</p>
    </div>
  );
}
