<?php
if ( ! defined( 'ABSPATH' ) ) exit;

class Dori_Chatbot_Admin_Settings {

    public static function init() {
        if (!is_admin()) {
            return;
        }

        add_action('admin_menu', array(__CLASS__, 'create_menu'));
        add_action('admin_enqueue_scripts', array(__CLASS__, 'hide_admin_footer'));
        add_action('admin_head', array(__CLASS__, 'admin_styles'));

        Dori_Chatbot_Settings_Service::init();
    }

    public static function admin_styles() {
        echo '<style>
            #adminmenu .toplevel_page_dori-chatbot-settings .wp-menu-image img {
                width: 20px;
                height: auto;
                padding-top: 7px;
                box-sizing: border-box;
            }
        </style>';
    }

    public static function create_menu() {
        add_menu_page(
            'Mori Setup',
            'Mori Chatbot',
            'manage_options',
            'dori-chatbot-settings',
            array(__CLASS__, 'render_settings_page'),
            plugins_url('assets/icon-menu.png', DORI_CHATBOT_PLUGIN_FILE),
            58
        );
    }

    public static function hide_admin_footer($hook) {
        if ($hook === 'toplevel_page_dori-chatbot-settings') {
            add_filter('admin_footer_text', '__return_empty_string', 11);
            add_filter('update_footer', '__return_empty_string', 11);
        }
    }

    public static function render_settings_page() {
        include dirname(__FILE__) . '/views/settings-page.php';
    }
}
