using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using TMPro;

namespace IStalk.UI
{
    public class LoadingScreen : MonoBehaviour
    {
        [SerializeField] private GameObject _panel;
        [SerializeField] private Slider _progressBar;
        [SerializeField] private TextMeshProUGUI _statusText;
        [SerializeField] private TextMeshProUGUI _tipsText;

        private static readonly string[] Tips =
        {
            "Heavier loot is worth more, but slows you down.",
            "The Eye gains Dread faster when runners make noise.",
            "Wall running makes less noise than sprinting on the ground.",
            "Deposit loot at altars to unlock extraction.",
            "Sealed rooms during overtime can trap you forever.",
            "Shrine items can turn the tide — spend wisely.",
            "Revive downed teammates by holding R near them.",
            "The Eye can possess props to scout ahead.",
            "Sliding under obstacles keeps momentum and is quieter.",
            "Air dashing uses stamina — manage it carefully."
        };

        private void Awake()
        {
            if (_panel != null) _panel.SetActive(false);
        }

        public void Show(string status = "Loading...")
        {
            if (_panel != null) _panel.SetActive(true);
            if (_statusText != null) _statusText.text = status;
            if (_progressBar != null) _progressBar.value = 0;
            if (_tipsText != null)
                _tipsText.text = Tips[Random.Range(0, Tips.Length)];
        }

        public void SetProgress(float progress)
        {
            if (_progressBar != null) _progressBar.value = progress;
        }

        public void SetStatus(string status)
        {
            if (_statusText != null) _statusText.text = status;
        }

        public void Hide()
        {
            if (_panel != null) _panel.SetActive(false);
        }
    }
}
