<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cardProduct"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:clickable="true"
    android:focusable="true"
    android:foreground="?attr/selectableItemBackground"
    app:cardCornerRadius="12dp"
    app:cardElevation="4dp"
    app:cardBackgroundColor="@color/background"
    app:strokeColor="@color/gray"
    app:strokeWidth="1dp">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="16dp">

        <!-- 圖片區域 1:1 -->
        <ImageView
            android:id="@+id/imageProductPicture"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:adjustViewBounds="true"
            android:scaleType="centerCrop"
            android:src="@drawable/default_product"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <!-- 商品編號標籤 (左上角) -->
        <TextView
            android:id="@+id/textProductId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginStart="8dp"
            android:background="@color/primary"
            android:paddingHorizontal="10dp"
            android:paddingVertical="4dp"
            android:textColor="@color/onPrimary"
            android:textSize="14sp"
            android:textStyle="bold"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <!-- 商品名稱 -->
        <TextView
            android:id="@+id/textProductName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:layout_marginHorizontal="12dp"
            android:ellipsize="end"
            android:maxLines="2"
            android:minLines="1"
            android:text="@string/product_name"
            android:textColor="@color/black"
            android:textSize="22sp"
            android:textStyle="bold"
            android:gravity="center"
            app:layout_constraintTop_toBottomOf="@id/imageProductPicture" />

        <!-- 保留隱藏的按鈕 ID 避免 Adapter 崩潰，但設為 GONE -->
        <Button
            android:id="@+id/buttonSlotProductSelect"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:visibility="gone"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</com.google.android.material.card.MaterialCardView>