<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:theme="@style/Theme.Ecommerce_serang"
    tools:context=".ui.order.history.detailorder.DetailOrderStatusActivity">

    <include
        android:id="@+id/header"
        layout="@layout/header"/>

    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.core.widget.NestedScrollView
        android:id="@+id/scrollViewDetail"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/buttonLayout"
        app:layout_constraintTop_toBottomOf="@+id/header">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <!-- Status header -->
            <!-- Order Status Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="2dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/tvStatusHeader"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/blue_500"
                        android:paddingVertical="8dp"
                        android:paddingHorizontal="16dp"
                        android:text="Belum Bayar"
                        android:fontFamily="@font/dmsans_medium"
                        android:textColor="@color/white"
                        android:textSize="16sp"
                        android:textStyle="bold" />

<!--                     Status Note (if any) -->
                    <TextView
                        android:id="@+id/tvStatusNote"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingHorizontal="16dp"
                        android:paddingVertical="8dp"
                        android:fontFamily="@font/dmsans_medium"
                        android:text="Pesanan ini harus dibayar sebelum 18 November 2024"
                        android:textColor="@color/blue_400"
                        android:textSize="14sp"
                        android:visibility="visible"/>

                    <!-- Order dates -->
                    <androidx.constraintlayout.widget.ConstraintLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/white"
                        android:paddingStart="16dp"
                        android:paddingEnd="16dp"
                        android:paddingBottom="16dp">

                        <TextView
                            android:id="@+id/tvOrderDateLabel"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="8dp"
                            android:layout_marginStart="8dp"
                            android:text="Tanggal Pesanan:"
                            android:textColor="@color/black"
                            android:textSize="14sp"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent" />

                        <TextView
                            android:id="@+id/tvOrderDate"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="4dp"
                            android:text="15 November 2024"
                            android:textColor="@color/black"
                            android:textSize="14sp"
                            app:layout_constraintStart_toStartOf="@id/tvOrderDateLabel"
                            app:layout_constraintTop_toBottomOf="@id/tvOrderDateLabel" />

                        <TextView
                            android:id="@+id/tvPaymentDeadlineLabel"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginEnd="8dp"
                            android:text="Batas Pembayaran:"
                            android:textColor="@color/black"
                            android:textSize="14sp"
                            app:layout_constraintTop_toTopOf="@id/tvOrderDateLabel"
                            app:layout_constraintEnd_toEndOf="parent"/>

                        <TextView
                            android:id="@+id/tvPaymentDeadline"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="18 November 2024"
                            android:textColor="@color/black"
                            android:textSize="14sp"
                            app:layout_constraintStart_toStartOf="@id/tvPaymentDeadlineLabel"
                            app:layout_constraintTop_toTopOf="@id/tvOrderDate" />

                    </androidx.constraintlayout.widget.ConstraintLayout>
                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <View
                android:layout_width="match_parent"
                android:layout_height="8dp"
                android:background="@color/light_gray" />

            <!-- Shipping Information -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="2dp">

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

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Informasi Pengiriman"
                        android:textColor="@color/black"
                        android:fontFamily="@font/dmsans_bold"
                        android:textSize="16sp"/>

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="12dp"
                        android:text="Alamat"
                        android:fontFamily="@font/dmsans_medium"
                        android:textColor="@color/black"
                        android:textSize="14sp" />

                    <TextView
                        android:id="@+id/tvRecipientName"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="4dp"
                        android:text="Gracia 081234533453"
                        android:fontFamily="@font/dmsans_italic"
                        android:textColor="@color/black_400"
                        android:textSize="14sp" />

                    <TextView
                        android:id="@+id/tvAddress"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Jl. Pegangsaan Timur"
                        android:fontFamily="@font/dmsans_italic"
                        android:textColor="@color/black_400"
                        android:textSize="14sp" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:text="Kurir"
                        android:fontFamily="@font/dmsans_medium"
                        android:textColor="@color/black"
                        android:textSize="14sp" />

                    <TextView
                        android:id="@+id/tvCourier"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="4dp"
                        android:text="JNE Reguler"
                        android:fontFamily="@font/dmsans_italic"
                        android:textColor="@color/black_400"
                        android:textSize="14sp" />
                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <View
                android:layout_width="match_parent"
                android:layout_height="8dp"
                android:background="@color/light_gray" />

            <!-- Order Items -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="2dp">

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

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rvOrderItems"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:nestedScrollingEnabled="false"
                        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                        tools:itemCount="2"
                        tools:listitem="@layout/item_order_detail_product" />
                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- Payment Method Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="2dp">

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

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Metode Pembayaran"
                        android:textColor="@color/black"

                        android:textSize="16sp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/tvPaymentMethod"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:text="Bank Transfer - Bank BCA"
                        android:textColor="@color/black_400"
                        android:textSize="14sp" />
                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- Order Summary Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="2dp">

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

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Subtotal"
                        android:textColor="@color/black"
                        android:textSize="16sp"
                        android:textStyle="bold" />

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <TextView
                            android:id="@+id/tv_item_count"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="Harga Total Produk"
                            android:textColor="@color/black_400"
                            android:textSize="14sp" />

                        <TextView
                            android:id="@+id/tvSubtotal"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Rp65.000"
                            android:textColor="@color/black"
                            android:textSize="14sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <TextView
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="Biaya Pengiriman"
                            android:textColor="@color/black_400"
                            android:textSize="14sp" />

                        <TextView
                            android:id="@+id/tvShippingCost"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Rp15.000"
                            android:textColor="@color/black"
                            android:textSize="14sp" />
                    </LinearLayout>

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginTop="8dp"
                        android:background="@color/light_gray" />

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <TextView
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="Total"
                            android:textColor="@color/black"
                            android:textSize="16sp"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/tvTotal"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Rp75.000"
                            android:textColor="@color/blue_500"
                            android:textSize="16sp"
                            android:textStyle="bold" />
                    </LinearLayout>
                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- Add space at the bottom for buttons -->
            <View
                android:layout_width="match_parent"
                android:layout_height="80dp" />
        </LinearLayout>
    </androidx.core.widget.NestedScrollView>

    <!-- Buttons at the bottom -->
    <LinearLayout
        android:id="@+id/buttonLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:elevation="8dp"
        android:orientation="horizontal"
        android:padding="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/scrollViewDetail">

        <com.google.android.material.button.MaterialButton
            android:id="@+id/btnSecondary"
            style="@style/Widget.MaterialComponents.Button.OutlinedButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_weight="1"
            android:text="Batalkan Pesanan"
            android:textAllCaps="false"
            android:visibility="gone"
            tools:visibility="visible" />

        <com.google.android.material.button.MaterialButton
            android:id="@+id/btnPrimary"
            style="@style/Widget.MaterialComponents.Button"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_weight="1"
            android:text="Bayar Sekarang"
            android:textAllCaps="false"
            android:visibility="gone"
            tools:visibility="visible" />
    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>