<?php

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

class AIEO_DMM_Missing_Hot_Sellers extends AIEO_DMM_Module_Base {

    public function get_id()        { return 'missing_hot_sellers'; }
    public function get_label()     { return __('Missing Hot Sellers', 'ai-eshop-optimizer'); }
    public function get_group()     { return 'catalog_sync'; }
    public function get_priority()  { return 71; } 
    public function is_pro_locked() { return true; }

    public function get_pro_promo() {
        return array(
            'title'       => __('Missing Hot Sellers — publish what already sells', 'ai-eshop-optimizer'),
            'description' => __('See the SKUs your physical stores sell the most that aren’t live in the eshop yet, so you publish the highest-impact products first.', 'ai-eshop-optimizer'),
            'bullets'     => array(
                __('Ranked by real physical-store turnover', 'ai-eshop-optimizer'),
                __('Direct edit link + flags for what each draft is missing', 'ai-eshop-optimizer'),
                __('Computed over the most recent valid ERP data period', 'ai-eshop-optimizer'),
            ),
        );
    }

    public function render_subtab() {
        if (!class_exists('AIEO_DMM_Physical_Recovery')) {
            echo '<div class="notice notice-error"><p>' . esc_html__('Stock Recovery engine unavailable.', 'ai-eshop-optimizer') . '</p></div>';
            return;
        }
        $this->render_template('missing-hot-sellers.php', array(
            'nonce'         => wp_create_nonce(AIEO_DMM::NONCE_ACTION),
            'data_asof'     => AIEO_DMM_Physical_Recovery::get_data_asof(),
            'gaps'          => AIEO_DMM_Physical_Recovery::get_catalog_gaps(500),
            'totals'        => AIEO_DMM_Physical_Recovery::get_catalog_gap_totals(),
            'gap_min_units' => AIEO_DMM_Physical_Recovery::gap_min_units(),
            'gap_recency'   => AIEO_DMM_Physical_Recovery::gap_recency(),
            'channel_pct'   => AIEO_DMM_Physical_Recovery::channel_pct(),
            'gap_statuses'  => AIEO_DMM_Physical_Recovery::gap_statuses(),
            'gap_excludes'  => AIEO_DMM_Physical_Recovery::gap_name_excludes(),
            'gap_excluded'  => AIEO_DMM_Physical_Recovery::get_gap_excluded(),
            'all_branches'  => AIEO_DMM_Physical_Recovery::BRANCHES,
            'pub_kpis'      => AIEO_DMM_Physical_Recovery::get_gap_published_kpis(),
            'pub_events'    => AIEO_DMM_Physical_Recovery::get_gap_published_events(200),
        ));
    }
}
