<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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/background"
    android:padding="32dp">

    <!-- Logo / Title -->
    <TextView
        android:id="@+id/login_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ARCHON"
        android:textColor="@color/primary"
        android:textSize="36sp"
        android:textStyle="bold"
        android:fontFamily="monospace"
        app:layout_constraintBottom_toTopOf="@id/login_subtitle"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_chainStyle="packed"
        app:layout_constraintVertical_bias="0.3" />

    <TextView
        android:id="@+id/login_subtitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="AUTARCH Companion"
        android:textColor="@color/text_secondary"
        android:textSize="14sp"
        android:layout_marginTop="4dp"
        android:layout_marginBottom="40dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/login_title" />

    <!-- Server IP -->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/layout_server_ip"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp"
        android:hint="Server IP"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/login_subtitle">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/input_login_server_ip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="text"
            android:textColor="@color/text_primary"
            android:hint="10.0.0.26" />
    </com.google.android.material.textfield.TextInputLayout>

    <!-- Username -->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/layout_username"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:hint="Username"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/layout_server_ip">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/input_login_username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="text"
            android:textColor="@color/text_primary" />
    </com.google.android.material.textfield.TextInputLayout>

    <!-- Password -->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/layout_password"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:hint="Password"
        app:endIconMode="password_toggle"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/layout_username">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/input_login_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPassword"
            android:textColor="@color/text_primary" />
    </com.google.android.material.textfield.TextInputLayout>

    <!-- Port (smaller, below password) -->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/layout_port"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="120dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:hint="Port"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/layout_password">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/input_login_port"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="number"
            android:text="8181"
            android:textColor="@color/text_primary" />
    </com.google.android.material.textfield.TextInputLayout>

    <!-- Auto-detect button -->
    <com.google.android.material.button.MaterialButton
        android:id="@+id/btn_login_detect"
        style="@style/Widget.MaterialComponents.Button.TextButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="AUTO-DETECT"
        android:textColor="@color/primary"
        app:layout_constraintBottom_toBottomOf="@id/layout_port"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@id/layout_port" />

    <!-- Login button -->
    <com.google.android.material.button.MaterialButton
        android:id="@+id/btn_login"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        android:text="LOGIN"
        android:textSize="16sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/layout_port" />

    <!-- Status message -->
    <TextView
        android:id="@+id/login_status"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:gravity="center"
        android:textColor="@color/text_secondary"
        android:textSize="13sp"
        android:fontFamily="monospace"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/btn_login" />

    <!-- Skip/offline button at bottom -->
    <com.google.android.material.button.MaterialButton
        android:id="@+id/btn_login_skip"
        style="@style/Widget.MaterialComponents.Button.TextButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="SKIP (OFFLINE MODE)"
        android:textColor="@color/text_muted"
        android:textSize="12sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
