import 'package:flutter/material.dart';

import '../../app/theme.dart';

/// CTA distruttiva nera con icona rossa (INTERROMPI, FERMA TRASMISSIONE).
class DestructiveCta extends StatelessWidget {
  const DestructiveCta({
    super.key,
    required this.label,
    required this.onPressed,
    this.loading = false,
    this.compact = false,
  });

  final String label;
  final VoidCallback? onPressed;
  final bool loading;
  final bool compact;

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return SizedBox(
      width: compact ? null : double.infinity,
      height: compact ? 44 : 52,
      child: OutlinedButton(
        onPressed: loading ? null : onPressed,
        style: OutlinedButton.styleFrom(
          backgroundColor: Colors.black,
          foregroundColor: AppTheme.primaryRed,
          side: BorderSide(
            color: AppTheme.primaryRed.withValues(alpha: 0.6),
          ),
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(compact ? 10 : 12),
          ),
        ),
        child: loading
            ? const SizedBox(
                width: 20,
                height: 20,
                child: CircularProgressIndicator(
                  strokeWidth: 2,
                  color: AppTheme.primaryRed,
                ),
              )
            : Row(
                mainAxisAlignment: MainAxisAlignment.center,
                mainAxisSize: compact ? MainAxisSize.min : MainAxisSize.max,
                children: [
                  const Icon(Icons.stop_circle_outlined, size: 20),
                  const SizedBox(width: 8),
                  Text(
                    label,
                    style: theme.textTheme.labelLarge?.copyWith(
                      color: AppTheme.primaryRed,
                      fontSize: compact ? 12 : 14,
                    ),
                  ),
                ],
              ),
      ),
    );
  }
}
