<?php
/**
 * Blog Over Pro Feature Card Control
 *
 * Renders a beautiful gold-badge informational card in the WordPress Customizer.
 * Shows real Pro features for each section so users know exactly what they unlock.
 *
 * Follows WordPress.org theme guidelines:
 *  - No disabled controls, no fake toggles, no trialware behavior.
 *  - Purely informational — a styled notice with a link.
 *
 * @package Blog_Over
 * @since   2.2.0
 */

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

if ( ! class_exists( 'WP_Customize_Control' ) ) {
	return;
}

/**
 * Pro Feature Card control — gold-badge styled notice for Customizer sections.
 *
 * Usage:
 *   new Blog_Over_Pro_Card_Control( $wp_customize, $id, array(
 *       'section'       => 'some_section',
 *       'section_label' => __( 'Menu & Header', 'blog-over' ),
 *       'features'      => array( 'Feature one', 'Feature two' ),
 *       'pro_url'       => 'https://awplife.com/wordpress-themes/blog-over/',
 *       'priority'      => 999,
 *   ) );
 */
class Blog_Over_Pro_Card_Control extends WP_Customize_Control {

	/**
	 * Control type identifier.
	 *
	 * @var string
	 */
	public $type = 'blog-over-pro-feature';

	/**
	 * Human-readable section label shown in the card header.
	 *
	 * @var string
	 */
	public $section_label = '';

	/**
	 * Array of Pro feature strings to list inside the card.
	 *
	 * @var array
	 */
	public $features = array();

	/**
	 * URL for the "Upgrade to Pro" button.
	 *
	 * @var string
	 */
	public $pro_url = 'https://awplife.com/wordpress-themes/blog-over/';

	/**
	 * Render the card HTML.
	 */
	public function render_content() {
		$label   = ! empty( $this->section_label ) ? $this->section_label : __( 'This Section', 'blog-over' );
		$pro_url = esc_url( $this->pro_url );
		?>
		<div class="blog-over-pro-card" role="note" aria-label="<?php esc_attr_e( 'Pro features available', 'blog-over' ); ?>">

			<div class="blog-over-pro-card-header">
				<span class="blog-over-pro-badge">
					<span class="blog-over-pro-badge-star">&#9733;</span>
					<?php esc_html_e( 'PRO', 'blog-over' ); ?>
				</span>
				<span class="blog-over-pro-card-title">
					<?php
					/* translators: %s: section label */
					printf( esc_html__( '%s — Unlock More', 'blog-over' ), esc_html( $label ) );
					?>
				</span>
			</div>

			<?php if ( ! empty( $this->features ) ) : ?>
				<ul class="blog-over-pro-features-list">
					<?php foreach ( $this->features as $feature ) : ?>
						<li><?php echo esc_html( $feature ); ?></li>
					<?php endforeach; ?>
				</ul>
			<?php endif; ?>

			<a href="<?php echo $pro_url; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>"
				class="blog-over-pro-card-link"
				target="_blank"
				rel="noopener noreferrer">
				<?php esc_html_e( 'Upgrade to Pro &rarr;', 'blog-over' ); ?>
			</a>

		</div>
		<?php
	}
}
