import React from "react";
import {
  View,
  Text,
  StyleSheet,
  TouchableOpacity,
  Dimensions,
} from "react-native";
import { MaterialIcons } from "@expo/vector-icons";

interface PaymentDueCardProps {
  label: string;
  amount: number;
  onPress: () => void;
}

const formatAmount = (amount: number | null) => {
  if (!amount) return "₹0";
  return `₹${amount.toLocaleString("en-IN")}`;
};

const PaymentDueCard: React.FC<PaymentDueCardProps> = ({
  label,
  amount,
  onPress,
}) => {
  return (
    <View style={styles.container}>
      <View style={styles.leftSection}>
        <View style={styles.iconWrapper}>
          <MaterialIcons name="info-outline" size={20} color="#D92D20" />
        </View>
        <View style={styles.textGroup}>
          <Text style={styles.label}>{label}</Text>
          <Text style={styles.amount}>{formatAmount(amount)}</Text>
        </View>
      </View>
      <TouchableOpacity
        style={styles.button}
        onPress={onPress}
        activeOpacity={0.8}
      >
        <Text style={styles.buttonText}>Pay Now</Text>
      </TouchableOpacity>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    backgroundColor: "#FCFCFC",
    borderRadius: 10,
    padding: 16,
    flexDirection: "row",
    justifyContent: "space-between",
    alignItems: "center",
    width: "100%",
    gap: 16,
  },
  leftSection: {
    flexDirection: "row",
    alignItems: "center",
    flex: 1,
  },
  iconWrapper: {
    width: 40,
    height: 40,
    borderRadius: 20,
    backgroundColor: "#FFEAEA",
    justifyContent: "center",
    alignItems: "center",
  },
  textGroup: {
    marginLeft: 12,
  },
  label: {
    fontSize: 12,
    color: "#565F70",
    fontFamily: "Inter-Medium",
    marginBottom: 4,
  },
  amount: {
    fontSize: 14,
    color: "#252A34",
    fontFamily: "Inter-SemiBold",
  },
  button: {
    backgroundColor: "#00825B",
    paddingVertical: 8,
    paddingHorizontal: 16,
    borderRadius: 4,
  },
  buttonText: {
    color: "#FCFCFC",
    fontSize: 12,
    fontFamily: "Inter-Medium",
  },
});

export default PaymentDueCard;
