<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingLeft="16dp"
        android:paddingTop="18dp"
        android:paddingRight="16dp"
        android:paddingBottom="32dp">

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

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:text="@string/settings_subtitle"
            android:textColor="@color/ink_soft_color"
            android:lineSpacingExtra="2dp"
            android:textSize="13sp" />

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/settings_overview_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            app:cardBackgroundColor="@color/surface_strong"
            app:cardCornerRadius="20dp"
            app:strokeColor="@color/border_color"
            app:strokeWidth="1dp">

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

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

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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/bg_card"
                    android:orientation="vertical"
                    android:paddingLeft="12dp"
                    android:paddingRight="12dp">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:paddingTop="9dp"
                        android:paddingBottom="9dp">

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

                        <TextView
                            android:id="@+id/settings_qbooks_overview_detail_text"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="3dp"
                            android:textColor="@color/ink_soft_color"
                            android:textSize="12sp" />
                    </LinearLayout>

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:background="@color/border_color" />

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:paddingTop="9dp"
                        android:paddingBottom="9dp">

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

                        <TextView
                            android:id="@+id/settings_update_overview_detail_text"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="3dp"
                            android:textColor="@color/ink_soft_color"
                            android:textSize="12sp" />
                    </LinearLayout>

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

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/catalog_settings_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:visibility="gone"
            app:cardBackgroundColor="@color/surface_color"
            app:cardCornerRadius="18dp"
            app:strokeColor="@color/border_color"
            app:strokeWidth="1dp">

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

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

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="12dp"
                    android:text="@string/label_server_url"
                    android:textColor="@color/ink_soft_color"
                    android:textSize="12sp" />

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="6dp"
                    android:background="@drawable/bg_card"
                    app:boxBackgroundMode="none">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/qbooks_url_input"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/settings_server_placeholder"
                        android:inputType="textUri"
                        android:paddingLeft="18dp"
                        android:paddingTop="12dp"
                        android:paddingRight="18dp"
                        android:paddingBottom="12dp"
                        android:textColor="@color/ink_color"
                        android:textColorHint="@color/ink_soft_color" />
                </com.google.android.material.textfield.TextInputLayout>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:text="@string/label_username"
                    android:textColor="@color/ink_soft_color"
                    android:textSize="12sp" />

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="6dp"
                    android:background="@drawable/bg_card"
                    app:boxBackgroundMode="none">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/qbooks_username_input"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/settings_username_placeholder"
                        android:paddingLeft="18dp"
                        android:paddingTop="12dp"
                        android:paddingRight="18dp"
                        android:paddingBottom="12dp"
                        android:textColor="@color/ink_color"
                        android:textColorHint="@color/ink_soft_color" />
                </com.google.android.material.textfield.TextInputLayout>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:text="@string/label_password"
                    android:textColor="@color/ink_soft_color"
                    android:textSize="12sp" />

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="6dp"
                    app:boxBackgroundColor="@color/surface_color"
                    app:boxBackgroundMode="filled"
                    app:boxStrokeWidth="0dp"
                    app:boxStrokeWidthFocused="0dp"
                    app:endIconMode="password_toggle">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/qbooks_password_input"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/settings_password_placeholder"
                        android:inputType="textPassword"
                        android:paddingLeft="18dp"
                        android:paddingTop="12dp"
                        android:paddingRight="18dp"
                        android:paddingBottom="12dp"
                        android:textColor="@color/ink_color"
                        android:textColorHint="@color/ink_soft_color" />
                </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="14dp"
                    app:cardBackgroundColor="@color/surface_muted"
                    app:cardCornerRadius="16dp"
                    app:strokeColor="@color/border_color"
                    app:strokeWidth="1dp">

                    <TextView
                        android:id="@+id/security_hint_text"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="14dp"
                        android:textColor="@color/ink_soft_color"
                        android:textSize="13sp" />
                </com.google.android.material.card.MaterialCardView>

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

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/test_connection_button"
                        style="@style/Widget.Aletheia.Button.Secondary"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/action_test" />

                    <Space
                        android:layout_width="1dp"
                        android:layout_height="10dp" />

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/save_settings_button"
                        style="@style/Widget.Aletheia.Button.Primary"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/action_save" />
                </LinearLayout>

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

                    <TextView
                        android:id="@+id/connection_status_text"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:textColor="@color/ink_soft_color"
                        android:textSize="13sp" />

                    <ProgressBar
                        android:id="@+id/connection_progress"
                        android:layout_width="22dp"
                        android:layout_height="22dp"
                        android:indeterminateTint="@color/accent_color"
                        android:visibility="gone" />
                </LinearLayout>
            </LinearLayout>
        </com.google.android.material.card.MaterialCardView>

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

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

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

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

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="6dp"
                    app:boxBackgroundColor="@color/surface_color"
                    app:boxBackgroundMode="filled"
                    app:boxStrokeWidth="0dp"
                    app:boxStrokeWidthFocused="0dp"
                    app:endIconMode="dropdown_menu">

                    <com.google.android.material.textfield.MaterialAutoCompleteTextView
                        android:id="@+id/font_size_dropdown"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="none"
                        android:paddingLeft="18dp"
                        android:paddingTop="14dp"
                        android:paddingRight="18dp"
                        android:paddingBottom="14dp"
                        android:textColor="@color/ink_color" />
                </com.google.android.material.textfield.TextInputLayout>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="12dp"
                    android:text="@string/label_font_family"
                    android:textColor="@color/ink_soft_color"
                    android:textSize="12sp" />

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="6dp"
                    app:boxBackgroundColor="@color/surface_color"
                    app:boxBackgroundMode="filled"
                    app:boxStrokeWidth="0dp"
                    app:boxStrokeWidthFocused="0dp"
                    app:endIconMode="dropdown_menu">

                    <com.google.android.material.textfield.MaterialAutoCompleteTextView
                        android:id="@+id/font_family_dropdown"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="none"
                        android:paddingLeft="18dp"
                        android:paddingTop="14dp"
                        android:paddingRight="18dp"
                        android:paddingBottom="14dp"
                        android:textColor="@color/ink_color" />
                </com.google.android.material.textfield.TextInputLayout>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="12dp"
                    android:text="@string/label_reader_theme"
                    android:textColor="@color/ink_soft_color"
                    android:textSize="12sp" />

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="6dp"
                    app:boxBackgroundColor="@color/surface_color"
                    app:boxBackgroundMode="filled"
                    app:boxStrokeWidth="0dp"
                    app:boxStrokeWidthFocused="0dp"
                    app:endIconMode="dropdown_menu">

                    <com.google.android.material.textfield.MaterialAutoCompleteTextView
                        android:id="@+id/theme_dropdown"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="none"
                        android:paddingLeft="18dp"
                        android:paddingTop="14dp"
                        android:paddingRight="18dp"
                        android:paddingBottom="14dp"
                        android:textColor="@color/ink_color" />
                </com.google.android.material.textfield.TextInputLayout>

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

                <com.google.android.material.slider.Slider
                    android:id="@+id/brightness_slider"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:valueFrom="10"
                    android:valueTo="100"
                    app:haloColor="@android:color/transparent"
                    app:thumbColor="@color/accent_dark_color"
                    app:trackColorActive="@color/accent_color"
                    app:trackColorInactive="@color/surface_strong" />
            </LinearLayout>
        </com.google.android.material.card.MaterialCardView>

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

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

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

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

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

                <TextView
                    android:id="@+id/update_current_version_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="4dp"
                    android:fontFamily="@font/open_sans_semibold"
                    android:textColor="@color/ink_color"
                    android:textSize="16sp" />

                <TextView
                    android:id="@+id/update_release_label"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="12dp"
                    android:text="@string/settings_update_release_label"
                    android:textColor="@color/ink_soft_color"
                    android:textSize="12sp"
                    android:visibility="gone" />

                <TextView
                    android:id="@+id/update_release_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="4dp"
                    android:fontFamily="@font/open_sans_semibold"
                    android:textColor="@color/ink_color"
                    android:textSize="16sp"
                    android:visibility="gone" />

                <TextView
                    android:id="@+id/update_release_meta_text"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="6dp"
                    android:textColor="@color/ink_soft_color"
                    android:textSize="13sp"
                    android:visibility="gone" />

                <TextView
                    android:id="@+id/update_release_notes_text"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:textColor="@color/ink_color"
                    android:textSize="13sp"
                    android:visibility="gone" />

                <com.google.android.material.card.MaterialCardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="14dp"
                    app:cardBackgroundColor="@color/surface_muted"
                    app:cardCornerRadius="16dp"
                    app:strokeColor="@color/border_color"
                    app:strokeWidth="1dp">

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

                        <TextView
                            android:id="@+id/update_status_title_text"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:fontFamily="@font/open_sans_semibold"
                            android:textColor="@color/ink_color"
                            android:textSize="14sp" />

                        <TextView
                            android:id="@+id/update_status_detail_text"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="6dp"
                            android:textColor="@color/ink_soft_color"
                            android:textSize="13sp" />

                        <TextView
                            android:id="@+id/update_installer_event_text"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="10dp"
                            android:textColor="@color/ink_soft_color"
                            android:textSize="12sp"
                            android:visibility="gone" />
                    </LinearLayout>
                </com.google.android.material.card.MaterialCardView>

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

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/check_updates_button"
                        style="@style/Widget.Aletheia.Button.Secondary"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/action_check_updates" />

                    <Space
                        android:layout_width="1dp"
                        android:layout_height="10dp" />

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/install_update_button"
                        style="@style/Widget.Aletheia.Button.Primary"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/action_install_update"
                        android:visibility="gone" />
                </LinearLayout>

                <ProgressBar
                    android:id="@+id/update_progress"
                    android:layout_width="22dp"
                    android:layout_height="22dp"
                    android:layout_gravity="end"
                    android:layout_marginTop="12dp"
                    android:indeterminateTint="@color/accent_color"
                    android:visibility="gone" />
            </LinearLayout>
        </com.google.android.material.card.MaterialCardView>

    </LinearLayout>

</ScrollView>
