<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
    tools:context=".ui.product.category.CategoryProductsActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="200dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginEnd="64dp">

            <ImageView
                android:id="@+id/iv_category_header"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"
                android:contentDescription="Category Header Image" />

            <View
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/blue_50" />

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        </com.google.android.material.appbar.CollapsingToolbarLayout>

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <!-- Category Title Section -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="16dp">

                <TextView
                    android:id="@+id/tv_category_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Category Name"
                    android:textSize="24sp"
                    android:textStyle="bold"
                    android:textColor="@color/black_500"
                    android:gravity="center" />

                <View
                    android:layout_width="60dp"
                    android:layout_height="3dp"
                    android:layout_gravity="center"
                    android:layout_marginTop="8dp"
                    android:background="@color/blue_500" />

            </LinearLayout>

            <!-- Products Section -->
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp">

                <!-- Loading State -->
                <ProgressBar
                    android:id="@+id/progress_bar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginTop="32dp"
                    android:visibility="gone" />

                <!-- Products RecyclerView -->
                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rv_products"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:clipToPadding="false"
                    tools:listitem="@layout/item_product_grid" />

                <!-- Empty State -->
                <LinearLayout
                    android:id="@+id/layout_empty"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:orientation="vertical"
                    android:padding="32dp"
                    android:gravity="center"
                    android:visibility="gone">

                    <ImageView
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:src="@drawable/baseline_search_24"
                        android:layout_marginBottom="16dp"
                        android:contentDescription="No Products" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="No products found in this category"
                        android:textSize="16sp"
                        android:textColor="@color/black_200"
                        android:gravity="center" />

                </LinearLayout>

                <!-- Error State -->
                <LinearLayout
                    android:id="@+id/layout_error"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:orientation="vertical"
                    android:padding="32dp"
                    android:gravity="center"
                    android:visibility="gone">

                    <ImageView
                        android:layout_width="120dp"
                        android:layout_height="120dp"
                        android:src="@drawable/baseline_alarm_24"
                        android:layout_marginBottom="16dp"
                        android:contentDescription="Error" />

                    <TextView
                        android:id="@+id/tv_error_message"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Something went wrong"
                        android:textSize="16sp"
                        android:textColor="@color/black_200"
                        android:gravity="center"
                        android:layout_marginBottom="16dp" />

                    <Button
                        android:id="@+id/btn_retry"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Retry"
                        style="@style/Widget.MaterialComponents.Button.OutlinedButton" />

                </LinearLayout>

            </FrameLayout>

        </LinearLayout>

    </androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>