import 'dart:ui';

import 'package:flutter/material.dart';

import '../tema/pluriwave_theme.dart';

class PluriGlassSurface extends StatelessWidget {
  const PluriGlassSurface({
    super.key,
    required this.child,
    this.padding = const EdgeInsets.all(16),
    this.borderRadius,
    this.blurSigma = 18,
    this.glowColor,
  });

  final Widget child;
  final EdgeInsetsGeometry padding;
  final BorderRadius? borderRadius;
  final double blurSigma;
  final Color? glowColor;

  @override
  Widget build(BuildContext context) {
    final t = context.pluriTokens;
    final radius = borderRadius ?? BorderRadius.circular(t.radiusMd);
    return RepaintBoundary(
      child: ClipRRect(
        borderRadius: radius,
        child: BackdropFilter(
          filter: ImageFilter.blur(sigmaX: blurSigma, sigmaY: blurSigma),
          child: DecoratedBox(
            decoration: BoxDecoration(
              color: t.glassSurface,
              borderRadius: radius,
              border: Border.all(color: t.glassBorder),
              boxShadow: [
                BoxShadow(
                  color: glowColor ?? t.glowColor.withValues(alpha: 0.12),
                  blurRadius: 30,
                  spreadRadius: -14,
                  offset: const Offset(0, 18),
                ),
              ],
            ),
            child: Padding(padding: padding, child: child),
          ),
        ),
      ),
    );
  }
}
