import 'package:flutter/material.dart';
import 'package:niogu_app/core/constants/app_color.dart';
import 'package:niogu_app/core/constants/app_font_size.dart';
import 'package:niogu_app/core/utils/currency_format.dart';
import 'package:sizer/sizer.dart';

class SummaryCostInfo extends StatelessWidget {
  final double totalOrder;
  final double deliveryFee;
  final double totalAmount;
  const SummaryCostInfo({
    super.key,
    required this.totalOrder,
    required this.deliveryFee,
    required this.totalAmount,
  });

  @override
  Widget build(BuildContext context) {
    final bool isTablet = 100.w >= 600;
    return Container(
      padding: EdgeInsets.all(4.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4.w),
        border: Border.all(color: Colors.grey.shade200),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.02),
            blurRadius: 10,
            offset: const Offset(0, 4),
          ),
        ],
      ),
      child: Column(
        children: [
          _buildCostRow(
            isTablet,
            "Total Harga (2 Produk)",
            CurrencyFormat.formatToIdr(totalOrder, 0),
          ),
          _buildCostRow(
            isTablet,
            "Biaya Pengiriman",
            CurrencyFormat.formatToIdr(deliveryFee, 0),
          ),
          Divider(height: 3.h),
          _buildCostRow(
            isTablet,
            "Total Pesanan",
            CurrencyFormat.formatToIdr(totalAmount, 0),
            isTotal: true,
          ),
          SizedBox(height: 3.h),
        ],
      ),
    );
  }

  Widget _buildCostRow(
    bool isTablet,
    String label,
    String value, {
    bool isTotal = false,
  }) {
    return Padding(
      padding: EdgeInsets.symmetric(vertical: 0.5.h),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            label,
            style: TextStyle(
              fontSize: isTotal
                  ? AppFontSize.medium.sp
                  : isTablet
                  ? (AppFontSize.medium - 1.25).sp
                  : (AppFontSize.small - 1.25).sp,
              fontWeight: isTotal ? FontWeight.bold : FontWeight.normal,
            ),
          ),
          Text(
            value,
            style: TextStyle(
              fontSize: isTotal
                  ? AppFontSize.medium.sp
                  : isTablet
                  ? (AppFontSize.medium - 1.25).sp
                  : (AppFontSize.small - 1.25).sp,
              fontWeight: FontWeight.bold,
              color: isTotal ? AppColor.primaryColor : Colors.black87,
            ),
          ),
        ],
      ),
    );
  }
}
