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

    <include
        android:id="@+id/searchContainer"
        layout="@layout/view_search"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        app:layout_constraintTop_toTopOf="parent" />

    <!-- Home content in ScrollView -->
    <ScrollView
        android:id="@+id/home"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toBottomOf="@id/searchContainer"
        app:layout_constraintBottom_toBottomOf="parent">

        <!-- Your existing home content here -->
        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <!-- Remove searchContainer from here, it's now at the top level -->

            <androidx.viewpager2.widget.ViewPager2
                android:id="@+id/banners"
                android:layout_width="match_parent"
                android:layout_height="132dp"
                android:layout_marginTop="4dp"
                android:orientation="vertical"
                app:layout_constraintTop_toTopOf="parent"
                android:background="@drawable/banner_default"
                tools:layout_editor_absoluteX="16dp" />

            <TextView
                android:id="@+id/categoriesText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="32dp"
                android:layout_marginTop="16dp"
                android:text="@string/fragment_home_categories"
                android:textColor="@color/blue_500"
                android:fontFamily="@font/dmsans_bold"
                android:textSize="18sp"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/banners" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/showAll"
                style="@style/Widget.MaterialComponents.Button.TextButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="32dp"
                android:text="@string/show_all"
                android:textAllCaps="false"
                android:textColor="@color/blue_600"
                android:textSize="14sp"
                app:layout_constraintBaseline_toBaselineOf="@id/categoriesText"
                app:layout_constraintEnd_toEndOf="parent" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/categories"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:clipChildren="false"
                android:clipToPadding="false"
                android:orientation="horizontal"
                android:paddingHorizontal="24dp"
                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                app:layout_constraintTop_toBottomOf="@id/categoriesText"
                tools:layout_editor_absoluteX="0dp"
                tools:listitem="@layout/item_category_home" />

            <TextView
                android:id="@+id/new_products_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="32dp"
                android:layout_marginTop="16dp"
                android:text="@string/sold_product_text"
                android:textColor="@color/blue_500"
                android:fontFamily="@font/dmsans_bold"
                android:textSize="18sp"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/categories" />
            <com.google.android.material.button.MaterialButton
                android:id="@+id/productshowAll"
                style="@style/Widget.MaterialComponents.Button.TextButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="32dp"
                android:text="@string/show_all"
                android:textAllCaps="false"
                android:textColor="@color/blue_600"
                android:textSize="14sp"
                app:layout_constraintBaseline_toBaselineOf="@id/new_products_text"
                app:layout_constraintEnd_toEndOf="parent" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/new_products"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:layout_marginBottom="16dp"
                android:orientation="vertical"
                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                app:layout_constraintTop_toBottomOf="@id/new_products_text"
                tools:itemCount="5"
                tools:listitem="@layout/item_section_horizontal" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/searchResultsRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:visibility="gone"
        app:layout_constraintTop_toBottomOf="@id/searchContainer"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <!-- All other search-related elements at the top level -->
    <LinearLayout
        android:id="@+id/searchHistoryHeader"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="16dp"
        android:visibility="gone"
        app:layout_constraintTop_toBottomOf="@id/searchContainer">
        <!-- ... -->
    </LinearLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/searchHistoryRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:visibility="gone"
        app:layout_constraintTop_toBottomOf="@id/searchHistoryHeader"
        app:layout_constraintBottom_toBottomOf="parent" />

    <TextView
        android:id="@+id/noResultsText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="No results found"
        android:textSize="16sp"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/searchContainer" />

    <ProgressBar
        android:id="@+id/searchProgressBar"
        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_toBottomOf="@id/searchContainer" />

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

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

</androidx.constraintlayout.widget.ConstraintLayout>


    <!--            <com.zhpan.indicator.IndicatorView-->
    <!--                android:id="@+id/indicator"-->
    <!--                android:layout_width="wrap_content"-->
    <!--                android:layout_height="wrap_content"-->
    <!--                android:layout_marginTop="20dp"-->
    <!--                app:layout_constraintEnd_toEndOf="parent"-->
    <!--                app:layout_constraintStart_toStartOf="parent"-->
    <!--                app:layout_constraintTop_toBottomOf="@+id/banners" />-->