<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    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/bg_dark"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingStart="16dp"
        android:paddingEnd="16dp"
        android:paddingTop="20dp"
        android:paddingBottom="24dp">

        <!-- Status Bar -->
        <com.google.android.material.card.MaterialCardView
            android:id="@+id/hceStatusCard"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            app:cardBackgroundColor="@color/card_dark"
            app:cardCornerRadius="12dp"
            app:strokeColor="@color/divider"
            app:strokeWidth="1dp">

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

                <View
                    android:id="@+id/hceStatusDot"
                    android:layout_width="10dp"
                    android:layout_height="10dp"
                    android:background="@drawable/dot_inactive" />

                <TextView
                    android:id="@+id/tvHceStatus"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_marginStart="10dp"
                    android:text="@string/hce_status_inactive"
                    android:textColor="@color/text_primary"
                    android:textSize="14sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="HCE"
                    android:textColor="@color/text_secondary"
                    android:textSize="11sp"
                    android:letterSpacing="0.15" />

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

        <!-- Config Card -->
        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="12dp"
            app:cardBackgroundColor="@color/card_dark"
            app:cardCornerRadius="12dp"
            app:strokeColor="@color/divider"
            app:strokeWidth="1dp">

            <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="KONFIGURATION"
                    style="@style/JrzSectionLabel"
                    android:layout_marginBottom="12dp" />

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/tilAid"
                    style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="12dp"
                    android:hint="@string/hce_aid_hint"
                    app:helperText="Standard: D2760000850101 (NDEF)"
                    app:boxStrokeColor="@color/accent_cyan_alpha20"
                    app:hintTextColor="@color/text_secondary">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/etAid"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fontFamily="monospace"
                        android:textColor="@color/accent_cyan"
                        android:inputType="textCapCharacters|text"
                        android:text="D2760000850101" />

                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/tilPayload"
                    style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/hce_payload_hint"
                    app:boxStrokeColor="@color/accent_cyan_alpha20"
                    app:hintTextColor="@color/text_secondary">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/etPayload"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:minLines="2"
                        android:gravity="top"
                        android:textColor="@color/text_primary"
                        android:inputType="textMultiLine" />

                </com.google.android.material.textfield.TextInputLayout>

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

        <!-- Buttons -->
        <com.google.android.material.button.MaterialButton
            android:id="@+id/btnEnableHce"
            android:layout_width="match_parent"
            android:layout_height="52dp"
            android:layout_marginBottom="8dp"
            android:text="@string/hce_enable_btn"
            android:textColor="@color/bg_dark"
            android:textStyle="bold"
            android:letterSpacing="0.08"
            app:backgroundTint="@color/accent_cyan"
            app:cornerRadius="12dp" />

        <com.google.android.material.button.MaterialButton
            android:id="@+id/btnDisableHce"
            style="@style/Widget.Material3.Button.OutlinedButton"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_marginBottom="20dp"
            android:text="@string/hce_disable_btn"
            android:textColor="@color/text_secondary"
            android:enabled="false"
            app:strokeColor="@color/divider"
            app:cornerRadius="12dp" />

        <!-- Warning -->
        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            app:cardBackgroundColor="@color/warning_alpha20"
            app:cardCornerRadius="12dp"
            app:strokeColor="@color/warning_orange"
            app:strokeWidth="1dp">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="12dp"
                android:textColor="@color/warning_orange"
                android:textSize="12sp"
                android:lineSpacingExtra="2dp"
                android:text="@string/hce_warning" />

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

        <!-- APDU Log -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="center_vertical"
            android:layout_marginBottom="8dp">

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="APDU-LOG"
                style="@style/JrzSectionLabel"
                android:textColor="@color/accent_cyan" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/btnClearLog"
                style="@style/Widget.Material3.Button.TextButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Leeren"
                android:textColor="@color/text_secondary"
                android:textSize="11sp" />

        </LinearLayout>

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/cardApduLog"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardBackgroundColor="@color/log_background"
            app:cardCornerRadius="12dp"
            app:strokeColor="@color/accent_cyan_alpha10"
            app:strokeWidth="1dp">

            <TextView
                android:id="@+id/tvApduLog"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="14dp"
                android:fontFamily="monospace"
                android:textColor="@color/log_text"
                android:textSize="11sp"
                android:lineSpacingExtra="3dp"
                android:minLines="6"
                android:text="Kein APDU-Verkehr…" />

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

    </LinearLayout>
</ScrollView>
