import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

/// A card widget representing an order type in the creation flow.
class OrderTypeCard extends StatelessWidget {
  /// Creates an [OrderTypeCard].
  const OrderTypeCard({
    required this.icon,
    required this.title,
    required this.description,
    required this.backgroundColor,
    required this.borderColor,
    required this.iconBackgroundColor,
    required this.iconColor,
    required this.textColor,
    required this.descriptionColor,
    required this.onTap,
    super.key,
  });

  /// Icon to display at the top of the card.
  final IconData icon;

  /// Main title of the order type.
  final String title;

  /// Brief description of what this order type entails.
  final String description;

  /// Background color of the card.
  final Color backgroundColor;

  /// Color of the card's border.
  final Color borderColor;

  /// Background color for the icon container.
  final Color iconBackgroundColor;

  /// Color of the icon itself.
  final Color iconColor;

  /// Color of the title text.
  final Color textColor;

  /// Color of the description text.
  final Color descriptionColor;

  /// Callback when the card is tapped.
  final VoidCallback onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        padding: const EdgeInsets.all(UiConstants.space5),
        decoration: BoxDecoration(
          color: backgroundColor,
          borderRadius: BorderRadius.circular(UiConstants.radiusBase),
          border: Border.all(color: borderColor, width: 2),
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Container(
              width: 48,
              height: 48,
              margin: const EdgeInsets.only(bottom: UiConstants.space3),
              decoration: BoxDecoration(
                color: iconBackgroundColor,
                borderRadius: BorderRadius.circular(UiConstants.radiusBase),
              ),
              child: Icon(icon, color: iconColor, size: 24),
            ),
            Text(title, style: UiTypography.body2b.copyWith(color: textColor)),
            const SizedBox(height: UiConstants.space1),
            Expanded(
              child: Text(
                description,
                style: UiTypography.footnote1r.copyWith(
                  color: descriptionColor,
                ),
                maxLines: 2,
                overflow: TextOverflow.ellipsis,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
