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

class Sifency_Addons_System {

    public function render_system_info_tab() {
            $system_info_data = [];
            if ( class_exists('\Elementor\System_Info\Manager') ) {
                $system_info_data = \Elementor\System_Info\Manager::get_system_info();
            }
            ?>
            <h2><?php esc_html_e( 'System Information', 'sifency-addons' ); ?></h2>
            <p><?php esc_html_e( 'Use this information when reporting issues to our support team.', 'sifency-addons' ); ?></p>
            <textarea id="sifency-system-info-textarea" readonly rows="20"><?php
                $report = '';
                $report .= "---\n\n";
                $report .= "## Sifency Addons Info ##\n\n";
                $report .= "Plugin Version: " . SIFENCY_ADDONS_VERSION . "\n";
                $report .= "\n---\n\n";
                foreach ( $system_info_data as $section_key => $section ) {
                    if ( in_array($section_key, ['wp-server', 'wp-active-plugins', 'wp-theme']) ) {
                        $report .= "## " . esc_html( $section['label'] ) . " ##\n\n";
                        foreach ( $section['fields'] as $field_key => $field ) {
                            $report .= esc_html( $field['label'] ) . ": " . esc_html( $field['value'] ) . "\n";
                        }
                        $report .= "\n---\n\n";
                    }
                }
                echo esc_textarea( $report );
            ?></textarea>
            <p><button id="sifency-copy-system-info" class="button button-primary sifency-admin-btn"><?php esc_html_e( 'Copy for Support', 'sifency-addons' ); ?></button></p>
            <?php
        }
}