<?php
/**
 * Teaser pages for locked Pro features.
 *
 * Renders placeholder pages for Campaigns, Tiers, and Donors when the Pro
 * add-on is inactive. Each teaser shows a preview mockup of the feature
 * and a CTA routing to the Upgrade page (Placement 1).
 *
 * Per Placement 2 in docs/WEEK6-UPSELL-SPEC.md.
 *
 * @package Donatico\Admin
 */

declare(strict_types=1);

namespace Donatico\Admin;

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

/**
 * Renders feature teaser pages that promote Donatico Pro.
 */
class Teasers {

	/**
	 * Render the Campaigns teaser page.
	 *
	 * @return void
	 */
	public function renderCampaigns(): void {
		$this->renderTeaserPage(
			__( 'Campaigns — coming with Donatico Pro', 'donatico' ),
			__( 'Track fundraising goals across multiple causes. Set targets, watch progress in real time, and celebrate when each campaign closes. Built-in progress bars and donor counts make it easy to share traction with your supporters.', 'donatico' ),
			'campaigns.svg',
			__( 'Campaigns dashboard preview showing the Winter Coat Drive 2026 campaign with progress bar at 70 percent funded', 'donatico' )
		);
	}

	/**
	 * Render the Tiers teaser page.
	 *
	 * @return void
	 */
	public function renderTiers(): void {
		$this->renderTeaserPage(
			__( 'Donation Tiers — coming with Donatico Pro', 'donatico' ),
			__( 'Guide donors toward meaningful gifts with preset tiers. Configure suggested amounts with descriptive labels — what does $25 provide? $50? Tiers convert higher than open-ended donation forms because donors see the impact of each gift level.', 'donatico' ),
			'tiers.svg',
			__( 'Donation tier selector showing three preset amounts of 25, 50, and 100 dollars with the middle tier highlighted as popular', 'donatico' )
		);
	}

	/**
	 * Render the Recurring Donations teaser page.
	 *
	 * @return void
	 */
	public function renderRecurring(): void {
		$this->renderTeaserPage(
			__( 'Recurring Donations — coming with Donatico Pro', 'donatico' ),
			__( 'Turn one-time gifts into dependable monthly support. Recurring donations give your cause predictable income that compounds over time — a single $25/month donor is worth $300 a year, renewing automatically through Stripe. Supporters can manage their own subscriptions through a secure self-service portal, and you see your Monthly Recurring Revenue at a glance.', 'donatico' ),
			'recurring.svg',
			__( 'Subscriptions dashboard showing monthly recurring donors with amounts, statuses, and total recurring revenue.', 'donatico' )
		);
	}

	/**
	 * Render the Donors teaser page.
	 *
	 * @return void
	 */
	public function renderDonors(): void {
		$this->renderTeaserPage(
			__( 'Donors — coming with Donatico Pro', 'donatico' ),
			__( 'Manage your donor relationships from inside WordPress. See lifetime giving totals, donation history, and last gift date for every supporter. Sort, filter, and follow up with the right people at the right time.', 'donatico' ),
			'donors.svg',
			__( 'Donor management table showing five donors with lifetime totals, donation counts, and last gift dates', 'donatico' )
		);
	}

	/**
	 * Render the shared teaser page layout.
	 *
	 * @param string $heading      The page H1 heading.
	 * @param string $description  The 2-3 sentence feature description.
	 * @param string $mockup_file  The SVG filename in assets/upgrade/teasers/.
	 * @param string $mockup_alt   The alt text for the mockup image.
	 * @return void
	 */
	private function renderTeaserPage( string $heading, string $description, string $mockup_file, string $mockup_alt ): void {
		if ( ! current_user_can( 'manage_options' ) ) {
			return;
		}

		$mockup_url  = DONATICO_PLUGIN_URL . 'assets/upgrade/teasers/' . $mockup_file;
		$upgrade_url = admin_url( 'admin.php?page=donatico-upgrade' );
		?>
		<div class="wrap donatico-teaser-wrap">

			<div class="donatico-teaser-card">

				<div class="donatico-teaser-badge">
					<span class="donatico-teaser-badge-icon" aria-hidden="true">★</span>
					<?php esc_html_e( 'Pro Feature', 'donatico' ); ?>
				</div>

				<h1 class="donatico-teaser-heading"><?php echo esc_html( $heading ); ?></h1>

				<p class="donatico-teaser-description"><?php echo esc_html( $description ); ?></p>

				<div class="donatico-teaser-mockup">
					<img
						src="<?php echo esc_url( $mockup_url ); ?>"
						alt="<?php echo esc_attr( $mockup_alt ); ?>"
						class="donatico-teaser-mockup-img"
					/>
				</div>

				<div class="donatico-teaser-cta">

						<a
						href="<?php echo esc_url( $upgrade_url ); ?>"
						class="button button-primary button-hero donatico-teaser-cta-button"
					>
						<?php esc_html_e( 'Learn more about Pro →', 'donatico' ); ?>
					</a>
					<p class="donatico-teaser-cta-subtext">
						<?php esc_html_e( 'Plans start at $49/year with a 14-day money-back guarantee.', 'donatico' ); ?>
					</p>
				</div>

			</div>

		</div>
		<?php
	}
}
