<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#F5F5F5"
    tools:context=".FormsFragment">

    <!-- NYTT: Toolbar med tilbake-knapp -->
    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Light">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/forms_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/white"
            app:navigationIcon="@android:drawable/ic_menu_revert"
            app:titleTextColor="@color/black"
            app:title="Laster..." />

    </com.google.android.material.appbar.AppBarLayout>

    <!-- Resten er likt, men nå under toolbaren -->

    <LinearLayout
        android:id="@+id/history_wrapper"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:orientation="vertical"
        android:background="#FFFFFF"
        android:elevation="4dp"
        android:layout_marginBottom="8dp"
        android:padding="16dp">

        <TextView
            android:id="@+id/lbl_history"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Tidligere innsendinger"
            android:textSize="18sp"
            android:textStyle="bold"
            android:textColor="#333333"
            android:layout_marginBottom="10dp"/>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/historyContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" />
        </ScrollView>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="7"
        android:orientation="vertical"
        android:background="#FFFFFF"
        android:elevation="4dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="center_vertical"
            android:padding="8dp"
            android:background="#FAFAFA">

            <ProgressBar
                android:id="@+id/loading_spinner"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:visibility="gone"
                android:layout_marginEnd="8dp"/>

            <TextView
                android:id="@+id/txt_status"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:textColor="#666666"
                android:textSize="12sp"
                android:text="" />

            <ImageView
                android:id="@+id/btn_toggle_history"
                android:layout_width="32dp"
                android:layout_height="32dp"
                android:src="@android:drawable/arrow_up_float"
                android:background="?attr/selectableItemBackgroundBorderless"
                android:padding="4dp"
                android:contentDescription="Vis/Skjul historikk"
                app:tint="#666666" />
        </LinearLayout>

        <ScrollView
            android:id="@+id/form_scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="16dp"
            android:fillViewport="true">

            <LinearLayout
                android:id="@+id/form_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingBottom="40dp">
            </LinearLayout>
        </ScrollView>
    </LinearLayout>

</LinearLayout>