import 'package:flutter/material.dart';

class CustomLoader extends StatelessWidget {
  final String? message;
  final Color? backgroundColor;
  final double size;
  final Color loaderColor;
  final bool useBlurBackground;

  const CustomLoader({
    super.key,
    this.message,
    this.backgroundColor,
    this.size = 50,
    this.loaderColor = Colors.blue,
    this.useBlurBackground = false,
  });

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        if (useBlurBackground) Container(color: Colors.black.withOpacity(0.4)),
        Center(
          child: Container(
            padding: const EdgeInsets.all(20),
            decoration: BoxDecoration(
              color: backgroundColor ?? Colors.white,
              borderRadius: BorderRadius.circular(12),
              boxShadow: [
                BoxShadow(color: Colors.black.withOpacity(0.1), blurRadius: 10),
              ],
            ),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                SizedBox(
                  width: size,
                  height: size,
                  child: CircularProgressIndicator(
                    color: loaderColor,
                    strokeWidth: 4,
                  ),
                ),
                if (message != null) ...[
                  const SizedBox(height: 12),
                  Text(
                    message!,
                    style: const TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                ],
              ],
            ),
          ),
        ),
      ],
    );
  }
}
