package be.kdg.labyrinth.JavaFX.view;

import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;

public class HighscoresView extends StackPane {
    private Button backButton;
    private Label highscoresLabel;
    private Label titleLabel;
    private VBox vbox;

    public HighscoresView() {
        initializeNodes();
        layoutNodes();
        this.setPrefSize(1000, 800);
    }

    private void initializeNodes() {
        backButton = new Button("Back");
        highscoresLabel = new Label();
        titleLabel = new Label("Highscores");

        // Styling
        backButton.setStyle(
                "-fx-font-size: 25px; " +
                        "-fx-font-family: 'Berlin Sans FB'; " +
                        "-fx-padding: 15px; " +
                        "-fx-min-width: 150px; " +
                        "-fx-min-height: 70px; " +
                        "-fx-border-color: white; " +
                        "-fx-border-radius: 10px; " +
                        "-fx-border-width: 3px; " +
                        "-fx-text-fill: white; " +
                        "-fx-background-color: transparent; " +
                        "-fx-background-insets: 0; " +
                        "-fx-background-radius: 10px;");

        // Stel de tekstkleur van de highscoresLabel in op wit
        highscoresLabel.setStyle("-fx-font-size: 30px; -fx-font-family: 'Berlin Sans FB'; -fx-text-fill: white;");
        titleLabel.setStyle("-fx-font-size: 50px; -fx-font-family: 'Berlin Sans FB'; -fx-text-fill: white;");
    }

    private void layoutNodes() {
        // Achtergrondafbeelding instellen
        Image backgroundImage = new Image("file:src/be/kdg/labyrinth/LabyrinthAchtergrond.jpg");
        ImageView backgroundView = new ImageView(backgroundImage);
        backgroundView.setFitWidth(1920);
        backgroundView.setFitHeight(1080);

        // Semi-transparante overlay
        Region overlay = new Region();
        overlay.setPrefSize(800, 600);
        overlay.setStyle("-fx-background-color: rgba(0, 0, 0, 0.5);"); // 50% transparantie

        vbox = new VBox(20);
        vbox.setAlignment(Pos.CENTER);
        vbox.getChildren().addAll(titleLabel, highscoresLabel, backButton);

        this.getChildren().addAll(backgroundView, overlay, vbox);
        this.setAlignment(Pos.CENTER);
    }

    public Button getBackButton() {
        return backButton;
    }

    public void updateHighscores(String highscores) {
        highscoresLabel.setText(highscores);
    }
}