<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#0f172a">

    <!-- Splash screen (shown briefly on launch if setup is already done) -->
    <LinearLayout
        android:id="@+id/splashContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center"
        android:visibility="visible">

        <ImageView
            android:layout_width="260dp"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_logo"
            android:adjustViewBounds="true"
            android:scaleType="fitCenter"
            android:layout_marginBottom="16dp"
            android:contentDescription="EverShelf" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="La tua dispensa smart"
            android:textColor="#64748b"
            android:textSize="16sp"
            android:layout_marginBottom="48dp" />

        <ProgressBar
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:indeterminateTint="#7c3aed" />
    </LinearLayout>

    <!-- WebView (shown after setup) -->
    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone" />

    <!-- Settings gear (shown after setup, over WebView) — bottom-right corner so it never
         overlaps the webapp header buttons (e.g. the 📷 scan button at top-right) -->
    <ImageButton
        android:id="@+id/btnSettings"
        android:layout_width="44dp"
        android:layout_height="44dp"
        android:layout_gravity="bottom|end"
        android:layout_marginBottom="80dp"
        android:layout_marginEnd="8dp"
        android:background="@android:color/transparent"
        android:src="@android:drawable/ic_menu_manage"
        android:alpha="0.28"
        android:contentDescription="Settings"
        android:scaleType="centerInside"
        android:visibility="gone" />

    <!-- Update banner (shown at the TOP when a new version is available) -->
    <LinearLayout
        android:id="@+id/updateBanner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:orientation="vertical"
        android:background="#1e293b"
        android:visibility="gone">

        <!-- Banner row: message + buttons -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingStart="16dp"
            android:paddingEnd="8dp"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:gravity="center_vertical">

            <TextView
                android:id="@+id/tvUpdateMessage"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:textColor="#fbbf24"
                android:textSize="13sp"
                android:text="" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/btnInstallUpdate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:text="⬇ Scarica"
                android:textSize="12sp"
                android:textColor="#1e293b"
                android:backgroundTint="#fbbf24"
                style="@style/Widget.MaterialComponents.Button" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/btnDismissUpdate"
                android:layout_width="36dp"
                android:layout_height="36dp"
                android:layout_marginStart="4dp"
                android:text="✕"
                android:textSize="14sp"
                android:textColor="#94a3b8"
                android:backgroundTint="@android:color/transparent"
                style="@style/Widget.MaterialComponents.Button.TextButton" />
        </LinearLayout>

        <!-- Thin progress bar at the bottom of the banner -->
        <ProgressBar
            android:id="@+id/bannerProgressBar"
            style="@android:style/Widget.ProgressBar.Horizontal"
            android:layout_width="match_parent"
            android:layout_height="4dp"
            android:progressTint="#7c3aed"
            android:progressBackgroundTint="#334155"
            android:max="100"
            android:progress="0"
            android:indeterminate="false"
            android:visibility="gone" />

    </LinearLayout>

    <!-- Download progress (used by download progress poll) -->
    <ProgressBar
        android:id="@+id/downloadProgressBar"
        style="@android:style/Widget.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="4dp"
        android:layout_gravity="top"
        android:layout_marginTop="56dp"
        android:progressTint="#7c3aed"
        android:progressBackgroundTint="#334155"
        android:max="100"
        android:progress="0"
        android:indeterminate="false"
        android:visibility="gone" />

    <TextView
        android:id="@+id/downloadProgressText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top|center_horizontal"
        android:layout_marginTop="64dp"
        android:text=""
        android:textColor="#94a3b8"
        android:textSize="12sp"
        android:visibility="gone" />

</FrameLayout>
