<?php
/**
 * Template: About
 *
 * Displays plugin version, connected account info, and support links.
 *
 * @var array $data JSON data from Cloud API (heartbeat response).
 *                  Expected keys: websiteId, planName, accountEmail, domain, apiVersion, latestPluginVersion.
 * @package Biscotti_CMP
 */

defined( 'ABSPATH' ) || exit;

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template is included inside Biscotti_Admin::render_dynamic_page(); these are function-scoped locals, not globals.

$page_title = __( 'About Biscotti CMP', 'biscotti-cmp' );
include __DIR__ . '/partials/page-header.php';
?>

<div class="biscotti-page biscotti-page-about">

	<?php if ( empty( $data ) ) : ?>
		<?php include __DIR__ . '/partials/loading-state.php'; ?>
	<?php else : ?>

		<!-- Plugin Information -->
		<div class="biscotti-info-card">
			<h2><?php esc_html_e( 'Plugin Information', 'biscotti-cmp' ); ?></h2>
			<table class="form-table" role="presentation">
				<tbody>
					<tr>
						<th scope="row"><?php esc_html_e( 'Plugin Version', 'biscotti-cmp' ); ?></th>
						<td><?php echo esc_html( BISCOTTI_VERSION ); ?></td>
					</tr>
					<tr>
						<th scope="row"><?php esc_html_e( 'Website ID', 'biscotti-cmp' ); ?></th>
						<td><code><?php echo esc_html( $data['websiteId'] ?? '' ); ?></code></td>
					</tr>
					<tr>
						<th scope="row"><?php esc_html_e( 'Plan', 'biscotti-cmp' ); ?></th>
						<td><?php echo esc_html( $data['planName'] ?? __( 'Unknown', 'biscotti-cmp' ) ); ?></td>
					</tr>
					<tr>
						<th scope="row"><?php esc_html_e( 'Account Email', 'biscotti-cmp' ); ?></th>
						<td><?php echo esc_html( $data['accountEmail'] ?? '' ); ?></td>
					</tr>
					<tr>
						<th scope="row"><?php esc_html_e( 'Connected Domain', 'biscotti-cmp' ); ?></th>
						<td><?php echo esc_html( $data['domain'] ?? '' ); ?></td>
					</tr>
				</tbody>
			</table>
		</div>

		<!-- Support Links -->
		<div class="biscotti-info-card">
			<h2><?php esc_html_e( 'Support & Resources', 'biscotti-cmp' ); ?></h2>
			<table class="form-table" role="presentation">
				<tbody>
					<tr>
						<th scope="row"><?php esc_html_e( 'Documentation', 'biscotti-cmp' ); ?></th>
						<td>
							<a href="<?php echo esc_url( 'https://docs.biscotti-cmp.com' ); ?>" target="_blank" rel="noopener">
								<?php esc_html_e( 'View Documentation', 'biscotti-cmp' ); ?>
							</a>
						</td>
					</tr>
					<tr>
						<th scope="row"><?php esc_html_e( 'Contact Support', 'biscotti-cmp' ); ?></th>
						<td>
							<a href="<?php echo esc_url( 'mailto:support@biscotti-cmp.com' ); ?>">
								<?php esc_html_e( 'support@biscotti-cmp.com', 'biscotti-cmp' ); ?>
							</a>
						</td>
					</tr>
					<tr>
						<th scope="row"><?php esc_html_e( 'Dashboard', 'biscotti-cmp' ); ?></th>
						<td>
							<a href="<?php echo esc_url( 'https://app.biscotti-cmp.com' ); ?>" target="_blank" rel="noopener">
								<?php esc_html_e( 'Open Biscotti Dashboard', 'biscotti-cmp' ); ?>
							</a>
						</td>
					</tr>
				</tbody>
			</table>
		</div>

	<?php endif; ?>

</div>
