#pragma once

#include "CoreMinimal.h"
#include "CommonUserWidget.h"
#include "UIPlayerStatus_StatRow.generated.h"

class UButton;
class UHorizontalBox;
class UTextBlock;

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FZMMOOnStatRowPlusClicked, int32, StatId);

/**
 *  Linha de um stat primário (STR/AGI/VIT/INT/DEX/LUK) na janela de Status.
 *  Layout: ícone + nome + valor base + (sinal + bônus) + botão "+".
 *
 *  Sem lógica de domínio — a janela (UUIPlayerStatus_Window) injeta o
 *  StatId e os valores via Setup/SetValues; o clique no "+" é re-emitido
 *  como OnPlusClicked(StatId).
 *
 *  Pareada com o WBP UI_PlayerStatus_StatRow.
 */
UCLASS(Abstract, Blueprintable)
class ZMMO_API UUIPlayerStatus_StatRow : public UCommonUserWidget
{
	GENERATED_BODY()

public:
	/** Setup único chamado pela window quando inicializa a linha. */
	UFUNCTION(BlueprintCallable, Category = "Zeus|Status")
	void SetupStat(int32 InStatId, FText IconLetter, FText DisplayName);

	/** Atualiza valores. Bonus=0 esconde a parte "+N". */
	UFUNCTION(BlueprintCallable, Category = "Zeus|Status")
	void SetValues(int32 Base, int32 Bonus);

	/** Mostra/esconde o botão "+". */
	UFUNCTION(BlueprintCallable, Category = "Zeus|Status")
	void SetPlusVisible(bool bVisible);

	/** Habilita/desabilita o botão "+" (independente da visibilidade). */
	UFUNCTION(BlueprintCallable, Category = "Zeus|Status")
	void SetPlusEnabled(bool bEnabled);

	/** Disparado quando o usuário clica em "+". */
	UPROPERTY(BlueprintAssignable, Category = "Zeus|Status")
	FZMMOOnStatRowPlusClicked OnPlusClicked;

protected:
	virtual void NativeOnInitialized() override;
	virtual void NativeDestruct() override;

	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UTextBlock> Border_StatIconWrap_Label;
	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UTextBlock> Text_StatName;
	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UTextBlock> Text_StatBase;
	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UTextBlock> Text_Sign;
	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UTextBlock> Text_StatBonus;
	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UButton>    Button_PlusBtn;

	/** HBox que envolve sinal+bonus; ocultado quando bonus = 0. Bind opcional —
	 *  se o WBP não expuser, cai pra ocultar Text_Sign/Text_StatBonus individualmente. */
	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UHorizontalBox> Layout_BonusGroup;

private:
	UFUNCTION() void HandlePlusClicked();

	int32 StatId = 0;
};
