<?php
/**
 * The Upgrade page — the ONE Pro pointer wp.org allows in the free build
 * (Guideline 5). It ships in BOTH builds and is our own localized landing page,
 * never the Freemius SDK's English-only pricing app. It carries no locked
 * feature surface: it is purely informational and links to the checkout.
 *
 * Present in the free build on purpose (it is the allowed pointer), so it lives
 * in the free engine, not behind a premium marker.
 *
 * @package ErenLabs\QuickVariableProducts
 */

defined( 'ABSPATH' ) || exit;

class ERENQVP_Upgrade {

	const PAGE = 'erenqvp-upgrade';

	/**
	 * @return void
	 */
	public static function init() {
		add_action( 'admin_menu', array( __CLASS__, 'menu' ), 20 );
		add_action( 'admin_enqueue_scripts', array( __CLASS__, 'assets' ) );
	}

	/**
	 * Add the Upgrade submenu — only for users who don't already have Pro.
	 *
	 * @return void
	 */
	public static function menu() {
		if ( function_exists( 'erenqvp_is_pro' ) && erenqvp_is_pro() ) {
			return;
		}
		add_submenu_page(
			'erenqvp-add',
			__( 'Upgrade to Pro', 'quick-variable-products' ),
			// A leading mark + the label; the menu stylesheet makes it stand out.
			'<span class="qvp-menu-up">✦ ' . esc_html__( 'Upgrade', 'quick-variable-products' ) . '</span>',
			ERENQVP_CAP,
			self::PAGE,
			array( __CLASS__, 'render' )
		);
	}

	/**
	 * Highlight stylesheet loads on every admin page (so the menu item stands out);
	 * the full landing-page stylesheet loads only on the Upgrade screen.
	 *
	 * @param string $hook Current admin page hook.
	 * @return void
	 */
	public static function assets( $hook ) {
		wp_enqueue_style( 'erenqvp-menu', ERENQVP_URL . 'assets/qvp-menu.css', array(), ERENQVP_VER );
		if ( false !== strpos( (string) $hook, self::PAGE ) ) {
			// Cache-bust by file mtime so a stylesheet change within the same plugin
			// version is never served stale by a page cache or proxy.
			$path = ERENQVP_DIR . 'assets/qvp-upgrade.css';
			$ver  = file_exists( $path ) ? ERENQVP_VER . '.' . (string) filemtime( $path ) : ERENQVP_VER;
			wp_enqueue_style( 'erenqvp-upgrade', ERENQVP_URL . 'assets/qvp-upgrade.css', array(), $ver );
		}
	}

	/**
	 * The comparison rows: mirrors the ACTUAL Pro feature list (readme.txt) so the
	 * page never under-sells. label => is-in-free.
	 *
	 * @return array
	 */
	private static function rows() {
		return array(
			array( __( 'Variation-matrix create screen (any attributes, per-row stock/SKU/price)', 'quick-variable-products' ), true ),
			array( __( 'Per-variation images', 'quick-variable-products' ), true ),
			array( __( 'Simple products', 'quick-variable-products' ), true ),
			array( __( 'Templates / presets for reusable axis + settings setups', 'quick-variable-products' ), false ),
			array( __( 'Add new variation combinations to an existing product', 'quick-variable-products' ), false ),
			array( __( 'Extend one axis across many products at once (preview + undo)', 'quick-variable-products' ), false ),
			array( __( 'Catalog Bulk Editor: price, sale, cost, stock, weight, dimensions', 'quick-variable-products' ), false ),
			array( __( 'Bulk edit tax/shipping class, backorders, SKU, title, description', 'quick-variable-products' ), false ),
			array( __( 'Bulk edit categories, tags, brands, visibility and status', 'quick-variable-products' ), false ),
			array( __( 'Smart views (on-sale, no-cost, low-margin, low-stock, missing-SKU)', 'quick-variable-products' ), false ),
			array( __( 'Exact dry-run before → after preview', 'quick-variable-products' ), false ),
			array( __( 'Target-margin pricing (cost ÷ (1 − margin%) + charm ending)', 'quick-variable-products' ), false ),
			array( __( 'Persistent, conflict-safe undo of any recent run', 'quick-variable-products' ), false ),
			array( __( 'Saved filter + operation recipes', 'quick-variable-products' ), false ),
			array( __( 'CSV import / export of the variation matrix', 'quick-variable-products' ), false ),
			array( __( 'Attribute-value variation galleries', 'quick-variable-products' ), false ),
			array( __( 'Wizard-guided bulk flow with a live match count and automatic preview', 'quick-variable-products' ), false ),
			array( __( 'Text tools: find & replace, prefix/suffix, case transform and regex', 'quick-variable-products' ), false ),
			array( __( 'Run history panel — review, undo or forget any of the last 10 runs', 'quick-variable-products' ), false ),
			array( __( 'Priority email support', 'quick-variable-products' ), false ),
		);
	}

	/**
	 * The in-depth feature catalogue, grouped by job-to-be-done. Every Pro
	 * capability appears here — including the ones too granular for the table.
	 *
	 * @return array
	 */
	private static function deep_groups() {
		return array(
			array(
				'existing',
				__( 'Create faster', 'quick-variable-products' ),
				array(
					__( 'Templates: save an axis + settings setup once, reuse it on every new product', 'quick-variable-products' ),
					__( 'Add new combinations to any existing variable product — duplicates are detected and skipped', 'quick-variable-products' ),
					__( 'Extend one axis across up to 20 products per run, with a dry-run count before anything is written', 'quick-variable-products' ),
					__( 'Per-value variation galleries, stored natively in WooCommerce — plus rtwpvg and Additional Variation Images formats when those plugins are active', 'quick-variable-products' ),
				),
			),
			array(
				'bulk',
				__( 'Edit at scale', 'quick-variable-products' ),
				array(
					__( '23 editable fields: prices, cost, stock, weight, dimensions, tax and shipping classes, backorders, statuses, visibility, featured, categories, tags, brands, SKU, title and descriptions', 'quick-variable-products' ),
					__( 'A guided three-step wizard: filter → operation → apply, with a live match count at every step', 'quick-variable-products' ),
					__( 'Spreadsheet-style inline editing on the filtered rows for one-off touch-ups', 'quick-variable-products' ),
					__( 'Parent-level fields are written once per product — never fanned out to every variation', 'quick-variable-products' ),
					__( 'Changes apply in small batches with idempotent replay, so a flaky connection never double-applies', 'quick-variable-products' ),
				),
			),
			array(
				'margin',
				__( 'Price intelligently', 'quick-variable-products' ),
				array(
					__( 'Target-margin pricing straight from cost: cost ÷ (1 − margin%)', 'quick-variable-products' ),
					__( 'Charm endings and rounding controls (.99, .90, whole numbers)', 'quick-variable-products' ),
					__( 'Five smart views: on sale, no cost, low margin, low stock, missing SKU', 'quick-variable-products' ),
					__( 'Cost data stays portable: native WooCommerce COGS when enabled, plus a compatible meta fallback', 'quick-variable-products' ),
				),
			),
			array(
				'undo',
				__( 'Stay safe', 'quick-variable-products' ),
				array(
					__( 'A checkpoint of every field is stored before the first write of a run', 'quick-variable-products' ),
					__( 'Undo verifies each row against a SHA-256 fingerprint of what the run wrote', 'quick-variable-products' ),
					__( 'Rows edited later by a teammate are skipped as conflicts; the run stays retryable', 'quick-variable-products' ),
					__( 'The history panel keeps 10 runs for 30 days — undo or forget any of them', 'quick-variable-products' ),
					__( 'Run locks: two bulk jobs can never write over each other', 'quick-variable-products' ),
				),
			),
			array(
				'label',
				__( 'Move data & get help', 'quick-variable-products' ),
				array(
					__( 'CSV import / export of the variation matrix — round-trip through Excel or Google Sheets', 'quick-variable-products' ),
					__( 'Regex and case transforms for cleaning up SKUs, titles and descriptions in bulk', 'quick-variable-products' ),
					__( 'Priority email support — your questions jump the queue', 'quick-variable-products' ),
				),
			),
		);
	}

	/**
	 * The pricing tiers. Prices live in the Freemius dashboard (plan 56756);
	 * these mirror them for display and deep-link straight into the hosted
	 * checkout for the matching licence count.
	 *
	 * @return array
	 */
	private static function tiers() {
		return array(
			array(
				'licenses' => 1,
				'name'     => __( 'Single Site', 'quick-variable-products' ),
				'price'    => '$59',
				'note'     => __( 'For one store', 'quick-variable-products' ),
				'featured' => false,
			),
			array(
				'licenses' => 5,
				'name'     => __( '5 Sites', 'quick-variable-products' ),
				'price'    => '$189',
				'note'     => __( 'That’s $37.80 per site', 'quick-variable-products' ),
				'featured' => true,
			),
			array(
				'licenses' => 20,
				'name'     => __( '20 Sites', 'quick-variable-products' ),
				'price'    => '$499',
				'note'     => __( 'That’s $24.95 per site', 'quick-variable-products' ),
				'featured' => false,
			),
		);
	}

	/**
	 * Top Pro feature cards: title, one-line pitch, inline-SVG icon key.
	 *
	 * @return array
	 */
	private static function cards() {
		return array(
			array( 'bulk', __( 'Catalog Bulk Editor', 'quick-variable-products' ), __( 'Change price, cost, stock, tax, taxonomy and text across every product matching your filters — with an exact preview first.', 'quick-variable-products' ) ),
			array( 'undo', __( 'Conflict-safe undo', 'quick-variable-products' ), __( 'Keep ten recent runs for 30 days and roll any of them back without overwriting a teammate’s newer edit.', 'quick-variable-products' ) ),
			array( 'existing', __( 'Add to existing', 'quick-variable-products' ), __( 'Load any variable product and bulk-add new combinations, or extend one axis across many products at once.', 'quick-variable-products' ) ),
			array( 'margin', __( 'Target-margin pricing', 'quick-variable-products' ), __( 'Price straight from cost and a target margin, with charm endings — plus smart views for low-margin or no-cost items.', 'quick-variable-products' ) ),
			array( 'recipe', __( 'Saved recipes', 'quick-variable-products' ), __( 'Save a filter + operation once and re-run it, e.g. “low-margin → 40% target margin → .99 ending”.', 'quick-variable-products' ) ),
			array( 'label', __( 'CSV import & export', 'quick-variable-products' ), __( 'Round-trip the whole variation matrix through Excel or Google Sheets — export, edit in bulk, re-import safely.', 'quick-variable-products' ) ),
		);
	}

	/**
	 * @param string $key Icon key.
	 * @return string Inline SVG (allowed in PHP output; check 7 excludes <svg>).
	 */
	private static function icon( $key ) {
		$paths = array(
			'bulk'     => '<path d="M3 5h18M3 12h18M3 19h18"/><circle cx="7" cy="5" r="1.6"/><circle cx="14" cy="12" r="1.6"/><circle cx="10" cy="19" r="1.6"/>',
			'undo'     => '<path d="M3 7v6h6"/><path d="M3 13a9 9 0 1 0 3-7.7L3 8"/>',
			'existing' => '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M12 9v6M9 12h6"/>',
			'margin'   => '<path d="M4 20L20 4"/><circle cx="7" cy="7" r="2.5"/><circle cx="17" cy="17" r="2.5"/>',
			'recipe'   => '<path d="M6 3h9l3 3v15H6z"/><path d="M9 8h6M9 12h6M9 16h4"/>',
			'label'    => '<path d="M3 8h14l4 4-4 4H3z"/><path d="M7 12h.01M10 12h.01M13 12h.01"/>',
		);
		$d = isset( $paths[ $key ] ) ? $paths[ $key ] : '';
		return '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' . $d . '</svg>';
	}

	/**
	 * Allowed tags/attributes for echoing our inline SVG icons through wp_kses()
	 * (wp.org never accepts an output-escaping suppression, even for static SVG).
	 *
	 * @return array
	 */
	private static function svg_allowed() {
		$attr = array( 'viewbox' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'aria-hidden' => true, 'd' => true, 'cx' => true, 'cy' => true, 'r' => true, 'x' => true, 'y' => true, 'width' => true, 'height' => true, 'rx' => true );
		return array(
			'svg'    => $attr,
			'path'   => $attr,
			'circle' => $attr,
			'rect'   => $attr,
		);
	}

	/**
	 * The primary call-to-action pair (button + risk-reversal microcopy). One
	 * markup source so every CTA on the page stays identical.
	 *
	 * @param string $url  Checkout URL.
	 * @param string $text Button label.
	 * @return void
	 */
	private static function cta( $url, $text ) {
		?>
		<p class="qvp-up-cta">
			<a class="qvp-up-btn" href="<?php echo esc_url( $url ); ?>" target="_blank" rel="noopener"><?php echo esc_html( $text ); ?> <span aria-hidden="true">→</span></a>
			<span class="qvp-up-guarantee"><?php echo esc_html__( '30-day money-back guarantee · instant delivery · automatic updates', 'quick-variable-products' ); ?></span>
		</p>
		<?php
	}

	/**
	 * Render the landing page.
	 *
	 * @return void
	 */
	public static function render() {
		$url = function_exists( 'erenqvp_upgrade_url' ) ? erenqvp_upgrade_url() : 'https://checkout.freemius.com/plugin/34490/plan/56756/';
		?>
		<div class="wrap qvp-up">
			<hr class="wp-header-end"><!-- keep other plugins'/theme/core admin notices out of the marketing hero; WP renders them here, above it (never hidden) -->

			<section class="qvp-up-hero">
				<div class="qvp-up-hero-copy">
					<span class="qvp-up-kicker">✦ <?php echo esc_html__( 'Quick Variable Products Pro', 'quick-variable-products' ); ?></span>
					<h1><?php echo esc_html__( 'Bulk-edit your entire catalog — with an exact preview and undo you can trust.', 'quick-variable-products' ); ?></h1>
					<p><?php echo esc_html__( 'Everything you use today stays free. Pro adds the catalog workspace: filter thousands of variations, see the exact before → after, apply in safe batches — and roll any run back for 30 days.', 'quick-variable-products' ); ?></p>
					<?php self::cta( $url, __( 'Get Pro', 'quick-variable-products' ) ); ?>
					<p class="qvp-up-price-hint"><?php echo esc_html__( 'From $59 / year · 14-day free trial, no card needed', 'quick-variable-products' ); ?></p>
					<ul class="qvp-up-chips" aria-label="<?php echo esc_attr__( 'Key facts', 'quick-variable-products' ); ?>">
						<li><?php echo esc_html__( 'Native WooCommerce data — no lock-in', 'quick-variable-products' ); ?></li>
						<li><?php echo esc_html__( 'Admin-only, zero storefront impact', 'quick-variable-products' ); ?></li>
						<li><?php echo esc_html__( 'Works with any theme', 'quick-variable-products' ); ?></li>
						<li><?php echo esc_html__( 'Speaks 8 languages', 'quick-variable-products' ); ?></li>
					</ul>
				</div>
				<div class="qvp-up-hero-shot" aria-hidden="true">
					<div class="qvp-up-shot">
						<div class="qvp-up-shot-bar">
							<i></i><i></i><i></i>
							<span><?php echo esc_html__( 'Catalog Bulk Editor', 'quick-variable-products' ); ?></span>
						</div>
						<div class="qvp-up-shot-filters">
							<span class="qvp-up-tag"><?php echo esc_html__( 'Category: Dresses', 'quick-variable-products' ); ?></span>
							<span class="qvp-up-tag"><?php echo esc_html__( 'On sale', 'quick-variable-products' ); ?></span>
							<span class="qvp-up-tag is-hot"><?php echo esc_html__( 'Margin < 30%', 'quick-variable-products' ); ?></span>
							<span class="qvp-up-count"><?php echo esc_html__( '32 variations match', 'quick-variable-products' ); ?></span>
						</div>
						<div class="qvp-up-shot-rows">
							<div class="qvp-up-shot-row"><span>Red / S</span><em>29.90</em><b>→</b><strong>39.99</strong></div>
							<div class="qvp-up-shot-row"><span>Red / M</span><em>29.90</em><b>→</b><strong>39.99</strong></div>
							<div class="qvp-up-shot-row"><span>Blue / S</span><em>34.90</em><b>→</b><strong>44.99</strong></div>
							<div class="qvp-up-shot-row is-skip"><span>Blue / M</span><em>44.99</em><b>·</b><strong><?php echo esc_html__( 'no change', 'quick-variable-products' ); ?></strong></div>
						</div>
						<div class="qvp-up-shot-foot">
							<span class="qvp-up-shot-ok">✓ <?php echo esc_html__( 'Preview matches — safe to apply', 'quick-variable-products' ); ?></span>
							<span class="qvp-up-shot-apply"><?php echo esc_html__( 'Apply', 'quick-variable-products' ); ?></span>
						</div>
					</div>
					<div class="qvp-up-shot-badge">↩ <?php echo esc_html__( 'Undoable for 30 days', 'quick-variable-products' ); ?></div>
				</div>
			</section>

			<section class="qvp-up-stats" aria-label="<?php echo esc_attr__( 'By the numbers', 'quick-variable-products' ); ?>">
				<div class="qvp-up-stat"><strong>23</strong><span><?php echo esc_html__( 'bulk-editable fields — price to SEO-critical titles', 'quick-variable-products' ); ?></span></div>
				<div class="qvp-up-stat"><strong>10×30</strong><span><?php echo esc_html__( 'runs kept, days each — undo any of them', 'quick-variable-products' ); ?></span></div>
				<div class="qvp-up-stat"><strong>100%</strong><span><?php echo esc_html__( 'exact dry-run preview before anything is saved', 'quick-variable-products' ); ?></span></div>
				<div class="qvp-up-stat"><strong>0</strong><span><?php echo esc_html__( 'teammate edits ever overwritten by an undo', 'quick-variable-products' ); ?></span></div>
			</section>

			<section class="qvp-up-spot">
				<div class="qvp-up-spot-copy">
					<h2><?php echo esc_html__( 'Change prices without holding your breath', 'quick-variable-products' ); ?></h2>
					<p><?php echo esc_html__( 'Bulk tools are scary because one wrong click rewrites the whole store. Pro is built around a safety model no competitor matches:', 'quick-variable-products' ); ?></p>
					<ol class="qvp-up-steps">
						<li>
							<h3><?php echo esc_html__( 'Checkpoint first', 'quick-variable-products' ); ?></h3>
							<p><?php echo esc_html__( 'Before a single value is saved, the run stores a snapshot of every field it is about to touch.', 'quick-variable-products' ); ?></p>
						</li>
						<li>
							<h3><?php echo esc_html__( 'Fingerprinted undo', 'quick-variable-products' ); ?></h3>
							<p><?php echo esc_html__( 'Undo restores a field only if its current value still matches what the run wrote — verified with a cryptographic hash.', 'quick-variable-products' ); ?></p>
						</li>
						<li>
							<h3><?php echo esc_html__( 'Conflicts are kept, never clobbered', 'quick-variable-products' ); ?></h3>
							<p><?php echo esc_html__( 'If a teammate edited a row after your run, undo skips exactly that row and the run stays retryable — nothing newer is ever lost.', 'quick-variable-products' ); ?></p>
						</li>
					</ol>
				</div>
				<div class="qvp-up-spot-visual" aria-hidden="true">
					<div class="qvp-up-timeline">
						<div class="qvp-up-tl-item is-run"><span class="qvp-up-tl-dot"></span><b><?php echo esc_html__( 'Your run', 'quick-variable-products' ); ?></b><em>110 → 120</em></div>
						<div class="qvp-up-tl-item is-edit"><span class="qvp-up-tl-dot"></span><b><?php echo esc_html__( 'Teammate edits', 'quick-variable-products' ); ?></b><em>120 → 999</em></div>
						<div class="qvp-up-tl-item is-undo"><span class="qvp-up-tl-dot"></span><b><?php echo esc_html__( 'Your undo', 'quick-variable-products' ); ?></b><em><?php echo esc_html__( '31 restored · 1 kept safe', 'quick-variable-products' ); ?></em></div>
					</div>
				</div>
			</section>

			<section class="qvp-up-cards">
				<h2 class="qvp-up-cards-title"><?php echo esc_html__( 'The whole Pro toolbox', 'quick-variable-products' ); ?></h2>
				<div class="qvp-up-cards-grid">
					<?php foreach ( self::cards() as $c ) : ?>
						<div class="qvp-up-card">
							<span class="qvp-up-ico"><?php echo wp_kses( self::icon( $c[0] ), self::svg_allowed() ); ?></span>
							<h3><?php echo esc_html( $c[1] ); ?></h3>
							<p><?php echo esc_html( $c[2] ); ?></p>
						</div>
					<?php endforeach; ?>
				</div>
			</section>

			<section class="qvp-up-deep">
				<h2><?php echo esc_html__( 'Every Pro capability, in detail', 'quick-variable-products' ); ?></h2>
				<p class="qvp-up-deep-sub"><?php echo esc_html__( 'No hidden add-ons and no per-feature pricing — every plan below includes all of it.', 'quick-variable-products' ); ?></p>
				<div class="qvp-up-deep-grid">
					<?php foreach ( self::deep_groups() as $g ) : ?>
						<div class="qvp-up-deep-col">
							<h3><span class="qvp-up-ico"><?php echo wp_kses( self::icon( $g[0] ), self::svg_allowed() ); ?></span><?php echo esc_html( $g[1] ); ?></h3>
							<ul>
								<?php foreach ( $g[2] as $item ) : ?>
									<li><?php echo esc_html( $item ); ?></li>
								<?php endforeach; ?>
							</ul>
						</div>
					<?php endforeach; ?>
				</div>
			</section>

			<section class="qvp-up-how">
				<h2><?php echo esc_html__( 'Up and running in three minutes', 'quick-variable-products' ); ?></h2>
				<div class="qvp-up-how-grid">
					<div class="qvp-up-how-step"><span>1</span>
						<h3><?php echo esc_html__( 'Checkout', 'quick-variable-products' ); ?></h3>
						<p><?php echo esc_html__( 'Secure checkout by Freemius. The download link and licence key arrive instantly.', 'quick-variable-products' ); ?></p>
					</div>
					<div class="qvp-up-how-step"><span>2</span>
						<h3><?php echo esc_html__( 'Install the Pro plugin', 'quick-variable-products' ); ?></h3>
						<p><?php echo esc_html__( 'Upload it next to this free plugin and activate the licence — your settings and workflow carry over untouched.', 'quick-variable-products' ); ?></p>
					</div>
					<div class="qvp-up-how-step"><span>3</span>
						<h3><?php echo esc_html__( 'New screens appear', 'quick-variable-products' ); ?></h3>
						<p><?php echo esc_html__( 'The Bulk Editor, Add-to-existing and recipes show up in this same menu. Automatic updates keep Pro current.', 'quick-variable-products' ); ?></p>
					</div>
				</div>
			</section>

			<section class="qvp-up-pricing" id="qvp-pricing">
				<h2><?php echo esc_html__( 'Simple annual pricing', 'quick-variable-products' ); ?></h2>
				<p class="qvp-up-pricing-sub"><?php echo esc_html__( 'Every plan includes every Pro feature — pick how many stores you run.', 'quick-variable-products' ); ?></p>
				<div class="qvp-up-tiers">
					<?php foreach ( self::tiers() as $t ) : ?>
						<div class="qvp-up-tier<?php echo esc_attr( $t['featured'] ? ' is-featured' : '' ); ?>">
							<?php if ( $t['featured'] ) : ?>
								<span class="qvp-up-tier-flag"><?php echo esc_html__( 'Most popular', 'quick-variable-products' ); ?></span>
							<?php endif; ?>
							<h3><?php echo esc_html( $t['name'] ); ?></h3>
							<p class="qvp-up-tier-price"><strong><?php echo esc_html( $t['price'] ); ?></strong><span>/ <?php echo esc_html__( 'year', 'quick-variable-products' ); ?></span></p>
							<p class="qvp-up-tier-note"><?php echo esc_html( $t['note'] ); ?></p>
							<ul class="qvp-up-tier-list">
								<li><?php echo esc_html__( 'All Pro features, no exceptions', 'quick-variable-products' ); ?></li>
								<li><?php echo esc_html__( 'One year of updates & priority support', 'quick-variable-products' ); ?></li>
								<li><?php echo esc_html__( '14-day free trial — no card needed', 'quick-variable-products' ); ?></li>
								<li><?php echo esc_html__( '30-day money-back guarantee', 'quick-variable-products' ); ?></li>
							</ul>
							<a class="qvp-up-btn<?php echo esc_attr( $t['featured'] ? '' : ' is-ghost' ); ?>" href="<?php echo esc_url( function_exists( 'erenqvp_checkout_url' ) ? erenqvp_checkout_url( $t['licenses'] ) : $url ); ?>" target="_blank" rel="noopener"><?php echo esc_html__( 'Buy now', 'quick-variable-products' ); ?> <span aria-hidden="true">→</span></a>
						</div>
					<?php endforeach; ?>
				</div>
				<p class="qvp-up-pricing-fine">
					<a href="<?php echo esc_url( ( function_exists( 'erenqvp_checkout_url' ) ? erenqvp_checkout_url( 1 ) : $url ) . '&trial=free' ); ?>" target="_blank" rel="noopener"><?php echo esc_html__( 'Start the 14-day free trial instead →', 'quick-variable-products' ); ?></a><br>
					<?php echo esc_html__( 'Prices in USD. Licences renew yearly — cancel anytime. Taxes are handled at checkout by Freemius, our merchant of record.', 'quick-variable-products' ); ?>
				</p>
			</section>

			<section class="qvp-up-compare">
				<h2><?php echo esc_html__( 'Free vs Pro', 'quick-variable-products' ); ?></h2>
				<p class="qvp-up-compare-note"><?php echo esc_html__( 'The free plugin is not a trial: everything below marked Free stays free forever, with no limits.', 'quick-variable-products' ); ?></p>
				<table class="qvp-up-table">
					<thead>
						<tr>
							<th><?php echo esc_html__( 'Feature', 'quick-variable-products' ); ?></th>
							<th><?php echo esc_html__( 'Free', 'quick-variable-products' ); ?></th>
							<th class="qvp-up-pro"><?php echo esc_html__( 'Pro', 'quick-variable-products' ); ?></th>
						</tr>
					</thead>
					<tbody>
						<?php foreach ( self::rows() as $r ) : ?>
							<tr>
								<td><?php echo esc_html( $r[0] ); ?></td>
								<td class="qvp-up-mark">
									<?php if ( $r[1] ) : ?>
										<span class="qvp-up-yes" aria-label="<?php echo esc_attr__( 'Included', 'quick-variable-products' ); ?>">✓</span>
									<?php else : ?>
										<span class="qvp-up-no" aria-label="<?php echo esc_attr__( 'Not included', 'quick-variable-products' ); ?>">–</span>
									<?php endif; ?>
								</td>
								<td class="qvp-up-mark"><span class="qvp-up-yes" aria-label="<?php echo esc_attr__( 'Included', 'quick-variable-products' ); ?>">✓</span></td>
							</tr>
						<?php endforeach; ?>
					</tbody>
				</table>
			</section>

			<section class="qvp-up-faq">
				<h2><?php echo esc_html__( 'Questions', 'quick-variable-products' ); ?></h2>
				<details open>
					<summary><?php echo esc_html__( 'Is my free workflow affected?', 'quick-variable-products' ); ?></summary>
					<p><?php echo esc_html__( 'No. The create-fast screen and everything you use today stays exactly the same and free, with no limits. Pro adds new screens.', 'quick-variable-products' ); ?></p>
				</details>
				<details>
					<summary><?php echo esc_html__( 'Can I undo a bulk change safely?', 'quick-variable-products' ); ?></summary>
					<p><?php echo esc_html__( 'Yes. Pro keeps ten recent runs for 30 days. Undo restores a field only if its current value still matches what the run wrote, so a teammate’s later edit is never overwritten.', 'quick-variable-products' ); ?></p>
				</details>
				<details>
					<summary><?php echo esc_html__( 'How is Pro delivered?', 'quick-variable-products' ); ?></summary>
					<p><?php echo esc_html__( 'Pro is a separate download with automatic updates and a licence, handled through Freemius. It requires this free plugin.', 'quick-variable-products' ); ?></p>
				</details>
				<details>
					<summary><?php echo esc_html__( 'What exactly does the price include?', 'quick-variable-products' ); ?></summary>
					<p><?php echo esc_html__( 'Every tier includes every Pro feature — the only difference is how many stores you can activate. The licence covers one year of updates and priority support and renews yearly; you can cancel the renewal anytime and keep using the installed version.', 'quick-variable-products' ); ?></p>
				</details>
				<details>
					<summary><?php echo esc_html__( 'What happens if I deactivate Pro later?', 'quick-variable-products' ); ?></summary>
					<p><?php echo esc_html__( 'Nothing breaks. Every change Pro made is stored as plain WooCommerce data, so your products, prices and stock stay exactly as they are — you only lose the Pro screens.', 'quick-variable-products' ); ?></p>
				</details>
				<details>
					<summary><?php echo esc_html__( 'What if it is not for me?', 'quick-variable-products' ); ?></summary>
					<p><?php echo esc_html__( 'Every purchase includes a 30-day money-back guarantee — one email, full refund, no questions asked.', 'quick-variable-products' ); ?></p>
				</details>
			</section>

			<section class="qvp-up-band">
				<h2><?php echo esc_html__( 'Ready to speed up your whole catalog?', 'quick-variable-products' ); ?></h2>
				<p class="qvp-up-band-sub"><?php echo esc_html__( 'Join the stores that manage variations in seconds, not evenings.', 'quick-variable-products' ); ?></p>
				<?php self::cta( $url, __( 'Get Quick Variable Products Pro', 'quick-variable-products' ) ); ?>
			</section>
		</div>
		<?php
	}
}
