<?php

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

echo '<!-- PAGE GENERATED AT: ' . esc_html(gmdate('Y-m-d H:i:s')) . ' -->';
echo '<!-- RANDOM: ' . absint(wp_rand(10000, 99999)) . ' -->';

$checkbox_options = [
    'aieo_create_attributes',
    'aieo_create_needs',
    'aieo_create_catalogue',
    'aieo_create_orders',
    'aieo_erp_consolidation',
    'aieo_erp_merge_orders',
    'aieo_include_unsold',
    'aieo_include_aggregate_stats',
    'aieo_include_aggregate_cust_std_stats',
    'aieo_include_aggregate_cust_adv_stats',
    'aieo_create_uuids',
    'aieo_create_export',
    'aieo_include_text',
    'aieo_include_attributes',
    'aieo_include_full_text',
    'aieo_include_price',
    'aieo_variations_choice',
    'aieo_include_eponymous',
    'aieo_include_reciprocity',
    'aieo_include_seasonality',
    'aieo_include_restricted_seasonality',
    'aieo_instore_anonymous',
    'aieo_season_days_past',
    'aieo_season_days_after'
];
foreach ($checkbox_options as $opt) {
    wp_cache_delete($opt, 'options');
}

function aieo_getRandomNumberBetween1And3()
{
    $randomNumber = wp_rand(1, 3);
    return $randomNumber;
}
$randomNumber = aieo_getRandomNumberBetween1And3();

function aieo_get_temp_orders_table_for_insights()
{
    global $wpdb;
    $table = get_option('aieo_site_orders_table', $wpdb->prefix . 'aieo_temp_orders');
    if (!$table) {
        return '';
    }
    $table = sanitize_text_field($table);
    if (!preg_match('/^[a-zA-Z0-9_]+$/', $table)) {
        return '';
    }
    $table_exists = $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $table));
    if (!$table_exists) {
        return '';
    }
    return $table;
}

function aieo_fetch_single_product_focus($table, $limit = 10)
{
    global $wpdb;
    $cache_key = 'aieo_insight_single_' . md5($table . $limit);
    $cached = get_transient($cache_key);
    if ($cached !== false) {
        if (!empty($cached)) {
            return $cached;
        }
        delete_transient($cache_key);
    }

    
    $sql = $wpdb->prepare(
        "SELECT t.ParentProductId AS product_id,
                   SUM(COALESCE(t.PrimaryQty, 1)) AS total_units,
                   COUNT(*) AS order_lines
            FROM {$table} t
            INNER JOIN (
                SELECT OrderId
                FROM {$table}
                GROUP BY OrderId
                HAVING COUNT(*) = 1
            ) single ON t.OrderId = single.OrderId
            WHERE t.ParentProductId IS NOT NULL
            GROUP BY t.ParentProductId
            ORDER BY total_units DESC
            LIMIT %d",
        $limit
    );
    
    $rows = $wpdb->get_results($sql);
    $results = [];
    if ($rows) {
        foreach ($rows as $row) {
            $product_id = (int) $row->product_id;
            if (!$product_id) {
                continue;
            }
            $title = get_the_title($product_id);
            if (!$title) {
                continue;
            }
            $permalink = get_permalink($product_id);
            $results[] = array(
                'product_id' => $product_id,
                'title' => $title,
                'permalink' => $permalink,
                'units' => (float) $row->total_units,
                'orders' => (int) $row->order_lines,
            );
        }
    }

    if (!empty($results)) {
        usort($results, function ($a, $b) {
            $brand_a = $a['brand'] ?? '';
            $brand_b = $b['brand'] ?? '';
            return strcasecmp($brand_a, $brand_b);
        });
        set_transient($cache_key, $results, HOUR_IN_SECONDS);
    } else {
        delete_transient($cache_key);
    }
    return $results;
}

function aieo_fetch_favourite_products($table, $limit = 10)
{
    global $wpdb;
    $cache_key = 'aieo_insight_favourites_' . md5($table . $limit);
    $cached = get_transient($cache_key);
    if ($cached !== false) {
        if (!empty($cached)) {
            return $cached;
        }
        delete_transient($cache_key);
    }

    
    $sql = $wpdb->prepare(
        "SELECT fav.*
            FROM (
                SELECT ParentProductId AS product_id,
                       MAX(COALESCE(FirstItemSales, 0)) AS first_units,
                       MAX(COALESCE(LastItemSales, 0))  AS last_units
                FROM {$table}
                WHERE ParentProductId IS NOT NULL
                GROUP BY ParentProductId
            ) fav
            WHERE (fav.first_units + fav.last_units) > 0
            ORDER BY (fav.first_units + fav.last_units) DESC
            LIMIT %d",
        $limit
    );
    
    $rows = $wpdb->get_results($sql);
    $results = [];
    if ($rows) {
        foreach ($rows as $row) {
            $product_id = (int) $row->product_id;
            if (!$product_id) {
                continue;
            }
            $title = get_the_title($product_id);
            if (!$title) {
                continue;
            }
            $permalink = get_permalink($product_id);
            $first_units = (float) $row->first_units;
            $last_units = (float) $row->last_units;
            if (($first_units + $last_units) <= 0) {
                continue;
            }
            $results[] = array(
                'product_id' => $product_id,
                'title' => $title,
                'permalink' => $permalink,
                'first_units' => $first_units,
                'last_units' => $last_units,
                'score' => $first_units + $last_units,
            );
        }
    }

    if (empty($results)) {
        
        $fallback_sql = $wpdb->prepare(
            "SELECT fav.*
                         FROM (
                             SELECT ParentProductId AS product_id,
                                    SUM(CASE WHEN OrderSize > 1 AND ItemSequence = 1 THEN COALESCE(PrimaryQty,1) ELSE 0 END) AS first_units,
                                    SUM(CASE WHEN OrderSize > 1 AND ItemSequence = OrderSize THEN COALESCE(PrimaryQty,1) ELSE 0 END) AS last_units
                             FROM {$table}
                             WHERE ParentProductId IS NOT NULL
                             GROUP BY ParentProductId
                         ) fav
                         WHERE (fav.first_units + fav.last_units) > 0
                         ORDER BY (fav.first_units + fav.last_units) DESC
                         LIMIT %d",
            $limit
        );
        
        $rows = $wpdb->get_results($fallback_sql);
        if ($rows) {
            foreach ($rows as $row) {
                $product_id = (int) $row->product_id;
                if (!$product_id) {
                    continue;
                }
                $title = get_the_title($product_id);
                if (!$title) {
                    continue;
                }
                $permalink = get_permalink($product_id);
                $first_units = (float) $row->first_units;
                $last_units = (float) $row->last_units;
                if (($first_units + $last_units) <= 0) {
                    continue;
                }
                $results[] = array(
                    'product_id' => $product_id,
                    'title' => $title,
                    'permalink' => $permalink,
                    'first_units' => $first_units,
                    'last_units' => $last_units,
                    'score' => $first_units + $last_units,
                );
            }
        }
    }

    if (!empty($results)) {
        set_transient($cache_key, $results, HOUR_IN_SECONDS);
    } else {
        delete_transient($cache_key);
    }
    return $results;
}

function aieo_fetch_brand_focus($table, $limit = 10)
{
    global $wpdb;
    $cache_key = 'aieo_insight_brands_' . md5($table . $limit);
    $cached = get_transient($cache_key);
    if ($cached !== false) {
        if (!empty($cached)) {
            return $cached;
        }
        delete_transient($cache_key);
    }

    
    $sql = $wpdb->prepare(
        "SELECT brand_name,
                   single_units,
                   first_units,
                   last_units,
                   score
            FROM (
                SELECT brand_name,
                       SUM(single_unit) AS single_units,
                       SUM(first_unit) AS first_units,
                       SUM(last_unit) AS last_units,
                       SUM(single_unit + first_unit + last_unit) AS score
                FROM (
                    SELECT COALESCE(NULLIF(TRIM(Brand), ''), 'Unbranded') AS brand_name,
                           MAX(COALESCE(UniqueItemSales, 0)) AS single_unit,
                           MAX(COALESCE(FirstItemSales, 0)) AS first_unit,
                           MAX(COALESCE(LastItemSales, 0)) AS last_unit
                    FROM {$table}
                    WHERE ParentProductId IS NOT NULL
                    GROUP BY ParentProductId, COALESCE(NULLIF(TRIM(Brand), ''), 'Unbranded')
                ) product_brand
                GROUP BY brand_name
                HAVING SUM(single_unit + first_unit + last_unit) > 0
                ORDER BY score DESC
                LIMIT %d
            ) top_brands
            ORDER BY brand_name ASC",
        $limit
    );
    
    $rows = $wpdb->get_results($sql);
    $results = [];
    if ($rows) {
        foreach ($rows as $row) {
            $brand = $row->brand_name;
            $single_units = (float) $row->single_units;
            $first_units = (float) $row->first_units;
            $last_units = (float) $row->last_units;
            $results[] = array(
                'brand' => $brand,
                'single_units' => $single_units,
                'first_units' => $first_units,
                'last_units' => $last_units,
                'score' => $single_units + $first_units + $last_units,
            );
        }
    }

    if (!empty($results)) {
        set_transient($cache_key, $results, HOUR_IN_SECONDS);
    } else {
        delete_transient($cache_key);
    }
    return $results;
}

$aieo_insight_data = array(
    'available' => false,
    'single_products' => array(),
    'favourite_products' => array(),
    'brands' => array(),
);

$aieo_orders_table = aieo_get_temp_orders_table_for_insights();
if ($aieo_orders_table) {
    global $wpdb;
    $has_product_stats = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$aieo_orders_table} WHERE TotalItemSales IS NOT NULL AND TotalItemSales > 0 LIMIT 1");
    $has_adv_stats = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$aieo_orders_table} WHERE AvgOrderSize IS NOT NULL AND AvgOrderSize > 0 LIMIT 1");

    if ($has_product_stats && $has_adv_stats) {
        $aieo_insight_data['single_products'] = aieo_fetch_single_product_focus($aieo_orders_table);
        $aieo_insight_data['favourite_products'] = aieo_fetch_favourite_products($aieo_orders_table);
        $aieo_insight_data['brands'] = aieo_fetch_brand_focus($aieo_orders_table);
        if (!empty($aieo_insight_data['single_products']) || !empty($aieo_insight_data['favourite_products']) || !empty($aieo_insight_data['brands'])) {
            $aieo_insight_data['available'] = true;
        }
    }
}

?>
<div id="aieo-wpbody-content">
    <div class="aieo-top-bar">
        <a href="https://rooster.systems/get-aieo/?utm_source=woo&utm_medium=plugin&utm_campaign=header"
            class="aieo-top-bar-logo" target="_blank">
            <img src="<?php echo esc_url(AIEO_URI); ?>assets/images/OMLogo-300.webp" />
        </a>

        <?php
        
        require_once AIEO_DIR . 'assets/pages/navigation-tabs.php';
        ?>

        <div class="aieo-top-bar-infos">
            <div class="aieo-top-bar-info-item">
                <div class="aieo-version">
                    <a href="https://eshop-optimizer.com/changelog/?utm_source=woo&utm_medium=plugin&utm_campaign=header"
                        class="aieo-website" target="_blank"><strong>v<?php echo esc_html(AIEO_VERSION); ?></strong></a>
                </div>
            </div>
            <div class="aieo-top-bar-info-item">
                <strong><a href="https://rooster.systems/get-aieo/?utm_source=woo&utm_medium=plugin&utm_campaign=header"
                        class="aieo-website" target="_blank">
                        Rooster AI Eshop Optimizer<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
                            xmlns="http://www.w3.org/2000/svg">
                            <path fill-rule="evenodd" clip-rule="evenodd"
                                d="M13.6 2.40002H7.20002L8.00002 4.00002H11.264L6.39202 8.88002L7.52002 10.008L12 5.53602V8.00002L13.6 8.80002V2.40002ZM9.60002 9.60002V12H4.00002V6.40002H7.20002L8.80002 4.80002H2.40002V13.6H11.2V8.00002L9.60002 9.60002Z"
                                fill="#3858E9"></path>
                        </svg>
                    </a></strong>
            </div>
        </div>
    </div>

    <div class="wrap aieo-merchant-wrap">
        <div class="aieo-modules-header<?php echo absint($randomNumber); ?>">
            <div class="aieo-modules-header-left">
                <div class="aieo-modules-header-heading">
                    <?php esc_html_e('Welcome to AI eShop Optimizer 👋🏻', 'ai-eshop-optimizer'); ?>
                    </br><?php esc_html_e('Build on your strengths and value your loyal clients.', 'ai-eshop-optimizer'); ?>
                </div>
                <div class="aieo-modules-header-subheading">
                    <?php
                    $current_user = wp_get_current_user();
                    
                    printf(esc_html__('We\'re glad to see you %s :)', 'ai-eshop-optimizer'), '<strong>' . esc_html($current_user->display_name) . '</strong>'); ?>
                    <div class="aieo-card-dark">
                        <?php echo wp_kses_post(__('AI eShop Optimizer is the first AI-powered service for <strong>generalized product catalog optimization</strong> and is available for Woocommerce-powered shops.', 'ai-eshop-optimizer')); ?>
                        </br></br><?php echo wp_kses_post(__('Our innovative work on <strong>AI-powered semantic-triple analysis</strong> now provides optimal recommendations in retail e-commerce.', 'ai-eshop-optimizer')); ?>
                        </br></br><?php echo wp_kses_post(__('AI eShop Optimizer analyses all your orders and generates <strong>optimal cross-sells and up-sells</strong> for all your products!', 'ai-eshop-optimizer')); ?>
                        </br></br><?php echo wp_kses_post(__('With a few clicks you will get relevant recommendations in seconds <strong>saving you thousands of hours</strong>!', 'ai-eshop-optimizer')); ?>
                        </br></br><?php echo wp_kses_post(__('Our existing-beta customers have observed an <strong>increase in sales of over 57% within a year</strong>!', 'ai-eshop-optimizer')); ?>
                        </br></br><?php echo wp_kses_post(__('Play on your strengths and <strong>trust those who trust you: your existing clients!</strong>', 'ai-eshop-optimizer')); ?>
                        </br></br><?php
                        
                        printf(wp_kses_post(__('Get your <strong><a href="%s" target="_blank">GraphDB-powered</a> free analysis</strong> of up to 50000 order items!', 'ai-eshop-optimizer')), 'https://eshop-optimizer.com/ai-powered-product-recommendations'); ?>
                        </br></br><?php
                        
                        printf(wp_kses_post(__('Follow the steps below and <strong><a href="%s" target="_blank">create a free account today!</a></strong>', 'ai-eshop-optimizer')), 'https://eshop-optimizer.com/my-account/?utm_source=woo&utm_medium=plugin&utm_campaign=subheading'); ?>
                    </div>
                </div>
            </div>
            <div class="aieo-modules-header-right">
                <ul class="aieo-modules-header-shortlinks">
                    <li>
                        <a href="#" data-aieo-nav-trigger="1" role="button">
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                                <circle cx="11" cy="11" r="6" stroke="#787C82" stroke-width="2" fill="none"/>
                                <path d="M16 16l4 4" stroke="#787C82" stroke-width="2" stroke-linecap="round"/>
                            </svg>
                            <span><?php echo wp_kses_post(__('<strong>Quick navigator</strong> &nbsp;<kbd style="font-size:10px;background:#e5e7eb;padding:1px 5px;border-radius:3px;">⌘K</kbd>', 'ai-eshop-optimizer')); ?></span>
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                                <path d="M10.8626 8.04102L14.2809 12.0291L10.8626 16.0172L9.72363 15.041L12.3053 12.0291L9.72363 9.01721L10.8626 8.04102Z" fill="#757575"/>
                            </svg>
                        </a>
                    </li>
                    <li>
                        <a href="<?php echo esc_url(admin_url('admin.php?page=' . (class_exists('AIEO_DMM') ? AIEO_DMM::MENU_SLUG : 'ai-eshop-dmm'))); ?>">
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                                <path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z" fill="#787C82"/>
                            </svg>
                            <span><?php
                                echo wp_kses_post(sprintf(
                                    
                                    __('Go to <strong>%s</strong>', 'ai-eshop-optimizer'),
                                    class_exists('AIEO_DMM') ? esc_html(AIEO_DMM::get_menu_title()) : 'e-shop Manager'
                                ));
                            ?></span>
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                                <path d="M10.8626 8.04102L14.2809 12.0291L10.8626 16.0172L9.72363 15.041L12.3053 12.0291L9.72363 9.01721L10.8626 8.04102Z" fill="#757575"/>
                            </svg>
                        </a>
                    </li>
                    <li>
                        <a href="<?php echo esc_url(admin_url('admin.php?page=ai-eshop-chat')); ?>">
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M20 2H4C2.9 2 2 2.9 2 4V22L6 18H20C21.1 18 22 17.1 22 16V4C22 2.9 21.1 2 20 2ZM20 16H6L4 18V4H20V16Z"
                                    fill="#787C82"></path>
                                <path d="M7 9H17V11H7V9ZM7 12H14V14H7V12Z" fill="#787C82"></path>
                            </svg>
                            <span><?php echo wp_kses_post(__('Go to <strong>AI Chat</strong>', 'ai-eshop-optimizer')); ?></span>
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M10.8626 8.04102L14.2809 12.0291L10.8626 16.0172L9.72363 15.041L12.3053 12.0291L9.72363 9.01721L10.8626 8.04102Z"
                                    fill="#757575"></path>
                            </svg>
                        </a>
                    </li>
                    <li>
                        <a href="https://rooster.systems/my-account/?utm_source=woo&utm_medium=plugin&utm_campaign=setup"
                            target="_blank">
                            <svg width=" 24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M18.7744 12.9949C18.652 12.8581 18.5845 12.6822 18.5845 12.5C18.5845 12.3178 18.652 12.1419 18.7744 12.0051L19.7516 10.9252C19.8593 10.8072 19.9261 10.6588 19.9426 10.5012C19.959 10.3435 19.9242 10.1848 19.8432 10.0478L18.3164 7.45319C18.2362 7.31635 18.114 7.20788 17.9673 7.14324C17.8206 7.07861 17.6569 7.06111 17.4995 7.09324L16.0643 7.3782C15.8817 7.41526 15.6916 7.38539 15.5299 7.29421C15.3681 7.20303 15.246 7.05685 15.1864 6.88326L14.7208 5.51095C14.6695 5.362 14.572 5.23264 14.4418 5.14113C14.3117 5.04963 14.1556 5.00061 13.9955 5.00102H10.9419C10.7754 4.99248 10.6107 5.03771 10.4728 5.12979C10.335 5.22187 10.2316 5.35574 10.1785 5.51095L9.751 6.88326C9.69146 7.05685 9.56929 7.20303 9.40756 7.29421C9.24582 7.38539 9.05571 7.41526 8.87309 7.3782L7.39972 7.09324C7.25051 7.07252 7.0984 7.09565 6.96256 7.15971C6.82671 7.22376 6.71319 7.32588 6.63632 7.45319L5.10951 10.0478C5.02642 10.1833 4.98906 10.3411 5.00277 10.4987C5.01648 10.6563 5.08056 10.8056 5.18585 10.9252L6.15537 12.0051C6.27776 12.1419 6.34526 12.3178 6.34526 12.5C6.34526 12.6822 6.27776 12.8581 6.15537 12.9949L5.18585 14.0748C5.08056 14.1944 5.01648 14.3437 5.00277 14.5013C4.98906 14.6589 5.02642 14.8167 5.10951 14.9522L6.63632 17.5468C6.71655 17.6837 6.83871 17.7921 6.98538 17.8568C7.13206 17.9214 7.29576 17.9389 7.45316 17.9068L8.88836 17.6218C9.07098 17.5847 9.26109 17.6146 9.42282 17.7058C9.58456 17.797 9.70673 17.9431 9.76627 18.1167L10.2319 19.489C10.2851 19.6443 10.3884 19.7781 10.5263 19.8702C10.6641 19.9623 10.8289 20.0075 10.9953 19.999H14.049C14.209 19.9994 14.3651 19.9504 14.4953 19.8589C14.6254 19.7674 14.723 19.638 14.7742 19.489L15.2399 18.1167C15.2994 17.9431 15.4216 17.797 15.5833 17.7058C15.745 17.6146 15.9352 17.5847 16.1178 17.6218L17.553 17.9068C17.7104 17.9389 17.8741 17.9214 18.0208 17.8568C18.1674 17.7921 18.2896 17.6837 18.3698 17.5468L19.8966 14.9522C19.9777 14.8152 20.0125 14.6565 19.996 14.4988C19.9796 14.3412 19.9127 14.1928 19.805 14.0748L18.7744 12.9949ZM17.637 13.9998L18.2477 14.6747L17.2705 16.3395L16.3697 16.1595C15.8199 16.0491 15.2479 16.1408 14.7624 16.4173C14.2769 16.6938 13.9117 17.1357 13.736 17.6593L13.4459 18.4992H11.4916L11.2167 17.6443C11.041 17.1208 10.6758 16.6788 10.1903 16.4023C9.70476 16.1258 9.13281 16.0341 8.58299 16.1445L7.68218 16.3245L6.68976 14.6672L7.30048 13.9923C7.67604 13.5798 7.88367 13.0459 7.88367 12.4925C7.88367 11.9391 7.67604 11.4052 7.30048 10.9927L6.68976 10.3178L7.66691 8.66802L8.56773 8.848C9.11755 8.9584 9.68949 8.86665 10.175 8.59018C10.6605 8.31371 11.0258 7.87175 11.2015 7.3482L11.4916 6.50082H13.4459L13.736 7.3557C13.9117 7.87925 14.2769 8.32121 14.7624 8.59768C15.2479 8.87415 15.8199 8.9659 16.3697 8.8555L17.2705 8.67552L18.2477 10.3403L17.637 11.0152C17.2656 11.4267 17.0606 11.9576 17.0606 12.5075C17.0606 13.0574 17.2656 13.5883 17.637 13.9998ZM12.4687 9.50041C11.8648 9.50041 11.2744 9.67633 10.7722 10.0059C10.2701 10.3355 9.87867 10.804 9.64755 11.3521C9.41643 11.9002 9.35595 12.5033 9.47378 13.0852C9.5916 13.6671 9.88243 14.2015 10.3095 14.621C10.7365 15.0405 11.2806 15.3262 11.873 15.442C12.4653 15.5577 13.0793 15.4983 13.6373 15.2713C14.1953 15.0442 14.6722 14.6598 15.0077 14.1665C15.3432 13.6732 15.5223 13.0933 15.5223 12.5C15.5223 11.7045 15.2006 10.9415 14.6279 10.379C14.0553 9.81644 13.2786 9.50041 12.4687 9.50041ZM12.4687 13.9998C12.1667 13.9998 11.8716 13.9118 11.6205 13.747C11.3694 13.5822 11.1737 13.348 11.0581 13.0739C10.9426 12.7999 10.9123 12.4983 10.9712 12.2074C11.0302 11.9165 11.1756 11.6492 11.3891 11.4395C11.6026 11.2297 11.8747 11.0869 12.1709 11.029C12.467 10.9712 12.774 11.0009 13.053 11.1144C13.332 11.2279 13.5704 11.4201 13.7382 11.6668C13.906 11.9134 13.9955 12.2034 13.9955 12.5C13.9955 12.8978 13.8347 13.2792 13.5483 13.5605C13.262 13.8418 12.8737 13.9998 12.4687 13.9998Z"
                                    fill="#787C82"></path>
                            </svg>
                            <span><?php echo wp_kses_post(__('Manage your <strong>Account</strong>', 'ai-eshop-optimizer')); ?></span>
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M10.8626 8.04102L14.2809 12.0291L10.8626 16.0172L9.72363 15.041L12.3053 12.0291L9.72363 9.01721L10.8626 8.04102Z"
                                    fill="#757575"></path>
                            </svg>
                        </a>
                    </li>
                    <li>
                        <a href="https://rooster.systems/help-and-support/?utm_source=woo&utm_medium=plugin&utm_campaign=setup"
                            target="_blank">
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M11.96 16.8C12.24 16.8 12.4768 16.7032 12.6704 16.5096C12.8635 16.3165 12.96 16.08 12.96 15.8C12.96 15.52 12.8635 15.2835 12.6704 15.0904C12.4768 14.8968 12.24 14.8 11.96 14.8C11.68 14.8 11.4432 14.8968 11.2496 15.0904C11.0565 15.2835 10.96 15.52 10.96 15.8C10.96 16.08 11.0565 16.3165 11.2496 16.5096C11.4432 16.7032 11.68 16.8 11.96 16.8ZM12.08 8.56C12.4533 8.56 12.7533 8.6632 12.98 8.8696C13.2067 9.07653 13.32 9.34667 13.32 9.68C13.32 9.90667 13.2435 10.1365 13.0904 10.3696C12.9368 10.6032 12.72 10.8467 12.44 11.1C12.04 11.4467 11.7467 11.78 11.56 12.1C11.3733 12.42 11.28 12.74 11.28 13.06C11.28 13.2467 11.3501 13.4032 11.4904 13.5296C11.6301 13.6565 11.7933 13.72 11.98 13.72C12.1667 13.72 12.3333 13.6533 12.48 13.52C12.6267 13.3867 12.72 13.22 12.76 13.02C12.8 12.7933 12.8901 12.5835 13.0304 12.3904C13.1701 12.1968 13.4 11.9467 13.72 11.64C14.1333 11.2533 14.4235 10.9 14.5904 10.58C14.7568 10.26 14.84 9.90667 14.84 9.52C14.84 8.84 14.5835 8.2832 14.0704 7.8496C13.5568 7.41653 12.8933 7.2 12.08 7.2C11.52 7.2 11.0235 7.30667 10.5904 7.52C10.1568 7.73333 9.82 8.06 9.58 8.5C9.48667 8.67333 9.45333 8.8432 9.48 9.0096C9.50667 9.17653 9.6 9.31333 9.76 9.42C9.93333 9.52667 10.1235 9.56 10.3304 9.52C10.5368 9.48 10.7067 9.36667 10.84 9.18C10.9867 8.98 11.1635 8.82667 11.3704 8.72C11.5768 8.61333 11.8133 8.56 12.08 8.56ZM12 20C10.9067 20 9.87333 19.7899 8.9 19.3696C7.92667 18.9499 7.0768 18.38 6.3504 17.66C5.62347 16.94 5.05013 16.0933 4.6304 15.12C4.21013 14.1467 4 13.1067 4 12C4 10.8933 4.21013 9.85333 4.6304 8.88C5.05013 7.90667 5.62347 7.06 6.3504 6.34C7.0768 5.62 7.92667 5.04987 8.9 4.6296C9.87333 4.20987 10.9067 4 12 4C13.12 4 14.1667 4.20987 15.14 4.6296C16.1133 5.04987 16.96 5.62 17.68 6.34C18.4 7.06 18.9667 7.90667 19.38 8.88C19.7933 9.85333 20 10.8933 20 12C20 13.1067 19.7933 14.1467 19.38 15.12C18.9667 16.0933 18.4 16.94 17.68 17.66C16.96 18.38 16.1133 18.9499 15.14 19.3696C14.1667 19.7899 13.12 20 12 20ZM12 18.4C13.7867 18.4 15.3 17.7768 16.54 16.5304C17.78 15.2835 18.4 13.7733 18.4 12C18.4 10.2267 17.78 8.71653 16.54 7.4696C15.3 6.2232 13.7867 5.6 12 5.6C10.2533 5.6 8.74987 6.2232 7.4896 7.4696C6.22987 8.71653 5.6 10.2267 5.6 12C5.6 13.7733 6.22987 15.2835 7.4896 16.5304C8.74987 17.7768 10.2533 18.4 12 18.4Z"
                                    fill="#787C82"></path>
                            </svg>
                            <span><?php echo wp_kses_post(__('Get <strong>help and support</strong>', 'ai-eshop-optimizer')); ?></span>
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M10.8626 8.04102L14.2809 12.0291L10.8626 16.0172L9.72363 15.041L12.3053 12.0291L9.72363 9.01721L10.8626 8.04102Z"
                                    fill="#757575"></path>
                            </svg>
                        </a>
                    </li>
                    <li>
                        <a href="https://rooster.systems/help-and-support/feedback/?utm_source=woo&utm_medium=plugin&utm_campaign=setup"
                            target="_blank">
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M6.09407 4L5.18893 4.8922L6.53571 6.22098L7.43957 5.32878L6.09343 4H6.09407ZM17.9066 4L16.5598 5.32878L17.4643 6.22098L18.8104 4.89283L17.9066 4ZM12 4.39597C11.7879 4.39851 11.5731 4.41056 11.3571 4.43658C11.3507 4.43658 11.3443 4.43531 11.3379 4.43658C8.73043 4.73165 6.65529 6.81112 6.29464 9.3735C6.00664 11.4358 6.86807 13.3059 8.30357 14.5103C8.89076 15.005 9.28793 15.6838 9.42857 16.433V20.2404H10.8943C11.118 20.6193 11.5262 20.875 12 20.875C12.4738 20.875 12.882 20.6193 13.1057 20.2404H14.5714V17.7022H14.6319V16.9483C14.6319 16.018 15.1217 15.0801 15.9176 14.351C16.9821 13.2989 17.7857 11.8045 17.7857 10.088C17.7857 6.95327 15.1719 4.36678 12 4.39597ZM12 5.6651C14.4846 5.63083 16.5 7.6386 16.5 10.088C16.5 11.4168 15.8764 12.5869 15.0131 13.4385L15.0336 13.4588C14.1757 14.2398 13.6209 15.292 13.4651 16.4337H10.6532C10.5118 15.346 10.0393 14.2933 9.14636 13.5382C8.01043 12.5863 7.3335 11.1522 7.55979 9.53278C7.84071 7.5339 9.48386 5.92654 11.4973 5.70635C11.6635 5.68347 11.8309 5.66991 11.9987 5.66573L12 5.6651ZM3 10.088V11.3572H4.92857V10.088H3ZM19.0714 10.088V11.3572H21V10.088H19.0714ZM6.53571 15.2242L5.18957 16.5523L6.09407 17.4452L7.43893 16.1164L6.53571 15.2242ZM17.4643 15.2242L16.5604 16.1164L17.9059 17.4452L18.8104 16.5523L17.4643 15.2242ZM10.7143 17.7028H13.2857V18.9719H10.7143V17.7028Z"
                                    fill="#787C82"></path>
                            </svg>
                            <span><?php echo wp_kses_post(__('Have an <strong>idea or feedback?</strong>', 'ai-eshop-optimizer')); ?></span>
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M10.8626 8.04102L14.2809 12.0291L10.8626 16.0172L9.72363 15.041L12.3053 12.0291L9.72363 9.01721L10.8626 8.04102Z"
                                    fill="#757575"></path>
                            </svg>
                        </a>
                    </li>
                    <li>
                        <a href="https://wordpress.org/plugins/ai-eshop-optimizer/" target="_blank">
                            <svg width=" 24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M12 7L13.2747 9.35645L16 9.73445L14 11.4545L14.6667 14L12 12.5682L9.33333 14L10 11.4545L8 9.73445L10.8 9.35645L12 7Z"
                                    fill="#787C82"></path>
                                <path
                                    d="M13.116 21L12 20.3846L14.5714 16.0769H18.4286C18.5975 16.0772 18.7648 16.0455 18.9209 15.9837C19.077 15.922 19.2188 15.8313 19.3383 15.717C19.4577 15.6026 19.5524 15.4669 19.6169 15.3174C19.6815 15.168 19.7145 15.0078 19.7143 14.8462V7.46154C19.7145 7.29984 19.6815 7.13969 19.6169 6.99026C19.5524 6.84082 19.4577 6.70505 19.3383 6.59071C19.2188 6.47638 19.077 6.38573 18.9209 6.32396C18.7648 6.2622 18.5975 6.23053 18.4286 6.23077H5.57143C5.40251 6.23053 5.23521 6.2622 5.07911 6.32396C4.923 6.38573 4.78117 6.47638 4.66173 6.59071C4.54228 6.70505 4.44759 6.84082 4.38307 6.99026C4.31854 7.13969 4.28546 7.29984 4.28571 7.46154V14.8462C4.28546 15.0078 4.31854 15.168 4.38307 15.3174C4.44759 15.4669 4.54228 15.6026 4.66173 15.717C4.78117 15.8313 4.923 15.922 5.07911 15.9837C5.23521 16.0455 5.40251 16.0772 5.57143 16.0769H11.3571V17.3077H5.57143C4.88944 17.3077 4.23539 17.0484 3.75315 16.5867C3.27092 16.1251 3 15.499 3 14.8462V7.46154C2.99992 7.13826 3.06637 6.81814 3.19557 6.51945C3.32476 6.22077 3.51417 5.94938 3.75297 5.72079C3.99176 5.4922 4.27527 5.31088 4.58729 5.18721C4.8993 5.06353 5.23372 4.99992 5.57143 5H18.4286C18.7663 4.99992 19.1007 5.06353 19.4127 5.18721C19.7247 5.31088 20.0082 5.4922 20.247 5.72079C20.4858 5.94938 20.6752 6.22077 20.8044 6.51945C20.9336 6.81814 21.0001 7.13826 21 7.46154V14.8462C21 15.499 20.7291 16.1251 20.2468 16.5867C19.7646 17.0484 19.1106 17.3077 18.4286 17.3077H15.3204L13.116 21Z"
                                    fill="#787C82"></path>
                            </svg>
                            <span><?php echo wp_kses_post(__('<strong>Review</strong> on Wordpress.org', 'ai-eshop-optimizer')); ?></span>
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
                                xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M10.8626 8.04102L14.2809 12.0291L10.8626 16.0172L9.72363 15.041L12.3053 12.0291L9.72363 9.01721L10.8626 8.04102Z"
                                    fill="#757575"></path>
                            </svg>
                        </a>
                    </li>
                </ul>
            </div>
        </div>

        <?php
        
        
        
        
        
        
        $aieo_optimizer_toc = array(
            array( 'id' => 'aieo-card-intro',                  'label' => __( 'Overview', 'ai-eshop-optimizer' ),       'href' => '#aieo-card-intro' ),
            array( 'id' => 'aieo-card-status',                 'label' => __( 'Preferences', 'ai-eshop-optimizer' ),    'href' => '#aieo-card-status' ),
            array( 'id' => 'aieo-card-orders-export',          'label' => __( 'Orders Export', 'ai-eshop-optimizer' ),  'href' => '#aieo-card-orders-export' ),
            array( 'id' => 'aieo-card-indicative-statistics',  'label' => __( 'Statistics', 'ai-eshop-optimizer' ),     'href' => '#aieo-card-indicative-statistics' ),
            array( 'id' => 'aieo-card-process-data',           'label' => __( 'AI Processing', 'ai-eshop-optimizer' ),  'href' => '#aieo-card-process-data' ),
            array( 'id' => 'aieo-card-eshop-update',           'label' => __( 'Eshop Update', 'ai-eshop-optimizer' ),   'href' => '#aieo-card-eshop-update' ),
            array( 'id' => 'aieo-card-expert-services',        'label' => __( 'Expert Services', 'ai-eshop-optimizer' ),'href' => '#aieo-card-expert-services' ),
            array( 'id' => 'aieo-card-pro-panel',              'label' => __( 'Pro Panel', 'ai-eshop-optimizer' ),      'href' => '#aieo-card-pro-panel' ),
        );
        
        
        
        
        $aieo_menu_active_group = 'setup';
        require AIEO_DIR . 'assets/pages/dmm/_menu-bar.php';
        ?>

        <div class="aieo-modules-panel">

            <div class="aieo-modules-box" id="aieo-card-intro">
                <div class="aieo-modules-box-heading">
                    <?php esc_html_e('Introducing the Graph Database AI-powered optimizer for the best in market, zero data point, recommendations', 'ai-eshop-optimizer'); ?>
                </div>
                <div class="aieo-modules-list-promo">

                    <div class="aieo-modules-list-item">
                        <div class="aieo-modules-list-item-icon">
                            <svg width="20" height="14" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 14">
                                <path d="M0 1.5A1.5 1.5 0 0 1 1.5 0h17A1.5 1.5 0 0 1 20 1.5V3H0V1.5Z"></path>
                                <path d="M0 5v7.5A1.5 1.5 0 0 0 1.5 14h17a1.5 1.5 0 0 0 1.5-1.5V5H0Zm7 4H2V7h5v2Z">
                                </path>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title">
                                <?php esc_html_e('Free analysis of up to 50000 order items!', 'ai-eshop-optimizer'); ?>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('In this version, up to 50000 order items can be exported with OrderID larger or equal than the OrderID you set.', 'ai-eshop-optimizer'); ?>
                                <div class="aieo-pro">
                                    <?php echo wp_kses_post(__('In the pro-version the volume of the orders is unlimited and the frequency of updates is unlimited.</br> A number of different AI network analysis algorithms such as Closeness, Adamic-Adar, Jaccard, Louvain, and Breadth First Search are used to determine the optimal recommendations.</br> You just provide us your orders (as well as the products that were never sold in your eshop) and with a click, in minutes, all your products get their optimal recommendations!', 'ai-eshop-optimizer')); ?>
                                </div>
                                </br><?php esc_html_e('We are using only the following data: Order ID, Product ID, Category IDs, Tag IDs, Order items, Date and time, Stock, Unit Prices and Product Title. Even with minimal data points the results to your bottom line are impressive!', 'ai-eshop-optimizer'); ?>
                                <div class="aieo-pro">
                                    <?php esc_html_e('The pro-version also factors for your existing crossells and upsells as well as the product categories, tags and the full-text description of each product.', 'ai-eshop-optimizer'); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="aieo-modules-box" id="aieo-card-status">
                <div class="aieo-modules-box-heading">
                    <?php esc_html_e('Your status and display preferences', 'ai-eshop-optimizer'); ?>
                </div>
                <div class="aieo-modules-list">

                    <div class="aieo-modules-list-item-setup">
                        <div class="aieo-modules-list-item-icon-setup">
                            <svg id="glipy_copy_4" data-name="glipy copy 4" xmlns="http://www.w3.org/2000/svg"
                                viewBox="0 0 64 64">
                                <title>1</title>
                                <path
                                    d="M32,2A30,30,0,1,0,62,32,30.03661,30.03661,0,0,0,32,2ZM43.57,50.56H20.43a.71507.71507,0,0,1,0-1.43h5.23l1.29-4.87h1.49l-1.3,4.87h9.72l-1.3-4.87h1.49l1.28,4.87h5.24a.70634.70634,0,0,1,.71.71A.72142.72142,0,0,1,43.57,50.56Zm6.28-7.73H14.14A2.14236,2.14236,0,0,1,12,40.69c-.26-.33,40.01-.01,40-.12A2.14808,2.14808,0,0,1,49.85,42.83ZM52,39.14H12V15.59a2.15746,2.15746,0,0,1,2.14-2.15H49.85A2.15952,2.15952,0,0,1,52,15.59Z" />
                                <path
                                    d="M24.83,23.17l-3.34,3.32a.74346.74346,0,0,0,0,1.02l3.34,3.33a.71433.71433,0,0,0,1.01-1.01L23.01,27l2.83-2.83A.71078.71078,0,0,0,24.83,23.17Z" />
                                <path
                                    d="M32.98,21.77l-3.32,10a.71324.71324,0,0,0,1.35.46l3.33-10A.718.718,0,0,0,32.98,21.77Z" />
                                <path
                                    d="M39.17,23.17a.71078.71078,0,0,0-1.01,1L40.99,27l-2.83,2.83a.72249.72249,0,0,0,.5,1.22.71055.71055,0,0,0,.51-.21l3.34-3.33a.74346.74346,0,0,0,0-1.02Z" />
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-display-preferences">
                                <?php esc_html_e('Display preferences', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator-setup"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('Please choose the recommendation option choices that will appear in your single product pages.', 'ai-eshop-optimizer'); ?></br></br>
                                <div class="aieo-table">
                                    <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                                        <?php wp_nonce_field('eshop_optimizer_update_display_preferences', 'eshop_optimizer_nonce_field_1'); ?>
                                        <input type="hidden" name="action" value="eshop_optimizer_display_references">
                                        <div class="aieo-row">
                                            <div class="aieo-cell aieo-input aieo-display-preferences">
                                                <label><input type="checkbox" id="aieo_display_upsells"
                                                        name="aieo_display_upsells" value="1" <?php checked(1, get_option('aieo_display_upsells'), true); ?>><?php echo wp_kses_post(__('Please display <i>Up-sells</i>', 'ai-eshop-optimizer')); ?><label>
                                            </div>
                                            <div class="aieo-cell"></div>
                                        </div>
                                        <div class="aieo-row">
                                            <div class="aieo-cell aieo-input aieo-display-preferences">
                                                <label><input type="checkbox" id="aieo_display_cross_sells"
                                                        name="aieo_display_cross_sells" value="1" <?php checked(1, get_option('aieo_display_cross_sells'), true); ?>><?php echo wp_kses_post(__('Please display <i>Cross-sells</i>', 'ai-eshop-optimizer')); ?><label>
                                            </div>
                                            <div class="aieo-cell"></div>
                                        </div>
                                        <div class="aieo-row">
                                            <div class="aieo-cell aieo-input aieo-display-preferences">
                                                <label><input type="checkbox" id="aieo_display_related"
                                                        name="aieo_display_related" value="1" <?php checked(1, get_option('aieo_display_related'), true); ?>><?php echo wp_kses_post(__('Please display <i>Related by Woo</i>', 'ai-eshop-optimizer')); ?><label>
                                            </div>
                                            <div class="aieo-cell"></div>
                                        </div>
                                        <div class="aieo-row">
                                            <div class="aieo-cell aieo-input aieo-display-preferences">
                                                <label><input type="checkbox" id="aieo_display_recently_viewed_products"
                                                        name="aieo_display_recently_viewed_products" value="1" <?php checked(1, get_option('aieo_display_recently_viewed_products'), true); ?>><?php echo wp_kses_post(__('Please display <i>Viewed Recently</i>', 'ai-eshop-optimizer')); ?><label>
                                            </div>
                                            <div class="aieo-cell"></div>
                                        </div>
                                        <div class="aieo-row">
                                            <div class="aieo-cell aieo-input aieo-display-preferences">
                                                <label><input type="checkbox" id="aieo_display_same_needs"
                                                        name="aieo_display_same_needs" value="1" <?php checked(1, get_option('aieo_display_same_needs'), true); ?>><?php echo wp_kses_post(__('Please display <i>Products for the same needs</i>', 'ai-eshop-optimizer')); ?><label>
                                            </div>
                                            <div class="aieo-cell"></div>
                                        </div>
                                        <div class="aieo-row">
                                            <div class="aieo-cell aieo-input aieo-display-preferences">
                                                <label><input type="checkbox" id="aieo_display_categories_by_sales"
                                                        name="aieo_display_categories_by_sales" value="1" <?php checked(1, get_option('aieo_display_categories_by_sales'), true); ?>><?php esc_html_e('Please display categories based on their sales', 'ai-eshop-optimizer'); ?><label>
                                            </div>
                                            <div class="aieo-cell"></div>
                                        </div>
                                        <div class="aieo-row" id="aieo_category_sales_period_row" style="<?php echo get_option('aieo_display_categories_by_sales') ? '' : 'display:none;'; ?>">
                                            <div class="aieo-cell aieo-input aieo-display-preferences" style="padding-left: 25px;">
                                                <label for="aieo_category_sales_period"><?php esc_html_e('Time period for category sales:', 'ai-eshop-optimizer'); ?></label>
                                                <select id="aieo_category_sales_period" name="aieo_category_sales_period">
                                                    <option value="all_time" <?php selected(get_option('aieo_category_sales_period', 'all_time'), 'all_time'); ?>><?php esc_html_e('All time', 'ai-eshop-optimizer'); ?></option>
                                                    <option value="last_30_days" <?php selected(get_option('aieo_category_sales_period', 'all_time'), 'last_30_days'); ?>><?php esc_html_e('Last 30 days', 'ai-eshop-optimizer'); ?></option>
                                                    <option value="last_3_months" <?php selected(get_option('aieo_category_sales_period', 'all_time'), 'last_3_months'); ?>><?php esc_html_e('Last 3 months', 'ai-eshop-optimizer'); ?></option>
                                                    <option value="last_6_months" <?php selected(get_option('aieo_category_sales_period', 'all_time'), 'last_6_months'); ?>><?php esc_html_e('Last 6 months', 'ai-eshop-optimizer'); ?></option>
                                                    <option value="last_12_months" <?php selected(get_option('aieo_category_sales_period', 'all_time'), 'last_12_months'); ?>><?php esc_html_e('Last 12 months', 'ai-eshop-optimizer'); ?></option>
                                                </select>
                                            </div>
                                            <div class="aieo-cell"></div>
                                        </div>
                                        <div class="aieo-rowspantwo">
                                            </br></br>
                                            <?php
                                            
                                            
                                            
                                            
                                            
                                            
                                            
                                            
                                            
                                            $reco_order_url = esc_url( admin_url('admin.php?page=ai-eshop-dmm&dmm_tab=product_display#aieo-card-recommendations-order') );
                                            printf(
                                                
                                                wp_kses_post( __('Want to change the order in which the recommendation rails appear (and which ones to hide)? Use the new <strong><a href="%s">Recommendations Ordering</a></strong> card on the e-shop Manager dashboard — drag-and-drop ordering for every rail (Up-sells, Cross-sells, Related, Recently Viewed, Products for the same needs) plus any Custom Slots you create.', 'ai-eshop-optimizer') ),
                                                $reco_order_url
                                            );
                                            ?>
                                        </div>

                                </div>
                                <div class="aieo-cellsubmit">
                                    <input type="submit"
                                        class="aieo-button button-primary aieo-button-setup  aieo-center-content"
                                        value="<?php esc_attr_e('Update display preferences', 'ai-eshop-optimizer'); ?>">

                                </div>
                                </form>

                            </div>
                        </div>
                    </div>

                    <div class="aieo-modules-list-item-setup">
                        <div class="aieo-modules-list-item-icon-setup">
                            <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
                                xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 400 400"
                                style="enable-background:new 0 0 400 400;" xml:space="preserve">
                                <g>
                                    <path class="aieo-st0"
                                        d="M128.1,271.9L107,293c-51.3-51.3-51.3-134.7,0-186l21.1,21.1C88.4,167.7,88.4,232.3,128.1,271.9z" />
                                    <path class="aieo-st1"
                                        d="M293,293l-21.1-21.1c39.7-39.7,39.7-104.2,0-143.8L293,107C344.3,158.3,344.3,241.7,293,293z" />
                                    <path class="aieo-st2"
                                        d="M293,107l-21.1,21.1c-39.7-39.7-104.2-39.7-143.8,0L107,107C158.3,55.7,241.7,55.7,293,107z" />
                                    <path class="aieo-st3"
                                        d="M293,293c-51.3,51.3-134.7,51.3-186,0l21.1-21.1c39.7,39.7,104.2,39.7,143.8,0L293,293z" />
                                    <path class="aieo-st4"
                                        d="M281.9,97.1l-21.2,21.2c8,6,15.1,13.1,21.1,21.1l21.2-21.2C296.7,110.3,289.7,103.3,281.9,97.1z" />
                                    <path class="aieo-st5"
                                        d="M302.9,281.9l-21.2-21.2c-6,8-13.1,15.1-21.1,21.1l21.2,21.2C289.7,296.7,296.7,289.7,302.9,281.9z" />
                                    <path class="aieo-st6"
                                        d="M118.1,302.9l21.2-21.2c-8-6-15.1-13.1-21.1-21.1l-21.2,21.2C103.3,289.7,110.3,296.7,118.1,302.9z" />
                                    <path class="aieo-st7"
                                        d="M97.1,118.1l21.2,21.2c6-8,13.1-15.1,21.1-21.1l-21.2-21.2C110.3,103.3,103.3,110.3,97.1,118.1z" />
                                    <circle class="aieo-st8" cx="200" cy="200" r="111.8" />
                                </g>
                                <path d="M195.8,210.4v-13.5c2.7,0.8,5.6,0.8,8.4,0v13.5c0,5,4.1,9.1,9.1,9.1l0,0h0.1c4.6,17.7,20.9,30.6,40.1,30.1
    c21.2-0.6,38.6-18,39.1-39.2c0.5-21-14.9-38.5-35.2-41c0,0-8.7-8.5-15.4-13.5c-8.5-6.3-26.3-5.1-26.9,11.6h-30.3
    c-0.6-16.7-18.4-17.9-26.9-11.6c-6.8,5-15.4,13.5-15.4,13.5c-20.2,2.6-35.7,20.1-35.2,41.1c0.6,21.2,18,38.6,39.2,39.1
    c19.2,0.5,35.4-12.4,40-30.1h0.1C191.7,219.5,195.8,215.4,195.8,210.4z M147.6,239.6c-16.6,0-30.2-13.5-30.2-30.2
    s13.5-30.2,30.2-30.2s30.2,13.5,30.2,30.2S164.3,239.6,147.6,239.6z M200,191.2c-4.7,0-8.4-3.7-8.4-8.4s3.7-8.4,8.4-8.4
    s8.4,3.7,8.4,8.4S204.6,191.2,200,191.2z M147.8,187c-4.5,0-8.6,1.3-12,3.5c3.3,0.4,5.9,3.2,5.9,6.7c0,3.7-3,6.7-6.7,6.7
    c-3.3,0-6.1-2.5-6.6-5.6c-1.9,3.3-3,7.1-3,11.2c0,12.4,10,22.5,22.5,22.5c12.4,0,22.5-10,22.5-22.5C170.3,197,160.2,187,147.8,187z
     M232.8,198.2c0.5,3.2,3.3,5.6,6.6,5.6c3.7,0,6.7-3,6.7-6.7c0-3.5-2.6-6.3-5.9-6.7c3.5-2.2,7.6-3.5,12-3.5c12.4,0,22.5,10,22.5,22.5
    c0,12.4-10,22.5-22.5,22.5s-22.5-10-22.5-22.5C229.7,205.3,230.8,201.5,232.8,198.2z M252.4,239.6c-16.6,0-30.2-13.5-30.2-30.2
    s13.5-30.2,30.2-30.2s30.2,13.5,30.2,30.2S269,239.6,252.4,239.6z" />
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-utm-analytics">
                                <?php esc_html_e('Activate Google UTM Analytics for Each Recommendation Interaction', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator-setup"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('In your dashboard you can compare the sales that match our recommendations.', 'ai-eshop-optimizer'); ?></br>
                                <?php esc_html_e('In this section, you can opt to generate UTM reference codes for every recommendation, allowing you to track their effectiveness in Google Analytics.', 'ai-eshop-optimizer'); ?>
                                </br></br><?php esc_html_e('The recommendations in the product pages, will have their urls appended as follows:', 'ai-eshop-optimizer'); ?>
                                </br><i><strong>utm_source=AIO< (Empty or Cart)>
                                            < CrossSell/UpSell/WooRANDRelated/RecentlyViewed>&utm_campaign=<
                                                    recommendation sequence>_< origin productid>_< target productid>
                                    </strong></i>
                                </br></br>
                                <?php
                                
                                printf(wp_kses_post(__('<strong>IMPORTANT NOTICE:</strong> This choice assumes the default related/up-sell templates. <a href="%s" target="_blank">Please read detailed instructions here for further customizations</a>.', 'ai-eshop-optimizer')), 'https://eshop-optimizer.com/help-and-support'); ?>
                                </br>
                                </br>
                                <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                                    <?php wp_nonce_field('eshop_optimizer_utm_stats_action', 'eshop_optimizer_utm_stats_nonce_2'); ?>
                                    <input type="hidden" name="action" value="eshop_optimizer_utm_stats">

                                    <div class="aieo-cellsubmit">

                                        <input type="checkbox" id="aieo_activate_utm_stats"
                                            name="aieo_activate_utm_stats" value="1" <?php checked(1, get_option('aieo_activate_utm_stats'), true); ?>>
                                        <label
                                            for="aieo_activate_utm_stats"><?php esc_html_e('Activate UTM Stats', 'ai-eshop-optimizer'); ?></label>
                                    </div>
                                    <div class="aieo-row aieo-google-settings-row">
                                        <div class="aieo-cell">
                                            <?php esc_html_e('Google Measurement ID', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="text" id="aieo_google_ga4" name="aieo_google_ga4"
                                                value="<?php echo esc_attr(get_option('aieo_google_ga4')); ?>">
                                        </div>
                                    </div>

                                    <div class="aieo-cellsubmit">
                                        <input class="aieo-button button-primary aieo-button-setup aieo-center-content"
                                            type="submit"
                                            value="<?php esc_attr_e('Save UTM settings', 'ai-eshop-optimizer'); ?>">
                                    </div>
                                </form>
                            </div>
                        </div>

                    </div>

                    <!-- Session Tracker Settings -->
                    <?php
                    
                    
                    $is_pro_user_session = AIEO_DMM_Module_Base::is_aieo_pro_user();
                    ?>
                    <div
                        class="aieo-modules-list-item-setup <?php echo !$is_pro_user_session ? 'aieo-pro-locked' : ''; ?>">
                        <?php if (!$is_pro_user_session): ?>
                            <div class="aieo-pro-overlay">
                                <div class="aieo-pro-overlay-content">
                                    <div class="aieo-pro-badge">
                                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none"
                                            xmlns="http://www.w3.org/2000/svg">
                                            <path
                                                d="M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"
                                                fill="currentColor" />
                                        </svg>
                                        <span><?php esc_html_e('PRO', 'ai-eshop-optimizer'); ?></span>
                                    </div>
                                    <h3><?php esc_html_e('Premium Feature', 'ai-eshop-optimizer'); ?></h3>
                                    <p><?php esc_html_e('💡 Why pay $100+ monthly for Google Analytics BigQuery exports that bury critical insights in irrelevant data?', 'ai-eshop-optimizer'); ?>
                                    </p>
                                    <p><?php esc_html_e('Our tracker captures only what drives sales - engagement depth, product interactions, and cart behavior - metrics Google doesn\'t even provide clearly. Zero bloat. Zero cost. Maximum insight.', 'ai-eshop-optimizer'); ?>
                                    </p>
                                    <a href="https://rooster.systems/get-aieo/"
                                        target="_blank" class="aieo-pro-overlay-button">
                                        <?php esc_html_e('Upgrade to Pro', 'ai-eshop-optimizer'); ?> →
                                    </a>
                                </div>
                            </div>
                        <?php endif; ?>

                        <div class="aieo-modules-list-item-icon-setup">
                            <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"
                                fill="currentColor">
                                <path
                                    d="M10 2C5.58 2 2 5.58 2 10c0 4.42 3.58 8 8 8s8-3.58 8-8c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z" />
                                <circle cx="10" cy="10" r="3" />
                                <path d="M15 3l-2 2m4 0l-2-2M5 3l2 2M3 5l2-2M5 17l2-2m-4 0l2 2M15 17l-2-2m4 0l-2 2" />
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-ai-session-tracker">
                                <?php esc_html_e('AI Session Tracker (Core Analytics & AI Chat Context)', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator-setup"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <p style="color: #4b5563; margin-bottom: 15px;">
                                    <?php esc_html_e('Traditional analytics platforms charge $100+ monthly for BigQuery exports and bury you in irrelevant data. Our AI Session Tracker captures only the critical eCommerce signals that drive sales and power intelligent AI recommendations.', 'ai-eshop-optimizer'); ?>
                                </p>
                                <strong><?php esc_html_e('What gets tracked:', 'ai-eshop-optimizer'); ?></strong><br>
                                •
                                <?php esc_html_e('Product & category views with time spent', 'ai-eshop-optimizer'); ?><br>
                                •
                                <?php esc_html_e('Cart interactions (add/remove products)', 'ai-eshop-optimizer'); ?><br>
                                • <?php esc_html_e('Wishlist additions', 'ai-eshop-optimizer'); ?><br>
                                • <?php esc_html_e('Scroll depth & engagement metrics', 'ai-eshop-optimizer'); ?><br>
                                •
                                <?php esc_html_e('Device type & browser information', 'ai-eshop-optimizer'); ?><br><br>

                                <strong><?php esc_html_e('Privacy & GDPR:', 'ai-eshop-optimizer'); ?></strong>
                                <?php esc_html_e('Automatically integrates with CookieYes, Cookie Notice, and Complianz consent plugins. No personal data or coordinates are tracked.', 'ai-eshop-optimizer'); ?><br><br>

                                <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                                    <?php wp_nonce_field('eshop_optimizer_session_tracker_action', 'eshop_optimizer_session_tracker_nonce'); ?>
                                    <input type="hidden" name="action" value="eshop_optimizer_session_tracker">

                                    <div class="aieo-cellsubmit">
                                        <input type="checkbox" id="aieo_session_tracking_enabled"
                                            name="aieo_session_tracking_enabled" value="1" <?php checked(1, get_option('aieo_session_tracking_enabled', 0), true); ?> <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>>
                                        <label
                                            for="aieo_session_tracking_enabled"><strong><?php esc_html_e('Enable Session Tracking', 'ai-eshop-optimizer'); ?></strong></label>
                                    </div>

                                    <div class="aieo-row aieo-google-settings-row" style="margin-top: 15px;">
                                        <div class="aieo-cell" style="width: 200px;">
                                            <?php esc_html_e('Track Scroll Depth', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="checkbox" id="aieo_track_scroll_depth"
                                                name="aieo_track_scroll_depth" value="1" <?php checked(1, get_option('aieo_track_scroll_depth', 1), true); ?> <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>>
                                            <label
                                                for="aieo_track_scroll_depth"><?php esc_html_e('Track engagement (25%, 50%, 75%, 100%)', 'ai-eshop-optimizer'); ?></label>
                                        </div>
                                    </div>

                                    <div class="aieo-row aieo-google-settings-row">
                                        <div class="aieo-cell" style="width: 200px;">
                                            <?php esc_html_e('Track Clicks', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="checkbox" id="aieo_track_clicks" name="aieo_track_clicks"
                                                value="1" <?php checked(1, get_option('aieo_track_clicks', 1), true); ?>
                                                <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>>
                                            <label
                                                for="aieo_track_clicks"><?php esc_html_e('Track clicks on buttons and links', 'ai-eshop-optimizer'); ?></label>
                                        </div>
                                    </div>

                                    <div class="aieo-row aieo-google-settings-row">
                                        <div class="aieo-cell" style="width: 200px;">
                                            <?php esc_html_e('Throttle Click Events', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="checkbox" id="aieo_throttle_clicks" name="aieo_throttle_clicks"
                                                value="1" <?php checked(1, get_option('aieo_throttle_clicks', 1), true); ?>
                                                <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>>
                                            <label
                                                for="aieo_throttle_clicks"><?php esc_html_e('Throttle click event tracking to prevent flooding (recommended)', 'ai-eshop-optimizer'); ?></label>
                                        </div>
                                    </div>

                                    <div class="aieo-row aieo-google-settings-row">
                                        <div class="aieo-cell" style="width: 200px;">
                                            <?php esc_html_e('Cookie Consent', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="checkbox" id="aieo_session_bypass_consent"
                                                name="aieo_session_bypass_consent" value="1" <?php checked(1, get_option('aieo_session_bypass_consent', 1), true); ?> <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>>
                                            <label
                                                for="aieo_session_bypass_consent"><?php esc_html_e('Bypass cookie consent requirement (enable tracking without waiting for user consent)', 'ai-eshop-optimizer'); ?></label>
                                        </div>
                                    </div>

                                    <div class="aieo-row aieo-google-settings-row">
                                        <div class="aieo-cell" style="width: 200px;">
                                            <?php esc_html_e('Archive Frequency', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <select id="aieo_session_archive_frequency"
                                                name="aieo_session_archive_frequency" style="width: 150px;" <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>>
                                                <option value="daily" <?php selected(get_option('aieo_session_archive_frequency', 'weekly'), 'daily'); ?>>
                                                    <?php esc_html_e('Daily', 'ai-eshop-optimizer'); ?>
                                                </option>
                                                <option value="weekly" <?php selected(get_option('aieo_session_archive_frequency', 'weekly'), 'weekly'); ?>>
                                                    <?php esc_html_e('Weekly', 'ai-eshop-optimizer'); ?>
                                                </option>
                                                <option value="monthly" <?php selected(get_option('aieo_session_archive_frequency', 'weekly'), 'monthly'); ?>>
                                                    <?php esc_html_e('Monthly', 'ai-eshop-optimizer'); ?>
                                                </option>
                                            </select>
                                            <span
                                                style="margin-left: 10px; color: #666;"><?php esc_html_e('(default: Weekly)', 'ai-eshop-optimizer'); ?></span>
                                        </div>
                                    </div>

                                    <div class="aieo-row aieo-google-settings-row">
                                        <div class="aieo-cell" style="width: 200px;">
                                            <?php esc_html_e('Archive Hour (GMT)', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <select id="aieo_session_archive_hour" name="aieo_session_archive_hour"
                                                style="width: 150px;" <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>>
                                                <?php
                                                $current_hour = (int) get_option('aieo_session_archive_hour', 4);
                                                for ($hour = 0; $hour < 24; $hour++) {
                                                    $hour_label = sprintf('%02d:00', $hour);
                                                    echo '<option value="' . esc_attr($hour) . '" ' . selected($current_hour, $hour, false) . '>' . esc_html($hour_label) . '</option>';
                                                }
                                                ?>
                                            </select>
                                            <span
                                                style="margin-left: 10px; color: #666;"><?php esc_html_e('(default: 04:00)', 'ai-eshop-optimizer'); ?></span>
                                        </div>
                                    </div>

                                    <div class="aieo-row aieo-google-settings-row">
                                        <div class="aieo-cell" style="width: 200px;">
                                            <?php esc_html_e('Data Retention (days)', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="number" id="aieo_session_retention_days"
                                                name="aieo_session_retention_days"
                                                value="<?php echo esc_attr(get_option('aieo_session_retention_days', 30)); ?>"
                                                min="7" max="90" style="width: 80px;" <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>>
                                            <span
                                                style="margin-left: 10px; color: #666;"><?php esc_html_e('(7-90 days, default: 30)', 'ai-eshop-optimizer'); ?></span>
                                        </div>
                                    </div>
                                    
                                    <div class="aieo-row aieo-google-settings-row">
                                        <div class="aieo-cell aieo-textbox-legend" style="width: 200px;">
                                            <?php esc_html_e('Custom Image Click Rules', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <textarea id="aieo_custom_image_click_rules" name="aieo_custom_image_click_rules"
                                                rows="6" style="width: 100%; max-width: 600px; font-family: monospace;"
                                                <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>><?php echo esc_textarea(get_option('aieo_custom_image_click_rules', '')); ?></textarea>
                                            <div class="aieo-help-text">
                                                <?php esc_html_e('Track clicks on custom elements. One rule per line in format:', 'ai-eshop-optimizer'); ?><br>
                                                <strong>event_name | .css-selector</strong><br>
                                                <?php esc_html_e('Works for ANY element (images, buttons, divs, etc.). Only active on product pages.', 'ai-eshop-optimizer'); ?><br>
                                                <?php esc_html_e('Example:', 'ai-eshop-optimizer'); ?>
                                                <div class="aieo-code-example">
                                                    variation_swatch | .merchant-variation-item<br>
                                                    color_picker | .color-swatch<br>
                                                    size_button | .size-selector
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="aieo-cellsubmit" style="margin-top: 20px;">
                                        <input class="aieo-button button-primary aieo-button-setup aieo-center-content"
                                            type="submit"
                                            value="<?php esc_attr_e('Save Session Tracker Settings', 'ai-eshop-optimizer'); ?>"
                                            <?php echo !$is_pro_user_session ? 'disabled' : ''; ?>>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>

                    <style>
                        /* Pro Overlay Styles */
                        .aieo-pro-locked {
                            position: relative;
                        }

                        .aieo-pro-overlay {
                            position: absolute;
                            top: 0;
                            left: 0;
                            right: 0;
                            bottom: 0;
                            background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.75) 100%);
                            backdrop-filter: blur(0.5px);
                            border-radius: 8px;
                            z-index: 10;
                            display: flex;
                            align-items: center;
                            justify-content: center;
                            padding: 30px;
                            animation: fadeIn 0.3s ease;
                        }

                        @keyframes fadeIn {
                            from {
                                opacity: 0;
                            }

                            to {
                                opacity: 1;
                            }
                        }

                        .aieo-pro-overlay-content {
                            text-align: center;
                            color: white;
                            max-width: 400px;
                        }

                        .aieo-pro-badge {
                            display: inline-flex;
                            align-items: center;
                            gap: 6px;
                            background: rgba(255, 255, 255, 0.2);
                            padding: 8px 16px;
                            border-radius: 20px;
                            font-weight: 700;
                            font-size: 14px;
                            margin-bottom: 15px;
                            border: 2px solid rgba(255, 255, 255, 0.3);
                        }

                        .aieo-pro-badge svg {
                            width: 18px;
                            height: 18px;
                            color: #ffd97d;
                        }

                        .aieo-pro-overlay-content h3 {
                            margin: 0 0 12px 0;
                            font-size: 24px;
                            font-weight: 700;
                            color: white;
                            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
                        }

                        .aieo-pro-overlay-content p {
                            margin: 0 0 20px 0;
                            font-size: 15px;
                            line-height: 1.6;
                            opacity: 0.95;
                        }

                        .aieo-pro-overlay-button,
                        .aieo-pro-upgrade-btn {
                            display: inline-block;
                            background: white;
                            color: #667eea;
                            padding: 14px 32px;
                            border-radius: 8px;
                            text-decoration: none;
                            font-weight: 700;
                            font-size: 16px;
                            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
                            transition: all 0.3s ease;
                        }

                        .aieo-pro-overlay-button:hover,
                        .aieo-pro-upgrade-btn:hover {
                            transform: translateY(-2px);
                            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
                            color: #5568d3;
                            text-decoration: none;
                        }

                        .aieo-pro-locked .aieo-modules-list-item-content {
                            filter: blur(1px);
                            opacity: 0.6;
                            pointer-events: none;
                        }

                        @media (max-width: 768px) {
                            .aieo-pro-overlay {
                                padding: 20px;
                            }

                            .aieo-pro-overlay-content h3 {
                                font-size: 20px;
                            }

                            .aieo-pro-overlay-content p {
                                font-size: 14px;
                            }

                            .aieo-pro-overlay-button,
                            .aieo-pro-upgrade-btn {
                                padding: 12px 24px;
                                font-size: 14px;
                            }
                        }
                    </style>

                    <div class="aieo-modules-list-item-setup">
                        <div class="aieo-modules-list-item-icon-setup">
                            <svg width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
                                <path
                                    d="M9 0L0 5V13L9 18L18 13V5L9 0ZM16 12L9 16L2 12V6L9 2L16 6V12ZM9 8C8.4 8 8 8.4 8 9C8 9.6 8.4 10 9 10C9.6 10 10 9.6 10 9C10 8.4 9.6 8 9 8ZM6 6C5.4 6 5 6.4 5 7C5 7.6 5.4 8 6 8C6.6 8 7 7.6 7 7C7 6.4 6.6 6 6 6ZM12 6C11.4 6 11 6.4 11 7C11 7.6 11.4 8 12 8C12.6 8 13 7.6 13 7C13 6.4 12.6 6 12 6ZM6 10C5.4 10 5 10.4 5 11C5 11.6 5.4 12 6 12C6.6 12 7 11.6 7 11C7 10.4 6.6 10 6 10ZM12 10C11.4 10 11 10.4 11 11C11 11.6 11.4 12 12 12C12.6 12 13 11.6 13 11C13 10.4 12.6 10 12 10Z">
                                </path>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-db-performance">
                                <?php esc_html_e('Database Performance Optimization', 'ai-eshop-optimizer'); ?>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php
                                if (class_exists('Automattic\WooCommerce\Utilities\OrderUtil') && function_exists('WC')) {
                                    
                                    if (Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled()) {
                                        ?>
                                        <h4><?php esc_html_e('Great Job: High Performance Order Storage in Woocommerce is active in your installation!!!', 'ai-eshop-optimizer'); ?>
                                        </h4>
                                        <?php
                                    } else {
                                        
                                        ?>
                                        <h4><?php esc_html_e('Tip: High Performance Order Storage (HPOS) is not active in your installation. It improves not only the orders export process but your eshop\'s overall performance.', 'ai-eshop-optimizer'); ?>
                                        </h4>
                                        <?php
                                        
                                        printf(wp_kses_post(__('<a href="%s" target="_blank">Here is how you can enable it with a couple of clicks!</a>. It is also bound to multiply the speed of your transactions! :)', 'ai-eshop-optimizer')), 'https://woocommerce.com/document/high-performance-order-storage/'); ?>
                                        <?php
                                    }
                                }
                                if (aieo_is_index_wp_mysql_for_speed_active()) {
                                    echo '</br><h4>' . esc_html__('Also, your DB tables are properly indexed as you have actived Index WP MySQL For Speed!', 'ai-eshop-optimizer') . '</h4>';
                                } else {
                                    echo '</br><h4>';
                                    printf(
                                        
                                        esc_html__('Please consider the highly recommended %s to speed up your DB queries. It is bound to boost your overall performance!', 'ai-eshop-optimizer'),
                                        '<i><a href="https://wordpress.org/plugins/index-wp-mysql-for-speed/" target="_blank">' . esc_html__('Index WP MySQL For Speed', 'ai-eshop-optimizer') . '</a></i>'
                                    );
                                    echo '</h4>';
                                }

                                ?>
                                <?php
                                
                                require_once AIEO_DIR . 'includes/sql/apply_mariadb114_indexes.php';

                                
                                $db_check = aieo_check_mariadb_version();

                                
                                if (isset($db_check['db_type']) && $db_check['db_type'] === 'mysql8') {
                                    require_once AIEO_DIR . 'includes/sql/apply_mysql8_indexes.php';
                                }
                                ?>
                                <h4><?php echo esc_html($db_check['message']); ?></h4>

                                <?php if ($db_check['can_optimize']): ?>
                                    <?php if ($db_check['is_mariadb']): ?>
                                        <p><?php echo esc_html(sprintf(
                                            
                                            __('MariaDB %s detected! You can optimize your database indexes for maximum performance.', 'ai-eshop-optimizer'),
                                            $db_check['version_number'] ?? '11.4+'
                                        )); ?>
                                        </p>
                                        <p><strong><?php esc_html_e('Benefits:', 'ai-eshop-optimizer'); ?></strong></p>
                                        <ul style="margin-left: 20px;">
                                            <li><?php esc_html_e('90%+ faster customer statistics calculations', 'ai-eshop-optimizer'); ?>
                                            </li>
                                            <li><?php esc_html_e('60%+ faster product statistics', 'ai-eshop-optimizer'); ?>
                                            </li>
                                            <li><?php esc_html_e('Optimized window functions (ROW_NUMBER, PARTITION BY)', 'ai-eshop-optimizer'); ?>
                                            </li>
                                            <li><?php esc_html_e('Better query planning with persistent statistics', 'ai-eshop-optimizer'); ?>
                                            </li>
                                        </ul>
                                    <?php else: ?>
                                        <p><?php echo esc_html(sprintf(
                                            
                                            __('MySQL %s detected! You can optimize your database indexes for maximum performance.', 'ai-eshop-optimizer'),
                                            $db_check['version_number'] ?? '8.0+'
                                        )); ?>
                                        </p>
                                        <p><strong><?php esc_html_e('Benefits:', 'ai-eshop-optimizer'); ?></strong></p>
                                        <ul style="margin-left: 20px;">
                                            <li><?php esc_html_e('65%+ faster customer statistics calculations', 'ai-eshop-optimizer'); ?>
                                            </li>
                                            <li><?php esc_html_e('50%+ faster product statistics', 'ai-eshop-optimizer'); ?>
                                            </li>
                                            <li><?php esc_html_e('Histogram-based query optimization (MySQL 8 exclusive)', 'ai-eshop-optimizer'); ?>
                                            </li>
                                            <li><?php esc_html_e('Descending indexes for recent-data queries', 'ai-eshop-optimizer'); ?>
                                            </li>
                                            <li><?php esc_html_e('Improved hash join and CTE performance', 'ai-eshop-optimizer'); ?>
                                            </li>
                                        </ul>
                                    <?php endif; ?>
                                    <div class="aieo-cellsubmit">
                                        <button type="button" id="aieo-optimize-db-button"
                                            class="aieo-button button-primary aieo-button-setup aieo-center-content">
                                            <?php esc_html_e('Optimize Database Indexes', 'ai-eshop-optimizer'); ?>
                                        </button>
                                    </div>
                                    <div id="aieo-optimize-db-status" style="margin-top: 10px; display: none;"></div>

                                    <div id="aieo-index-stats" style="margin-top: 15px; display: none;">
                                        <h4><?php esc_html_e('Current Index Status:', 'ai-eshop-optimizer'); ?></h4>
                                        <div class="aieo-cellsubmit">
                                            <button type="button" id="aieo-show-indexes-button"
                                                class="aieo-button button-primary aieo-button-setup aieo-center-content">
                                                <?php esc_html_e('Show Current Indexes', 'ai-eshop-optimizer'); ?>
                                            </button>
                                        </div>

                                        <div id="aieo-indexes-list" style="margin-top: 10px;"></div>
                                    </div>

                                    <script>
                                        jQuery(document).ready(function ($) {
                                            // Toggle category sales period dropdown based on checkbox
                                            $('#aieo_display_categories_by_sales').on('change', function() {
                                                if ($(this).is(':checked')) {
                                                    $('#aieo_category_sales_period_row').slideDown();
                                                } else {
                                                    $('#aieo_category_sales_period_row').slideUp();
                                                }
                                            });

                                            // Optimize Database Button
                                            $('#aieo-optimize-db-button').on('click', function () {
                                                var $button = $(this);
                                                var $status = $('#aieo-optimize-db-status');

                                                $button.prop('disabled', true).text('<?php echo esc_js(__('Optimizing...', 'ai-eshop-optimizer')); ?>');
                                                $status.show().html('<p><?php echo esc_js(__('Please wait, optimizing database indexes...', 'ai-eshop-optimizer')); ?></p>');

                                                $.ajax({
                                                    url: ajaxurl,
                                                    type: 'POST',
                                                    data: {
                                                        action: 'aieo_optimize_database',
                                                        nonce: '<?php echo esc_attr(wp_create_nonce('aieo_optimize_db')); ?>'
                                                    },
                                                    success: function (response) {
                                                        if (response.success) {
                                                            $status.html('<div style="color: green;"><strong><?php echo esc_js(__('✓ Success!', 'ai-eshop-optimizer')); ?></strong><br>' + response.data.message + '</div>');
                                                            if (response.data.details) {
                                                                var detailsHtml = '<ul style="margin-left: 20px; margin-top: 10px;">';
                                                                response.data.details.forEach(function (detail) {
                                                                    detailsHtml += '<li>' + detail + '</li>';
                                                                });
                                                                detailsHtml += '</ul>';
                                                                $status.append(detailsHtml);
                                                            }
                                                            $('#aieo-index-stats').show();
                                                            $button.text('<?php echo esc_js(__('✓ Optimization Complete', 'ai-eshop-optimizer')); ?>').css('background-color', '#46b450');
                                                        } else {
                                                            $status.html('<div style="color: red;"><strong><?php echo esc_js(__('✗ Error:', 'ai-eshop-optimizer')); ?></strong> ' + response.data.message + '</div>');
                                                            $button.prop('disabled', false).text('<?php echo esc_js(__('Retry Optimization', 'ai-eshop-optimizer')); ?>');
                                                        }
                                                    },
                                                    error: function () {
                                                        $status.html('<div style="color: red;"><strong><?php echo esc_js(__('✗ Error:', 'ai-eshop-optimizer')); ?></strong> <?php echo esc_js(__('Failed to communicate with server', 'ai-eshop-optimizer')); ?></div>');
                                                        $button.prop('disabled', false).text('<?php echo esc_js(__('Retry Optimization', 'ai-eshop-optimizer')); ?>');
                                                    }
                                                });
                                            });

                                            // Show Indexes Button
                                            $('#aieo-show-indexes-button').on('click', function () {
                                                var $button = $(this);
                                                var $list = $('#aieo-indexes-list');

                                                $button.prop('disabled', true).text('<?php echo esc_js(__('Loading...', 'ai-eshop-optimizer')); ?>');

                                                $.ajax({
                                                    url: ajaxurl,
                                                    type: 'POST',
                                                    data: {
                                                        action: 'aieo_get_index_stats',
                                                        nonce: '<?php echo esc_attr(wp_create_nonce('aieo_get_indexes')); ?>'
                                                    },
                                                    success: function (response) {
                                                        if (response.success && response.data.indexes) {
                                                            var html = '<table style="width: 100%; border-collapse: collapse; margin-top: 10px;">';
                                                            html += '<tr style="background: #f0f0f0;"><th style="padding: 8px; text-align: left;">Index Name</th><th style="padding: 8px; text-align: left;">Columns</th><th style="padding: 8px; text-align: left;">Comment</th></tr>';
                                                            response.data.indexes.forEach(function (idx) {
                                                                html += '<tr style="border-bottom: 1px solid #ddd;">';
                                                                html += '<td style="padding: 8px;"><code>' + idx.index_name + '</code></td>';
                                                                html += '<td style="padding: 8px;">' + idx.columns + '</td>';
                                                                html += '<td style="padding: 8px; font-size: 0.9em;">' + (idx.comment || '-') + '</td>';
                                                                html += '</tr>';
                                                            });
                                                            html += '</table>';
                                                            $list.html(html);
                                                            $button.text('<?php echo esc_js(__('Refresh Indexes', 'ai-eshop-optimizer')); ?>');
                                                        } else {
                                                            $list.html('<p><?php echo esc_js(__('No indexes found or error loading data.', 'ai-eshop-optimizer')); ?></p>');
                                                            $button.text('<?php echo esc_js(__('Retry', 'ai-eshop-optimizer')); ?>');
                                                        }
                                                        $button.prop('disabled', false);
                                                    },
                                                    error: function () {
                                                        $list.html('<p style="color: red;"><?php echo esc_js(__('Error loading index information.', 'ai-eshop-optimizer')); ?></p>');
                                                        $button.prop('disabled', false).text('<?php echo esc_js(__('Retry', 'ai-eshop-optimizer')); ?>');
                                                    }
                                                });
                                            });

                                            // Fix Collation Button
                                            $('#aieo-fix-collation-button').on('click', function () {
                                                var $button = $(this);
                                                var $status = $('#aieo-collation-status');

                                                if (!confirm('This will standardize collations for WordPress core tables and plugin tables used in queries. This is safe but may take a few moments. Continue?')) {
                                                    return;
                                                }

                                                $button.prop('disabled', true).text('<?php echo esc_js(__('Fixing Collations...', 'ai-eshop-optimizer')); ?>');
                                                $status.show().html('<p><?php echo esc_js(__('Please wait, standardizing collations...', 'ai-eshop-optimizer')); ?></p>');

                                                $.ajax({
                                                    url: ajaxurl,
                                                    type: 'POST',
                                                    data: {
                                                        action: 'aieo_fix_collations',
                                                        nonce: '<?php echo esc_attr(wp_create_nonce('aieo_fix_collation')); ?>'
                                                    },
                                                    success: function (response) {
                                                        if (response.success) {
                                                            $status.html('<div style="color: green;"><strong><?php echo esc_js(__('✓ Success!', 'ai-eshop-optimizer')); ?></strong><br>' + response.data.message + '</div>');
                                                            if (response.data.details && response.data.details.length > 0) {
                                                                var detailsHtml = '<div style="max-height: 300px; overflow-y: auto; margin-top: 10px; border: 1px solid #ddd; padding: 10px;"><ul style="margin: 0;">';
                                                                response.data.details.forEach(function (detail) {
                                                                    detailsHtml += '<li style="font-size: 0.9em;">' + detail + '</li>';
                                                                });
                                                                detailsHtml += '</ul></div>';
                                                                $status.append(detailsHtml);
                                                            }
                                                            $button.text('<?php echo esc_js(__('✓ Collation Fix Complete', 'ai-eshop-optimizer')); ?>').css('background-color', '#46b450');
                                                        } else {
                                                            $status.html('<div style="color: red;"><strong><?php echo esc_js(__('✗ Error:', 'ai-eshop-optimizer')); ?></strong> ' + response.data.message + '</div>');
                                                            if (response.data.details) {
                                                                var detailsHtml = '<ul style="margin-left: 20px; margin-top: 10px;">';
                                                                response.data.details.forEach(function (detail) {
                                                                    detailsHtml += '<li>' + detail + '</li>';
                                                                });
                                                                detailsHtml += '</ul>';
                                                                $status.append(detailsHtml);
                                                            }
                                                            $button.prop('disabled', false).text('<?php echo esc_js(__('Retry Collation Fix', 'ai-eshop-optimizer')); ?>');
                                                        }
                                                    },
                                                    error: function () {
                                                        $status.html('<div style="color: red;"><strong><?php echo esc_js(__('✗ Error:', 'ai-eshop-optimizer')); ?></strong> <?php echo esc_js(__('Failed to communicate with server', 'ai-eshop-optimizer')); ?></div>');
                                                        $button.prop('disabled', false).text('<?php echo esc_js(__('Retry Collation Fix', 'ai-eshop-optimizer')); ?>');
                                                    }
                                                });
                                            });
                                        });
                                    </script>

                                    <!-- Collation Fix Section -->
                                    <div style="margin-top: 25px; padding-top: 20px; border-top: 2px solid #ddd;">
                                        <h4><?php esc_html_e('Database Collation Standardization', 'ai-eshop-optimizer'); ?>
                                        </h4>
                                        <p><?php esc_html_e('If you\'re experiencing "Illegal mix of collations" errors, use this tool to standardize all text columns to utf8mb4_unicode_ci.', 'ai-eshop-optimizer'); ?>
                                        </p>
                                        <p><strong><?php esc_html_e('What it does:', 'ai-eshop-optimizer'); ?></strong></p>
                                        <ul style="margin-left: 20px;">
                                            <li><?php esc_html_e('Scans WordPress core tables (posts, terms, taxonomy, etc.)', 'ai-eshop-optimizer'); ?>
                                            </li>
                                            <li><?php esc_html_e('Scans all plugin tables', 'ai-eshop-optimizer'); ?></li>
                                            <li><?php esc_html_e('Converts VARCHAR/TEXT columns to utf8mb4_unicode_ci collation', 'ai-eshop-optimizer'); ?>
                                            </li>
                                            <li><?php esc_html_e('Prevents collation mismatch errors in stored procedures', 'ai-eshop-optimizer'); ?>
                                            </li>
                                        </ul>
                                        <div class="aieo-cellsubmit">
                                            <button type="button" id="aieo-fix-collation-button"
                                                class="aieo-button button-secondary aieo-button-setup aieo-center-content"
                                                style="background-color: #2271b1;">
                                                <?php esc_html_e('Fix Database Collations', 'ai-eshop-optimizer'); ?>
                                            </button>
                                        </div>
                                        <div id="aieo-collation-status" style="margin-top: 10px; display: none;"></div>
                                    </div>

                                <?php elseif ($db_check['is_mariadb']): ?>
                                    <p><?php esc_html_e('You are running MariaDB', 'ai-eshop-optimizer'); ?>
                                        <?php echo esc_html($db_check['version_number'] ?? 'Unknown'); ?>.
                                    </p>
                                    <p><?php esc_html_e('For optimal performance, consider upgrading to MariaDB 11.4 or higher.', 'ai-eshop-optimizer'); ?>
                                    </p>
                                <?php else: ?>
                                    <p><?php esc_html_e('You are running MySQL. These optimizations are specifically designed for MariaDB 11.4+.', 'ai-eshop-optimizer'); ?>
                                    </p>
                                    <p><?php esc_html_e('Consider migrating to MariaDB for better performance features.', 'ai-eshop-optimizer'); ?>
                                    </p>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

            <div class="aieo-modules-box" id="aieo-card-orders-export">
                <div class="aieo-modules-box-heading">
                    <?php esc_html_e('Superfast Export of your Orders', 'ai-eshop-optimizer'); ?>
                </div>
                <div class="aieo-modules-list">

                    <div class="aieo-modules-list-item-action">
                        <div class="aieo-modules-list-item-icon-action">
                            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="16" viewBox="0 0 20 16">
                                <path
                                    d="M12.5 8c0 1.654-1.122 3-2.5 3S7.5 9.654 7.5 8 8.622 5 10 5s2.5 1.346 2.5 3Zm7.5-.449S16.457 16 10.012 16C4.03 16 0 7.551 0 7.551S3.705 0 10.012 0C16.424 0 20 7.551 20 7.551ZM14.167 8c0-2.757-1.87-5-4.167-5-2.298 0-4.167 2.243-4.167 5s1.87 5 4.167 5c2.297 0 4.167-2.243 4.167-5Z">
                                </path>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-privacy-first">
                                <?php esc_html_e('Privacy first!', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('Our optimization algorithm may carry out semantic/textual analysis on the titles of your products or product variations, and could also consider their pricing when suggesting up-sells and cross-sells.', 'ai-eshop-optimizer'); ?>
                                </br></br><?php esc_html_e('However, you have the option to exclude product titles and prices from this analysis. Despite these omissions, our robust algorithm can still offer highly relevant recommendations!', 'ai-eshop-optimizer'); ?>
                                </br></br>
                                <div><label><input type="checkbox" id="aieo_include_text" name="aieo_include_text"
                                            value="1" <?php checked(get_option('aieo_include_text', '1'), '1'); ?>><?php esc_html_e('Please include product\categories\tags text', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="aieo_include_attributes"
                                            name="aieo_include_attributes" value="1" <?php checked(get_option('aieo_include_attributes', '1'), '1'); ?>><?php esc_html_e('Please include product brand, colour, size and principal subcategory hierarchy', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label class="aieo-soon"><input type="checkbox" id="aieo_include_full_text"
                                            name="aieo_include_full_text" value="1" <?php checked(get_option('aieo_include_full_text', '0'), '1'); ?>
                                            disabled="disabled"><?php esc_html_e('Please include the full text for sentiment analysis', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="aieo_include_price" name="aieo_include_price"
                                            value="1" <?php checked(get_option('aieo_include_price', '1'), '1'); ?>><?php esc_html_e('Please include product price data', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="aieo_variations_choice"
                                            name="aieo_variations_choice" value="1" <?php checked(get_option('aieo_variations_choice', '1'), '1'); ?>><?php esc_html_e('Please base the computations on the parent (not variation) products', 'ai-eshop-optimizer'); ?></label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="aieo-modules-list-item-action">
                        <div class="aieo-modules-list-item-icon-action">
                            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
                                <path
                                    d="M1.493 2.879C3.757 2.562 6.757 1.616 9.128.233a1.733 1.733 0 0 1 1.728-.004c2.369 1.354 5.502 2.29 7.65 2.628.818.128 1.491.81 1.491 1.638v.501c.031 6.043-.48 11.332-9.472 14.903a1.45 1.45 0 0 1-1.062 0C.478 16.328-.029 11.04.001 4.996L0 4.499c-.002-.83.672-1.505 1.493-1.62Zm9.214 6.414a1 1 0 1 0-1.414 1.414 1 1 0 0 0 1.414-1.414Zm-4 0a1 1 0 1 0-1.414 1.414 1 1 0 0 0 1.414-1.414Zm8 0a1 1 0 1 0-1.414 1.414 1 1 0 0 0 1.414-1.414Z">
                                </path>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-repeat-customers">
                                <?php esc_html_e('Consider Repeat Registered Customers', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('We track whether a purchase has been made by a guest or a registered user.', 'ai-eshop-optimizer'); ?></br><?php esc_html_e('We also offer the option to adjust based on the preferences of customers who\'ve chosen to register on your e-shop.', 'ai-eshop-optimizer'); ?>
                                </br></br><?php esc_html_e('You can choose not to provide the user ID, but we\'ll still distinguish between guest and registered user purchases.', 'ai-eshop-optimizer'); ?>
                                <div class="aieo-pro">
                                    <?php esc_html_e('The pro-version provides you with option to apply more weight to the choices made by your most loyal customers', 'ai-eshop-optimizer'); ?>
                                </div>
                                </br>
                                <div><label><input type="checkbox" id="aieo_include_eponymous"
                                            name="aieo_include_eponymous" value="1" <?php checked(get_option('aieo_include_eponymous', '1'), '1'); ?>><?php esc_html_e('Please include (anonymous) customer IDs', 'ai-eshop-optimizer'); ?></label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="aieo-modules-list-item-action">
                        <div class="aieo-modules-list-item-icon-action">
                            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
                                <path
                                    d="M1.493 2.879C3.757 2.562 6.757 1.616 9.128.233a1.733 1.733 0 0 1 1.728-.004c2.369 1.354 5.502 2.29 7.65 2.628.818.128 1.491.81 1.491 1.638v.501c.031 6.043-.48 11.332-9.472 14.903a1.45 1.45 0 0 1-1.062 0C.478 16.328-.029 11.04.001 4.996L0 4.499c-.002-.83.672-1.505 1.493-1.62Zm9.214 6.414a1 1 0 1 0-1.414 1.414 1 1 0 0 0 1.414-1.414Zm-4 0a1 1 0 1 0-1.414 1.414 1 1 0 0 0 1.414-1.414Zm8 0a1 1 0 1 0-1.414 1.414 1 1 0 0 0 1.414-1.414Z">
                                </path>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-product-choices">
                                <?php esc_html_e('Account for Product Choices based Brand, Sizes, Colours & Seasonality', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('You have the flexibility to adjust for seasonality by defining an optimal timeframe centered around the current date.', 'ai-eshop-optimizer'); ?>
                                <div class="aieo-pro">
                                    <?php esc_html_e('The pro version offers season-specific recommendations based on your selected duration, granted there are enough data points. Furthermore, we aim to provide consistent, automatic updates in the future.', 'ai-eshop-optimizer'); ?>
                                </div>
                                </br>

                                <div class="aieo-table">
                                    <div class="aieo-row">
                                        <div class="aieo-cell aieo-description">
                                            <?php esc_html_e('Vendor attribute slug', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="text" id="aieo_core_attribute_vendor"
                                                name="aieo_core_attribute_vendor"
                                                placeholder="<?php esc_attr_e('pa_vendor', 'ai-eshop-optimizer'); ?>"
                                                value="<?php echo esc_attr(get_option('aieo_core_attribute_vendor')); ?>"
                                                required>
                                        </div>
                                    </div>
                                    <div class="aieo-row">
                                        <div class="aieo-cell aieo-description">
                                            <?php esc_html_e('Brand attribute slug', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="text" id="aieo_core_attribute_brands"
                                                name="aieo_core_attribute_brands"
                                                placeholder="<?php esc_attr_e('product_brand', 'ai-eshop-optimizer'); ?>"
                                                value="<?php echo esc_attr(get_option('aieo_core_attribute_brands')); ?>"
                                                required>
                                        </div>
                                    </div>
                                    <div class="aieo-row">
                                        <div class="aieo-cell aieo-description">
                                            <?php esc_html_e('Size attribute slugs', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="text" id="aieo_core_attribute_size"
                                                name="aieo_core_attribute_size"
                                                placeholder="<?php esc_attr_e('pa_size,pa_fit', 'ai-eshop-optimizer'); ?>"
                                                value="<?php echo esc_attr(get_option('aieo_core_attribute_size')); ?>">
                                        </div>
                                    </div>
                                    <div class="aieo-row">
                                        <div class="aieo-cell aieo-description">
                                            <?php esc_html_e('Colour attribute slugs', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="text" id="aieo_core_attribute_color"
                                                name="aieo_core_attribute_color"
                                                placeholder="<?php esc_attr_e('pa_color,pa_colour', 'ai-eshop-optimizer'); ?>"
                                                value="<?php echo esc_attr(get_option('aieo_core_attribute_color')); ?>">
                                        </div>
                                    </div>
                                    <div class="aieo-row">
                                        <div class="aieo-cell aieo-description">
                                            <?php esc_html_e('Need attribute slug', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="text" id="aieo_core_attribute_need"
                                                name="aieo_core_attribute_need"
                                                placeholder="<?php esc_attr_e('pa_need', 'ai-eshop-optimizer'); ?>"
                                                value="<?php echo esc_attr(get_option('aieo_core_attribute_need', 'pa_need')); ?>">
                                        </div>
                                    </div>

                                </div>
                                <br>
                                <div><label><input type="checkbox" id="aieo_include_reciprocity"
                                            name="aieo_include_reciprocity" value="1" <?php checked(get_option('aieo_include_reciprocity', '0'), '1'); ?>><?php esc_html_e('Yes, consider reciprocal/replacement products', 'ai-eshop-optimizer'); ?></label>
                                </div>

                                <br>
                                <div><label><input type="checkbox" id="aieo_include_seasonality"
                                            name="aieo_include_seasonality" value="1" <?php checked(get_option('aieo_include_seasonality', '0'), '1'); ?>><?php esc_html_e('Yes, I am interested in adjusting recommendations based on orders and product seasonality, category, size, color and brand', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div class="aieo-table">
                                    <div class="aieo-row aieo-seasonality-settings-row">
                                        <div class="aieo-cell aieo-description">
                                            <?php echo wp_kses_post(__('Consideration period <i>before</i> current date (in days)', 'ai-eshop-optimizer')); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="number" id="aieo_season_days_past" name="aieo_season_days_past"
                                                placeholder="15"
                                                value="<?php echo esc_attr(get_option('aieo_season_days_past')); ?>">
                                        </div>
                                    </div>
                                    <div class="aieo-row aieo-seasonality-settings-row">
                                        <div class="aieo-cell aieo-description">
                                            <?php echo wp_kses_post(__('Consideration period <i>after</i> current date (in days)', 'ai-eshop-optimizer')); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="number" id="aieo_season_days_after"
                                                name="aieo_season_days_after" placeholder="60"
                                                value="<?php echo esc_attr(get_option('aieo_season_days_after')); ?>">
                                        </div>
                                    </div>

                                </div>
                                <div class="aieo-seasonality-settings-row"><label><input type="checkbox"
                                            id="aieo_include_restricted_seasonality"
                                            name="aieo_include_restricted_seasonality" value="1" <?php checked(get_option('aieo_include_restricted_seasonality', '0'), '1'); ?>><?php esc_html_e('Recommend based on the products sold during the specified time frame, but consider the overall shopping behaviour of the customers', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div class="aieo-seasonality-settings-row"><label><input type="checkbox"
                                            id="aieo_instore_anonymous" name="aieo_instore_anonymous" value="1" <?php checked(get_option('aieo_instore_anonymous', '0'), '1'); ?>><?php esc_html_e('Consider the shopping behaviour of anonymous in-store customers', 'ai-eshop-optimizer'); ?></label>
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="aieo-modules-list-item-action">
                        <div class="aieo-modules-list-item-icon-action">
                            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
                                <path
                                    d="M1.493 2.879C3.757 2.562 6.757 1.616 9.128.233a1.733 1.733 0 0 1 1.728-.004c2.369 1.354 5.502 2.29 7.65 2.628.818.128 1.491.81 1.491 1.638v.501c.031 6.043-.48 11.332-9.472 14.903a1.45 1.45 0 0 1-1.062 0C.478 16.328-.029 11.04.001 4.996L0 4.499c-.002-.83.672-1.505 1.493-1.62Zm9.214 6.414a1 1 0 1 0-1.414 1.414 1 1 0 0 0 1.414-1.414Zm-4 0a1 1 0 1 0-1.414 1.414 1 1 0 0 0 1.414-1.414Zm8 0a1 1 0 1 0-1.414 1.414 1 1 0 0 0 1.414-1.414Z">
                                </path>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-operational-efficiency">
                                <?php esc_html_e('Operational Efficiency Settings', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('By leveraging Stored Procedures, we can achieve an export rate of approximately 100,000 order items per minute. Ideally, all the boxes should be checked for optimal functionality.', 'ai-eshop-optimizer'); ?>
                                </br><?php esc_html_e('However, you have the autonomy to adjust settings; for instance, you might choose to initially process your orders before running aggregate statistics or forgo the more resource-intensive step of rebuilding the product table (which handles about 10,000 variable products per minute).', 'ai-eshop-optimizer'); ?></br></br>

                                <?php if (false): ?>
                                    <div
                                        style="background: #fff3cd; border: 1px solid #ffc107; padding: 10px; margin: 10px 0; font-family: monospace; font-size: 11px;">
                                        <strong>DEBUG - What server sees:</strong><br>
                                        <?php
                                        global $wpdb;
                                        $raw_sql = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name IN ('aieo_create_attributes', 'aieo_create_catalogue', 'aieo_create_orders', 'aieo_erp_merge_orders')");
                                        echo "<strong style='color: red;'>RAW DATABASE (bypassing cache):</strong><br>";
                                        foreach ($raw_sql as $row) {
                                            echo esc_html($row->option_name) . ' = ' . esc_html($row->option_value) . '<br>';
                                        }
                                        echo "<br><strong style='color: blue;'>VIA get_option():</strong><br>";
                                        ?>
                                        create_attributes =
                                        <?php echo esc_html(get_option('aieo_create_attributes', '0')); ?>
                                        (<?php echo get_option('aieo_create_attributes', '0') === '1' ? 'CHECKED' : 'unchecked'; ?>)<br>
                                        create_catalogue = <?php echo esc_html(get_option('aieo_create_catalogue', '0')); ?>
                                        (<?php echo get_option('aieo_create_catalogue', '0') === '1' ? 'CHECKED' : 'unchecked'; ?>)<br>
                                        create_orders = <?php echo esc_html(get_option('aieo_create_orders', '0')); ?>
                                        (<?php echo get_option('aieo_create_orders', '0') === '1' ? 'CHECKED' : 'unchecked'; ?>)<br>
                                        erp_merge_orders = <?php echo esc_html(get_option('aieo_erp_merge_orders', '0')); ?>
                                        (<?php echo get_option('aieo_erp_merge_orders', '0') === '1' ? 'CHECKED' : 'unchecked'; ?>)<br>
                                        Page generated: <?php echo esc_html(gmdate('Y-m-d H:i:s')); ?>
                                    </div>
                                <?php endif; ?>

                                <?php esc_html_e('Your available options are:', 'ai-eshop-optimizer'); ?>
                                <div class="aieo-checkbox-controls">
                                    <a href="#" id="aieo-select-all" class="button-link"><?php esc_html_e('Select all', 'ai-eshop-optimizer'); ?></a> |
                                    <a href="#" id="aieo-deselect-all" class="button-link"><?php esc_html_e('Deselect all', 'ai-eshop-optimizer'); ?></a>
                                </div>
                                <div><label><input type="checkbox" id="create_attributes" name="aieo_create_attributes"
                                            value="1" <?php checked(get_option('aieo_create_attributes', '0'), '1'); ?>><?php esc_html_e('Please recreate the product core attributes and principal categories', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="create_needs" name="aieo_create_needs" value="1"
                                            <?php checked(get_option('aieo_create_needs', '0'), '1'); ?>><?php esc_html_e('Please populate product vitals with stated needs', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="create_catalogue" name="aieo_create_catalogue"
                                            value="1" <?php checked(get_option('aieo_create_catalogue', '0'), '1'); ?>><?php esc_html_e('Please recreate the full product catalogue', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="process_eshop_orders" name="aieo_create_orders"
                                            value="1" <?php checked(get_option('aieo_create_orders', '0'), '1'); ?>><?php esc_html_e('Please process and transform the eshop orders to the required format', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="process_instore_orders"
                                            name="aieo_erp_consolidation" value="1" <?php checked(get_option('aieo_erp_consolidation', '0'), '1'); ?>><?php esc_html_e('Please process and transform the in-store orders to the required format', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="merge_orders" name="aieo_erp_merge_orders"
                                            value="1" <?php checked(get_option('aieo_erp_merge_orders', '0'), '1'); ?>><?php esc_html_e('Please merge in-store orders with the eshop orders for further analysis', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="include_unsold" name="aieo_include_unsold"
                                            value="1" <?php checked(get_option('aieo_include_unsold', '0'), '1'); ?>><?php esc_html_e('Please include products that have no sales', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="aggregate_product_stats"
                                            name="aieo_include_aggregate_stats" value="1" <?php checked(get_option('aieo_include_aggregate_stats', '0'), '1'); ?>><?php esc_html_e('Please include aggregate statistics for products', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="aggregate_category_brand_stats"
                                            name="aieo_include_aggregate_category_brand_stats" value="1" <?php checked(get_option('aieo_include_aggregate_category_brand_stats', '0'), '1'); ?>><?php esc_html_e('Please include aggregate statistics per product categories and brands', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="aggregate_customer_std_stats"
                                            name="aieo_include_aggregate_cust_std_stats" value="1" <?php checked(get_option('aieo_include_aggregate_cust_std_stats', '0'), '1'); ?>><?php echo wp_kses_post(__('Please include aggregate statistics for customers <span style="color: #d63638; font-size: 0.9em;">(⚠ Slow for large datasets with many customers)</span>', 'ai-eshop-optimizer')); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="aggregate_customer_adv_stats"
                                            name="aieo_include_aggregate_cust_adv_stats" value="1" <?php checked(get_option('aieo_include_aggregate_cust_adv_stats', '0'), '1'); ?>><?php echo wp_kses_post(__('Please include aggregate advanced statistics for customer behaviour <span style="color: #d63638; font-size: 0.9em;">(⚠ Very slow for large datasets - may take several minutes)</span>', 'ai-eshop-optimizer')); ?></label>
                                </div>

                                <div><label><input type="checkbox" id="create_uuids" name="aieo_create_uuids" value="1"
                                            <?php checked(get_option('aieo_create_uuids', '0'), '1'); ?>><?php esc_html_e('Please create locally the UUIDs for the GraphDB\'s nodes & edges', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="create_need_suggestions" name="aieo_create_need_suggestions" value="1"
                                            <?php checked(get_option('aieo_create_need_suggestions', '0'), '1'); ?>><?php esc_html_e('Please generate products with the same needs', 'ai-eshop-optimizer'); ?></label>
                                </div>
                                <div><label><input type="checkbox" id="create_export" name="aieo_create_export"
                                            value="1" <?php checked(get_option('aieo_create_export', '0'), '1'); ?>><?php esc_html_e('Produce the export table/CSV', 'ai-eshop-optimizer'); ?></label>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="aieo-modules-list-item-action">
                        <div class="aieo-modules-list-item-icon-action">
                            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
                                <path
                                    d="M0 1.5A1.5 1.5 0 0 1 1.5 0h17A1.5 1.5 0 0 1 20 1.5v6A1.5 1.5 0 0 1 18.5 9h-5.889a1.5 1.5 0 0 1-1.5-1.5V5.111a1.111 1.111 0 1 0-2.222 0V7.5a1.5 1.5 0 0 1-1.5 1.5H1.5A1.5 1.5 0 0 1 0 7.5v-6Z">
                                </path>
                                <path
                                    d="M7 5a3 3 0 0 1 6 0v4.384a.5.5 0 0 0 .356.479l2.695.808a2.5 2.5 0 0 1 1.756 2.748l-.633 4.435A2.5 2.5 0 0 1 14.699 20H6.96a2.5 2.5 0 0 1-2.27-1.452l-2.06-4.464a2.417 2.417 0 0 1-.106-1.777c.21-.607.719-1.16 1.516-1.273 1.035-.148 2.016.191 2.961.82V5Zm3-1a1 1 0 0 0-1 1v7.793c0 1.39-1.609 1.921-2.527 1.16-.947-.784-1.59-.987-2.069-.948a.486.486 0 0 0 .042.241l2.06 4.463A.5.5 0 0 0 6.96 18h7.74a.5.5 0 0 0 .494-.43l.633-4.434a.5.5 0 0 0-.35-.55l-2.695-.808A2.5 2.5 0 0 1 11 9.384V5a1 1 0 0 0-1-1Z">
                                </path>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-dataset-start">
                                <?php esc_html_e('Specify Your Dataset\'s Starting Point', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('Designate a starting point for your order export file, bypassing initial or demo orders.', 'ai-eshop-optimizer'); ?>

                                <input type="hidden" name="action" value="eshop_optimizer_handle_export_orders">

                                <div class="aieo-table">
                                    <div class="aieo-row">
                                        <div class="aieo-cell aieo-description">
                                            <?php esc_html_e('Set initial Order ID', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="number" id="aieo_order_id" name="aieo_order_id"
                                                placeholder="<?php esc_attr_e('Set initial Order ID', 'ai-eshop-optimizer'); ?>"
                                                value="<?php echo esc_attr(get_option('aieo_order_id')); ?>" required>
                                        </div>
                                    </div>
                                    <div class="aieo-row">
                                        <div class="aieo-cell aieo-description">
                                            <?php esc_html_e('Maximum Number of Records', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div class="aieo-cell aieo-input">
                                            <input type="number" id="aieo_max_records" name="aieo_max_records"
                                                placeholder="<?php esc_attr_e('Maximum Number of Records', 'ai-eshop-optimizer'); ?>"
                                                value="<?php echo esc_attr(get_option('aieo_max_records')); ?>"
                                                required>
                                        </div>
                                    </div>
                                </div>

                                <div class="aieo-cellsubmit">
                                    <button type="button" id="aieo-save-settings-button"
                                        class="aieo-button button-secondary"><?php esc_html_e('Save Settings', 'ai-eshop-optimizer'); ?></button>
                                </div>
                                <div class="aieo-cellsubmit" id="analyze-data-section">
                                    <button type="button" id="aieo-export-start-button"
                                        class="aieo-button button-primary aieo-button-optimal"><?php esc_html_e('Save Settings & Analyze Data', 'ai-eshop-optimizer'); ?></button>
                                </div>

                                <div id="aieo-save-message" style="margin-top: 10px; padding: 10px; display: none;">
                                </div>
                                </form>

                                <!-- Export Progress Container -->
                                <div id="aieo-export-progress-container" style="display: none; margin-top: 30px;">
                                    <h3><?php esc_html_e('Export Progress', 'ai-eshop-optimizer'); ?></h3>

                                    <div class="aieo-progress-wrapper">
                                        <div class="aieo-progress-bar-container">
                                            <div id="aieo-export-progress-bar" class="aieo-progress-bar"></div>
                                            <span id="aieo-export-progress-text" class="aieo-progress-text">0%</span>
                                        </div>
                                    </div>

                                    <div id="aieo-export-current-stage" class="aieo-current-stage">
                                        <?php esc_html_e('Initializing...', 'ai-eshop-optimizer'); ?>
                                    </div>

                                    <div id="aieo-export-log-container" class="aieo-log-container">
                                        <h4><?php esc_html_e('Processing Log:', 'ai-eshop-optimizer'); ?></h4>
                                        <div id="aieo-export-log" class="aieo-log"></div>
                                    </div>
                                </div>

                                <?php
                                
                                $allowed_html_tags = array(
                                    'a' => array(
                                        'href' => array(),
                                        'title' => array(),
                                        'class' => array(),
                                        'style' => array(),
                                    ),
                                    'br' => array(),
                                );
                                $csv_info = get_option('aieo_last_export_csv', array());
                                $file_path = isset($csv_info['path']) ? $csv_info['path'] : '';
                                $download_url = isset($csv_info['url']) ? $csv_info['url'] : '';
                                $filename = isset($csv_info['filename']) ? $csv_info['filename'] : '';
                                $downloadfilemessage = '';
                                if ($download_url && $filename) {
                                    $downloadfilemessage = sprintf(
                                        
                                        __('The orders file has been created!!!</br>Download:</br><a href="%1$s">%2$s</a>', 'ai-eshop-optimizer'),
                                        esc_url($download_url),
                                        esc_html($filename)
                                    );
                                }
                                ?>
                            </div>
                        </div>
                    </div>
                    <?php
                    
                    
                    echo '<div id="aieo-download-section-container" style="display: ' . ($file_path && file_exists($file_path) ? 'block' : 'none') . ';">';

                    if ($file_path && file_exists($file_path)) {

                        echo '<div class="aieo-modules-list-item-support">
                        <div class="aieo-modules-list-item-icon-support">
                        <svg id="glipy_copy_4" data-name="glipy copy 4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><title>1</title><path d="M32,2A30,30,0,1,0,62,32,30.03657,30.03657,0,0,0,32,2ZM38.45,48.13a.717.717,0,0,1-.72.72H26.28a.71492.71492,0,0,1-.71-.72V45.27a.7151.7151,0,0,1,1.43,0v2.15H37.02V45.27a.715.715,0,1,1,1.43,0Zm-4.8-5.51a.695.695,0,0,1,1.01,0,.71226.71226,0,0,1,0,1.01l-2.14,2.15a.74336.74336,0,0,1-1.02,0l-2.15-2.15a.71773.71773,0,0,1,1.02-1.01l.92.92V32.39a.715.715,0,0,1,1.43,0V43.54Zm9.48-4.44-8.97-.04V32.39a2.15013,2.15013,0,0,0-4.3,0v5.74L18.3,38.08a6.361,6.361,0,0,1-1.41-12.55.86162.86162,0,0,0,.26-.34A6.70364,6.70364,0,0,1,28.67,23.1a.71653.71653,0,0,0,1.01.11c1.13-1.05-2.07-2.93-2.9-3.29a6.69654,6.69654,0,0,1,13.11,1.92.715.715,0,0,0,1.43,0,7.83085,7.83085,0,0,0-.12-1.29,8.9141,8.9141,0,0,1,1.93-.21C54.96,20.83,54.95,37.69,43.13,38.18Z"/></svg>
                        </div>
                        <div class="aieo-modules-list-item-content">';

                        
                        if ((int) get_option('aieo_activate_remote_connection') === 7) {

                            echo '<div class="aieo-modules-list-item-title">' . esc_html__('Your orders file has been uploaded!', 'ai-eshop-optimizer') . '<i class="aieo-modules-indicator-support"></i></div>
<div class="aieo-modules-list-item-desc">
<div class="aieo-file-download">' . esc_html__('Your orders file has been successfully uploaded to our server', 'ai-eshop-optimizer') . '</div>
<div class="aieo-promo"></br>' . esc_html__('You are going to be notified as soon as its processing completes in order to visit our portal and download your recommendations as well as see key vital statistics', 'ai-eshop-optimizer') . '</div>
</div>';
                        } else {

                            echo '<div class="aieo-modules-list-item-title">' . esc_html__('Download orders file & clean up!', 'ai-eshop-optimizer') . '
                                <i class="aieo-modules-indicator-support"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                            <div class="aieo-file-download">' . wp_kses($downloadfilemessage, $allowed_html_tags) . '</div>';

                            
                            if ((int) get_option('aieo_activate_remote_connection') === 1) {
                                echo '<div class="aieo-pro">' . esc_html__('As a pro user you can upload the file directly from this plugin via the upload data in your server tab', 'ai-eshop-optimizer') . '</div>';
                            } else {
                                echo '<div class="aieo-promo">' . esc_html__('Why do we save your file on your server?', 'ai-eshop-optimizer') . '</br>' . esc_html__('Our pro users on annual contracts are able to transfer their data directly into our server for optimization calculations and fully automate the process', 'ai-eshop-optimizer') . '
                            </div>';
                            }
                            $delete_url = wp_nonce_url(admin_url('admin-post.php?action=delete_exported_file'), 'delete_exported_file');
                            echo '<div class="aieo-cellsubmit"><a href="' . esc_url($delete_url) . '" class="aieo-button button-primary aieo-button-alarm aieo-buttonsubmit">' . esc_html__('Important! Click to remove the file from your server', 'ai-eshop-optimizer') . '</a></div></div>';
                        }
                        echo '</div>
              </div>';
                    }

                    echo '</div>'; 
                    ?>

                </div>

                <?php
                
                echo '<div id="aieo-statistics-section-container" style="' . (empty($aieo_insight_data['available']) ? 'display: none;' : '') . '">';

                if (!empty($aieo_insight_data['available'])):
                    ?>
                    <div class="aieo-modules-box" id="aieo-card-indicative-statistics">
                        <div class="aieo-modules-box-heading"><?php esc_html_e('Indicative Statistics', 'ai-eshop-optimizer'); ?></div>
                        <div class="aieo-modules-list">
                            <div class="aieo-modules-list-item-action">
                                <div class="aieo-modules-list-item-icon-action">
                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
                                        <path
                                            d="M32 6C17.664 6 6 17.664 6 32s11.664 26 26 26 26-11.664 26-26S46.336 6 32 6zm0 48C19.215 54 10 44.785 10 32S19.215 10 32 10s22 9.215 22 22-9.215 22-22 22z" />
                                        <path
                                            d="M44 32c0-6.627-5.373-12-12-12s-12 5.373-12 12 5.373 12 12 12 12-5.373 12-12zm-20 0c0-4.411 3.589-8 8-8s8 3.589 8 8-3.589 8-8 8-8-3.589-8-8z" />
                                    </svg>
                                </div>
                                <div class="aieo-modules-list-item-content">
                                    <div class="aieo-modules-list-item-title"><?php esc_html_e("Your customers' favourite products", 'ai-eshop-optimizer'); ?></div>
                                    <div class="aieo-modules-list-item-desc">
                                        <p><?php esc_html_e('Frequently the first or last items added to multi-product carts—perfect candidates for prominent placement.', 'ai-eshop-optimizer'); ?>
                                        </p>
                                        <ul class="aieo-insight-list">
                                            <?php foreach ($aieo_insight_data['favourite_products'] as $item): ?>
                                                <li>
                                                    <a href="<?php echo esc_url($item['permalink']); ?>"
                                                        target="_blank"><?php echo esc_html($item['title']); ?></a>
                                                    <span><?php
                                                    
                                                    printf(esc_html__('%1$s first-in-cart units · %2$s last-in-cart units', 'ai-eshop-optimizer'), esc_html(number_format_i18n($item['first_units'])), esc_html(number_format_i18n($item['last_units']))); ?></span>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="aieo-modules-list-item-action">
                                <div class="aieo-modules-list-item-icon-action">
                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
                                        <path
                                            d="M32 6C17.641 6 6 17.641 6 32s11.641 26 26 26 26-11.641 26-26S46.359 6 32 6zm0 48C19.215 54 10 44.785 10 32S19.215 10 32 10s22 9.215 22 22-9.215 22-22 22z" />
                                        <path
                                            d="M42.707 29.293a1 1 0 0 0-1.414 0L33 37.586V20a1 1 0 0 0-2 0v17.586l-8.293-8.293a1 1 0 1 0-1.414 1.414l10 10a1 1 0 0 0 1.414 0l10-10a1 1 0 0 0 0-1.414z" />
                                    </svg>
                                </div>
                                <div class="aieo-modules-list-item-content">
                                    <div class="aieo-modules-list-item-title"><?php esc_html_e('The 10 products you MUST focus', 'ai-eshop-optimizer'); ?></div>
                                    <div class="aieo-modules-list-item-desc">
                                        <p><?php esc_html_e('These products drive the highest number of single-item orders. Enhancing their recommendations can have an immediate impact.', 'ai-eshop-optimizer'); ?>
                                        </p>
                                        <ul class="aieo-insight-list">
                                            <?php foreach ($aieo_insight_data['single_products'] as $item): ?>
                                                <li>
                                                    <a href="<?php echo esc_url($item['permalink']); ?>"
                                                        target="_blank"><?php echo esc_html($item['title']); ?></a>
                                                    <span><?php
                                                    
                                                    printf(esc_html__('%1$s units across %2$s single-product orders', 'ai-eshop-optimizer'), esc_html(number_format_i18n($item['units'])), esc_html(number_format_i18n($item['orders']))); ?></span>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="aieo-modules-list-item-action">
                                <div class="aieo-modules-list-item-icon-action">
                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
                                        <path
                                            d="M12 8h40a2 2 0 0 1 2 2v44a2 2 0 0 1-2 2H12a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2zm0 4v40h40V12H12z" />
                                        <path d="M22 20h8v24h-8zm12 12h8v12h-8zm12-18h8v30h-8z" />
                                    </svg>
                                </div>
                                <div class="aieo-modules-list-item-content">
                                    <div class="aieo-modules-list-item-title"><?php esc_html_e('Brands that dominate single-entry carts', 'ai-eshop-optimizer'); ?></div>
                                    <div class="aieo-modules-list-item-desc">
                                        <p><?php esc_html_e('These brands excel in single-item purchases or taking the prime positions in multi-item orders.', 'ai-eshop-optimizer'); ?>
                                        </p>
                                        <ul class="aieo-insight-list">
                                            <?php foreach ($aieo_insight_data['brands'] as $item): ?>
                                                <li>
                                                    <span
                                                        class="aieo-insight-brand-name"><?php echo esc_html($item['brand']); ?></span>
                                                    <span><?php
                                                    
                                                    printf(esc_html__('%1$s single-order units · %2$s first-in-cart units · %3$s last-in-cart units', 'ai-eshop-optimizer'), esc_html(number_format_i18n($item['single_units'])), esc_html(number_format_i18n($item['first_units'])), esc_html(number_format_i18n($item['last_units']))); ?></span>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <?php
                    
                    
                    
                    ?>
                    <div class="aieo-visualizations-row" style="margin-top: 20px;">
                        <?php
                        $pro_is_active = apply_filters('aieo_pro_is_active', false);
                        if ($pro_is_active) {
                            
                            do_action('aieo_render_analytics_visualizations');
                        } else {
                            
                            ?>
                            <div class="aieo-pro-advertisement">
                                <h3><?php esc_html_e('Unlock Advanced Analytics', 'ai-eshop-optimizer'); ?></h3>
                                <p><?php esc_html_e('Get interactive treemap visualizations for category and brand popularity with drill-down functionality.', 'ai-eshop-optimizer'); ?></p>
                                <a href="https://developer.oxfordmetadata.com/ai-eshop-optimizer-pro" class="aieo-pro-cta" target="_blank">
                                    <?php esc_html_e('Upgrade to Pro', 'ai-eshop-optimizer'); ?>
                                </a>
                                <div class="aieo-pro-features">
                                    <div class="aieo-pro-feature">
                                        <span class="dashicons dashicons-chart-bar"></span>
                                        <span><?php esc_html_e('Category Treemaps', 'ai-eshop-optimizer'); ?></span>
                                    </div>
                                    <div class="aieo-pro-feature">
                                        <span class="dashicons dashicons-tag"></span>
                                        <span><?php esc_html_e('Brand Analytics', 'ai-eshop-optimizer'); ?></span>
                                    </div>
                                    <div class="aieo-pro-feature">
                                        <span class="dashicons dashicons-arrow-down-alt"></span>
                                        <span><?php esc_html_e('Drill-down Support', 'ai-eshop-optimizer'); ?></span>
                                    </div>
                                </div>
                            </div>
                            <?php
                        }
                        ?>
                    </div>
                    <?php
                endif;
                echo '</div>'; 
                ?>
                <?php
                
                require_once AIEO_DIR . 'assets/pages/rotating-banner-wordpress.php';
                ?>
                <div class="aieo-modules-box" id="aieo-card-process-data">
                    <div class="aieo-modules-box-heading"><?php esc_html_e('Process Data Using Our AI-Enhanced Service', 'ai-eshop-optimizer'); ?></div>
                    <div class="aieo-modules-list">
                        <a href="https://eshop-optimizer.com/my-account/" class="aieo-modules-list-item-action">
                            <div class="aieo-modules-list-item-icon-action">
                                <svg id="glipy_copy_3" data-name="glipy copy 3" xmlns="http://www.w3.org/2000/svg"
                                    viewBox="0 0 64 64">
                                    <title>1</title>
                                    <path
                                        d="M32,2A30,30,0,1,0,62,32,30.03661,30.03661,0,0,0,32,2ZM51.29,44.81H47.84v.89a2.14242,2.14242,0,0,1-2.14,2.14h-.89v3.45a.71.71,0,0,1-1.42,0V47.84h-2.6v1.17a.72337.72337,0,0,1-.72.72.71491.71491,0,0,1-.71-.72V47.84H36.74v3.45a.70634.70634,0,0,1-.71.71.72141.72141,0,0,1-.72-.71V47.84h-2.6v1.17a.71009.71009,0,1,1-1.42,0V47.84h-2.6v3.45a.71513.71513,0,0,1-1.43,0V47.84H24.64v1.17a.71491.71491,0,0,1-.71.72.72337.72337,0,0,1-.72-.72V47.84h-2.6v3.45a.71.71,0,1,1-1.42,0V47.84H18.3a2.14242,2.14242,0,0,1-2.14-2.14v-.89H12.71a.71.71,0,0,1,0-1.42h3.45v-2.6H14.99a.72341.72341,0,0,1-.72-.72.71491.71491,0,0,1,.72-.71h1.17V36.74H12.71a.71513.71513,0,0,1,0-1.43h3.45v-2.6H14.99a.71.71,0,0,1,0-1.42h1.17v-2.6H12.71a.71513.71513,0,0,1,0-1.43h3.45V24.64H14.99a.71491.71491,0,0,1-.72-.71.72342.72342,0,0,1,.72-.72h1.17v-2.6H12.71a.71.71,0,1,1,0-1.42h3.45V18.3a2.14247,2.14247,0,0,1,2.14-2.14h.89V12.71a.71.71,0,0,1,1.42,0v3.45h2.6V14.99a.72338.72338,0,0,1,.72-.72.71493.71493,0,0,1,.71.72v1.17h2.62V12.71a.70632.70632,0,0,1,.71-.71.7214.7214,0,0,1,.72.71v3.45h2.6V14.99a.71.71,0,0,1,1.42,0v1.17h2.6V12.71a.7214.7214,0,0,1,.72-.71.70632.70632,0,0,1,.71.71v3.45h2.62V14.99a.71493.71493,0,0,1,.71-.72.72338.72338,0,0,1,.72.72v1.17h2.6V12.71a.71.71,0,0,1,1.42,0v3.45h.89a2.14247,2.14247,0,0,1,2.14,2.14v.89h3.45a.71.71,0,0,1,0,1.42H47.84v2.6h1.17a.72342.72342,0,0,1,.72.72.71491.71491,0,0,1-.72.71H47.84v2.62h3.45a.71513.71513,0,0,1,0,1.43H47.84v2.6h1.17a.71.71,0,0,1,0,1.42H47.84v2.6h3.45a.71513.71513,0,0,1,0,1.43H47.84v2.62h1.17a.71491.71491,0,0,1,.72.71.72341.72341,0,0,1-.72.72H47.84v2.6h3.45a.71.71,0,1,1,0,1.42Z" />
                                    <path
                                        d="M44.81,40.57V23.43a.7444.7444,0,0,0-.2-.51l-3.53-3.53a.7444.7444,0,0,0-.51-.2H23.43a.7444.7444,0,0,0-.51.2l-3.53,3.53a.7444.7444,0,0,0-.2.51V40.57a.74414.74414,0,0,0,.2.50995l3.53,3.53a.7444.7444,0,0,0,.51.2H40.57a.7444.7444,0,0,0,.51-.2l3.53-3.53A.74414.74414,0,0,0,44.81,40.57Zm-1.42-.29-3.11,3.11H23.72l-3.11-3.11V23.72l3.11-3.11H40.28l3.11,3.11Z" />
                                    <path d="M19.41,43.69a.71.71,0,0,0,0,1.42A.71.71,0,0,0,19.41,43.69Z" />
                                    <path d="M19.41,20.11a.71.71,0,0,0,0-1.42A.71.71,0,0,0,19.41,20.11Z" />
                                    <path d="M44.41,18.69a.71.71,0,0,0,0,1.42A.71.71,0,0,0,44.41,18.69Z" />
                                    <path d="M44.41,43.69a.71.71,0,0,0,0,1.42A.71.71,0,0,0,44.41,43.69Z" />
                                </svg>
                            </div>
                            <div class="aieo-modules-list-item-content">
                                <div class="aieo-modules-list-item-title">
                                    <?php esc_html_e('Upload your order details to our AI Graph DB service', 'ai-eshop-optimizer'); ?>
                                </div>
                                <div class="aieo-modules-list-item-desc"><?php echo wp_kses_post(__('Visit <strong><u>Rooster AI Eshop Optimizer</u></strong> to open an account and upload your data. You will get the optimal upsells and crossells for your top selling products as well as extremely valuable statistics about your sales and tips on how to improve!', 'ai-eshop-optimizer')); ?>
                                    <div
                                        class="aieo-pro"><?php esc_html_e('In the pro-version we offer recommendations for all your products based on all your orders.', 'ai-eshop-optimizer'); ?></div>
                                </div>
                            </div>
                        </a>
                        <div class="aieo-modules-list-item-action">
                            <div class="aieo-modules-list-item-icon-action">
                                <svg id="glipy_copy_4" data-name="glipy copy 4" xmlns="http://www.w3.org/2000/svg"
                                    viewBox="0 0 64 64">
                                    <path
                                        d="M32,2A30,30,0,1,0,62,32,30.03657,30.03657,0,0,0,32,2ZM38.45,48.13a.717.717,0,0,1-.72.72H26.28a.71492.71492,0,0,1-.71-.72V45.27a.7151.7151,0,0,1,1.43,0v2.15H37.02V45.27a.715.715,0,1,1,1.43,0Zm-4.8-5.51a.695.695,0,0,1,1.01,0,.71226.71226,0,0,1,0,1.01l-2.14,2.15a.74336.74336,0,0,1-1.02,0l-2.15-2.15a.71773.71773,0,0,1,1.02-1.01l.92.92V32.39a.715.715,0,0,1,1.43,0V43.54Zm9.48-4.44-8.97-.04V32.39a2.15013,2.15013,0,0,0-4.3,0v5.74L18.3,38.08a6.361,6.361,0,0,1-1.41-12.55.86162.86162,0,0,0,.26-.34A6.70364,6.70364,0,0,1,28.67,23.1a.71653.71653,0,0,0,1.01.11c1.13-1.05-2.07-2.93-2.9-3.29a6.69654,6.69654,0,0,1,13.11,1.92.715.715,0,0,0,1.43,0,7.83085,7.83085,0,0,0-.12-1.29,8.9141,8.9141,0,0,1,1.93-.21C54.96,20.83,54.95,37.69,43.13,38.18Z" />
                                </svg>
                            </div>
                            <div class="aieo-modules-list-item-content">
                                <div class="aieo-modules-list-item-title"><?php esc_html_e('Download your existing up-sells and cross-sells', 'ai-eshop-optimizer'); ?><i class="aieo-modules-indicator"></i></div>
                                <div class="aieo-modules-list-item-desc"><?php esc_html_e('Backup your existing up-sells and cross-sells: Secure your current recommendations just in case you wish to revert to them in the unlikely event that our system’s suggestions don’t meet your expectations.', 'ai-eshop-optimizer'); ?></br></br>
                                    <div class="aieo-pro"><?php esc_html_e('The pro-version also factors for your existing crossells and you may need to provide them in order to account for the bias/impact of your existing recommendations.', 'ai-eshop-optimizer'); ?></br></div>
                                </div></br>
                                <form id="aieo-upsell-export-form" method="post"
                                    action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                                    <?php wp_nonce_field('eshop_optimizer_export_csv_action', 'eshop_optimizer_export_csv_nonce_4'); ?>
                                    <input type="hidden" name="action" value="eshop_optimizer_export_csv">
                                    <div class="aieo-cellsubmit">
                                        <button type="button" id="aieo-upsell-export-button"
                                            class="aieo-button aieo-button-optimal-reverse">
                                            <?php esc_html_e('Export your existing Up-sells and Cross-sells', 'ai-eshop-optimizer'); ?>
                                        </button>
                                    </div>
                                </form>

                                <div id="aieo-upsell-export-progress-container" style="display:none; margin-top:20px;">
                                    <h3><?php esc_html_e('Upsell Export Progress', 'ai-eshop-optimizer'); ?></h3>
                                    <div class="aieo-progress-wrapper">
                                        <div class="aieo-progress-bar-container">
                                            <div id="aieo-upsell-export-progress-bar" class="aieo-progress-bar"></div>
                                            <span id="aieo-upsell-export-progress-text"
                                                class="aieo-progress-text">0%</span>
                                        </div>
                                    </div>
                                    <div id="aieo-upsell-export-current-stage" class="aieo-current-stage">
                                        <?php esc_html_e('Initializing...', 'ai-eshop-optimizer'); ?>
                                    </div>
                                    <div id="aieo-upsell-export-log-container" class="aieo-log-container">
                                        <h4><?php esc_html_e('Processing Log:', 'ai-eshop-optimizer'); ?></h4>
                                        <div id="aieo-upsell-export-log" class="aieo-log"></div>
                                    </div>
                                    <div id="aieo-upsell-export-download" class="aieo-download-link"
                                        style="display:none;"></div>
                                </div>

                            </div>

                        </div>
                    </div>
                </div>
                <div class="aieo-modules-box" id="aieo-card-eshop-update">
                    <div class="aieo-modules-box-heading"><?php esc_html_e('Eshop Update', 'ai-eshop-optimizer'); ?></div>
                    <div class="aieo-modules-list-two-thirds">
                        <div class="aieo-modules-list-item-support-dual">

                            <div class="aieo-modules-list-item-icon-dual">
                                <svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                    <path
                                        d="M10 0c5.514 0 10 4.486 10 10s-4.486 10-10 10S0 15.514 0 10 4.486 0 10 0Zm1 8.414 1.293 1.293a1 1 0 1 0 1.414-1.414l-3-3a.998.998 0 0 0-1.414 0l-3 3a1 1 0 0 0 1.414 1.414L9 8.414V14a1 1 0 1 0 2 0V8.414Z">
                                    </path>
                                </svg>
                            </div>
                            <div class="aieo-modules-list-item-content-dual">
                                <div class="aieo-modules-list-item-title-dual">
                                    <?php esc_html_e('Monitor Your Server and Define Time-Out Limits', 'ai-eshop-optimizer'); ?>
                                    <i class="aieo-modules-indicator-support"></i>
                                </div>
                                <div class="aieo-modules-list-item-desc">
                                    <?php esc_html_e('Keep an eye on the duration it takes to update the Up-sells and Cross-sells for your items. This monitoring can assist in appropriately configuring the time-out parameters for your PHP and SQL operations.', 'ai-eshop-optimizer'); ?>
                                    </br></br>
                                    <form id="recommendationsUploadForm" method="post"
                                        action="<?php echo esc_url(admin_url('admin-post.php')); ?>"
                                        enctype="multipart/form-data">
                                        <?php wp_nonce_field('eshop_optimizer_handle_upload_action', 'eshop_optimizer_process_params_nonce_6'); ?>
                                        <input type="hidden" name="action" value="eshop_optimizer_handle_upload">

                                        <div><label><input type="checkbox" name="aieo_monitor_performance" value="1"
                                                    <?php checked(get_option('aieo_monitor_performance', '0'), '1'); ?>><?php esc_html_e('Monitor my performance', 'ai-eshop-optimizer'); ?></label>
                                        </div>

                                        <div class="aieo-table">
                                            <div class="aieo-row">
                                                <div class="aieo-cell aieo-description">
                                                    <?php esc_html_e('Batch size', 'ai-eshop-optimizer'); ?>
                                                </div>
                                                <div class="aieo-cell aieo-input">
                                                    <input type="number" id="aieo_batch_size" name="aieo_batch_size"
                                                        placeholder="<?php esc_attr_e('Set Batch Size', 'ai-eshop-optimizer'); ?>"
                                                        value="<?php echo esc_attr(get_option('aieo_batch_size', 300)); ?>"
                                                        required>
                                                </div>
                                            </div>
                                            <div class="aieo-row">
                                                <div class="aieo-cell aieo-description">
                                                    <?php esc_html_e('Sleep between batches (in seconds)', 'ai-eshop-optimizer'); ?>
                                                </div>
                                                <div class="aieo-cell aieo-input">
                                                    <input type="number" id="aieo_batch_sleep" name="aieo_batch_sleep"
                                                        placeholder="<?php esc_attr_e('Cooling time (s)', 'ai-eshop-optimizer'); ?>"
                                                        value="<?php echo esc_attr(get_option('aieo_batch_sleep', 0)); ?>"
                                                        required>
                                                </div>
                                            </div>

                                        </div>

                                </div>
                            </div>

                            <div class="aieo-modules-list-item-icon-dual-right">
                                <svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                    <path
                                        d="M10 0c5.514 0 10 4.486 10 10s-4.486 10-10 10S0 15.514 0 10 4.486 0 10 0Zm1 8.414 1.293 1.293a1 1 0 1 0 1.414-1.414l-3-3a.998.998 0 0 0-1.414 0l-3 3a1 1 0 0 0 1.414 1.414L9 8.414V14a1 1 0 1 0 2 0V8.414Z">
                                    </path>
                                </svg>
                            </div>
                            <div class="aieo-modules-list-item-content-dual">
                                <div class="aieo-modules-list-item-title">
                                    <?php esc_html_e('Update your products with their optimal recommendations', 'ai-eshop-optimizer'); ?>
                                    <i class="aieo-modules-indicator"></i>
                                </div>
                                <div class="aieo-modules-list-item-desc">
                                    <?php esc_html_e('Upload the file with your optimal recommendations.', 'ai-eshop-optimizer'); ?>
                                    <div class="aieo-cellsubmit">

                                        <input type="file" name="csv_file" id="csv_file">
                                    </div>
                                    <div class="aieo-cellsubmit">

                                        <button type="button" id="aieo-upsell-import-button"
                                            class="aieo-button button-primary aieo-button-optimal">
                                            <?php esc_html_e('Upload optimal Up-sells and Cross-sells', 'ai-eshop-optimizer'); ?>
                                        </button>
                                    </div>

                                    <div id="aieo-upsell-import-progress-container"
                                        style="display:none; margin-top:20px;">
                                        <h3><?php esc_html_e('Upsell Import Progress', 'ai-eshop-optimizer'); ?></h3>
                                        <div class="aieo-progress-wrapper">
                                            <div class="aieo-progress-bar-container">
                                                <div id="aieo-upsell-import-progress-bar" class="aieo-progress-bar">
                                                </div>
                                                <span id="aieo-upsell-import-progress-text"
                                                    class="aieo-progress-text">0%</span>
                                            </div>
                                        </div>
                                        <div id="aieo-upsell-import-current-stage" class="aieo-current-stage">
                                            <?php esc_html_e('Initializing...', 'ai-eshop-optimizer'); ?>
                                        </div>
                                        <div id="aieo-upsell-import-log-container" class="aieo-log-container">
                                            <h4><?php esc_html_e('Processing Log:', 'ai-eshop-optimizer'); ?></h4>
                                            <div id="aieo-upsell-import-log" class="aieo-log"></div>
                                        </div>
                                    </div>

                                    </form>
                                    <!--   <div id="progressBar">Waiting to start...</div> -->
                                </div>
                            </div>
                        </div>

                        <!--
                    <a href="https://eshop-optimizer.com" target="_blank" class="aieo-modules-list-item">
                        <div class="aieo-modules-list-item-icon">
                            <svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                <path d="M9 5a1 1 0 1 0-2 0v3a1 1 0 0 0 .293.707l2 2a1 1 0 0 0 1.414-1.414L9 7.586V5Z"></path>
                                <path d="m14.312 12.897 5.395 5.396a1 1 0 1 1-1.414 1.414l-5.396-5.395A7.954 7.954 0 0 1 8 16c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8a7.946 7.946 0 0 1-1.688 4.897ZM8 2C4.691 2 2 4.691 2 8s2.691 6 6 6 6-2.691 6-6-2.691-6-6-6Z"></path>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title">Monitor your sales and watch them grow!</div>
                            <div class="aieo-modules-list-item-desc">We bet that you are going to be gob smacked with the relevance of our recommendations.
                                </br></br>At times you may be in owe on... how on earth we discovered this or that suggestion while "knowing nothing" about your business. Well, thats AI for your store in full force!
                                </br></br>This is why we offer free analyses: We are sure that you will want to make the most of it and that you will also tell your friends!</div>
                        </div>
                    </a>

                -->
                    </div>
                </div>
            </div>

            <div class="aieo-modules-box" id="aieo-card-expert-services">
                <div class="aieo-modules-box-heading"><?php esc_html_e('Expert Performance Enhancement Services', 'ai-eshop-optimizer'); ?></div>
                <div class="aieo-modules-list">

                    <a href="https://eshop-optimizer.com/dashboard/" class="aieo-modules-list-item-pro" target="_blank">
                        <div class="aieo-modules-list-item-icon-pro">
                            <svg id="glipy_copy_4" data-name="glipy copy 4" xmlns="http://www.w3.org/2000/svg"
                                viewBox="0 0 64 64">
                                <title>1</title>
                                <path
                                    d="M32,2A30,30,0,1,0,62,32,30.03661,30.03661,0,0,0,32,2ZM13.86,19.09a2.08292,2.08292,0,0,1,2.17-1.98H47.97a2.08292,2.08292,0,0,1,2.17,1.98V39.64H40.09a5.78986,5.78986,0,0,0-4.15,1.72,1.57927,1.57927,0,0,1-1.13.46H29.19a1.57927,1.57927,0,0,1-1.13-.46,5.78986,5.78986,0,0,0-4.15-1.72H13.86ZM52,43.31a3.57428,3.57428,0,0,1-3.57,3.58H15.57A3.57428,3.57428,0,0,1,12,43.31V41.79a.71491.71491,0,0,1,.71-.72h11.2a4.44138,4.44138,0,0,1,3.15,1.3,2.96175,2.96175,0,0,0,2.13.88h5.62a2.96175,2.96175,0,0,0,2.13-.88,4.44138,4.44138,0,0,1,3.15-1.3h11.2a.71491.71491,0,0,1,.71.72Z" />
                                <path
                                    d="M29.14,37.71a2.1604,2.1604,0,0,0,2.02-1.42H43.43a.71513.71513,0,0,0,0-1.43H31.16a2.15551,2.15551,0,0,0-2.02-1.43,2.13281,2.13281,0,0,0-2.01,1.43H20.57a.71513.71513,0,0,0,0,1.43h6.56A2.13746,2.13746,0,0,0,29.14,37.71ZM29.86,35.57a.71522.71522,0,0,1-1.43,0A.71522.71522,0,0,1,29.86,35.57Z" />
                                <path
                                    d="M20.57,30.57H32.84A2.1556,2.1556,0,0,0,34.86,32a2.13289,2.13289,0,0,0,2.01-1.43h6.56a.71513.71513,0,0,0,0-1.43H36.87A2.13286,2.13286,0,0,0,34.86,27.71,2.15557,2.15557,0,0,0,32.84,29.14H20.57A.71513.71513,0,0,0,20.57,30.57Zm15-.71a.71522.71522,0,0,1-1.43,0A.71522.71522,0,0,1,35.57,29.86Z" />
                                <path
                                    d="M20.57,24.86h6.56a2.13281,2.13281,0,0,0,2.01,1.43,2.15552,2.15552,0,0,0,2.02-1.43H43.43a.71513.71513,0,0,0,0-1.43H31.16A2.15552,2.15552,0,0,0,29.14,22a2.13281,2.13281,0,0,0-2.01,1.43H20.57A.71513.71513,0,0,0,20.57,24.86Zm9.29-.72a.71507.71507,0,0,1-1.43,0A.71507.71507,0,0,1,29.86,24.14Z" />
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-fundamentals">
                                <?php esc_html_e('Establish Fundamentals, Oversee and Evaluate Progress', 'ai-eshop-optimizer'); ?>
                            </div>
                            <div class="aieo-modules-list-item-desc"><?php echo wp_kses_post(__('Register at <strong><u>Rooster AI Eshop Optimizer</u></strong> to input your existing product suggestions along with supplementary product data like categories, tags, attributes, and content quality metrics. Subsequently, the system will generate astute recommendations spanning your entire catalog, regardless of sales history.', 'ai-eshop-optimizer')); ?>
                                <div
                                    class="aieo-pro"><?php esc_html_e('This is only available in the pro-version and provides access to our dashboard with easy access to your most valuable products as well as exact metrics about the progress you are making', 'ai-eshop-optimizer'); ?></div>
                            </div>
                        </div>
                    </a>
                    <a href="https://eshop-optimizer.com/service/ga4-events-integration"
                        class="aieo-modules-list-item-pro" target="_blank">
                        <div class="aieo-modules-list-item-icon-pro">
                            <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
                                xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 400 400"
                                style="enable-background:new 0 0 400 400;" xml:space="preserve">
                                <g>
                                    <path class="aieo-st0"
                                        d="M128.1,271.9L107,293c-51.3-51.3-51.3-134.7,0-186l21.1,21.1C88.4,167.7,88.4,232.3,128.1,271.9z" />
                                    <path class="aieo-st1"
                                        d="M293,293l-21.1-21.1c39.7-39.7,39.7-104.2,0-143.8L293,107C344.3,158.3,344.3,241.7,293,293z" />
                                    <path class="aieo-st2"
                                        d="M293,107l-21.1,21.1c-39.7-39.7-104.2-39.7-143.8,0L107,107C158.3,55.7,241.7,55.7,293,107z" />
                                    <path class="aieo-st3"
                                        d="M293,293c-51.3,51.3-134.7,51.3-186,0l21.1-21.1c39.7,39.7,104.2,39.7,143.8,0L293,293z" />
                                    <path class="aieo-st4"
                                        d="M281.9,97.1l-21.2,21.2c8,6,15.1,13.1,21.1,21.1l21.2-21.2C296.7,110.3,289.7,103.3,281.9,97.1z" />
                                    <path class="aieo-st5"
                                        d="M302.9,281.9l-21.2-21.2c-6,8-13.1,15.1-21.1,21.1l21.2,21.2C289.7,296.7,296.7,289.7,302.9,281.9z" />
                                    <path class="aieo-st6"
                                        d="M118.1,302.9l21.2-21.2c-8-6-15.1-13.1-21.1-21.1l-21.2,21.2C103.3,289.7,110.3,296.7,118.1,302.9z" />
                                    <path class="aieo-st7"
                                        d="M97.1,118.1l21.2,21.2c6-8,13.1-15.1,21.1-21.1l-21.2-21.2C110.3,103.3,103.3,110.3,97.1,118.1z" />
                                    <circle class="aieo-st8" cx="200" cy="200" r="111.8" />
                                </g>
                                <path d="M195.8,210.4v-13.5c2.7,0.8,5.6,0.8,8.4,0v13.5c0,5,4.1,9.1,9.1,9.1l0,0h0.1c4.6,17.7,20.9,30.6,40.1,30.1
    c21.2-0.6,38.6-18,39.1-39.2c0.5-21-14.9-38.5-35.2-41c0,0-8.7-8.5-15.4-13.5c-8.5-6.3-26.3-5.1-26.9,11.6h-30.3
    c-0.6-16.7-18.4-17.9-26.9-11.6c-6.8,5-15.4,13.5-15.4,13.5c-20.2,2.6-35.7,20.1-35.2,41.1c0.6,21.2,18,38.6,39.2,39.1
    c19.2,0.5,35.4-12.4,40-30.1h0.1C191.7,219.5,195.8,215.4,195.8,210.4z M147.6,239.6c-16.6,0-30.2-13.5-30.2-30.2
    s13.5-30.2,30.2-30.2s30.2,13.5,30.2,30.2S164.3,239.6,147.6,239.6z M200,191.2c-4.7,0-8.4-3.7-8.4-8.4s3.7-8.4,8.4-8.4
    s8.4,3.7,8.4,8.4S204.6,191.2,200,191.2z M147.8,187c-4.5,0-8.6,1.3-12,3.5c3.3,0.4,5.9,3.2,5.9,6.7c0,3.7-3,6.7-6.7,6.7
    c-3.3,0-6.1-2.5-6.6-5.6c-1.9,3.3-3,7.1-3,11.2c0,12.4,10,22.5,22.5,22.5c12.4,0,22.5-10,22.5-22.5C170.3,197,160.2,187,147.8,187z
     M232.8,198.2c0.5,3.2,3.3,5.6,6.6,5.6c3.7,0,6.7-3,6.7-6.7c0-3.5-2.6-6.3-5.9-6.7c3.5-2.2,7.6-3.5,12-3.5c12.4,0,22.5,10,22.5,22.5
    c0,12.4-10,22.5-22.5,22.5s-22.5-10-22.5-22.5C229.7,205.3,230.8,201.5,232.8,198.2z M252.4,239.6c-16.6,0-30.2-13.5-30.2-30.2
    s13.5-30.2,30.2-30.2s30.2,13.5,30.2,30.2S269,239.6,252.4,239.6z" />
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-ga4-events">
                                <?php esc_html_e('Integrate and Retrieve Google GA4 Events', 'ai-eshop-optimizer'); ?>
                            </div>
                            <div class="aieo-modules-list-item-desc"><?php echo wp_kses_post(__('Set up an account at <strong><u>Rooster AI Eshop Optimizer</u></strong> and link your Google Big Query to fetch the "add to cart" events. This allows us to amalgamate completed transactions with the inclinations of your website\'s visitors.', 'ai-eshop-optimizer')); ?>
                                <div class="aieo-pro"><?php esc_html_e('This is only available in the pro-version and we undertake the set up of the Big Queries for an additional fee; all you have to do is to provide access to your Analytics', 'ai-eshop-optimizer'); ?>
                                </div>
                            </div>
                        </div>
                    </a>
                    <a href="https://eshop-optimizer.com/service/go-phygital-connect-and-scrutinize-your-offline-sales"
                        class="aieo-modules-list-item-pro" target="_blank">
                        <div class="aieo-modules-list-item-icon-pro">
                            <svg id="glipy_copy_4" data-name="glipy copy 4" xmlns="http://www.w3.org/2000/svg"
                                viewBox="0 0 64 64">
                                <title>1</title>
                                <path
                                    d="M32,2A30,30,0,1,0,62,32,30.03657,30.03657,0,0,0,32,2ZM13.86,19.09a2.08287,2.08287,0,0,1,2.17-1.98H47.97a2.08286,2.08286,0,0,1,2.17,1.98V39.64H40.09a5.78983,5.78983,0,0,0-4.15,1.72,1.57938,1.57938,0,0,1-1.13.46H29.19a1.57926,1.57926,0,0,1-1.13-.46,5.79,5.79,0,0,0-4.15-1.72H13.86ZM52,43.31a3.57432,3.57432,0,0,1-3.57,3.58H15.57A3.57428,3.57428,0,0,1,12,43.31V41.79a.7149.7149,0,0,1,.71-.72h11.2a4.44148,4.44148,0,0,1,3.15,1.3,2.96173,2.96173,0,0,0,2.13.88h5.62a2.96176,2.96176,0,0,0,2.13-.88,4.44124,4.44124,0,0,1,3.15-1.3h11.2a.71491.71491,0,0,1,.71.72Z" />
                                <path
                                    d="M46.19,31.39a1.9863,1.9863,0,0,0,0-3.19c-3.96-2.67-10.71-7.77-16.25-6.41-4.13.94-9.2,4.29-12.13,6.41a1.97538,1.97538,0,0,0,0,3.19c2.93,2.12,8,5.47,12.13,6.42C35.48,39.17,42.23,34.06,46.19,31.39Zm-7.25-6.11a56.96844,56.96844,0,0,1,6.4,4.08.53754.53754,0,0,1,0,.88,56.479,56.479,0,0,1-6.41,4.07A8.342,8.342,0,0,0,38.94,25.28ZM18.66,30.24a.53754.53754,0,0,1,0-.88,56.96453,56.96453,0,0,1,6.4-4.08,8.34176,8.34176,0,0,0,.01,9.03A56.4752,56.4752,0,0,1,18.66,30.24Zm11.8-7.12a6.84716,6.84716,0,1,1,.33,13.41A6.88648,6.88648,0,0,1,30.46,23.12Z" />
                                <path
                                    d="M32,25.3a4.495,4.495,0,0,0,0,8.99A4.48966,4.48966,0,0,0,32,25.3Zm-3.06,4.49a3.06008,3.06008,0,0,1,6.12,0A3.06008,3.06008,0,0,1,28.94,29.79Z" />
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-phygital">
                                <?php esc_html_e('Go Phygital: Connect and Scrutinize Offline Sales', 'ai-eshop-optimizer'); ?>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php echo wp_kses_post(__('Visit <strong><u>Rooster AI Eshop Optimizer</u></strong> to load the shopping baskets of your physical stores. Then we will then combine the purchasing behaviour in your store(s) with that of your website', 'ai-eshop-optimizer')); ?>
                                <div class="aieo-pro">
                                    <?php esc_html_e('This is only available in the pro-version at an additional fee; the invoices will be extracted from your ERP and the products will be matched based on their barcode and/or SKU', 'ai-eshop-optimizer'); ?>
                                </div>
                            </div>
                        </div>
                    </a>

                    <a href="https://eshop-optimizer.com/site-audit" target="_blank" class="aieo-modules-list-item-pro">
                        <div class="aieo-modules-list-item-icon-pro">
                            <svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                <path d="M9 5a1 1 0 1 0-2 0v3a1 1 0 0 0 .293.707l2 2a1 1 0 0 0 1.414-1.414L9 7.586V5Z">
                                </path>
                                <path
                                    d="m14.312 12.897 5.395 5.396a1 1 0 1 1-1.414 1.414l-5.396-5.395A7.954 7.954 0 0 1 8 16c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8a7.946 7.946 0 0 1-1.688 4.897ZM8 2C4.691 2 2 4.691 2 8s2.691 6 6 6 6-2.691 6-6-2.691-6-6-6Z">
                                </path>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-performance-audit">
                                <?php esc_html_e('Performance Audit', 'ai-eshop-optimizer'); ?>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('Prepare to be astounded by the pertinence of our suggestions. Occasionally, you might find yourself wondering how we unearthed a particular recommendation without having in-depth knowledge of your enterprise.', 'ai-eshop-optimizer'); ?>
                                </br></br><?php esc_html_e('That\'s the prowess of AI tailored for your store! Our confidence in our system\'s capabilities is why we offer complimentary analyses. We believe you\'ll want to maximize its potential and share your positive experiences with peers!', 'ai-eshop-optimizer'); ?>
                            </div>
                        </div>
                    </a>
                </div>
            </div>
            <div class="aieo-modules-box" id="aieo-card-pro-panel">
                <div class="aieo-modules-box-heading"><?php esc_html_e('Pro Panel', 'ai-eshop-optimizer'); ?></div>
                <div class="aieo-modules-list">

                    <!-- "Get Pro at rooster.systems" CTA card.
                         Replaced the legacy eshop-optimizer.com login form
                         (2026-05). Authentication is now Rooster Content
                         Connector-only — that's the card to the right of this
                         one. This card just markets the Pro upgrade and points
                         buyers at rooster.systems/get-aieo. Legacy option
                         values (aieo_account_username, aieo_account_password,
                         aieo_erp_*, aieo_subscription_expiration, etc.) are
                         left intact in the DB so already-Pro installs keep
                         their is_pro state via the eshop-optimizer.com path
                         until they migrate to a Rooster Content Connector token. -->
                    <?php
                    
                    
                    
                    $aieo_is_rooster_connected = (
                        (int) get_option('aieo_rooster_enabled', 0) === 1
                        && get_option('aieo_rooster_status', '') === 'connected'
                    );
                    $aieo_rooster_partner_label = (string) get_option('aieo_rooster_client_label', '');
                    ?>
                    <div class="aieo-modules-list-item-pro-section">
                        <div class="aieo-modules-list-item-icon-pro-section">
                            <svg width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
                                <path d="M9 0L11.09 5.26L17 5.27L12.45 8.74L14.55 14L9 10.53L3.45 14L5.55 8.74L1 5.27L6.91 5.26L9 0Z" />
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <?php if ( $aieo_is_rooster_connected ) : ?>
                                <div class="aieo-modules-list-item-title" id="aieo-card-pro-active">
                                    <?php esc_html_e('AIEO Pro is active', 'ai-eshop-optimizer'); ?>
                                    <i class="aieo-modules-indicator-pro-section"></i>
                                </div>
                                <div class="aieo-modules-list-item-desc">
                                    <p style="margin:0 0 10px;">
                                        <strong style="color:#059669;">✓ <?php esc_html_e('Subscribed via rooster.systems', 'ai-eshop-optimizer'); ?></strong>
                                        <?php if ( $aieo_rooster_partner_label !== '' ) : ?>
                                            <span style="color:#64748b;"> — <?php echo esc_html( $aieo_rooster_partner_label ); ?></span>
                                        <?php endif; ?>
                                    </p>
                                    <p style="margin:0 0 14px;">
                                        <?php esc_html_e('All 13 Pro admin features are unlocked on this site. Anthropic chat + Voyage embeddings are proxied through rooster.systems and metered against your AI Credits subscription.', 'ai-eshop-optimizer'); ?>
                                    </p>
                                    <div class="aieo-table">
                                        <div style="display:flex; flex-direction:column; gap:8px;">
                                            <a href="https://rooster.systems/get-credits/" target="_blank" rel="noopener"
                                               class="aieo-button button-primary aieo-button-pro-section aieo-center-content"
                                               style="display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:10px 18px; text-decoration:none;">
                                                <span><?php esc_html_e('Manage subscription + top up at rooster.systems →', 'ai-eshop-optimizer'); ?></span>
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            <?php else : ?>
                                <div class="aieo-modules-list-item-title" id="aieo-card-get-pro">
                                    <?php esc_html_e('Get AIEO Pro at rooster.systems', 'ai-eshop-optimizer'); ?>
                                    <i class="aieo-modules-indicator-pro-section"></i>
                                </div>
                                <div class="aieo-modules-list-item-desc">
                                    <?php esc_html_e('AIEO Pro ($39/month) unlocks 13 admin features: Insights Chat (33 Claude data abilities), Attribution Dashboard, Web Push notifications, Customer Intelligence + VoC surveys, Marketplace Order Importer, ERP Bridge & Database, Branch Stock Scanner, Order Cancellations, Shipment Cost Reports, Insights Remote DB streaming, Action Scheduler Cleanup, Order Documents & Couriers — plus the optimized cart/checkout runtime.', 'ai-eshop-optimizer'); ?>
                                    <br><br>
                                    <strong style="color:#7c3aed;"><?php esc_html_e('✨ Includes $10/month of AI Credits bundled in. AI features work the moment you connect — no separate purchase needed.', 'ai-eshop-optimizer'); ?></strong>
                                    <br><br>
                                    <?php esc_html_e('Subscribe at rooster.systems → AI Eshop Optimizer. After checkout you\'ll get a Content Connector token — paste it into the card on the right and Insights Chat + AI search are live.', 'ai-eshop-optimizer'); ?>
                                    <br><br>
                                    <div class="aieo-table">
                                        <div style="display:flex; flex-direction:column; gap:10px;">
                                            <a href="https://rooster.systems/get-aieo/" target="_blank" rel="noopener"
                                               class="aieo-button button-primary aieo-button-pro-section aieo-center-content"
                                               style="display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:12px 20px; text-decoration:none;">
                                                <span><?php esc_html_e('Get AIEO Pro →', 'ai-eshop-optimizer'); ?></span>
                                            </a>
                                            <a href="https://rooster.systems/get-aieo/#pricing" target="_blank" rel="noopener"
                                               style="text-align:center; font-size:13px; color:#7c3aed; text-decoration:none;">
                                                <?php esc_html_e('See pricing + full feature list', 'ai-eshop-optimizer'); ?>
                                            </a>
                                            <p style="margin:8px 0 0; font-size:11px; color:#94a3b8; text-align:center;">
                                                <?php esc_html_e('Already Pro? Use the Rooster Content Connector card to the right →', 'ai-eshop-optimizer'); ?>
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>
                    <!-- End of "Get Pro at rooster.systems" CTA card.
                         The legacy eshop-optimizer.com login form that used to
                         live here was removed entirely (2026-05); the handler
                         class-eshop-optimizer.php::aieo_handle_eshop_optimizer_account()
                         remains in place to serve any old bookmark to
                         admin-post.php?action=eshop_optimizer_account, but no UI
                         surface invokes it anymore. -->
                    <?php
                    
                    
                    
                    
                    if ( false ) :
                    ?>
                                        <div class="aieo-row aieo-account-settings-row">
                                            <div class="aieo-cell"><?php esc_html_e('User', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_account_username"
                                                    name="aieo_account_username"
                                                    value="<?php echo esc_attr(get_option('aieo_account_username')); ?>">
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Password', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <?php
                                                $account_pass_encrypted_in_db = get_option('aieo_account_password');
                                                $account_pass_method = 'aes-256-ctr';
                                                $account_pass_key = AUTH_KEY;
                                                $account_pass_iv = substr(AUTH_SALT, 0, 16);
                                                
                                                $decrypted_account_password = openssl_decrypt($account_pass_encrypted_in_db, $account_pass_method, $account_pass_key, 0, $account_pass_iv);
                                                ?>
                                                <input type="password" id="aieo_account_password"
                                                    name="aieo_account_password"
                                                    value="<?php echo esc_attr($decrypted_account_password); ?>">
                                            </div>
                                        </div>

                                        <div class="aieo-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Remember me for 30 days', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="checkbox" id="aieo_remember_auth" name="aieo_remember_auth"
                                                    value="1" <?php checked(1, get_option('aieo_remember_auth', 0), true); ?>>
                                                <span style="color: #6b7280; font-size: 13px; margin-left: 8px;">
                                                    <?php esc_html_e('Stay logged in and skip authentication for the next 30 days', 'ai-eshop-optimizer'); ?>
                                                </span>
                                            </div>
                                        </div>

                                        <div class="aieo-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('ERP Orders & Google Analytics BigQuery consolidation options', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="checkbox" id="aieo_erp_consolidation"
                                                    name="aieo_erp_consolidation" value="1" <?php checked(1, get_option('aieo_erp_consolidation', 0), true); ?>>
                                            </div>
                                        </div>

                                        <div class="aieo-row aieo-erp-data-settings-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Google Analytics User Journey Table', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_google_user_journey_table"
                                                    name="aieo_google_user_journey_table"
                                                    value="<?php echo esc_attr(get_option('aieo_google_user_journey_table')); ?>">
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-erp-data-settings-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Store ERP Products Table', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_erp_store_products_table"
                                                    name="aieo_erp_store_products_table"
                                                    value="<?php echo esc_attr(get_option('aieo_erp_store_products_table')); ?>">
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-erp-data-settings-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Store ERP Orders Table', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_erp_store_orders_table"
                                                    name="aieo_erp_store_orders_table"
                                                    value="<?php echo esc_attr(get_option('aieo_erp_store_orders_table')); ?>">
                                            </div>
                                        </div>

                                        <div class="aieo-row aieo-erp-data-settings-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Store ERP Customers Table', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_erp_store_customers_table"
                                                    name="aieo_erp_store_customers_table"
                                                    value="<?php echo esc_attr(get_option('aieo_erp_store_customers_table')); ?>">
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-erp-data-settings-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Eponymous identifier for customer analytics', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_analytics_eponymous_id_field"
                                                    name="aieo_analytics_eponymous_id_field"
                                                    value="<?php echo esc_attr(get_option('aieo_analytics_eponymous_id_field')); ?>">
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-erp-data-settings-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('ERP Cost Centres & Anonymous Receipt Consolidation', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="checkbox" id="aieo_erp_anonymous_consolidation"
                                                    name="aieo_erp_anonymous_consolidation" value="1" <?php checked(1, get_option('aieo_erp_anonymous_consolidation', 0), true); ?>>
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-erp-anonymous-data-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Store ERP Anonymous Customers', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_erp_store_anonymous_invoice_users"
                                                    name="aieo_erp_store_anonymous_invoice_users"
                                                    value="<?php echo esc_attr(get_option('aieo_erp_store_anonymous_invoice_users')); ?>">
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-erp-anonymous-data-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Cost centres to ignore', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_erp_series_to_ignore"
                                                    name="aieo_erp_series_to_ignore"
                                                    value="<?php echo esc_attr(get_option('aieo_erp_series_to_ignore')); ?>">
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-erp-anonymous-data-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('SKUs of products to ignore', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_erp_products_to_ignore"
                                                    name="aieo_erp_products_to_ignore"
                                                    value="<?php echo esc_attr(get_option('aieo_erp_products_to_ignore')); ?>">
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-erp-anonymous-data-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Price threshold (ignore products below this price)', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_erp_product_price_to_ignore"
                                                    name="aieo_erp_product_price_to_ignore"
                                                    value="<?php echo esc_attr(get_option('aieo_erp_product_price_to_ignore')); ?>">
                                            </div>
                                        </div>

                                        <div class="aieo-row aieo-erp-data-settings-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Aggregate Statistics per channel/branch', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="checkbox" id="aieo_erp_stats_per_channel"
                                                    name="aieo_erp_stats_per_channel" value="1" <?php checked(1, get_option('aieo_erp_stats_per_channel', 0), true); ?>>
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Datatable Prefix', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <!-- <input type="text" id="aieo_account_table" name="aieo_account_table" value=" -->
                                                <?php echo esc_attr(get_option('aieo_account_table')); ?>
                                                <!-- " > -->
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Latest Report Prefix', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <!-- <input type="text" id="aieo_account_table" name="aieo_account_table" value=" -->
                                                <?php echo esc_attr(get_option('aieo_account_report_table')); ?>
                                                <!-- " > -->
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Subscription Expiration:', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <!-- <input type="text" id="aieo_account_table" name="aieo_account_table" value=" -->
                                                <?php echo esc_attr(get_option('aieo_subscription_expiration')); ?>
                                                <!-- " > -->
                                            </div>
                                        </div>
                                        <div class="aieo-row aieo-account-settings-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('JWT Debugging', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <textarea name="aieo_remote_debugging" id="aieo_remote_debugging"
                                                    rows="5"
                                                    cols="30"><?php echo esc_textarea(get_option('aieo_jwt_debugging')); ?></textarea>

                                            </div>
                                        </div>
                                        <?php
                                        
                                        
                                        
                                        
                                        
                                        
                                        $auth_expiry_time = get_option('aieo_auth_expiry', 0);
                                        $has_valid_expiry = $auth_expiry_time && $auth_expiry_time > time();

                                        
                                        $has_pro_membership = get_option('aieo_user_membership') === 'Pro';

                                        
                                        
                                        
                                        
                                        
                                        
                                        $has_rooster_link = (
                                            get_option('aieo_rooster_enabled')
                                            && get_option('aieo_rooster_status') === 'connected'
                                        );

                                        
                                        $is_authenticated = $has_valid_expiry || $has_pro_membership || $has_rooster_link;

                                        if ($is_authenticated) {
                                            ?>
                                            <div class="aieo-cellsubmit">
                                                <p
                                                    style="color: #059669; font-weight: 600; margin: 0 0 15px 0; text-align: center;">
                                                    ✓
                                                    <?php echo esc_html__('You are currently logged in', 'ai-eshop-optimizer'); ?>
                                                    <?php
                                                    
                                                    if ($has_valid_expiry && $auth_expiry_time > 0) {
                                                        $days_remaining = ceil(($auth_expiry_time - time()) / DAY_IN_SECONDS);
                                                        
                                                        echo ' (' . sprintf(esc_html__('%d days remaining', 'ai-eshop-optimizer'), (int) $days_remaining) . ')';
                                                    } elseif ($has_pro_membership) {
                                                        
                                                        echo ' (' . esc_html__('Pro User', 'ai-eshop-optimizer') . ')';
                                                    } elseif ($has_rooster_link) {
                                                        
                                                        
                                                        echo ' (' . esc_html__('Pro via Rooster Content Connector', 'ai-eshop-optimizer') . ')';
                                                    }
                                                    ?>
                                                </p>
                                            </div>
                                            <div class="aieo-cellsubmit">
                                                <input type="submit"
                                                    class="aieo-button button-primary aieo-button-pro-section aieo-center-content"
                                                    value="<?php esc_attr_e('Update Settings', 'ai-eshop-optimizer'); ?>">
                                            </div>
                                            <div class="aieo-cellsubmit" style="margin-top: 10px;">
                                                <a href="<?php echo esc_url(wp_nonce_url(admin_url('admin-post.php?action=aieo_logout_account'), 'aieo_logout_account')); ?>"
                                                    class="aieo-button aieo-button-alarm aieo-center-content"
                                                    style="background: #dc2626; color: white; text-decoration: none; display: inline-block;">
                                                    <?php esc_html_e('Logout', 'ai-eshop-optimizer'); ?>
                                                </a>
                                            </div>
                                            <?php
                                        } else {
                                            
                                            ?>
                                            <div class="aieo-cellsubmit">
                                                <input type="submit"
                                                    class="aieo-button button-primary aieo-button-pro-section aieo-center-content"
                                                    value="<?php esc_attr_e('Validate my account', 'ai-eshop-optimizer'); ?>">
                                            </div>
                                            <?php
                                        }
                                        ?>
                                </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>

                    <!-- Rooster Content Connector -->
                    <div class="aieo-modules-list-item-pro-section">
                        <div class="aieo-modules-list-item-icon-pro-section">
                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="currentColor">
                                <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/>
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-rooster-content">
                                <?php esc_html_e('Rooster Content Connector', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator-pro-section"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('Connect to the Rooster optimization service to sync your orders, products, and customer data for advanced analysis and recommendations.', 'ai-eshop-optimizer'); ?>
                                </br></br>
                                <div class="aieo-table">
                                    <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                                        <?php wp_nonce_field('aieo_rooster_connector_action', 'aieo_rooster_connector_nonce'); ?>
                                        <input type="hidden" name="action" value="aieo_rooster_connector">
                                        <div class="aieo-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Activate Rooster Connection', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="checkbox" id="aieo_rooster_enabled"
                                                    name="aieo_rooster_enabled" value="1" <?php checked(1, get_option('aieo_rooster_enabled'), true); ?>>
                                            </div>
                                        </div>
                                        <div class="aieo-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Content Connector API Key', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="text" id="aieo_rooster_api_key"
                                                    name="aieo_rooster_api_key"
                                                    value="<?php echo esc_attr(get_option('aieo_rooster_api_key')); ?>"
                                                    placeholder="cc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                                                    style="width: 100%; font-family: monospace;">
                                            </div>
                                        </div>
                                        <div class="aieo-row">
                                            <div class="aieo-cell">
                                                <?php esc_html_e('Hub URL', 'ai-eshop-optimizer'); ?>
                                            </div>
                                            <div class="aieo-cell aieo-input">
                                                <input type="url" id="aieo_rooster_hub_url"
                                                    name="aieo_rooster_hub_url"
                                                    value="<?php echo esc_attr(get_option('aieo_rooster_hub_url', 'https://rooster.systems')); ?>"
                                                    style="width: 100%;">
                                            </div>
                                        </div>
                                        <?php
                                        $rooster_status = get_option('aieo_rooster_status', '');
                                        $rooster_enabled = get_option('aieo_rooster_enabled');
                                        $rooster_key = get_option('aieo_rooster_api_key');
                                        ?>
                                        <?php if ($rooster_status === 'connected') : ?>
                                            <div class="aieo-cellsubmit">
                                                <p style="color: #059669; font-weight: 600; margin: 10px 0; text-align: center;">
                                                    ✓ <?php esc_html_e('Connected to Rooster service', 'ai-eshop-optimizer'); ?>
                                                    <?php
                                                    $client_label = get_option('aieo_rooster_client_label');
                                                    if ($client_label) echo ' — ' . esc_html($client_label);
                                                    ?>
                                                </p>
                                            </div>
                                        <?php elseif ($rooster_status === 'select_site') : ?>
                                            <div class="aieo-row" style="background: #fef3c7; padding: 10px; border-radius: 6px; margin: 10px 0;">
                                                <div class="aieo-cell">
                                                    <strong><?php esc_html_e('Select your site:', 'ai-eshop-optimizer'); ?></strong>
                                                </div>
                                                <div class="aieo-cell aieo-input">
                                                    <select name="aieo_rooster_selected_client" style="width: 100%;">
                                                        <option value="">— <?php esc_html_e('Choose a site', 'ai-eshop-optimizer'); ?> —</option>
                                                        <?php
                                                        $sites_json = get_option('aieo_rooster_sites', '');
                                                        $sites = $sites_json ? json_decode($sites_json, true) : [];
                                                        foreach ($sites as $site) :
                                                            
                                                            $label = ($site['label'] ?: sprintf(__('Client #%d', 'ai-eshop-optimizer'), (int) $site['id'])) . ' — ' . ($site['site_url'] ?? '');
                                                            $linked = !empty($site['has_token']) && $site['token_status'] === 'active' ? ' ' . __('(already linked)', 'ai-eshop-optimizer') : '';
                                                        ?>
                                                            <option value="<?php echo esc_attr($site['id']); ?>"><?php echo esc_html($label . $linked); ?></option>
                                                        <?php endforeach; ?>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="aieo-cellsubmit">
                                                <input type="submit"
                                                    class="aieo-button button-primary aieo-button-pro-section aieo-center-content"
                                                    value="<?php esc_attr_e('Link This Site', 'ai-eshop-optimizer'); ?>"
                                                    style="background: #7c3aed; border-color: #7c3aed;">
                                            </div>
                                        <?php elseif ($rooster_status === 'error') : ?>
                                            <div class="aieo-cellsubmit">
                                                <p style="color: #dc2626; font-weight: 600; margin: 10px 0; text-align: center;">
                                                    ✗ <?php echo esc_html(get_option('aieo_rooster_status_message', 'Connection failed')); ?>
                                                </p>
                                            </div>
                                        <?php endif; ?>
                                        <?php if ($rooster_status !== 'select_site') : ?>
                                        <div class="aieo-cellsubmit">
                                            <input type="submit"
                                                class="aieo-button button-primary aieo-button-pro-section aieo-center-content"
                                                value="<?php echo esc_attr($rooster_status === 'connected' ? __('Update Settings', 'ai-eshop-optimizer') : __('Save & Authenticate', 'ai-eshop-optimizer')); ?>">
                                        </div>
                                        <?php endif; ?>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="aieo-modules-list-item-pro-section">
                        <div class="aieo-modules-list-item-icon-pro-section">
                            <svg id="Glyph_Line" data-name="Glyph Line" xmlns="http://www.w3.org/2000/svg"
                                viewBox="0 0 64 64">
                                <title>1</title>
                                <path
                                    d="M23.05,45.92a2.21016,2.21016,0,0,1,0-4.42A2.21016,2.21016,0,0,1,23.05,45.92Z" />
                                <path
                                    d="M28.55,33.72H17.64a.3222.3222,0,0,1-.32-.32V31.71a3.8367,3.8367,0,0,1,3.83-3.83h3.89a3.83671,3.83671,0,0,1,3.83,3.83V33.4A.329.329,0,0,1,28.55,33.72Z" />
                                <path
                                    d="M40.91,45.92a2.21008,2.21008,0,0,1,0-4.42A2.21008,2.21008,0,0,1,40.91,45.92Z" />
                                <path
                                    d="M46.36,33.72H35.45a.329.329,0,0,1-.32-.32V31.71a3.83671,3.83671,0,0,1,3.83-3.83h3.89a3.8367,3.8367,0,0,1,3.83,3.83V33.4A.3222.3222,0,0,1,46.36,33.72Z" />
                                <path
                                    d="M42.14,18.08H39.67a.97741.97741,0,0,0-.97.97v2.51c.05,2.8,4.36,2.8,4.41,0V19.05A.97091.97091,0,0,0,42.14,18.08Zm0,0H39.67a.97741.97741,0,0,0-.97.97v2.51c.05,2.8,4.36,2.8,4.41,0V19.05A.97091.97091,0,0,0,42.14,18.08ZM32,0A32,32,0,1,0,64,32,32.004,32.004,0,0,0,32,0Zm5.27,19.05a2.407,2.407,0,0,1,2.4-2.4h2.47a2.407,2.407,0,0,1,2.4,2.4v2.51c-.12,4.69-7.15,4.69-7.27,0Zm-17.81,0a2.407,2.407,0,0,1,2.4-2.4h2.47a2.407,2.407,0,0,1,2.4,2.4v2.51c-.12,4.69-7.15,4.69-7.27,0ZM51.3,44.43H44.47a3.6362,3.6362,0,0,1-7.12994,0H26.61a3.64351,3.64351,0,0,1-7.13,0H12.7a.71513.71513,0,0,1,0-1.43h6.78a3.658,3.658,0,0,1,2.86-2.86V35.15h-4.7a1.75836,1.75836,0,0,1-1.75-1.75V31.71A5.26642,5.26642,0,0,1,21.15,26.45h3.89a5.26642,5.26642,0,0,1,5.26,5.26V33.4a1.75836,1.75836,0,0,1-1.75,1.75H23.76v5A3.63452,3.63452,0,0,1,26.61,43H37.34a3.65938,3.65938,0,0,1,2.85-2.86V35.15H35.45A1.75836,1.75836,0,0,1,33.7,33.4V31.71A5.26642,5.26642,0,0,1,38.96,26.45h3.89a5.26642,5.26642,0,0,1,5.26,5.26V33.4a1.75836,1.75836,0,0,1-1.75,1.75H41.62v4.99A3.6461,3.6461,0,0,1,44.47,43H51.3A.71513.71513,0,0,1,51.3,44.43ZM43.11,21.56V19.05a.97091.97091,0,0,0-.97-.97H39.67a.97741.97741,0,0,0-.97.97v2.51C38.75,24.36,43.06,24.36,43.11,21.56Zm-17.81,0V19.05a.97741.97741,0,0,0-.97-.97H21.86a.97091.97091,0,0,0-.97.97v2.51C20.94,24.36,25.25,24.36,25.3,21.56Z" />
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-remote-transfer">
                                <?php esc_html_e('Remote Transfer', 'ai-eshop-optimizer'); ?>
                                <i class="aieo-modules-indicator-pro-section"></i>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php esc_html_e('Pro users can connect directly transfer into our servers to send their orders and other data for processing.', 'ai-eshop-optimizer'); ?>
                                </br></br>

                                <div class="aieo-table">
                                    <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                                        <?php wp_nonce_field('eshop_optimizer_transfer_to_remote_action', 'eshop_optimizer_transfer_to_remote_nonce_8'); ?>
                                        <input type="hidden" name="action" value="eshop_optimizer_transfer_to_remote">

                                </div>
                                <div class="aieo-cellsubmit">

                                    <?php
                                    
                                    $aieo_account_type = get_option('aieo_user_membership');

                                    
                                    if ($aieo_account_type !== 'Pro') {
                                        echo '<input type="submit" class="aieo-button button-primary aieo-button-pro-section aieo-center-content" value="' . esc_attr__('Remote Transfer of Orders', 'ai-eshop-optimizer') . '" disabled>';
                                    } else {
                                        echo '<input type="submit" class="aieo-button button-primary aieo-button-pro-section aieo-center-content" value="' . esc_attr__('Remote Transfer of Orders', 'ai-eshop-optimizer') . '">';
                                    }
                                    ?>

                                </div>
                                </form>

                                <?php
                                
                                $rooster_connected = get_option('aieo_rooster_status') === 'connected' && get_option('aieo_rooster_enabled');
                                if ($rooster_connected) :
                                ?>
                                <div style="margin-top: 15px; padding-top: 15px; border-top: 1px dashed #ccc;">
                                    <div class="aieo-cellsubmit" style="display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;">
                                        <button type="button" id="aieo-rooster-transfer-btn"
                                            class="aieo-button button-primary aieo-button-pro-section"
                                            style="background: #7c3aed; border-color: #7c3aed; cursor: pointer;"
                                            onclick="aieoRoosterTransfer('delta')">
                                            <?php esc_html_e('Sync New Orders', 'ai-eshop-optimizer'); ?>
                                        </button>
                                        <button type="button" id="aieo-rooster-full-sync-btn"
                                            class="aieo-button aieo-button-pro-section"
                                            style="background: #dc2626; border-color: #dc2626; color: white; cursor: pointer;"
                                            onclick="aieoRoosterTransfer('full')">
                                            <?php esc_html_e('Full Sync (replace all)', 'ai-eshop-optimizer'); ?>
                                        </button>
                                    </div>
                                    <div id="aieo-rooster-progress" style="display:none; margin-top: 12px;">
                                        <div style="background: #e5e7eb; border-radius: 8px; height: 24px; overflow: hidden; position: relative;">
                                            <div id="aieo-rooster-bar" style="background: #7c3aed; height: 100%; width: 0%; transition: width 0.3s; border-radius: 8px;"></div>
                                            <span id="aieo-rooster-pct" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 12px; font-weight: 600; color: #374151;">0%</span>
                                        </div>
                                        <div style="display: flex; gap: 8px; justify-content: center; margin-top: 8px;">
                                            <button type="button" id="aieo-rooster-pause" onclick="aieoRoosterPause()" style="display:none; padding: 4px 16px; border-radius: 6px; border: 1px solid #d97706; background: #fef3c7; color: #92400e; font-size: 12px; cursor: pointer;">
                                                ⏸ Pause
                                            </button>
                                            <button type="button" id="aieo-rooster-stop" onclick="aieoRoosterStop()" style="display:none; padding: 4px 16px; border-radius: 6px; border: 1px solid #dc2626; background: #fef2f2; color: #991b1b; font-size: 12px; cursor: pointer;">
                                                ⏹ Stop
                                            </button>
                                        </div>
                                        <p id="aieo-rooster-status" style="text-align: center; font-size: 12px; color: #666; margin-top: 6px;"><?php esc_html_e('Initializing...', 'ai-eshop-optimizer'); ?></p>
                                    </div>
                                    <?php
                                    $last_sync = get_option('aieo_rooster_last_sync');
                                    if ($last_sync) :
                                    ?>
                                    <p style="text-align: center; font-size: 12px; color: #059669; margin-top: 8px;">
                                        <?php echo esc_html__('Last sync: ', 'ai-eshop-optimizer') . esc_html($last_sync); ?>
                                    </p>
                                    <?php endif; ?>
                                </div>
                                <script>
                                var aieoRoosterI18n = {
                                    pause: <?php echo wp_json_encode(__('⏸ Pause', 'ai-eshop-optimizer')); ?>,
                                    resume: <?php echo wp_json_encode(__('▶ Resume', 'ai-eshop-optimizer')); ?>,
                                    paused: <?php echo wp_json_encode(__(' (paused)', 'ai-eshop-optimizer')); ?>,
                                    stopConfirm: <?php echo wp_json_encode(__('Stop the transfer? Data already sent will be kept.', 'ai-eshop-optimizer')); ?>,
                                    transferStopped: <?php echo wp_json_encode(__('Transfer stopped. Partial data saved.', 'ai-eshop-optimizer')); ?>,
                                    fullConfirm: <?php echo wp_json_encode(__('This will delete all existing data on the Hub and re-transfer everything. Continue?', 'ai-eshop-optimizer')); ?>,
                                    syncNewOrders: <?php echo wp_json_encode(__('Sync New Orders', 'ai-eshop-optimizer')); ?>,
                                    initializing: <?php echo wp_json_encode(__('Initializing...', 'ai-eshop-optimizer')); ?>,
                                    errorPrefix: <?php echo wp_json_encode(__('Error: ', 'ai-eshop-optimizer')); ?>,
                                    initFailed: <?php echo wp_json_encode(__('Init failed', 'ai-eshop-optimizer')); ?>,
                                    batchFailed: <?php echo wp_json_encode(__('Batch failed', 'ai-eshop-optimizer')); ?>,
                                    noNewData: <?php echo wp_json_encode(__('No new data to sync.', 'ai-eshop-optimizer')); ?>,
                                    transferring: <?php echo wp_json_encode(__('Transferring...', 'ai-eshop-optimizer')); ?>,
                                    transferComplete: <?php  echo wp_json_encode(__('Transfer complete: %s rows synced.', 'ai-eshop-optimizer')); ?>,
                                    rowsProgress: <?php  echo wp_json_encode(__('%1$s / %2$s rows', 'ai-eshop-optimizer')); ?>
                                };

                                var _roosterPaused = false;
                                var _roosterStopped = false;
                                var _roosterResumeCallback = null;

                                function aieoRoosterPause() {
                                    const pauseBtn = document.getElementById('aieo-rooster-pause');
                                    const status = document.getElementById('aieo-rooster-status');
                                    if (_roosterPaused) {
                                        _roosterPaused = false;
                                        pauseBtn.innerHTML = aieoRoosterI18n.pause;
                                        pauseBtn.style.background = '#fef3c7';
                                        pauseBtn.style.color = '#92400e';
                                        pauseBtn.style.borderColor = '#d97706';
                                        status.textContent = status.textContent.replace(aieoRoosterI18n.paused, '');
                                        if (_roosterResumeCallback) _roosterResumeCallback();
                                    } else {
                                        _roosterPaused = true;
                                        pauseBtn.innerHTML = aieoRoosterI18n.resume;
                                        pauseBtn.style.background = '#dcfce7';
                                        pauseBtn.style.color = '#166534';
                                        pauseBtn.style.borderColor = '#16a34a';
                                        status.textContent += aieoRoosterI18n.paused;
                                    }
                                }

                                function aieoRoosterStop() {
                                    if (!confirm(aieoRoosterI18n.stopConfirm)) return;
                                    _roosterStopped = true;
                                    _roosterPaused = false;
                                    const status = document.getElementById('aieo-rooster-status');
                                    status.textContent = aieoRoosterI18n.transferStopped;
                                    status.style.color = '#dc2626';
                                    _roosterResetButtons();
                                }

                                function _roosterResetButtons() {
                                    const btn = document.getElementById('aieo-rooster-transfer-btn');
                                    const fullBtn = document.getElementById('aieo-rooster-full-sync-btn');
                                    const pauseBtn = document.getElementById('aieo-rooster-pause');
                                    const stopBtn = document.getElementById('aieo-rooster-stop');
                                    if (btn) { btn.disabled = false; btn.textContent = aieoRoosterI18n.syncNewOrders; }
                                    if (fullBtn) fullBtn.disabled = false;
                                    if (pauseBtn) pauseBtn.style.display = 'none';
                                    if (stopBtn) stopBtn.style.display = 'none';
                                }

                                function aieoRoosterTransfer(mode) {
                                    if (mode === 'full' && !confirm(aieoRoosterI18n.fullConfirm)) return;

                                    const btn = document.getElementById('aieo-rooster-transfer-btn');
                                    const fullBtn = document.getElementById('aieo-rooster-full-sync-btn');
                                    const progress = document.getElementById('aieo-rooster-progress');
                                    const bar = document.getElementById('aieo-rooster-bar');
                                    const pct = document.getElementById('aieo-rooster-pct');
                                    const status = document.getElementById('aieo-rooster-status');

                                    _roosterPaused = false;
                                    _roosterStopped = false;
                                    btn.disabled = true;
                                    if (fullBtn) fullBtn.disabled = true;
                                    btn.textContent = aieoRoosterI18n.initializing;
                                    progress.style.display = 'block';
                                    document.getElementById('aieo-rooster-pause').style.display = '';
                                    document.getElementById('aieo-rooster-stop').style.display = '';

                                    // Step 1: Init
                                    jQuery.post(ajaxurl, {
                                        action: 'aieo_rooster_transfer_init',
                                        nonce: '<?php echo esc_js(wp_create_nonce("aieo_rooster_transfer_nonce")); ?>',
                                        mode: mode
                                    }, function(resp) {
                                        if (!resp.success) {
                                            status.textContent = aieoRoosterI18n.errorPrefix + (resp.data || aieoRoosterI18n.initFailed);
                                            status.style.color = '#dc2626';
                                            btn.disabled = false;
                                            _roosterResetButtons();
                                            return;
                                        }
                                        const d = resp.data;
                                        if (d.total_rows === 0) {
                                            bar.style.width = '100%';
                                            pct.textContent = '100%';
                                            status.textContent = aieoRoosterI18n.noNewData;
                                            status.style.color = '#059669';
                                            btn.disabled = false;
                                            _roosterResetButtons();
                                            return;
                                        }

                                        btn.textContent = aieoRoosterI18n.transferring;
                                        status.textContent = aieoRoosterI18n.rowsProgress
                                            .replace('%1$s', '0')
                                            .replace('%2$s', d.total_rows.toLocaleString());
                                        let totalSent = 0;

                                        function sendBatch(offset) {
                                            if (_roosterStopped) { _roosterResetButtons(); return; }
                                            if (_roosterPaused) {
                                                _roosterResumeCallback = function() { sendBatch(offset); };
                                                return;
                                            }
                                            jQuery.post(ajaxurl, {
                                                action: 'aieo_rooster_transfer_batch',
                                                nonce: '<?php echo esc_js(wp_create_nonce("aieo_rooster_transfer_nonce")); ?>',
                                                client_id: d.client_id,
                                                cursor: d.orders_cursor,
                                                batch_size: d.batch_size,
                                                offset: offset
                                            }, function(resp2) {
                                                if (!resp2.success) {
                                                    status.textContent = aieoRoosterI18n.errorPrefix + (resp2.data || aieoRoosterI18n.batchFailed);
                                                    status.style.color = '#dc2626';
                                                    btn.disabled = false;
                                                    _roosterResetButtons();
                                                    return;
                                                }
                                                totalSent += resp2.data.sent;
                                                const percent = Math.min(100, Math.round((totalSent / d.total_rows) * 100));
                                                bar.style.width = percent + '%';
                                                pct.textContent = percent + '%';
                                                status.textContent = aieoRoosterI18n.rowsProgress
                                                    .replace('%1$s', totalSent.toLocaleString())
                                                    .replace('%2$s', d.total_rows.toLocaleString());

                                                if (resp2.data.done) {
                                                    bar.style.width = '100%';
                                                    pct.textContent = '100%';
                                                    status.textContent = aieoRoosterI18n.transferComplete.replace('%s', totalSent.toLocaleString());
                                                    status.style.color = '#059669';
                                                    btn.disabled = false;
                                                    _roosterResetButtons();
                                                } else {
                                                    sendBatch(resp2.data.offset);
                                                }
                                            });
                                        }
                                        sendBatch(0);
                                    });
                                }
                                </script>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>

                    <div class="aieo-modules-list-item-pro-section">
                        <div class="aieo-modules-list-item-icon-pro-section">
                            <svg id="glipy" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
                                <title>1</title>
                                <path
                                    d="M32,3A29,29,0,1,0,61,32,29.0337,29.0337,0,0,0,32,3Zm0,52.5A23.5,23.5,0,1,1,55.5,32,23.524,23.524,0,0,1,32,55.5Z" />
                                <path
                                    d="M32,10.5A21.5,21.5,0,1,0,53.5,32,21.52451,21.52451,0,0,0,32,10.5Zm3.52,2.91A19.01318,19.01318,0,0,1,50.59,28.48a1.00782,1.00782,0,0,1-.8,1.17,1.10085,1.10085,0,0,1-.18.02,1.00667,1.00667,0,0,1-.99-.82A16.98412,16.98412,0,0,0,35.15,15.38a1.00224,1.00224,0,1,1,.37-1.97Zm6.77,9.68L35.21,34.87a.9238.9238,0,0,1-.34.34L23.09,42.29a1.06678,1.06678,0,0,1-.52.14,1.01537,1.01537,0,0,1-.86-1.52l7.08-11.78a.9244.9244,0,0,1,.34-.34l11.78-7.08A1.01248,1.01248,0,0,1,42.29,23.09ZM31,12.43a1,1,0,0,1,2,0v3.34a1,1,0,0,1-2,0Zm-2.52.98a1.0027,1.0027,0,0,1,1.17.8,1.01313,1.01313,0,0,1-.8,1.17A16.98412,16.98412,0,0,0,15.38,28.85a1.00667,1.00667,0,0,1-.99.82,1.10085,1.10085,0,0,1-.18-.02A1.00782,1.00782,0,0,1,13.41,28.48,19.01318,19.01318,0,0,1,28.48,13.41ZM11.43,32a1.003,1.003,0,0,1,1-1h3.34a1,1,0,0,1,0,2H12.43A1.003,1.003,0,0,1,11.43,32ZM28.67,50.61a1.22418,1.22418,0,0,1-.19-.02A19.01311,19.01311,0,0,1,13.41,35.52a1.00224,1.00224,0,0,1,1.97-.37A16.98419,16.98419,0,0,0,28.85,48.62a1.00377,1.00377,0,0,1-.18,1.99Zm4.33.96a1,1,0,0,1-2,0V48.23a1,1,0,0,1,2,0Zm2.52-.98a1.22418,1.22418,0,0,1-.19.02,1.00377,1.00377,0,0,1-.18-1.99,16.97933,16.97933,0,0,0,13.5-13.59.99955.99955,0,0,1,1.16-.81,1.01241,1.01241,0,0,1,.81,1.16A19.01834,19.01834,0,0,1,35.52,50.59ZM51.57,33H48.23a1,1,0,0,1,0-2h3.34a1,1,0,0,1,0,2Z" />
                                <polygon points="25.49 38.51 33.63 33.63 38.51 25.49 30.37 30.37 25.49 38.51" />
                            </svg>
                        </div>
                        <div class="aieo-modules-list-item-content">
                            <div class="aieo-modules-list-item-title" id="aieo-card-profitability">
                                <?php esc_html_e('Inspect Profitability and Identify Premium Products', 'ai-eshop-optimizer'); ?>
                            </div>
                            <div class="aieo-modules-list-item-desc">
                                <?php
                                
                                printf(wp_kses_post(__('Visit <strong><u><a href="%s" title="Dashboard" target="_blank">Rooster AI Eshop Optimizer</a></u></strong> to access the statistics of your most valuable products with tips on how improve them!', 'ai-eshop-optimizer')), 'https://rooster.systems/dashboard'); ?>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<?php

?>