<?php

if (!defined('ABSPATH')) { exit; }

class AIEO_DMM_Waitlist_Display extends AIEO_DMM_Module_Base {

    public function get_id()       { return 'waitlist_display'; }
    public function get_label()    { return __('Waitlist Display', 'ai-eshop-optimizer'); }
    public function get_priority() { return 20; }
    public function get_group()    { return 'visuals'; }

    public function register_hooks() {
        
    }

    public function enqueue_admin_assets() {
        wp_enqueue_style('wp-color-picker');
        wp_enqueue_script('wp-color-picker');
        wp_add_inline_script('wp-color-picker',
            'jQuery(function($){$(".aieo-dmm-waitlist-color").wpColorPicker();});'
        );
    }

    public function render_subtab() {
        $parent = $this->resolve_parent();
        if ($parent && method_exists($parent, 'get_settings')) {
            $this->render_template('waitlist-display.php', array(
                'settings' => $parent->get_settings(),
            ));
        } else {
            echo '<div class="aieo-dmm-section"><p style="color:#b91c1c;">'
               . esc_html__('Waitlist module is not loaded — check that AIEO_DMM_Waitlist is active.', 'ai-eshop-optimizer')
               . '</p></div>';
        }
    }

    private function resolve_parent() {
        if (!class_exists('AIEO_DMM')) { return null; }
        $dmm = AIEO_DMM::instance();
        if (!$dmm || !method_exists($dmm, 'get_module')) { return null; }
        return $dmm->get_module('waitlist');
    }
}
