<?php
/**
 * CartCue — Choose automation type before building.
 *
 * @var \CartCue\Plugin $plugin
 * @package CartCue
 */
defined( 'ABSPATH' ) || exit;

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- template scope.

$base     = add_query_arg( [ 'page' => 'cartcue', 'action' => 'new' ], admin_url( 'admin.php' ) );
$list_url = add_query_arg( [ 'page' => 'cartcue' ], admin_url( 'admin.php' ) );
$is_pro   = $plugin->is_pro();
?>
<div class="ap-wrap">

	<div class="ap-page-header">
		<div>
			<a href="<?php echo esc_url( $list_url ); ?>" class="ap-back-link">
				← <?php esc_html_e( 'Automations', 'cartcue-sales-automation' ); ?>
			</a>
			<h1 class="ap-page-title">
				<?php esc_html_e( 'What kind of automation?', 'cartcue-sales-automation' ); ?>
			</h1>
			<p class="ap-page-sub">
				<?php esc_html_e( 'Pick the type that matches your goal. You can always change the name later.', 'cartcue-sales-automation' ); ?>
			</p>
		</div>
	</div>

	<div class="ap-recipe-nudge">
		<i class="ti ti-template" aria-hidden="true"></i>
		<span><?php esc_html_e( 'Most people start from a template.', 'cartcue-sales-automation' ); ?></span>
		<a href="<?php echo esc_url( add_query_arg( [ 'page' => 'cartcue-recipes' ], admin_url( 'admin.php' ) ) ); ?>">
			<?php esc_html_e( 'Browse templates →', 'cartcue-sales-automation' ); ?>
		</a>
	</div>

	<div class="ap-type-picker">

		<a href="<?php echo esc_url( add_query_arg( 'automation_type', 'triggered', $base ) ); ?>"
		   class="ap-type-card">
			<i class="ti ti-bolt" aria-hidden="true"></i>
			<div class="ap-type-card__title">
				<?php esc_html_e( 'Triggered automation', 'cartcue-sales-automation' ); ?>
			</div>
			<p><?php esc_html_e( 'When a WooCommerce event happens, run one or more actions. Add follow-up steps to build a sequence.', 'cartcue-sales-automation' ); ?></p>
			<div class="ap-type-card__example">
				<?php esc_html_e( 'e.g. Cart abandoned → email → Day 3 follow-up → Day 7 coupon', 'cartcue-sales-automation' ); ?>
			</div>
		</a>

		<?php if ( $is_pro ) : ?>
		<a href="<?php echo esc_url( add_query_arg( 'automation_type', 'campaign', $base ) ); ?>"
		   class="ap-type-card">
			<i class="ti ti-calendar-event" aria-hidden="true"></i>
			<div class="ap-type-card__title">
				<?php esc_html_e( 'One-time blast', 'cartcue-sales-automation' ); ?>
			</div>
			<p><?php esc_html_e( 'Send to a filtered group of existing customers right now or on a scheduled date.', 'cartcue-sales-automation' ); ?></p>
			<div class="ap-type-card__example">
				<?php esc_html_e( 'e.g. All customers who bought in the last 30 days → flash sale email', 'cartcue-sales-automation' ); ?>
			</div>
		</a>
		<?php else : ?>
		<div class="ap-type-card ap-type-card--locked">
			<i class="ti ti-calendar-event" aria-hidden="true"></i>
			<div class="ap-type-card__title">
				<?php esc_html_e( 'One-time blast', 'cartcue-sales-automation' ); ?>
				<span class="ap-pro-badge" style="vertical-align:middle;margin-left:6px">Pro</span>
			</div>
			<p><?php esc_html_e( 'Send to a filtered group of existing customers right now or on a scheduled date.', 'cartcue-sales-automation' ); ?></p>
			<div class="ap-type-card__example">
				<?php esc_html_e( 'e.g. All customers who bought in the last 30 days → flash sale email', 'cartcue-sales-automation' ); ?>
			</div>
			<a href="<?php echo esc_url( \CartCue\Plugin::upgrade_url( 'type_picker_campaign' ) ); ?>"
			   class="ap-type-card__upgrade" target="_blank" rel="noopener noreferrer">
				<?php esc_html_e( 'Unlock with Pro →', 'cartcue-sales-automation' ); ?>
			</a>
		</div>
		<?php endif; ?>

	</div>

</div>
