import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../theme/app_colors.dart';
import '../theme/app_text_styles.dart';
import '../theme/app_radius.dart';

class MemoCard extends StatelessWidget {
  final String memo;

  const MemoCard({super.key, required this.memo});

  @override
  Widget build(BuildContext context) {
    if (memo.isEmpty) return const SizedBox.shrink();

    return Theme(
      data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
      child: ExpansionTile(
        tilePadding: EdgeInsets.zero,
        childrenPadding: EdgeInsets.zero,
        title: Text(
          '📋 Investment Memo',
          style: AppTextStyles.labelMedium.copyWith(color: AppColors.accentLight),
        ),
        children: [
          Container(
            width: double.infinity,
            padding: const EdgeInsets.all(12),
            decoration: BoxDecoration(
              color: AppColors.bgSecondary,
              border: Border.all(color: AppColors.border),
              borderRadius: AppRadius.smAll,
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(memo, style: AppTextStyles.monoSmall.copyWith(height: 1.6)),
                const SizedBox(height: 8),
                Align(
                  alignment: Alignment.centerRight,
                  child: GestureDetector(
                    onTap: () {
                      Clipboard.setData(ClipboardData(text: memo));
                      ScaffoldMessenger.of(context).showSnackBar(
                        const SnackBar(content: Text('Memo copied to clipboard')),
                      );
                    },
                    child: Text(
                      'Copy',
                      style: AppTextStyles.labelSmall.copyWith(color: AppColors.accentLight),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}