<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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/establishmentRoot"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorBackground"
    tools:context=".EstablishmentDashboardActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorBackground"
        app:elevation="0dp">

        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:title=""
            app:navigationIcon="@android:drawable/ic_menu_revert"
            app:navigationIconTint="@color/colorTextPrimary"/>

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <!-- HEADER TEXT -->
            <TextView
                android:id="@+id/txtEstabTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Bistro Manager"
                android:textColor="@color/colorTextPrimary"
                android:textSize="32sp"
                android:fontFamily="sans-serif-medium" />

            <TextView
                android:id="@+id/txtEstabSubtitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="4dp"
                android:text="Dashboard operacional. Acompanhe as reservas."
                android:textColor="@color/colorTextSecondary"
                android:textSize="14sp" />

            <com.google.android.material.chip.Chip
                android:id="@+id/txtEstabRole"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="Função: ADMIN"
                android:textColor="@color/colorPrimary"
                app:chipBackgroundColor="#1A000000"
                app:chipStrokeWidth="0dp"
                android:clickable="false" />

            <!-- ALERTS BANNER -->
            <com.google.android.material.card.MaterialCardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                app:cardBackgroundColor="#FFF3E0"
                app:cardCornerRadius="12dp"
                app:strokeWidth="0dp"
                app:cardElevation="0dp">

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

                    <ImageView
                        android:layout_width="24dp"
                        android:layout_height="24dp"
                        android:src="@android:drawable/ic_dialog_alert"
                        app:tint="#E65100" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="12dp"
                        android:text="Nenhum alerta crítico de momento."
                        android:textColor="#E65100"
                        android:textSize="14sp"
                        android:fontFamily="sans-serif-medium" />
                </LinearLayout>
            </com.google.android.material.card.MaterialCardView>

            <!-- STATS CARDS GRID -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:baselineAligned="false"
                android:orientation="horizontal">

                <!-- Reservas -->
                <com.google.android.material.card.MaterialCardView
                    android:id="@+id/cardReservasHoje"
                    android:layout_width="0dp"
                    android:layout_height="120dp"
                    android:layout_weight="1"
                    android:layout_marginEnd="6dp"
                    app:cardBackgroundColor="@color/colorSurface"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="2dp"
                    android:clickable="true"
                    android:focusable="true">

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

                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_my_calendar"
                            app:tint="@color/colorPrimary" />

                        <TextView
                            android:id="@+id/txtReservasHojeDash"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="12dp"
                            android:text="0"
                            android:textColor="@color/colorTextPrimary"
                            android:textSize="28sp"
                            android:fontFamily="sans-serif-medium" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Reservas"
                            android:textColor="@color/colorTextSecondary"
                            android:textSize="12sp" />
                    </LinearLayout>
                </com.google.android.material.card.MaterialCardView>

                <!-- Mesas -->
                <com.google.android.material.card.MaterialCardView
                    android:layout_width="0dp"
                    android:layout_height="120dp"
                    android:layout_weight="1"
                    android:layout_marginStart="6dp"
                    android:layout_marginEnd="6dp"
                    app:cardBackgroundColor="@color/colorSurface"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="2dp">

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

                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_sort_by_size"
                            app:tint="#4CAF50" />

                        <TextView
                            android:id="@+id/txtMesasLivresDash"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="12dp"
                            android:text="0"
                            android:textColor="@color/colorTextPrimary"
                            android:textSize="28sp"
                            android:fontFamily="sans-serif-medium" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Mesas Livres"
                            android:textColor="@color/colorTextSecondary"
                            android:textSize="12sp" />
                    </LinearLayout>
                </com.google.android.material.card.MaterialCardView>

                <!-- Espera -->
                <com.google.android.material.card.MaterialCardView
                    android:layout_width="0dp"
                    android:layout_height="120dp"
                    android:layout_weight="1"
                    android:layout_marginStart="6dp"
                    app:cardBackgroundColor="@color/colorSurface"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="2dp">

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

                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_recent_history"
                            app:tint="#F44336" />

                        <TextView
                            android:id="@+id/txtListaEsperaDash"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="12dp"
                            android:text="0"
                            android:textColor="@color/colorTextPrimary"
                            android:textSize="28sp"
                            android:fontFamily="sans-serif-medium" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Espera"
                            android:textColor="@color/colorTextSecondary"
                            android:textSize="12sp" />
                    </LinearLayout>
                </com.google.android.material.card.MaterialCardView>

            </LinearLayout>

            <!-- PROXIMAS RESERVAS -->
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="32dp"
                android:text="Próximas Reservas"
                android:textColor="@color/colorTextPrimary"
                android:textSize="20sp"
                android:fontFamily="sans-serif-medium" />

            <com.google.android.material.card.MaterialCardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                app:cardBackgroundColor="@color/colorSurface"
                app:cardCornerRadius="20dp"
                app:cardElevation="1dp"
                app:strokeWidth="1dp"
                app:strokeColor="#1A000000">

                <LinearLayout
                    android:id="@+id/llProximasReservas"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:padding="20dp">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="A procurar próximas reservas..."
                        android:textColor="@color/colorTextSecondary"
                        android:textSize="14sp" />
                </LinearLayout>
            </com.google.android.material.card.MaterialCardView>

            <!-- ACCOES RAPIDAS -->
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="32dp"
                android:text="Ações Rápidas"
                android:textColor="@color/colorTextPrimary"
                android:textSize="20sp"
                android:fontFamily="sans-serif-medium" />

            <!-- GRID OF ACTIONS -->
            <GridLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:layout_marginBottom="40dp"
                android:columnCount="2"
                android:useDefaultMargins="true">

                <!-- ACTION 1 -->
                <com.google.android.material.card.MaterialCardView
                    android:id="@+id/btnDetalhesReservas"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_columnWeight="1"
                    android:clickable="true"
                    android:focusable="true"
                    android:layout_margin="6dp"
                    app:cardBackgroundColor="@color/colorSurface"
                    app:cardCornerRadius="16dp"
                    app:cardElevation="2dp">
                    
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:padding="16dp"
                        android:gravity="center_vertical">
                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_agenda"
                            app:tint="@color/colorTextPrimary" />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="12dp"
                            android:text="Todas as\nReservas"
                            android:textColor="@color/colorTextPrimary"
                            android:textSize="14sp"
                            android:fontFamily="sans-serif-medium" />
                    </LinearLayout>
                </com.google.android.material.card.MaterialCardView>

                <!-- ACTION 2 -->
                <com.google.android.material.card.MaterialCardView
                    android:id="@+id/btnAbrirEspera"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_columnWeight="1"
                    android:clickable="true"
                    android:focusable="true"
                    android:layout_margin="6dp"
                    app:cardBackgroundColor="@color/colorSurface"
                    app:cardCornerRadius="16dp"
                    app:cardElevation="2dp">
                    
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:padding="16dp"
                        android:gravity="center_vertical">
                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_add"
                            app:tint="@color/colorTextPrimary" />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="12dp"
                            android:text="Adicionar à\nEspera"
                            android:textColor="@color/colorTextPrimary"
                            android:textSize="14sp"
                            android:fontFamily="sans-serif-medium" />
                    </LinearLayout>
                </com.google.android.material.card.MaterialCardView>

                <!-- ACTION 3 -->
                <com.google.android.material.card.MaterialCardView
                    android:id="@+id/btnGerirMesas"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_columnWeight="1"
                    android:clickable="true"
                    android:focusable="true"
                    android:layout_margin="6dp"
                    app:cardBackgroundColor="@color/colorSurface"
                    app:cardCornerRadius="16dp"
                    app:cardElevation="2dp">
                    
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:padding="16dp"
                        android:gravity="center_vertical">
                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_crop"
                            app:tint="@color/colorTextPrimary" />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="12dp"
                            android:text="Gerir\nMesas"
                            android:textColor="@color/colorTextPrimary"
                            android:textSize="14sp"
                            android:fontFamily="sans-serif-medium" />
                    </LinearLayout>
                </com.google.android.material.card.MaterialCardView>

                <!-- ACTION 4 -->
                <com.google.android.material.card.MaterialCardView
                    android:id="@+id/btnGestaoStaff"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_columnWeight="1"
                    android:clickable="true"
                    android:focusable="true"
                    android:layout_margin="6dp"
                    app:cardBackgroundColor="@color/colorSurface"
                    app:cardCornerRadius="16dp"
                    app:cardElevation="2dp">
                    
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:padding="16dp"
                        android:gravity="center_vertical">
                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_info_details"
                            app:tint="@color/colorTextPrimary" />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="12dp"
                            android:text="Gestão\nde Staff"
                            android:textColor="@color/colorTextPrimary"
                            android:textSize="14sp"
                            android:fontFamily="sans-serif-medium" />
                    </LinearLayout>
                </com.google.android.material.card.MaterialCardView>

                <!-- ACTION 5 -->
                <com.google.android.material.card.MaterialCardView
                    android:id="@+id/btnDefinicoes"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_columnWeight="1"
                    android:clickable="true"
                    android:focusable="true"
                    android:layout_margin="6dp"
                    app:cardBackgroundColor="@color/colorSurface"
                    app:cardCornerRadius="16dp"
                    app:cardElevation="2dp">
                    
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:padding="16dp"
                        android:gravity="center_vertical">
                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_preferences"
                            app:tint="@color/colorTextPrimary" />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="12dp"
                            android:text="Definições\nda Conta"
                            android:textColor="@color/colorTextPrimary"
                            android:textSize="14sp"
                            android:fontFamily="sans-serif-medium" />
                    </LinearLayout>
                </com.google.android.material.card.MaterialCardView>

            </GridLayout>

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