<?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:padding="16dp">

    <com.google.android.material.card.MaterialCardView
        android:id="@+id/headerCard"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:paddingStart="24dp"
        android:paddingEnd="24dp"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        app:cardBackgroundColor="@color/brand_surface"
        app:cardCornerRadius="16dp"
        app:strokeColor="@color/brand_stroke"
        app:strokeWidth="1dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

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

            <!-- Language (eigene Zeile) -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingBottom="6dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingStart="12dp"
                    android:paddingBottom="6dp"
                    android:text="Language"
                    android:textColor="@color/brand_text_dark"
                    android:textSize="12sp" />

                <Spinner
                    android:id="@+id/string_spinner1"
                    android:layout_width="match_parent"
                    android:layout_height="48dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginEnd="8dp"
                    android:background="@drawable/bg_field_filled"
                    android:paddingStart="12dp"
                    android:paddingEnd="12dp" />
            </LinearLayout>

            <!-- Client Code | Coach Code (gemeinsame Zeile) -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:baselineAligned="false"
                android:paddingBottom="6dp">

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

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingStart="12dp"
                        android:paddingBottom="6dp"
                        android:text="Client Code"
                        android:textColor="@color/brand_text_dark"
                        android:textSize="12sp" />

                    <EditText
                        android:id="@+id/editText"
                        android:layout_width="match_parent"
                        android:layout_height="48dp"
                        android:layout_marginStart="8dp"
                        android:layout_marginEnd="8dp"
                        android:background="@drawable/bg_field_filled"
                        android:ems="10"
                        android:inputType="text"
                        android:paddingStart="12dp"
                        android:paddingEnd="12dp"
                        android:tag="client_code"/>
                </LinearLayout>

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

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingStart="12dp"
                        android:paddingBottom="6dp"
                        android:text="Coach Code"
                        android:textColor="@color/brand_text_dark"
                        android:textSize="12sp" />

                    <EditText
                        android:id="@+id/coachEditText"
                        android:layout_width="match_parent"
                        android:layout_height="48dp"
                        android:layout_marginStart="8dp"
                        android:layout_marginEnd="8dp"
                        android:background="@drawable/bg_field_locked"
                        android:ems="10"
                        android:inputType="none"
                        android:focusable="false"
                        android:focusableInTouchMode="false"
                        android:clickable="false"
                        android:cursorVisible="false"
                        android:longClickable="false"
                        android:paddingStart="12dp"
                        android:paddingEnd="12dp"
                        android:drawableEnd="@drawable/ic_lock_24"
                        android:drawablePadding="8dp"
                        android:textColor="@color/brand_text_dark"
                        android:textStyle="bold"
                        android:tag="coach_code"/>

                </LinearLayout>
            </LinearLayout>

            <!-- Session/Online -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:paddingTop="6dp">

                <TextView
                    android:id="@+id/statusSession"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_marginStart="8dp"
                    android:text="Session: —"
                    android:textColor="@color/brand_text_dark"
                    android:textSize="13sp" />

                <TextView
                    android:id="@+id/statusOnline"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Offline"
                    android:textStyle="bold"
                    android:layout_marginEnd="8dp"
                    android:textSize="13sp"
                    android:textColor="#C62828"
                    android:paddingStart="12dp"/>
            </LinearLayout>

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

    <LinearLayout
        android:id="@+id/primaryActionsRow"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center"
        android:baselineAligned="false"
        android:layout_marginTop="20dp"
        app:layout_constraintTop_toBottomOf="@id/headerCard"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

        <com.google.android.material.button.MaterialButton
            android:id="@+id/loadButton"
            android:layout_width="0dp"
            android:layout_height="@dimen/pill_height"
            android:layout_weight="1"
            android:layout_marginEnd="12dp"
            android:textAllCaps="false"
            android:textColor="@android:color/white"
            app:icon="@drawable/ic_dot_16"
            app:iconTint="@android:color/white"
            app:iconPadding="8dp"
            app:iconGravity="textStart"
            app:cornerRadius="@dimen/pill_radius"
            app:backgroundTint="@color/brand_purple"/>

        <com.google.android.material.button.MaterialButton
            android:id="@+id/saveButton"
            android:layout_width="0dp"
            android:layout_height="@dimen/pill_height"
            android:layout_weight="1"
            android:textAllCaps="false"
            android:textColor="@android:color/white"
            app:icon="@drawable/ic_dot_16"
            app:iconTint="@android:color/white"
            app:iconPadding="8dp"
            app:iconGravity="textStart"
            app:cornerRadius="@dimen/pill_radius"
            app:backgroundTint="@color/brand_purple"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/secondaryActionsColumn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginTop="16dp"
        app:layout_constraintTop_toBottomOf="@id/primaryActionsRow"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

        <com.google.android.material.button.MaterialButton
            android:id="@+id/uploadButton"
            style="@style/Widget.MaterialComponents.Button.OutlinedButton"
            android:layout_width="match_parent"
            android:layout_height="@dimen/pill_height"
            android:layout_marginBottom="12dp"
            android:textAllCaps="false"
            android:textColor="@color/brand_purple"
            app:cornerRadius="@dimen/pill_radius"
            app:strokeColor="@color/brand_purple"
            app:strokeWidth="@dimen/pill_stroke"
            app:backgroundTint="@android:color/transparent"/>

        <com.google.android.material.button.MaterialButton
            android:id="@+id/downloadButton"
            style="@style/Widget.MaterialComponents.Button.OutlinedButton"
            android:layout_width="match_parent"
            android:layout_height="@dimen/pill_height"
            android:textAllCaps="false"
            android:textColor="@color/brand_purple"
            app:cornerRadius="@dimen/pill_radius"
            app:strokeColor="@color/brand_purple"
            app:strokeWidth="@dimen/pill_stroke"
            app:backgroundTint="@android:color/transparent"/>
    </LinearLayout>

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

    <androidx.core.widget.NestedScrollView
        android:id="@+id/questionnaireScroll"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:fillViewport="true"
        android:clipToPadding="false"
        android:paddingBottom="16dp"
        app:layout_constraintTop_toBottomOf="@id/textView"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

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

</androidx.constraintlayout.widget.ConstraintLayout>
