<?php
/**
 * 247ChatMate — Plan Access Support Diagnostics Summary
 *
 * Phase 5-A-21Q
 * Checkpoint: PLANLICENCECLEANEXPANDEDDIAGNOSTICS5A21Q
 *
 * Purpose:
 * - Replace the previous expanded diagnostic dump with a compact, customer-safe summary.
 * - Keep support diagnostics useful without exposing endpoints, raw registry payloads,
 *   install IDs, hashes, raw validation values or internal lifecycle panels.
 *
 * Does not:
 * - Validate licences, refresh registries, start trials, change entitlement decisions,
 *   change save handling, alter widget/chip behaviour or alter WhatsApp handoff.
 */

defined('ABSPATH') || exit;

$matewa_support_plan_label = isset($status_badge_text) ? (string) $status_badge_text : ucfirst((string) ($mode ?? 'free'));

$matewa_support_access_source = 'Saved settings';
if (('founder_beta_registry' === ($license_source ?? '')) || !empty($founder_beta_is_registered)) {
    $matewa_support_access_source = 'Founder Beta';
} elseif ('pro' === ($mode ?? '')) {
    $matewa_support_access_source = 'Paid licence';
} elseif ('trial_active' === ($mode ?? '')) {
    $matewa_support_access_source = 'Trial';
} elseif ('trial_expired' === ($mode ?? '')) {
    $matewa_support_access_source = 'Expired trial';
} elseif ('master' === ($mode ?? '')) {
    $matewa_support_access_source = 'Master access';
} elseif ('free' === ($mode ?? '')) {
    $matewa_support_access_source = 'Free plan';
}

$matewa_support_key_label = !empty($has_key) ? 'Saved' : 'Not saved';

$matewa_support_time_label = 'Not checked yet';
if (!empty($founder_beta_is_registered) && !empty($founder_beta_checked_display)) {
    $matewa_support_time_label = (string) $founder_beta_checked_display;
} elseif (!empty($paid_registry_checked_display) && 'Not synced yet' !== $paid_registry_checked_display) {
    $matewa_support_time_label = (string) $paid_registry_checked_display;
} elseif (!empty($trial_registry_checked_display) && 'Not checked yet' !== $trial_registry_checked_display) {
    $matewa_support_time_label = (string) $trial_registry_checked_display;
}

$matewa_support_countdown_label = 'Not active';
if (!empty($founder_beta_is_registered) && !empty($founder_beta_days_label)) {
    $matewa_support_countdown_label = (string) $founder_beta_days_label;
} elseif ('trial_active' === ($mode ?? '') && !empty($trial_remaining_label)) {
    $matewa_support_countdown_label = (string) $trial_remaining_label;
} elseif ('pro' === ($mode ?? '') || 'master' === ($mode ?? '')) {
    $matewa_support_countdown_label = 'Not needed';
}
?>

<div class="matewa-support-summary-grid" aria-label="Safe support summary">
    <div class="matewa-support-summary-card">
        <strong>Visible plan</strong>
        <span><?php echo esc_html($matewa_support_plan_label); ?></span>
    </div>

    <div class="matewa-support-summary-card">
        <strong>Access type</strong>
        <span><?php echo esc_html($matewa_support_access_source); ?></span>
    </div>

    <div class="matewa-support-summary-card">
        <strong>Countdown</strong>
        <span><?php echo esc_html($matewa_support_countdown_label); ?></span>
    </div>

    <div class="matewa-support-summary-card">
        <strong>Key status</strong>
        <span><?php echo esc_html($matewa_support_key_label); ?></span>
    </div>

    <div class="matewa-support-summary-card">
        <strong>Last status check</strong>
        <span><?php echo esc_html($matewa_support_time_label); ?></span>
    </div>
</div>

<p class="matewa-support-safe-note">
    Hidden from this screen: endpoint URLs, registry payloads, lifecycle dumps, install identifiers, hashes, raw licence values, invite codes and IP data.
</p>
