<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/chatDrawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/background_grey">

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="56dp"
                android:background="@color/primary_dark"
                android:gravity="center_vertical"
                android:paddingStart="16dp"
                android:paddingEnd="16dp">

                <ImageButton
                    android:id="@+id/btnHamburger"
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@drawable/baseline_menu_36"
                    android:background="?attr/selectableItemBackgroundBorderless"
                    android:contentDescription="Open menu"/>

                <TextView
                    android:id="@+id/tvChatTitle"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Customer Chat"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold"
                    android:paddingStart="8dp"
                    android:paddingEnd="8dp"/>

                <Button
                    android:id="@+id/btnCloseChat"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Close Chat"
                    android:textSize="12sp"
                    android:backgroundTint="@color/accent_coral"
                    android:textColor="@color/white"
                    android:visibility="gone"/>

            </LinearLayout>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rvMessages"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:padding="8dp"
                android:clipToPadding="false" />

            <LinearLayout
                android:id="@+id/layoutAttachmentPreview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="8dp"
                android:background="#E0E0E0"
                android:gravity="center_vertical"
                android:visibility="gone">

                <ImageView
                    android:id="@+id/ivPreview"
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:scaleType="centerCrop"
                    android:layout_marginEnd="8dp"
                    android:visibility="gone"/>

                <TextView
                    android:id="@+id/tvPreviewName"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:ellipsize="middle"
                    android:singleLine="true"
                    android:textColor="@color/text_dark"/>

                <ImageButton
                    android:id="@+id/btnRemoveAttachment"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:src="@android:drawable/ic_menu_close_clear_cancel"
                    android:background="?attr/selectableItemBackgroundBorderless"
                    android:contentDescription="Remove attachment"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="8dp"
                android:gravity="center_vertical"
                android:background="@color/white">

                <ImageButton
                    android:id="@+id/btnAttach"
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@android:drawable/ic_menu_add"
                    android:background="?attr/selectableItemBackgroundBorderless"
                    android:contentDescription="Attach file"
                    android:layout_marginEnd="4dp"/>

                <EditText
                    android:id="@+id/etMessage"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:hint="Type a message..."
                    android:inputType="text"
                    android:imeOptions="actionSend"
                    android:layout_marginEnd="8dp"
                    android:textColor="@color/text_dark"/>

                <Button
                    android:id="@+id/btnSend"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Send"
                    android:backgroundTint="@color/accent_coral"
                    android:textColor="@color/white"/>

            </LinearLayout>

        </LinearLayout>

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:visibility="gone"
            android:indeterminateTint="@color/accent_coral"/>

    </RelativeLayout>

    <androidx.core.widget.NestedScrollView
        android:id="@+id/chatListDrawer"
        android:layout_width="260dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/primary_dark">

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

            <LinearLayout
                android:id="@+id/headerActiveChats"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:clickable="true"
                android:focusable="true"
                android:background="?attr/selectableItemBackground"
                android:paddingStart="16dp"
                android:paddingEnd="16dp"
                android:paddingBottom="8dp">

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="ACTIVE CHATS"
                    android:textColor="@color/text_light"
                    android:textSize="11sp"
                    android:letterSpacing="0.15"
                    android:textStyle="bold"/>

                <ImageView
                    android:id="@+id/ivActiveChevron"
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:src="@android:drawable/arrow_up_float"
                    app:tint="@color/text_light"/>
            </LinearLayout>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rvActiveChats"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:nestedScrollingEnabled="false"
                android:layout_marginBottom="16dp"
                android:paddingStart="8dp"
                android:paddingEnd="8dp"/>

            <LinearLayout
                android:id="@+id/headerClosedChats"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:clickable="true"
                android:focusable="true"
                android:background="?attr/selectableItemBackground"
                android:paddingStart="16dp"
                android:paddingEnd="16dp"
                android:paddingTop="8dp"
                android:paddingBottom="8dp">

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="CLOSED CHATS"
                    android:textColor="@color/text_light"
                    android:textSize="11sp"
                    android:letterSpacing="0.15"
                    android:textStyle="bold"/>

                <ImageView
                    android:id="@+id/ivClosedChevron"
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:src="@android:drawable/arrow_down_float"
                    app:tint="@color/text_light"/>
            </LinearLayout>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rvClosedChats"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:nestedScrollingEnabled="false"
                android:visibility="gone"
                android:paddingStart="8dp"
                android:paddingEnd="8dp"/>

        </LinearLayout>
    </androidx.core.widget.NestedScrollView>

</androidx.drawerlayout.widget.DrawerLayout>