import 'package:flutter/material.dart';
import '../../../../app/theme/app_colors.dart';
import '../../../../app/theme/app_typography.dart';
import '../../../../app/theme/app_spacing.dart';
import '../../../../shared/widgets/genex_button.dart';

/// A3. 支付成功页
///
/// 成功动画、订单号、「查看我的券」「继续逛」
class PaymentSuccessPage extends StatelessWidget {
  final String orderNumber;
  final double amount;
  final String couponName;

  const PaymentSuccessPage({
    super.key,
    this.orderNumber = 'GNX-20260209-001234',
    this.amount = 21.25,
    this.couponName = '星巴克 \$25 礼品卡',
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Padding(
          padding: AppSpacing.pagePadding,
          child: Column(
            children: [
              const Spacer(flex: 2),

              // Success Icon
              Container(
                width: 88,
                height: 88,
                decoration: const BoxDecoration(
                  gradient: AppColors.successGradient,
                  shape: BoxShape.circle,
                ),
                child: const Icon(
                  Icons.check_rounded,
                  color: Colors.white,
                  size: 44,
                ),
              ),
              const SizedBox(height: 24),

              Text('支付成功', style: AppTypography.h1),
              const SizedBox(height: 8),
              Text(
                '券已到账，可在「我的券」中查看',
                style: AppTypography.bodyMedium.copyWith(color: AppColors.textSecondary),
              ),
              const SizedBox(height: 32),

              // Order Info Card
              Container(
                width: double.infinity,
                padding: AppSpacing.cardPadding,
                decoration: BoxDecoration(
                  color: AppColors.surface,
                  borderRadius: AppSpacing.borderRadiusMd,
                  border: Border.all(color: AppColors.borderLight),
                ),
                child: Column(
                  children: [
                    _infoRow('券名称', couponName),
                    const SizedBox(height: 10),
                    const Divider(),
                    const SizedBox(height: 10),
                    _infoRow('支付金额', '\$$amount'),
                    const SizedBox(height: 10),
                    const Divider(),
                    const SizedBox(height: 10),
                    _infoRow('订单号', orderNumber),
                    const SizedBox(height: 10),
                    const Divider(),
                    const SizedBox(height: 10),
                    _infoRow('支付时间', '2026-02-09 14:32:15'),
                  ],
                ),
              ),

              const Spacer(flex: 3),

              // Actions
              GenexButton(
                label: '查看我的券',
                onPressed: () {
                  Navigator.pushNamedAndRemoveUntil(context, '/main', (route) => false);
                },
              ),
              const SizedBox(height: 12),
              GenexButton(
                label: '继续逛',
                variant: GenexButtonVariant.outline,
                onPressed: () {
                  Navigator.pushNamedAndRemoveUntil(context, '/main', (route) => false);
                },
              ),
              const SizedBox(height: 24),
            ],
          ),
        ),
      ),
    );
  }

  Widget _infoRow(String label, String value) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Text(label, style: AppTypography.bodyMedium.copyWith(
          color: AppColors.textSecondary,
        )),
        Flexible(
          child: Text(
            value,
            style: AppTypography.labelMedium,
            overflow: TextOverflow.ellipsis,
          ),
        ),
      ],
    );
  }
}
