import 'package:flutter/material.dart';

class CardDetailsScreen extends StatelessWidget {
  const CardDetailsScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("My Cards"),
      ),
      body: Stack(
        children: [
          Padding(
            padding: const EdgeInsets.all(16.0),
            child: ListView(
              children: const [
                CardTile(
                  cardNumber: "**** **** **** 1234",
                  cardNetwork: "VISA",
                  cardType: "Debit Card",
                  validFrom: "01/22",
                  validTo: "01/27",
                ),
                SizedBox(height: 16),
                CardTile(
                  cardNumber: "**** **** **** 5678",
                  cardNetwork: "Mastercard",
                  cardType: "Debit Card",
                  validFrom: "07/21",
                  validTo: "07/26",
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

class CardTile extends StatelessWidget {
  final String cardNumber;
  final String cardNetwork;
  final String cardType;
  final String validFrom;
  final String validTo;

  const CardTile({
    super.key,
    required this.cardNumber,
    required this.cardNetwork,
    required this.cardType,
    required this.validFrom,
    required this.validTo,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(16),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(16),
        gradient: const LinearGradient(
          colors: [Colors.blue, Colors.indigo],
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
        ),
        boxShadow: const [
          BoxShadow(
            color: Colors.black26,
            blurRadius: 8,
            spreadRadius: 2,
            offset: Offset(2, 4),
          ),
        ],
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // Top row: Logo + Bank name
          Row(
            children: [
              Image.asset(
                'assets/images/logo.png',
                width: 40,
                height: 40,
              ),
              const SizedBox(width: 8),
              const Text(
                "Kangra Central Co-operative Bank",
                style: TextStyle(
                  color: Color.fromARGB(255, 238, 237, 237),
                  fontSize: 15,
                  fontWeight: FontWeight.bold,
                ),
                overflow: TextOverflow.visible,
                maxLines: 2,
              ),
            ],
          ),
          const SizedBox(height: 24),

          // Card number (masked)
          Text(
            cardNumber,
            style: const TextStyle(
              color: Colors.white,
              fontSize: 22,
              letterSpacing: 3,
              fontWeight: FontWeight.w500,
            ),
          ),
          const SizedBox(height: 16),

          // Validity
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  const Text("VALID FROM",
                      style: TextStyle(color: Colors.white70, fontSize: 10)),
                  Text(
                    validFrom,
                    style: const TextStyle(color: Colors.white, fontSize: 14),
                  ),
                ],
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  const Text("VALID UPTO",
                      style: TextStyle(color: Colors.white70, fontSize: 10)),
                  Text(
                    validTo,
                    style: const TextStyle(color: Colors.white, fontSize: 14),
                  ),
                ],
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Text(
                    cardNetwork,
                    style: const TextStyle(
                      color: Colors.white,
                      fontSize: 16,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  Text(
                    cardType,
                    style: const TextStyle(
                      color: Colors.white70,
                      fontSize: 12,
                    ),
                  ),
                ],
              ),
            ],
          ),
        ],
      ),
    );
  }
}
