import 'package:flutter/material.dart';
import '../tokens/unionflow_colors.dart';

/// Bouton d'action rapide UnionFlow
class UnionActionButton extends StatelessWidget {
  final IconData icon;
  final String label;
  final VoidCallback onTap;
  final Color? backgroundColor;
  final Color? iconColor;

  const UnionActionButton({
    super.key,
    required this.icon,
    required this.label,
    required this.onTap,
    this.backgroundColor,
    this.iconColor,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
        decoration: BoxDecoration(
          color: backgroundColor ?? UnionFlowColors.unionGreenPale,
          borderRadius: BorderRadius.circular(14),
          border: Border.all(
            color: (backgroundColor ?? UnionFlowColors.unionGreenPale)
                .withOpacity(0.2),
            width: 1,
          ),
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Icon(
              icon,
              size: 28,
              color: iconColor ?? UnionFlowColors.unionGreen,
            ),
            const SizedBox(height: 8),
            Text(
              label,
              style: const TextStyle(
                fontSize: 12,
                fontWeight: FontWeight.w600,
                color: UnionFlowColors.textPrimary,
              ),
              textAlign: TextAlign.center,
            ),
          ],
        ),
      ),
    );
  }
}

/// Grid d'actions rapides
class UnionActionGrid extends StatelessWidget {
  final List<UnionActionButton> actions;

  const UnionActionGrid({
    super.key,
    required this.actions,
  });

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        for (int i = 0; i < actions.length; i++) ...[
          Expanded(child: actions[i]),
          if (i < actions.length - 1) const SizedBox(width: 12),
        ],
      ],
    );
  }
}
