<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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/white"
    android:overScrollMode="never"
    android:paddingBottom="80dp">

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

        <!-- Header: Minimalist Patient Info -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal"
            android:layout_marginBottom="32dp">

            <ImageButton
                android:id="@+id/btnRefreshGuardian"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:background="?attr/selectableItemBackgroundBorderless"
                android:src="@android:drawable/stat_notify_sync"
                android:layout_marginEnd="12dp"
                app:tint="@color/theme_blue_primary" />

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

                <TextView
                    android:id="@+id/textPatientName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text=""
                    android:textColor="@color/theme_black_primary"
                    android:textSize="22sp"
                    android:fontFamily="sans-serif-medium" />

                <TextView
                    android:id="@+id/textPatientStatus"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text=""
                    android:textColor="@color/neutral_medium"
                    android:textSize="14sp" />
            </LinearLayout>
        </LinearLayout>

        <!-- Summary Status Section -->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Estado Geral"
            android:textColor="@color/neutral_medium"
            android:textSize="12sp"
            android:textAllCaps="true"
            android:letterSpacing="0.1"
            android:layout_marginBottom="12dp" />

        <LinearLayout
            android:id="@+id/cardStatusDashboard"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_guardian_card"
            android:backgroundTint="@color/theme_blue_bg"
            android:orientation="vertical"
            android:padding="20dp"
            android:layout_marginBottom="32dp">

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

                <ImageView
                    android:id="@+id/iconStatus"
                    android:layout_width="24dp"
                    android:layout_height="24dp"
                    android:src="@android:drawable/checkbox_on_background"
                    app:tint="@color/status_taken" />

                <TextView
                    android:id="@+id/textStatusTitle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="12dp"
                    android:text="Tudo em ordem"
                    android:textColor="@color/theme_blue_primary"
                    android:textSize="16sp"
                    android:fontFamily="sans-serif-medium" />
            </LinearLayout>

            <TextView
                android:id="@+id/textStatusDesc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="As medicações estão a ser tomadas conforme o planeado."
                android:textColor="@color/theme_blue_secondary"
                android:textSize="14sp" />
        </LinearLayout>

        <!-- Adherence Timeline / Daily History -->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Histórico de Hoje"
            android:textColor="@color/neutral_medium"
            android:textSize="12sp"
            android:textAllCaps="true"
            android:letterSpacing="0.1"
            android:layout_marginBottom="12dp" />

        <LinearLayout
            android:id="@+id/medicationStatusList"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginBottom="32dp">
            <!-- Items like: [Med Name] - [Time] - [Check Mark] -->
        </LinearLayout>

        <!-- Next Medication Card - Simplified -->
        <LinearLayout
            android:id="@+id/cardNextMedication"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_guardian_card"
            android:backgroundTint="@color/theme_purple_bg"
            android:padding="20dp"
            android:layout_marginBottom="32dp"
            android:orientation="horizontal"
            android:gravity="center_vertical">

            <TextView
                android:id="@+id/textNextTime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="--:--"
                android:textColor="@color/theme_purple_primary"
                android:textSize="24sp"
                android:fontFamily="sans-serif-medium" />

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

                <TextView
                    android:id="@+id/textNextTitle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Próxima Toma"
                    android:textColor="@color/theme_purple_primary"
                    android:textSize="16sp"
                    android:fontFamily="sans-serif-medium" />

                <TextView
                    android:id="@+id/textNextDetail"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text=""
                    android:textColor="@color/theme_purple_secondary"
                    android:textSize="14sp" />
            </LinearLayout>
        </LinearLayout>


        <!-- Managed Guardians Section -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="center_vertical"
            android:layout_marginBottom="12dp">

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Equipa de Cuidado"
                android:textColor="@color/neutral_medium"
                android:textSize="12sp"
                android:textAllCaps="true"
                android:letterSpacing="0.1" />

            <TextView
                android:id="@+id/btnAddGuardian"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="+ Adicionar"
                android:textColor="@color/theme_blue_primary"
                android:textSize="14sp"
                android:fontFamily="sans-serif-medium" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/guardianListContainer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <!-- Dynamic Guardian Items -->
        </LinearLayout>

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