<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bgColor"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <!-- Toolbar -->
    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="0dp"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/header"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <!-- Three Dots Menu Icon (leftmost) -->
    <ImageButton
        android:id="@+id/burgerMenuBtn"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:src="@drawable/ic_more_vert"
        android:background="?attr/selectableItemBackgroundBorderless"
        android:contentDescription="Menu"
        android:scaleType="centerInside"
        android:padding="12dp"
        app:layout_constraintTop_toTopOf="@id/toolbar"
        app:layout_constraintBottom_toBottomOf="@id/toolbar"
        app:layout_constraintStart_toStartOf="@id/toolbar"/>

    <!-- Dropdown Menu Container -->
    <LinearLayout
        android:id="@+id/dropdownMenu"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@android:color/white"
        android:elevation="4dp"
        android:visibility="gone"
        app:layout_constraintTop_toBottomOf="@id/toolbar"
        app:layout_constraintStart_toStartOf="parent">

        <!-- Logout Option -->
        <TextView
            android:id="@+id/menuLogout"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:text="Logout"
            android:textColor="@android:color/black"
            android:textSize="16sp"
            android:gravity="center_vertical"
            android:paddingStart="16dp"
            android:paddingEnd="16dp"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:focusable="true"/>

        <!-- New Post Option -->
        <TextView
            android:id="@+id/menuNewPost"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:text="New Post"
            android:textColor="@android:color/black"
            android:textSize="16sp"
            android:gravity="center_vertical"
            android:paddingStart="16dp"
            android:paddingEnd="16dp"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:focusable="true"/>

    </LinearLayout>

    <!-- Login Button -->
    <Button
        android:id="@+id/Loginbtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_background"
        android:text="Log in"
        android:textColor="@color/white"
        app:layout_constraintTop_toTopOf="@id/toolbar"
        app:layout_constraintBottom_toBottomOf="@id/toolbar"
        app:layout_constraintStart_toEndOf="@id/burgerMenuBtn"
        android:layout_marginStart="8dp"/>

    <!-- Register Button -->
    <Button
        android:id="@+id/Registerbtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_background"
        android:text="Register"
        android:textColor="@color/white"
        app:layout_constraintTop_toTopOf="@id/toolbar"
        app:layout_constraintBottom_toBottomOf="@id/toolbar"
        app:layout_constraintStart_toEndOf="@id/Loginbtn"
        android:layout_marginStart="8dp"/>

    <!-- Filter Button -->
    <ImageButton
        android:id="@+id/filterBtnToolbar"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:src="@drawable/ic_filter"
        android:background="?attr/selectableItemBackgroundBorderless"
        android:contentDescription="Filter"
        android:scaleType="centerInside"
        android:padding="12dp"
        app:layout_constraintTop_toTopOf="@id/toolbar"
        app:layout_constraintBottom_toBottomOf="@id/toolbar"
        app:layout_constraintEnd_toStartOf="@id/logoIcon"
        android:layout_marginEnd="8dp"/>

    <!-- App Logo Icon (rightmost) -->
    <ImageView
        android:id="@+id/logoIcon"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:src="@drawable/logo"
        android:contentDescription="Logo"
        app:layout_constraintTop_toTopOf="@id/toolbar"
        app:layout_constraintBottom_toBottomOf="@id/toolbar"
        app:layout_constraintEnd_toEndOf="@id/toolbar"
        android:layout_marginEnd="16dp"/>

    <!-- RecyclerView Feed -->
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/postsRecyclerView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:padding="16dp"
        app:layout_constraintTop_toBottomOf="@id/toolbar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:contentDescription="Enter How Much Cookies You Want"/>

    <!-- Logout Button (hidden - now in dropdown) -->
    <Button
        android:id="@+id/btnLogout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_background"
        android:text="Logout"
        android:visibility="gone"
        android:textColor="@color/white"
        app:layout_constraintTop_toTopOf="@id/toolbar"
        app:layout_constraintBottom_toBottomOf="@id/toolbar"
        app:layout_constraintStart_toEndOf="@id/burgerMenuBtn"
        android:layout_marginStart="8dp"/>

    <!-- New Post Button -->
    <Button
        android:id="@+id/newPostBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_background"
        android:text="New Post"
        android:layout_margin="16dp"
        android:visibility="gone"
        android:textColor="@color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>