<?php
/**
 * Diagnostics Page - Connection Health & Troubleshooting
 *
 * @package Consolety
 */
if (!defined('ABSPATH')) exit;

$consolety_ctx = \Consolety\PageContext::get();
?>

<div class="vp-dashboard">
    <?php
    $consolety_page_icon = 'dashicons-sos';
    $consolety_page_title = __('Diagnostics', 'consolety');
    $consolety_page_sub = __('Check your Consolety connection health and troubleshoot issues.', 'consolety');
    $consolety_show_credits = false;
    $consolety_show_tier = false;
    include CONSOLETY_PLUGIN_DIR . 'admin/views/components/page-header.php';
    ?>

    <!-- Diagnostics Results -->
    <div class="vp-card">
        <h2>
            <span class="dashicons dashicons-heart vp-card-icon"></span>
            <?php esc_html_e('Connection Health', 'consolety'); ?>
        </h2>

        <div id="diagnostics-results">
            <div class="vp-loading-state">
                <span class="spinner is-active"></span>
                <?php esc_html_e('Running diagnostics...', 'consolety'); ?>
            </div>
        </div>
    </div>

    <!-- Action Buttons -->
    <div class="vp-card">
        <h2>
            <span class="dashicons dashicons-admin-tools vp-card-icon"></span>
            <?php esc_html_e('Actions', 'consolety'); ?>
        </h2>
        <p class="vp-plan-card-desc">
            <?php esc_html_e('Use these tools to fix common issues.', 'consolety'); ?>
        </p>

        <div class="vp-diagnostics-actions">
            <button type="button" class="vp-btn vp-btn-secondary" id="btn-force-tier-sync">
                <span class="dashicons dashicons-update"></span>
                <?php esc_html_e('Force Tier Sync', 'consolety'); ?>
            </button>

            <button type="button" class="vp-btn vp-btn-secondary" id="btn-send-heartbeat">
                <span class="dashicons dashicons-heart"></span>
                <?php esc_html_e('Send Heartbeat', 'consolety'); ?>
            </button>

            <button type="button" class="vp-btn vp-btn-secondary" id="btn-clear-caches">
                <span class="dashicons dashicons-trash"></span>
                <?php esc_html_e('Clear Caches', 'consolety'); ?>
            </button>

            <button type="button" class="vp-btn vp-btn-primary" id="btn-rerun-diagnostics">
                <span class="dashicons dashicons-controls-repeat"></span>
                <?php esc_html_e('Re-run Diagnostics', 'consolety'); ?>
            </button>
        </div>
        <div id="action-status" style="margin-top: 12px; font-weight: 500;"></div>
    </div>

    <!-- Copy Diagnostics -->
    <div class="vp-card">
        <h2>
            <span class="dashicons dashicons-clipboard vp-card-icon"></span>
            <?php esc_html_e('Support', 'consolety'); ?>
        </h2>
        <p class="vp-plan-card-desc">
            <?php esc_html_e('Copy diagnostics data to share with support.', 'consolety'); ?>
        </p>
        <button type="button" class="vp-btn vp-btn-ghost" id="btn-copy-diagnostics">
            <span class="dashicons dashicons-admin-page"></span>
            <?php esc_html_e('Copy to Clipboard', 'consolety'); ?>
        </button>
    </div>
</div>
