<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/app_background"
    android:clipToPadding="false"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingStart="20dp"
        android:paddingTop="16dp"
        android:paddingEnd="20dp"
        android:paddingBottom="30dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:fontFamily="@font/open_sans_semibold"
                android:text="@string/library_title"
                android:textColor="@color/ink_color"
                android:textSize="30sp" />

            <TextView
                android:id="@+id/header_search_button"
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:background="@drawable/bg_circle_white"
                android:contentDescription="@string/action_search"
                android:gravity="center"
                android:text="⌕"
                android:textColor="@color/ink_color"
                android:textSize="28sp" />
        </LinearLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:text="@string/library_subtitle"
            android:textColor="@color/ink_soft_color"
            android:textSize="14sp" />

        <com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="54dp"
            android:layout_marginTop="16dp"
            android:background="@drawable/bg_search_pill"
            app:boxBackgroundMode="none"
            app:endIconMode="clear_text"
            app:startIconDrawable="@drawable/ic_nav_search"
            app:startIconTint="@color/ink_soft_color">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/books_search_input"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/transparent"
                android:hint="@string/label_search_books"
                android:imeOptions="actionSearch"
                android:singleLine="true"
                android:textColor="@color/ink_color"
                android:textColorHint="@color/ink_soft_color"
                android:textSize="16sp" />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="18dp"
            app:cardBackgroundColor="@color/white"
            app:cardCornerRadius="20dp"
            app:cardElevation="0dp"
            app:strokeColor="@color/border_color"
            app:strokeWidth="1dp">

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

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:fontFamily="@font/open_sans_semibold"
                    android:text="@string/library_goal_title"
                    android:textColor="@color/ink_color"
                    android:textSize="18sp" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:text="@string/library_goal_subtitle"
                    android:textColor="@color/ink_soft_color"
                    android:textSize="13sp" />

                <ProgressBar
                    style="?android:attr/progressBarStyleHorizontal"
                    android:layout_width="match_parent"
                    android:layout_height="5dp"
                    android:layout_marginTop="14dp"
                    android:max="7"
                    android:progress="1"
                    android:progressTint="@color/accent_color" />
            </LinearLayout>
        </com.google.android.material.card.MaterialCardView>

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/continue_reading_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:visibility="gone"
            app:cardBackgroundColor="@color/white"
            app:cardCornerRadius="20dp"
            app:cardElevation="0dp"
            app:strokeColor="@color/border_color"
            app:strokeWidth="1dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:padding="14dp">

                <ImageView
                    android:id="@+id/continue_cover"
                    android:layout_width="72dp"
                    android:layout_height="104dp"
                    android:scaleType="centerCrop" />

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="14dp"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/continue_reading_title"
                        android:textColor="@color/accent_color"
                        android:textSize="12sp" />

                    <TextView
                        android:id="@+id/continue_title"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:ellipsize="end"
                        android:fontFamily="@font/open_sans_semibold"
                        android:maxLines="2"
                        android:textColor="@color/ink_color"
                        android:textSize="16sp" />

                    <TextView
                        android:id="@+id/continue_author"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="3dp"
                        android:ellipsize="end"
                        android:maxLines="1"
                        android:textColor="@color/ink_soft_color"
                        android:textSize="13sp" />

                    <TextView
                        android:id="@+id/continue_progress"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="7dp"
                        android:textColor="@color/ink_soft_color"
                        android:textSize="12sp" />

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/continue_open_button"
                        android:layout_width="wrap_content"
                        android:layout_height="42dp"
                        android:layout_marginTop="8dp"
                        android:text="@string/reader_hub_continue"
                        app:cornerRadius="21dp" />
                </LinearLayout>
            </LinearLayout>
        </com.google.android.material.card.MaterialCardView>

        <HorizontalScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="18dp"
            android:scrollbars="none">

            <com.google.android.material.chip.ChipGroup
                android:id="@+id/library_filter_group"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:chipSpacingHorizontal="8dp"
                app:selectionRequired="true"
                app:singleSelection="true"
                app:singleLine="true">
                <com.google.android.material.chip.Chip android:id="@+id/library_filter_all" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:text="@string/library_filter_all" />
                <com.google.android.material.chip.Chip android:id="@+id/library_filter_reading" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/library_filter_reading" />
                <com.google.android.material.chip.Chip android:id="@+id/library_filter_downloaded" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/library_filter_downloaded" />
                <com.google.android.material.chip.Chip android:id="@+id/library_filter_finished" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/library_filter_finished" />
            </com.google.android.material.chip.ChipGroup>
        </HorizontalScrollView>

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/bookshelf_panel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="14dp"
            android:visibility="gone"
            app:cardBackgroundColor="@color/white"
            app:cardCornerRadius="20dp"
            app:cardElevation="0dp"
            app:strokeColor="@color/border_color"
            app:strokeWidth="1dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingStart="14dp"
                android:paddingTop="12dp"
                android:paddingEnd="14dp"
                android:paddingBottom="14dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="44dp"
                    android:gravity="center_vertical"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:fontFamily="@font/open_sans_semibold"
                        android:text="@string/library_shelf_section"
                        android:textColor="@color/ink_color"
                        android:textSize="20sp" />

                    <TextView
                        android:id="@+id/local_shelf_all_button"
                        android:layout_width="wrap_content"
                        android:layout_height="44dp"
                        android:gravity="center"
                        android:paddingStart="10dp"
                        android:paddingEnd="10dp"
                        android:text="@string/action_show_all"
                        android:textColor="@color/accent_color" />
                </LinearLayout>

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/books_recycler"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:clipToPadding="false"
                    android:contentDescription="@string/a11y_books_list"
                    android:scrollbars="none" />
            </LinearLayout>
        </com.google.android.material.card.MaterialCardView>

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/empty_library_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="18dp"
            android:clickable="true"
            android:focusable="true"
            app:cardBackgroundColor="@color/white"
            app:cardCornerRadius="20dp"
            app:cardElevation="0dp"
            app:strokeColor="@color/border_color"
            app:strokeWidth="1dp">

            <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" android:padding="28dp">
                <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:fontFamily="@font/open_sans_semibold" android:gravity="center" android:text="@string/status_empty_library" android:textColor="@color/ink_color" android:textSize="20sp" />
                <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:gravity="center" android:text="@string/status_empty_library_subtitle" android:textColor="@color/ink_soft_color" android:textSize="14sp" />
                <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:text="@string/action_add_file" android:textColor="@color/accent_color" android:textSize="15sp" />
            </LinearLayout>
        </com.google.android.material.card.MaterialCardView>

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/empty_search_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="18dp"
            android:visibility="gone"
            app:cardBackgroundColor="@color/white"
            app:cardCornerRadius="20dp"
            app:cardElevation="0dp">

            <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" android:padding="24dp">
                <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:fontFamily="@font/open_sans_semibold" android:gravity="center" android:text="@string/status_empty_library_search" android:textColor="@color/ink_color" android:textSize="19sp" />
                <TextView android:id="@+id/empty_search_detail_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:gravity="center" android:textColor="@color/ink_soft_color" />
                <com.google.android.material.button.MaterialButton android:id="@+id/clear_library_search_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="14dp" android:text="@string/action_clear_search" />
            </LinearLayout>
        </com.google.android.material.card.MaterialCardView>

        <LinearLayout
            android:id="@+id/qbooks_home_section"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:visibility="gone">
            <TextView android:id="@+id/qbooks_all_button" android:layout_width="wrap_content" android:layout_height="wrap_content" />
            <androidx.recyclerview.widget.RecyclerView android:id="@+id/qbooks_home_recycler" android:layout_width="match_parent" android:layout_height="wrap_content" />
        </LinearLayout>
    </LinearLayout>
</androidx.core.widget.NestedScrollView>
