package com.gbcm.client.beans;

import java.io.Serializable;

import jakarta.enterprise.context.SessionScoped;
import jakarta.inject.Named;

@Named("guestPreferences")
@SessionScoped
public class GuestPreferences implements Serializable {

    private String layout = "light";
    private String menuTheme = "light";
    private String topbarTheme = "light";
    private String menuMode = "layout-sidebar";
    private String darkMode = "light";
    private String inputStyleClass = "";
    private String inputStyle = "outlined";
    private String componentTheme = "blue";
    private boolean lightLogo = false;

    public String getLayout() {
        return layout;
    }

    public void setLayout(String layout) {
        this.layout = layout;
    }

    public String getMenuTheme() {
        return menuTheme;
    }

    public void setMenuTheme(String menuTheme) {
        this.menuTheme = menuTheme;
    }

    public String getTopbarTheme() {
        return topbarTheme;
    }

    public void setTopbarTheme(String topbarTheme) {
        this.topbarTheme = topbarTheme;
    }

    public String getMenuMode() {
        return menuMode;
    }

    public void setMenuMode(String menuMode) {
        this.menuMode = menuMode;
    }

    public String getDarkMode() {
        return darkMode;
    }

    public void setDarkMode(String darkMode) {
        this.darkMode = darkMode;
        this.layout = darkMode;
    }

    public void toggleDarkMode() {
        setDarkMode("dark".equals(darkMode) ? "light" : "dark");
    }

    public String getInputStyleClass() {
        return inputStyleClass;
    }

    public void setInputStyleClass(String inputStyleClass) {
        this.inputStyleClass = inputStyleClass;
    }

    public String getInputStyle() {
        return inputStyle;
    }

    public void setInputStyle(String inputStyle) {
        this.inputStyle = inputStyle;
        // Mettre à jour la classe CSS en fonction du style
        if ("filled".equals(inputStyle)) {
            this.inputStyleClass = "ui-input-filled";
        } else {
            this.inputStyleClass = "";
        }
    }

    public String getComponentTheme() {
        return componentTheme;
    }

    public void setComponentTheme(String componentTheme) {
        this.componentTheme = componentTheme;
    }

    // Propriétés manquantes pour le template Freya complet
    public boolean isLightLogo() {
        return "dark".equals(topbarTheme) || "dark".equals(darkMode);
    }

    public void setLightLogo(boolean lightLogo) {
        this.lightLogo = lightLogo;
    }

    public void onMenuTypeChange() {
        // Méthode appelée lors du changement de type de menu
    }

    // Liste des thèmes de composants disponibles
    public java.util.List<ComponentTheme> getComponentThemes() {
        java.util.List<ComponentTheme> themes = new java.util.ArrayList<>();
        themes.add(new ComponentTheme("blue", "#007ad9", "Blue"));
        themes.add(new ComponentTheme("green", "#10ac84", "Green"));
        themes.add(new ComponentTheme("orange", "#ff9f43", "Orange"));
        themes.add(new ComponentTheme("purple", "#5f27cd", "Purple"));
        themes.add(new ComponentTheme("red", "#ee5a52", "Red"));
        themes.add(new ComponentTheme("teal", "#00d2d3", "Teal"));
        themes.add(new ComponentTheme("yellow", "#feca57", "Yellow"));
        themes.add(new ComponentTheme("pink", "#ff6b9d", "Pink"));
        themes.add(new ComponentTheme("indigo", "#3742fa", "Indigo"));
        themes.add(new ComponentTheme("cyan", "#0abde3", "Cyan"));
        return themes;
    }

    // Classe interne pour les thèmes de composants
    public static class ComponentTheme {
        private String file;
        private String color;
        private String name;

        public ComponentTheme(String file, String color, String name) {
            this.file = file;
            this.color = color;
            this.name = name;
        }

        public String getFile() { return file; }
        public void setFile(String file) { this.file = file; }
        public String getColor() { return color; }
        public void setColor(String color) { this.color = color; }
        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
    }

    public String getLayoutClass() {
        StringBuilder sb = new StringBuilder();
        sb.append("layout-wrapper ");
        sb.append("layout-").append(layout).append(" ");
        sb.append(menuTheme).append(" ");
        sb.append(topbarTheme).append(" ");
        sb.append("layout-menu-").append(menuMode);
        return sb.toString();
    }
}
