<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:fitsSystemWindows="true">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/help_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:minHeight="?attr/actionBarSize" />

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

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

            <!-- App Header Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="16dp"
                app:cardElevation="2dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="12dp">

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

                    <androidx.cardview.widget.CardView
                        android:layout_width="72dp"
                        android:layout_height="72dp"
                        app:cardCornerRadius="16dp"
                        app:cardElevation="0dp"
                        android:background="?attr/colorPrimary">

                        <ImageView
                            android:layout_width="48dp"
                            android:layout_height="48dp"
                            android:layout_gravity="center"
                            android:src="@drawable/ic_launcher"
                            android:scaleType="centerInside"
                            app:tint="@android:color/white" />

                    </androidx.cardview.widget.CardView>

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

                        <TextView
                            android:id="@+id/afwall_title"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAppearance="?android:attr/textAppearanceLarge"
                            android:textStyle="bold"
                            android:textColor="?android:attr/textColorPrimary"
                            android:text="" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Android Firewall+"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="?android:attr/textColorSecondary"
                            android:layout_marginTop="4dp" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Advanced iptables firewall for Android"
                            android:textAppearance="?android:attr/textAppearanceSmall"
                            android:textColor="?android:attr/textColorSecondary"
                            android:layout_marginTop="4dp" />

                    </LinearLayout>
                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- Legend Section integrated here -->
            <include layout="@layout/help_legend_section" />

            <!-- Key Features Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="16dp"
                app:cardElevation="2dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="12dp">

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

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Key Features"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textStyle="bold"
                        android:textColor="?attr/colorPrimary"
                        android:layout_marginBottom="12dp" />

                    <!-- Feature Item 1 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:layout_marginBottom="8dp">

                        <androidx.cardview.widget.CardView
                            android:layout_width="32dp"
                            android:layout_height="32dp"
                            app:cardCornerRadius="16dp"
                            app:cardElevation="0dp"
                            android:background="?attr/itemBackground">

                            <ImageView
                                android:layout_width="16dp"
                                android:layout_height="16dp"
                                android:layout_gravity="center"
                                android:src="@android:drawable/ic_secure"
                                app:tint="?attr/colorPrimary" />

                        </androidx.cardview.widget.CardView>

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

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="Network Control"
                                android:textAppearance="?android:attr/textAppearanceMedium"
                                android:textStyle="bold"
                                android:textColor="?android:attr/textColorPrimary" />

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="Restrict which apps can access data networks"
                                android:textAppearance="?android:attr/textAppearanceSmall"
                                android:textColor="?android:attr/textColorSecondary"
                                android:layout_marginTop="2dp" />

                        </LinearLayout>
                    </LinearLayout>

                    <!-- Feature Item 2 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:layout_marginBottom="8dp">

                        <androidx.cardview.widget.CardView
                            android:layout_width="32dp"
                            android:layout_height="32dp"
                            app:cardCornerRadius="16dp"
                            app:cardElevation="0dp"
                            android:background="?attr/itemBackground">

                            <ImageView
                                android:layout_width="16dp"
                                android:layout_height="16dp"
                                android:layout_gravity="center"
                                android:src="@android:drawable/ic_menu_save"
                                app:tint="?attr/colorPrimary" />

                        </androidx.cardview.widget.CardView>

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

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="Data Savings"
                                android:textAppearance="?android:attr/textAppearanceMedium"
                                android:textStyle="bold"
                                android:textColor="?android:attr/textColorPrimary" />

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="Perfect for limited data plans and battery savings"
                                android:textAppearance="?android:attr/textAppearanceSmall"
                                android:textColor="?android:attr/textColorSecondary"
                                android:layout_marginTop="2dp" />

                        </LinearLayout>
                    </LinearLayout>

                    <!-- Feature Item 3 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal">

                        <androidx.cardview.widget.CardView
                            android:layout_width="32dp"
                            android:layout_height="32dp"
                            app:cardCornerRadius="16dp"
                            app:cardElevation="0dp"
                            android:background="?attr/itemBackground">

                            <ImageView
                                android:layout_width="16dp"
                                android:layout_height="16dp"
                                android:layout_gravity="center"
                                android:src="@android:drawable/ic_lock_lock"
                                app:tint="?attr/colorPrimary" />

                        </androidx.cardview.widget.CardView>

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

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="Privacy Protection"
                                android:textAppearance="?android:attr/textAppearanceMedium"
                                android:textStyle="bold"
                                android:textColor="?android:attr/textColorPrimary" />

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="Enhanced privacy by controlling app network access"
                                android:textAppearance="?android:attr/textAppearanceSmall"
                                android:textColor="?android:attr/textColorSecondary"
                                android:layout_marginTop="2dp" />

                        </LinearLayout>
                    </LinearLayout>

                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- App Description Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="16dp"
                app:cardElevation="2dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="12dp">

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

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="About AFWall+"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textStyle="bold"
                        android:textColor="?attr/colorAccent"
                        android:layout_marginBottom="12dp" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="AFWall+ (aka Android Firewall+) is a front-end application for the powerful iptables Linux firewall. It allows you to restrict which applications are permitted to access data networks. This is the perfect solution if you have a limited data plan, want to extend battery life, or want to improve your privacy."
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorSecondary"
                        android:lineSpacingMultiplier="1.3" />

                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- Links Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="16dp"
                app:cardElevation="2dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="12dp">

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

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Useful Links"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textStyle="bold"
                        android:textColor="?attr/colorAccent"
                        android:layout_marginBottom="12dp" />

                    <!-- Online Help -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:gravity="center_vertical"
                        android:paddingVertical="4dp">

                        <ImageView
                            android:layout_width="16dp"
                            android:layout_height="16dp"
                            android:src="@android:drawable/ic_menu_help"
                            app:tint="?attr/colorPrimary" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Wiki &amp; FAQ"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="?attr/colorPrimary"
                            android:layout_marginStart="8dp" />
                    </LinearLayout>

                    <!-- Source Code -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:gravity="center_vertical"
                        android:paddingVertical="4dp">

                        <ImageView
                            android:layout_width="16dp"
                            android:layout_height="16dp"
                            android:src="@android:drawable/ic_menu_view"
                            app:tint="?attr/colorPrimary" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Source Code"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="?attr/colorPrimary"
                            android:layout_marginStart="8dp" />
                    </LinearLayout>

                    <!-- Report Issues -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:gravity="center_vertical"
                        android:paddingVertical="4dp">

                        <ImageView
                            android:layout_width="16dp"
                            android:layout_height="16dp"
                            android:src="@android:drawable/ic_menu_report_image"
                            app:tint="?attr/colorPrimary" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Report Issues"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="?attr/colorPrimary"
                            android:layout_marginStart="8dp" />
                    </LinearLayout>

                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- Developers Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="16dp"
                app:cardElevation="2dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="12dp">

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

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Developers"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textStyle="bold"
                        android:textColor="?attr/colorAccent"
                        android:layout_marginBottom="12dp" />

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:paddingVertical="2dp">

                        <TextView
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="Umakanthan Chandran"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="?android:attr/textColorPrimary" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Active"
                            android:textAppearance="?android:attr/textAppearanceSmall"
                            android:textColor="?attr/colorPrimary"
                            android:textStyle="bold" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:paddingVertical="2dp">

                        <TextView
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="Kevin Cernekee"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="?android:attr/textColorPrimary" />
                    </LinearLayout>

                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- Credits Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="16dp"
                app:cardElevation="2dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="12dp">

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

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Special Thanks"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textStyle="bold"
                        android:textColor="?attr/colorAccent"
                        android:layout_marginBottom="12dp" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="• Pragma (Networklog)\n• Rodrigo Rosauro (DroidWall)\n• PdtS, werewolfdev, Material Design Icons (Icons)\n• CHEF-KOCH (AFWall+ Wiki)\n• All translators and contributors"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorSecondary"
                        android:lineSpacingMultiplier="1.4" />

                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- License Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="16dp"
                app:cardElevation="2dp"
                app:cardBackgroundColor="?attr/itemBackground">

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

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="License &amp; Libraries"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textStyle="bold"
                        android:textColor="?attr/colorAccent"
                        android:layout_marginBottom="12dp" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="AFWall+ is licensed under GNU General Public License v3.0"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorSecondary"
                        android:layout_marginBottom="8dp" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Key Libraries: iptables (GPLv2), Busybox (GPLv2), libsuperuser (Apache 2.0), material-dialogs (MIT), DBFlow (MIT), RxJava (Apache 2.0)"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorSecondary"
                        android:lineSpacingMultiplier="1.3" />

                </LinearLayout>
            </androidx.cardview.widget.CardView>

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

</LinearLayout>