import 'package:flutter/material.dart';
import 'package:kmobile/l10n/app_localizations.dart';

// Data model for a single FAQ item
class FaqItem {
  final String question;
  final String answer;

  FaqItem({required this.question, required this.answer});
}

class FaqsScreen extends StatefulWidget {
  const FaqsScreen({super.key});

  @override
  State<FaqsScreen> createState() => _FaqsScreenState();
}

class _FaqsScreenState extends State<FaqsScreen> {
  // List of FAQs
  final List<FaqItem> _faqs = [
    FaqItem(
      question: "How do I log in to the mobile banking app?",
      answer:
          "You can log in using your customer number and password. Biometric login (fingerprint) and MPIN is also available for supported devices.",
    ),
    FaqItem(
      question: "Is my banking information secure on this app?",
      answer:
          "Yes. We use industry-standard encryption and multi-factor authentication to ensure your data is safe.",
    ),
    FaqItem(
      question: "How can I check my account balance?",
      answer:
          "Once logged in, your account balance will be displayed on the home screen. You can also view detailed balances under the “Accounts” section.",
    ),
    FaqItem(
      question: "Can I transfer money to other bank accounts?",
      answer:
          "Yes. You can use NEFT, RTGS or IMPS to transfer funds to any bank account in India.",
    ),
    FaqItem(
      question: "How do I view my transaction history?",
      answer:
          "Click on the “Account Statement” icon under the Home Screen to view recent and past transactions.",
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(AppLocalizations.of(context).faq),
      ),
      body: Stack(
        children: [
          // Background logo
          IgnorePointer(
            child: Center(
              child: Opacity(
                opacity: 0.07,
                child: ClipOval(
                  child: Image.asset(
                    'assets/images/logo.png',
                    width: 200,
                    height: 200,
                  ),
                ),
              ),
            ),
          ),
          // FAQ List
          ListView.builder(
            padding: const EdgeInsets.all(8.0),
            itemCount: _faqs.length,
            itemBuilder: (context, index) {
              final faq = _faqs[index];
              return Card(
                margin:
                    const EdgeInsets.symmetric(vertical: 8.0, horizontal: 4.0),
                elevation: 2.0,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(12.0),
                ),
                child: ExpansionTile(
                  title: Text(
                    faq.question,
                    style: const TextStyle(
                      fontWeight: FontWeight.w600,
                    ),
                  ),
                  children: <Widget>[
                    Padding(
                      padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 16.0),
                      child: Text(
                        faq.answer,
                        style: TextStyle(
                          fontSize: 14,
                          color: Colors.grey[700],
                          height: 1.5,
                        ),
                      ),
                    ),
                  ],
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}
