import 'package:flutter/material.dart';
import '../theme/app_colors.dart';

// Widget per i pulsanti di selezione della forma dell'arena
class NeonShapeButton extends StatelessWidget {
  final IconData icon;
  final String label;
  final bool isSelected;
  final VoidCallback onTap;
  final ShapeBorder shape; // La forma geometrica del pulsante

  const NeonShapeButton({
    super.key,
    required this.icon,
    required this.label,
    required this.isSelected,
    required this.onTap,
    this.shape = const RoundedRectangleBorder( // Forma di default
        borderRadius: BorderRadius.all(Radius.circular(12.0))),
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: AnimatedContainer(
        duration: const Duration(milliseconds: 300),
        curve: Curves.easeInOut,
        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
        decoration: ShapeDecoration(
          shape: shape,
          color: isSelected
              ? AppColors.neonGreen.withOpacity(0.2) // Sfondo luminoso se selezionato
              : AppColors.surface.withOpacity(0.5), // Sfondo più scuro se non selezionato
          shadows: isSelected
              ? [ // Bagliore intenso se selezionato
            BoxShadow(
              color: AppColors.neonGreen.withOpacity(0.6),
              blurRadius: 12.0,
              spreadRadius: 2.0,
            ),
          ]
              : [],
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Icon(
              icon,
              color: isSelected ? AppColors.neonGreen : AppColors.textSecondary,
              size: 28,
            ),
            const SizedBox(height: 4),
            Text(
              label,
              style: TextStyle(
                color: isSelected ? AppColors.textPrimary : AppColors.textSecondary,
                fontSize: 12,
                fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

// Widget per i pulsanti di selezione della taglia dell'arena
class NeonSizeButton extends StatelessWidget {
  final String label;
  final bool isSelected;
  final VoidCallback onTap;

  const NeonSizeButton({
    super.key,
    required this.label,
    required this.isSelected,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: AnimatedContainer(
        duration: const Duration(milliseconds: 300),
        curve: Curves.easeInOut,
        width: 50,
        height: 50,
        decoration: BoxDecoration(
          shape: BoxShape.circle, // Forma circolare
          color: isSelected
              ? AppColors.neonBlue.withOpacity(0.2)
              : AppColors.surface.withOpacity(0.5),
          border: Border.all(
            color: isSelected ? AppColors.neonBlue : AppColors.surfaceLight,
            width: 2.0,
          ),
          shadows: isSelected
              ? [
            BoxShadow(
              color: AppColors.neonBlue.withOpacity(0.6),
              blurRadius: 10.0,
              spreadRadius: 1.5,
            ),
          ]
              : [],
        ),
        child: Center(
          child: Text(
            label,
            style: TextStyle(
              color: isSelected ? AppColors.textPrimary : AppColors.textSecondary,
              fontSize: 16,
              fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
            ),
          ),
        ),
      ),
    );
  }
}

// Widget per l'interruttore della modalità tempo (Clessidra)
class NeonTimeSwitch extends StatelessWidget {
  final bool isTimeMode;
  final VoidCallback onTap;

  const NeonTimeSwitch({
    super.key,
    required this.isTimeMode,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: AnimatedContainer(
        duration: const Duration(milliseconds: 300),
        curve: Curves.easeInOut,
        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(30.0), // Forma arrotondata per lo switch
          color: isTimeMode
              ? AppColors.neonGreen.withOpacity(0.2)
              : AppColors.surface.withOpacity(0.5),
          border: Border.all(
            color: isTimeMode ? AppColors.neonGreen : AppColors.surfaceLight,
            width: 2.0,
          ),
          shadows: isTimeMode
              ? [
            BoxShadow(
              color: AppColors.neonGreen.withOpacity(0.6),
              blurRadius: 12.0,
              spreadRadius: 2.0,
            ),
          ]
              : [],
        ),
        child: Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            Icon(
              Icons.hourglass_empty, // Icona clessidra
              color: isTimeMode ? AppColors.neonGreen : AppColors.textSecondary,
            ),
            const SizedBox(width: 8),
            Text(
              isTimeMode ? 'A TEMPO' : 'SENZA TEMPO',
              style: TextStyle(
                color: isTimeMode ? AppColors.textPrimary : AppColors.textSecondary,
                fontWeight: isTimeMode ? FontWeight.bold : FontWeight.normal,
              ),
            ),
          ],
        ),
      ),
    );
  }
}