<?php
/**
 * KooKoa Folders — Pricing Page Template
 *
 * @package KookoaWPF
 */

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

// External checkout URL — Freemius is our payment gateway (card + PayPal).
// The Freemius SDK itself is NOT bundled in the plugin; this is a plain
// link to checkout.freemius.com, same pattern as linking to any other
// payment provider (Stripe Checkout, Paddle, Lemon Squeezy, etc.).
$kookoawpf_checkout_pro = 'https://checkout.freemius.com/plugin/27000/plan/44695/licenses/1/';

// Trial signup URL — Freemius hosted trial form. Only shown when the user
// has not yet consumed their trial on this site (kookoawpf_trial_used flag).
$kookoawpf_trial_url = 'https://checkout.freemius.com/plugin/27000/plan/44695/licenses/1/?trial=free';

// Three states for the smart block on the right of the pricing grid.
// A  → user never started a trial here          → show "Start Free Trial" CTA.
// A2 → user is currently in trial               → show motivational message.
// B  → trial was used and is no longer active   → show TRIAL20 discount code.
//
// Both flags are written from PRO at bootstrap:
// - kookoawpf_trial_used:   set-only, persists across PRO uninstall.
// - kookoawpf_trial_active: live mirror of kwf_fs()->is_trial(), removed
// from FREE namespace when PRO is uninstalled.
$kookoawpf_trial_used   = (bool) get_option( 'kookoawpf_trial_used', false );
$kookoawpf_trial_active = (bool) get_option( 'kookoawpf_trial_active', false );

// FASE 4: paid license ever activated. Hide all commercial content
// (PRO card, trial/discount block, Free-vs-PRO comparison) and show
// a thank-you page instead. Triggered by direct URL hit; the orange
// "Upgrade to PRO" Settings tab and Folder-page links are already
// gated upstream by the same flag.
$kookoawpf_fase4 = (bool) get_option( 'kookoawpf_paid_license_activated', false );
if ( $kookoawpf_fase4 ) {
	// FASE 4 + this page is rendered = FREE plugin alone (PRO deactivated
	// or uninstalled). The license is still on file but PRO isn't running,
	// so don't say "license is active" — instead point the user back to
	// re-installing PRO and re-activating the license they already own.
	?>
	<div class="kookoawpf-pricing-wrap">
		<div class="kookoawpf-pricing-inner">
			<div class="kookoawpf-pricing-header">
				<div class="kookoawpf-pricing-logo">
					KK<span class="kookoawpf-arr">&gt;</span><span class="kookoawpf-cursor">_</span> FOLDERS
				</div>
				<div class="kookoawpf-pricing-subtitle"><?php esc_html_e( "You're already a PRO customer", 'kookoa-folders' ); ?></div>
				<div class="kookoawpf-pricing-tagline"><?php esc_html_e( 'Install KooKoa Folders PRO again and activate your existing license to resume the full feature set.', 'kookoa-folders' ); ?></div>
			</div>
		</div>
	</div>
	<?php
	return;
}
?>
<div class="kookoawpf-pricing-wrap">
<div class="kookoawpf-pricing-inner">

	<!-- ── HEADER ── -->
	<div class="kookoawpf-pricing-header">
		<div class="kookoawpf-pricing-logo">
			KK<span class="kookoawpf-arr">&gt;</span><span class="kookoawpf-cursor">_</span> FOLDERS
		</div>
		<div class="kookoawpf-pricing-subtitle"><?php esc_html_e( 'Upgrade your workflow', 'kookoa-folders' ); ?></div>
		<div class="kookoawpf-pricing-tagline"><?php esc_html_e( 'Organize your WordPress like a pro. One-time payment, lifetime updates.', 'kookoa-folders' ); ?></div>
	</div>

		<!-- ── PRICING (PRO card 1/3 + smart trial/discount block 2/3) ── -->
		<div class="kookoawpf-plans-grid">

			<!-- PRO card -->
			<div class="kookoawpf-plan-card">
				<div class="kookoawpf-plan-name"><?php esc_html_e( 'PRO', 'kookoa-folders' ); ?></div>
				<div class="kookoawpf-plan-price">
					<span class="kookoawpf-dollar">$</span><span class="kookoawpf-amount">69</span><span class="kookoawpf-currency">USD</span>
				</div>
				<div class="kookoawpf-plan-term"><?php esc_html_e( 'Lifetime License', 'kookoa-folders' ); ?></div>
				<div class="kookoawpf-plan-sites">&bull; <?php esc_html_e( '1 Website', 'kookoa-folders' ); ?></div>
				<div class="kookoawpf-plan-sites">&bull; <?php esc_html_e( 'All PRO features', 'kookoa-folders' ); ?></div>
				<div class="kookoawpf-plan-per-site">&bull; <?php esc_html_e( 'Free updates forever', 'kookoa-folders' ); ?></div>
				<a href="<?php echo esc_url( $kookoawpf_checkout_pro ); ?>"
					class="kookoawpf-btn-buy" target="_blank" rel="noopener noreferrer">
					<?php esc_html_e( 'BUY NOW', 'kookoa-folders' ); ?>
				</a>
			</div>

			<!-- Smart block: trial CTA / in-trial message / discount code, depending on trial state. -->
			<?php if ( ! $kookoawpf_trial_used ) : ?>
				<!-- ── Stato A: trial CTA (trial not yet consumed) ── -->
				<div class="kookoawpf-trial-block">
					<div class="kookoawpf-popular-badge"><?php esc_html_e( 'RECOMMENDED', 'kookoa-folders' ); ?></div>
					<div class="kookoawpf-trial-block-body">
						<div class="kookoawpf-trial-block-title"><?php esc_html_e( 'Try PRO free for 14 days', 'kookoa-folders' ); ?></div>
						<div class="kookoawpf-trial-block-text">
						<?php esc_html_e( 'No credit card required.', 'kookoa-folders' ); ?><br>
						<?php esc_html_e( 'Test every PRO feature on your own site.', 'kookoa-folders' ); ?>
					</div>
					</div>
					<a href="<?php echo esc_url( $kookoawpf_trial_url ); ?>"
						class="kookoawpf-trial-block-cta" target="_blank" rel="noopener noreferrer">
						<?php esc_html_e( 'START FREE TRIAL', 'kookoa-folders' ); ?>
					</a>
				</div>
			<?php elseif ( $kookoawpf_trial_active ) : ?>
				<!-- ── Stato A2: trial currently active (motivational, no CTA — Buy Now lives on the PRO card to the left) ── -->
				<div class="kookoawpf-trial-block kookoawpf-trial-block-active">
					<div class="kookoawpf-popular-badge"><?php esc_html_e( 'TRIAL ACTIVE', 'kookoa-folders' ); ?></div>
					<div class="kookoawpf-trial-block-body">
						<div class="kookoawpf-trial-block-title"><?php esc_html_e( "You're trying PRO", 'kookoa-folders' ); ?></div>
						<div class="kookoawpf-trial-block-text">
							<?php esc_html_e( 'Take your 14 days. No rush.', 'kookoa-folders' ); ?><br>
							<?php esc_html_e( 'Whenever you\'re ready, the lifetime license is here — $69 once, free updates forever.', 'kookoa-folders' ); ?>
						</div>
					</div>
				</div>
			<?php else : ?>
				<!-- ── Stato B: discount code (trial consumed and no longer active) ── -->
				<div class="kookoawpf-trial-block kookoawpf-trial-block-used">
					<div class="kookoawpf-popular-badge"><?php esc_html_e( 'DISCOUNT CODE', 'kookoa-folders' ); ?></div>
					<div class="kookoawpf-trial-block-body">
						<div class="kookoawpf-trial-block-title"><?php esc_html_e( "You've used your trial", 'kookoa-folders' ); ?></div>
						<div class="kookoawpf-trial-block-text"><?php esc_html_e( "Loved KooKoa Folders PRO? Here's 20% off if you decide to keep it.", 'kookoa-folders' ); ?></div>
						<div class="kookoawpf-discount-code">TRIAL20</div>
						<div class="kookoawpf-discount-hint"><?php esc_html_e( 'Use this code at checkout for 20% off', 'kookoa-folders' ); ?></div>
					</div>
				</div>
			<?php endif; ?>

		</div><!-- .kookoawpf-plans-grid -->

	<!-- ── COMPARISON TABLE (always visible) ── -->
	<div class="kookoawpf-comparison-section">
		<div class="kookoawpf-comparison-title"><?php esc_html_e( 'Free vs PRO', 'kookoa-folders' ); ?></div>

		<table class="kookoawpf-comparison-table">
			<thead>
				<tr>
					<th><?php esc_html_e( 'Feature', 'kookoa-folders' ); ?></th>
					<th class="kookoawpf-th-free"><?php esc_html_e( 'FREE', 'kookoa-folders' ); ?></th>
					<th class="kookoawpf-th-pro"><?php esc_html_e( 'PRO', 'kookoa-folders' ); ?></th>
				</tr>
			</thead>
			<tbody>
				<!-- Section: Core (both) -->
				<tr class="kookoawpf-section-row">
					<td colspan="3"><?php esc_html_e( 'Core Organization', 'kookoa-folders' ); ?></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Unlimited Folders', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Unlimited Subfolders (multilevel)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Smart Folders (rule-based, auto-populated)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Download Folder as ZIP', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Drag & Drop', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Context Menu', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Keyboard Shortcuts', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Colors & Icons', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Pin & Lock Folders', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Sort Folders', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Breadcrumb Navigation', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Media Modal Integration', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Works with Gutenberg, Elementor, Divi, WooCommerce', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Import / Export Folders (JSON)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Upload Folder Structure (from your computer)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Folder Migration from Other Plugins', 'kookoa-folders' ); ?><br class="kookoawpf-cpt-examples-br"><span class="kookoawpf-cpt-examples" style="font-size:13px;display:inline-block;margin-top:6px;"><?php esc_html_e( 'FileBird (Ninja Team), Folders (Premio), Real Media Library (devowl.io)', 'kookoa-folders' ); ?></span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Media hover info (+EXIF)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Access Control (role-based)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>

				<!-- Section: PRO Features -->
				<tr class="kookoawpf-section-row">
					<td colspan="3"><?php esc_html_e( 'PRO Features', 'kookoa-folders' ); ?></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Folders for Posts & Pages', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Folders for Custom Post Types', 'kookoa-folders' ); ?><br class="kookoawpf-cpt-examples-br"><span class="kookoawpf-cpt-examples" style="font-size:14px;display:inline-block;margin-top:6px;"><?php esc_html_e( 'WooCommerce products, courses, portfolio items, etc.', 'kookoa-folders' ); ?></span></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'AI Image Generator (text-to-image)', 'kookoa-folders' ); ?><br class="kookoawpf-cpt-examples-br"><span class="kookoawpf-cpt-examples" style="font-size:13px;display:inline-block;margin-top:6px;"><?php esc_html_e( 'requires your OpenAI API key', 'kookoa-folders' ); ?></span></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'AI Image Editor (text-guided edits)', 'kookoa-folders' ); ?><br class="kookoawpf-cpt-examples-br"><span class="kookoawpf-cpt-examples" style="font-size:13px;display:inline-block;margin-top:6px;"><?php esc_html_e( 'requires your OpenAI API key', 'kookoa-folders' ); ?></span></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'WebP / AVIF Converter', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Replace Media (same name or rename)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Watermark Images (logo or text)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Clean Unused Media', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Find Duplicate Media (byte-exact + perceptual hash)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Image Editor (crop, rotate, filters, resize)', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Media Stats Dashboard', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
				<tr>
					<td><?php esc_html_e( 'Priority Email Support', 'kookoa-folders' ); ?></td>
					<td><span class="kookoawpf-dash">&#10007;</span></td>
					<td><span class="kookoawpf-check">&#10003;</span></td>
				</tr>
			</tbody>
		</table>
	</div><!-- .kookoawpf-comparison-section -->

	<!-- ── FOOTER ── -->
	<div class="kookoawpf-pricing-footer">
		<div class="kookoawpf-guarantee">
			<span class="kookoawpf-guarantee-icon">&#9711;</span>
			<?php esc_html_e( 'Secure checkout powered by Freemius. Pay with credit card or PayPal.', 'kookoa-folders' ); ?>
		</div>
		<div class="kookoawpf-payment-logos" style="text-align:right;margin:20px 0;">
			<img src="<?php echo esc_url( KOOKOAWPF_PLUGIN_URL . 'assets/images/freemius-logo-payment.png' ); ?>" alt="<?php esc_attr_e( 'Payment methods', 'kookoa-folders' ); ?>" style="max-width:400px;width:100%;height:auto;" />
		</div>
		<div class="kookoawpf-pricing-footer-logo">
			KK<span class="kookoawpf-arr">&gt;</span><span class="kookoawpf-cursor">_</span>
		</div>
	</div>

</div><!-- .kookoawpf-pricing-inner -->
</div><!-- .kookoawpf-pricing-wrap -->
