<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/brand_window_bg"
    android:padding="16dp">

    <com.google.android.material.card.MaterialCardView
        android:id="@+id/headerCard"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:cardBackgroundColor="@android:color/transparent"
        app:cardCornerRadius="24dp"
        app:cardElevation="4dp"
        app:strokeColor="@color/brand_header_stroke"
        app:strokeWidth="1dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_header_surface"
            android:orientation="vertical"
            android:paddingStart="20dp"
            android:paddingTop="20dp"
            android:paddingEnd="20dp"
            android:paddingBottom="18dp">

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

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

                    <TextView
                        android:id="@+id/headerWelcome"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/brand_text_muted"
                        android:textSize="14sp" />

                    <TextView
                        android:id="@+id/coachNameDisplay"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="2dp"
                        android:ellipsize="end"
                        android:maxLines="2"
                        android:textColor="@color/brand_purple"
                        android:textSize="22sp"
                        android:textStyle="bold" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/statusChipContainer"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="8dp"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:paddingStart="10dp"
                    android:paddingTop="6dp"
                    android:paddingEnd="12dp"
                    android:paddingBottom="6dp">

                    <ImageView
                        android:id="@+id/statusDot"
                        android:layout_width="8dp"
                        android:layout_height="8dp"
                        android:contentDescription="@null"
                        android:src="@drawable/ic_dot_16" />

                    <TextView
                        android:id="@+id/statusOnline"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="6dp"
                        android:textSize="12sp"
                        android:textStyle="bold" />
                </LinearLayout>

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

                    <androidx.appcompat.widget.AppCompatImageButton
                        android:id="@+id/settingsButton"
                        android:layout_width="44dp"
                        android:layout_height="44dp"
                        android:layout_marginEnd="8dp"
                        android:background="@drawable/bg_header_icon_button"
                        android:contentDescription="@string/settings_content_description"
                        android:gravity="center"
                        android:padding="0dp"
                        android:scaleType="center"
                        android:src="@drawable/ic_settings_24"
                        android:tint="@color/brand_purple" />

                    <FrameLayout
                        android:layout_width="44dp"
                        android:layout_height="44dp">

                        <androidx.appcompat.widget.AppCompatImageButton
                            android:id="@+id/refreshButton"
                            android:layout_width="44dp"
                            android:layout_height="44dp"
                            android:background="@drawable/bg_header_icon_button"
                            android:contentDescription="@string/refresh_content_description"
                            android:gravity="center"
                            android:padding="0dp"
                            android:scaleType="center"
                            android:src="@drawable/ic_refresh_24"
                            android:tint="@color/brand_purple" />

                        <ProgressBar
                            android:id="@+id/refreshProgress"
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:layout_gravity="center"
                            android:indeterminate="true"
                            android:visibility="gone" />
                    </FrameLayout>
                </LinearLayout>
            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="16dp"
                android:layout_marginBottom="14dp"
                android:background="@color/brand_header_divider" />

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

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

                    <TextView
                        android:id="@+id/labelLanguage"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingStart="4dp"
                        android:paddingBottom="4dp"
                        android:textColor="@color/brand_text_muted"
                        android:textSize="11sp" />

                    <Spinner
                        android:id="@+id/string_spinner1"
                        android:layout_width="match_parent"
                        android:layout_height="44dp"
                        android:background="@drawable/bg_control_chip"
                        android:popupBackground="@drawable/bg_spinner_popup"
                        android:paddingStart="12dp"
                        android:paddingEnd="12dp" />
                </LinearLayout>

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

                    <TextView
                        android:id="@+id/labelClientCode"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingStart="4dp"
                        android:paddingBottom="4dp"
                        android:textColor="@color/brand_text_muted"
                        android:textSize="11sp" />

                    <FrameLayout
                        android:id="@+id/clientSelectorRow"
                        android:layout_width="match_parent"
                        android:layout_height="44dp"
                        android:background="@drawable/bg_control_chip"
                        android:clickable="true"
                        android:contentDescription="@string/client_selector_content_description"
                        android:focusable="true"
                        android:foreground="?attr/selectableItemBackground">

                        <TextView
                            android:id="@+id/clientCodeDisplay"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:ellipsize="end"
                            android:gravity="start|center_vertical"
                            android:maxLines="1"
                            android:paddingStart="12dp"
                            android:paddingEnd="16dp"
                            android:textColor="@color/brand_text_dark"
                            android:textStyle="bold" />

                        <ImageView
                            android:layout_width="@dimen/spinner_dropdown_arrow_size_compact"
                            android:layout_height="@dimen/spinner_dropdown_arrow_size_compact"
                            android:layout_gravity="center_vertical|end"
                            android:layout_marginEnd="@dimen/spinner_dropdown_arrow_inset"
                            android:contentDescription="@null"
                            android:importantForAccessibility="no"
                            android:src="@drawable/ic_chevron_down" />
                    </FrameLayout>
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </com.google.android.material.card.MaterialCardView>

    <TextView
        android:id="@+id/noClientsAssignedText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:gravity="center"
        android:lineSpacingExtra="4dp"
        android:paddingHorizontal="24dp"
        android:textColor="@color/brand_text_muted"
        android:textSize="16sp"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/headerCard" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:textColor="@color/brand_text_dark"
        android:textSize="22sp"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/nextStepBannerCard" />

    <com.google.android.material.card.MaterialCardView
        android:id="@+id/nextStepBannerCard"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        app:cardBackgroundColor="@color/brand_emphasis_bg"
        app:cardCornerRadius="18dp"
        app:cardElevation="3dp"
        app:strokeColor="@color/brand_purple"
        app:strokeWidth="1dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/headerCard">

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

            <TextView
                android:id="@+id/nextStepEyebrow"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:textColor="@color/brand_purple"
                android:textSize="12sp"
                android:textStyle="bold" />

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

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

                    <TextView
                        android:id="@+id/nextStepTitle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textColor="@color/brand_text_dark"
                        android:textSize="15sp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/nextStepBody"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="3dp"
                        android:textColor="@color/brand_text_muted"
                        android:textSize="13sp" />
                </LinearLayout>

                <com.google.android.material.button.MaterialButton
                    android:id="@+id/nextStepActionButton"
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/pill_height"
                    android:layout_marginStart="12dp"
                    android:minWidth="96dp"
                    android:textAllCaps="false"
                    android:textColor="@color/white"
                    app:backgroundTint="@color/brand_purple"
                    app:cornerRadius="@dimen/pill_radius"
                    app:rippleColor="@color/brand_ripple_on_surface" />
            </LinearLayout>
        </LinearLayout>
    </com.google.android.material.card.MaterialCardView>

    <FrameLayout
        android:id="@+id/questionnaireListHost"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="12dp"
        app:layout_constraintBottom_toTopOf="@id/bottomUploadDock"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/textView">

        <androidx.core.widget.NestedScrollView
            android:id="@+id/questionnaireScroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:fillViewport="true"
            android:paddingBottom="8dp">

            <LinearLayout
                android:id="@+id/buttonContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" />
        </androidx.core.widget.NestedScrollView>

        <include
            android:id="@+id/questionnaireListLoading"
            layout="@layout/view_screen_loading_overlay"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>

    <FrameLayout
        android:id="@+id/bottomUploadDock"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/brand_header_surface"
        android:elevation="10dp"
        android:paddingStart="4dp"
        android:paddingTop="12dp"
        android:paddingEnd="4dp"
        android:paddingBottom="4dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

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

            <com.google.android.material.button.MaterialButton
                android:id="@+id/reviewScoresButton"
                android:layout_width="match_parent"
                android:layout_height="@dimen/pill_height"
                android:layout_marginBottom="8dp"
                android:textAllCaps="false"
                android:textColor="@color/brand_purple"
                app:backgroundTint="@color/brand_header_surface"
                app:cornerRadius="@dimen/pill_radius"
                app:rippleColor="@color/brand_ripple_on_surface"
                app:strokeColor="@color/brand_purple"
                app:strokeWidth="1dp" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/uploadButton"
                android:layout_width="match_parent"
                android:layout_height="@dimen/pill_height"
                android:textAllCaps="false"
                android:textColor="@color/white"
                app:backgroundTint="@color/brand_purple"
                app:cornerRadius="@dimen/pill_radius"
                app:elevation="2dp"
                app:rippleColor="@color/brand_ripple_on_surface" />
        </LinearLayout>
    </FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
