<?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/constraint_search"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="?attr/colorSurface"
    android:clipToPadding="false">

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/divider">

        <LinearLayout
            android:id="@+id/no_results_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:gravity="center">

            <ImageView
                android:id="@+id/icon_no_results"
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:src="@drawable/ic_search" />

            <com.google.android.material.textview.MaterialTextView
                android:id="@+id/notice_text"
                style="@style/TextAppearance.Material3.TitleLarge"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:paddingTop="8dp"
                android:text="@string/search_and_filter_games"
                tools:visibility="visible" />

        </LinearLayout>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/grid_games_search"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false" />

    </RelativeLayout>

    <FrameLayout
        android:id="@+id/frame_search"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:layout_marginHorizontal="20dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/search_background"
            style="?attr/materialCardViewFilledStyle"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            app:cardCornerRadius="28dp">

            <LinearLayout
                android:id="@+id/search_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginStart="24dp"
                android:layout_marginEnd="56dp"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="28dp"
                    android:layout_height="28dp"
                    android:layout_gravity="center_vertical"
                    android:layout_marginEnd="24dp"
                    android:src="@drawable/ic_search"
                    app:tint="?attr/colorOnSurfaceVariant" />

                <EditText
                    android:id="@+id/search_text"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@android:color/transparent"
                    android:hint="@string/home_search_games"
                    android:inputType="text"
                    android:maxLines="1"
                    android:imeOptions="flagNoFullscreen" />

            </LinearLayout>

            <ImageView
                android:id="@+id/clear_button"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_gravity="center_vertical|end"
                android:layout_marginEnd="24dp"
                android:background="?attr/selectableItemBackground"
                android:src="@drawable/ic_clear"
                android:visibility="invisible"
                app:tint="?attr/colorOnSurfaceVariant"
                tools:visibility="visible" />

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

    </FrameLayout>

    <HorizontalScrollView
        android:id="@+id/horizontalScrollView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fadingEdge="horizontal"
        android:scrollbars="none"
        android:layout_marginVertical="4dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/frame_search">

        <com.google.android.material.chip.ChipGroup
            android:id="@+id/chip_group"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clipToPadding="false"
            android:paddingVertical="4dp"
            app:chipSpacingHorizontal="12dp"
            app:singleLine="true"
            app:singleSelection="true">

            <com.google.android.material.chip.Chip
                android:id="@+id/chip_recently_played"
                style="@style/Widget.Material3.Chip.Suggestion.Elevated"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="false"
                android:text="@string/search_recently_played"
                app:chipCornerRadius="28dp" />

            <com.google.android.material.chip.Chip
                android:id="@+id/chip_recently_added"
                style="@style/Widget.Material3.Chip.Suggestion.Elevated"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="false"
                android:text="@string/search_recently_added"
                app:chipCornerRadius="28dp" />

            <com.google.android.material.chip.Chip
                android:id="@+id/chip_installed"
                style="@style/Widget.Material3.Chip.Suggestion.Elevated"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="false"
                android:text="@string/search_installed"
                app:chipCornerRadius="28dp" />

        </com.google.android.material.chip.ChipGroup>

    </HorizontalScrollView>

    <com.google.android.material.divider.MaterialDivider
        android:id="@+id/divider"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="20dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/horizontalScrollView" />

</androidx.constraintlayout.widget.ConstraintLayout>
