<layout xmlns:android="http://schemas.android.com/apk/res/android">
    <data>

        <import type="android.view.View" />

        <!-- Import the PaymentStatus enum -->
        <import type="com.dspread.pos.ui.cashier.CashierViewModel.PaymentStatus" />

        <variable
            name="viewModel"
            type="com.dspread.pos.ui.cashier.CashierViewModel" />
    </data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center"
        android:padding="16dp">

        <!-- Real-time amount display -->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@{viewModel.amount + ` ` + viewModel.currencyCode}"
            android:textSize="24sp"
            android:textStyle="bold"
            android:textColor="@color/black"
            android:layout_marginTop="16dp"
            android:gravity="center"/>

        <EditText
            android:id="@+id/etAmountInput"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="numberDecimal"
            android:hint="Enter amount"
            android:imeOptions="actionDone"
            android:maxLines="1"/>

        <!-- Waiting State -->
        <LinearLayout
            android:id="@+id/waitingLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center"
            android:visibility="@{viewModel.paymentStatus == PaymentStatus.WAITING ? View.VISIBLE : View.GONE}">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Enter amount for pinpad M50 to pay"
                android:textSize="18sp"
                android:textStyle="bold"
                android:gravity="center" />
        </LinearLayout>

        <!-- Success State -->
        <LinearLayout
            android:id="@+id/successLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center"
            android:visibility="@{viewModel.paymentStatus == PaymentStatus.SUCCESS ? View.VISIBLE : View.GONE}">

<!--            <TextView-->
<!--                android:layout_width="wrap_content"-->
<!--                android:layout_height="wrap_content"-->
<!--                android:text="@{viewModel.amount + ` ` + viewModel.currencyCode}"-->
<!--                android:textSize="24sp"-->
<!--                android:textStyle="bold"-->
<!--                android:gravity="center" />-->

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Print Receipt"
                android:onClick="@{() -> viewModel.printReceipt()}"
                android:layout_marginTop="16dp" />
        </LinearLayout>

        <!-- Failed State -->
        <LinearLayout
            android:id="@+id/failedLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center"
            android:visibility="@{viewModel.paymentStatus == PaymentStatus.FAILED ? View.VISIBLE : View.GONE}">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Payment Failed. Please try again."
                android:textSize="18sp"
                android:textStyle="bold"
                android:gravity="center" />
        </LinearLayout>
    </LinearLayout>
</layout>