<?php
/**
 * Onboarding wizard – EasySite Setup admin page.
 *
 * @package EasySite_Pro
 */

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

/**
 * Register admin menu.
 */
function easysite_onboarding_menu() {
	add_menu_page(
		__( 'EasySite Setup', 'easysite-pro' ),
		__( 'EasySite Setup', 'easysite-pro' ),
		'manage_options',
		'easysite-setup',
		'easysite_render_onboarding_page',
		'dashicons-welcome-learn-more',
		3
	);

	add_submenu_page(
		'easysite-setup',
		__( 'Help & Tutorials', 'easysite-pro' ),
		__( 'Help & Tutorials', 'easysite-pro' ),
		'manage_options',
		'easysite-help',
		'easysite_render_help_page'
	);
}
add_action( 'admin_menu', 'easysite_onboarding_menu' );

/**
 * Redirect to setup on first theme activation.
 */
function easysite_activation_redirect() {
	if ( ! get_option( 'easysite_setup_complete' ) ) {
		set_transient( 'easysite_activation_redirect', true, 30 );
	}
}
add_action( 'after_switch_theme', 'easysite_activation_redirect' );

/**
 * Handle activation redirect.
 */
function easysite_maybe_redirect_to_setup() {
	if ( ! get_transient( 'easysite_activation_redirect' ) ) {
		return;
	}
	delete_transient( 'easysite_activation_redirect' );
	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		return;
	}
	wp_safe_redirect( admin_url( 'admin.php?page=easysite-setup' ) );
	exit;
}
add_action( 'admin_init', 'easysite_maybe_redirect_to_setup' );

/**
 * Render onboarding wizard.
 */
function easysite_render_onboarding_page() {
	$step     = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
	$max_step = 5;
	$options  = get_option( 'easysite_onboarding', array() );
	?>
	<div class="wrap easysite-onboarding">
		<h1><?php esc_html_e( 'Welcome! In a few simple steps, you\'ll have a complete website.', 'easysite-pro' ); ?></h1>
		<p class="easysite-intro"><?php esc_html_e( 'You don\'t need any technical skills—just follow the steps and type your text.', 'easysite-pro' ); ?></p>

		<nav class="easysite-steps" aria-label="<?php esc_attr_e( 'Setup steps', 'easysite-pro' ); ?>">
			<?php for ( $i = 1; $i <= $max_step; $i++ ) : ?>
				<span class="easysite-step <?php echo $i === $step ? 'is-active' : ''; ?> <?php echo $i < $step ? 'is-done' : ''; ?>">
					<?php echo esc_html( $i ); ?>
				</span>
			<?php endfor; ?>
		</nav>

		<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="easysite-setup-form" enctype="multipart/form-data">
			<?php wp_nonce_field( 'easysite_onboarding', 'easysite_onboarding_nonce' ); ?>
			<input type="hidden" name="action" value="easysite_save_onboarding" />
			<input type="hidden" name="easysite_step" value="<?php echo esc_attr( $step ); ?>" />

			<div class="easysite-step-content">
				<?php
				switch ( $step ) {
					case 1:
						easysite_onboarding_step_basics( $options );
						break;
					case 2:
						easysite_onboarding_step_layout( $options );
						break;
					case 3:
						easysite_onboarding_step_starter( $options );
						break;
					case 4:
						easysite_onboarding_step_shop( $options );
						break;
					case 5:
						easysite_onboarding_step_finish( $options );
						break;
				}
				?>
			</div>

			<?php if ( $step < $max_step ) : ?>
				<p class="submit">
					<button type="submit" class="button button-primary button-hero"><?php esc_html_e( 'Save & Continue', 'easysite-pro' ); ?></button>
					<?php if ( $step > 1 ) : ?>
						<a href="<?php echo esc_url( admin_url( 'admin.php?page=easysite-setup&step=' . ( $step - 1 ) ) ); ?>" class="button"><?php esc_html_e( 'Back', 'easysite-pro' ); ?></a>
					<?php endif; ?>
				</p>
			<?php endif; ?>
		</form>
	</div>
	<?php
}

/**
 * Step 1: Site basics.
 *
 * @param array $options Saved options.
 */
function easysite_onboarding_step_basics( $options ) {
	?>
	<h2><?php esc_html_e( 'Step 1: Site Basics', 'easysite-pro' ); ?></h2>
	<table class="form-table">
		<tr>
			<th><label for="site_type"><?php esc_html_e( 'Site type', 'easysite-pro' ); ?></label></th>
			<td>
				<select name="site_type" id="site_type">
					<?php foreach ( array( 'business', 'shop', 'portfolio', 'blog' ) as $type ) : ?>
						<option value="<?php echo esc_attr( $type ); ?>" <?php selected( $options['site_type'] ?? '', $type ); ?>><?php echo esc_html( ucfirst( $type ) ); ?></option>
					<?php endforeach; ?>
				</select>
			</td>
		</tr>
		<tr>
			<th><label for="site_name"><?php esc_html_e( 'Site name', 'easysite-pro' ); ?></label></th>
			<td><input type="text" name="site_name" id="site_name" class="regular-text" value="<?php echo esc_attr( $options['site_name'] ?? get_bloginfo( 'name' ) ); ?>" /></td>
		</tr>
		<tr>
			<th><label for="site_tagline"><?php esc_html_e( 'Tagline', 'easysite-pro' ); ?></label></th>
			<td><input type="text" name="site_tagline" id="site_tagline" class="regular-text" value="<?php echo esc_attr( $options['site_tagline'] ?? get_bloginfo( 'description' ) ); ?>" /></td>
		</tr>
		<tr>
			<th><label for="main_color"><?php esc_html_e( 'Main brand color', 'easysite-pro' ); ?></label></th>
			<td><input type="color" name="main_color" id="main_color" value="<?php echo esc_attr( $options['main_color'] ?? '#2563eb' ); ?>" /></td>
		</tr>
		<tr>
			<th><label for="gradient_preset"><?php esc_html_e( 'Gradient colors', 'easysite-pro' ); ?></label></th>
			<td>
				<select name="gradient_preset" id="gradient_preset">
					<?php foreach ( easysite_get_gradient_presets() as $key => $preset ) : ?>
						<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $options['gradient_preset'] ?? 'brand', $key ); ?>><?php echo esc_html( $preset['label'] ); ?></option>
					<?php endforeach; ?>
				</select>
				<p class="description"><?php esc_html_e( 'Pick a gradient look for buttons, heroes, and call-to-action sections.', 'easysite-pro' ); ?></p>
				<?php easysite_render_gradient_swatches( $options['gradient_preset'] ?? 'brand' ); ?>
			</td>
		</tr>
	</table>
	<?php
}

/**
 * Step 2: Layout.
 *
 * @param array $options Saved options.
 */
function easysite_onboarding_step_layout( $options ) {
	?>
	<h2><?php esc_html_e( 'Step 2: Layout & Style Preset', 'easysite-pro' ); ?></h2>
	<table class="form-table">
		<tr>
			<th><?php esc_html_e( 'Design preset', 'easysite-pro' ); ?></th>
			<td>
				<?php foreach ( easysite_get_design_presets() as $key => $preset ) : ?>
					<label class="easysite-preset-option">
						<input type="radio" name="design_preset" value="<?php echo esc_attr( $key ); ?>" <?php checked( $options['design_preset'] ?? 'modern', $key ); ?> />
						<?php echo esc_html( $preset['label'] ); ?>
					</label><br />
				<?php endforeach; ?>
			</td>
		</tr>
		<tr>
			<th><?php esc_html_e( 'Header style', 'easysite-pro' ); ?></th>
			<td>
				<label><input type="radio" name="header_style" value="logo-left" <?php checked( $options['header_style'] ?? 'logo-left', 'logo-left' ); ?> /> <?php esc_html_e( 'Logo left', 'easysite-pro' ); ?></label><br />
				<label><input type="radio" name="header_style" value="logo-center" <?php checked( $options['header_style'] ?? '', 'logo-center' ); ?> /> <?php esc_html_e( 'Logo center', 'easysite-pro' ); ?></label>
			</td>
		</tr>
		<tr>
			<th><?php esc_html_e( 'Sticky header', 'easysite-pro' ); ?></th>
			<td><label><input type="checkbox" name="sticky_header" value="1" <?php checked( ! empty( $options['sticky_header'] ) ); ?> /> <?php esc_html_e( 'Keep menu visible when scrolling', 'easysite-pro' ); ?></label></td>
		</tr>
	</table>
	<?php
}

/**
 * Step 3: Starter website.
 *
 * @param array $options Saved options.
 */
function easysite_onboarding_step_starter( $options ) {
	$starters = easysite_get_starter_sites();
	?>
	<h2><?php esc_html_e( 'Step 3: Choose a Starter Website', 'easysite-pro' ); ?></h2>
	<p><?php esc_html_e( 'Pick a ready-made layout. You can edit or delete any demo content later.', 'easysite-pro' ); ?></p>
	<div class="easysite-starter-grid">
		<?php foreach ( $starters as $key => $starter ) : ?>
			<label class="easysite-starter-card">
				<input type="radio" name="starter_site" value="<?php echo esc_attr( $key ); ?>" <?php checked( $options['starter_site'] ?? 'business', $key ); ?> />
				<strong><?php echo esc_html( $starter['label'] ); ?></strong>
				<p><?php echo esc_html( $starter['description'] ); ?></p>
			</label>
		<?php endforeach; ?>
	</div>
	<?php
}

/**
 * Step 4: Shop & payments.
 *
 * @param array $options Saved options.
 */
function easysite_onboarding_step_shop( $options ) {
	$wc_active = easysite_wc_active();
	?>
	<h2><?php esc_html_e( 'Step 4: Shop & Payments', 'easysite-pro' ); ?></h2>
	<?php if ( $wc_active ) : ?>
		<p><?php esc_html_e( 'WooCommerce lets you sell products on your site. Choose how customers can pay you—PayPal and Stripe may charge transaction fees, but this theme does not add any extra cost.', 'easysite-pro' ); ?></p>
		<p><a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings' ) ); ?>" class="button"><?php esc_html_e( 'Open WooCommerce Settings', 'easysite-pro' ); ?></a></p>
		<table class="form-table">
			<tr>
				<th><?php esc_html_e( 'Homepage shop section', 'easysite-pro' ); ?></th>
				<td><label><input type="checkbox" name="highlight_shop" value="1" <?php checked( ! empty( $options['highlight_shop'] ) ); ?> /> <?php esc_html_e( 'Highlight shop on homepage', 'easysite-pro' ); ?></label></td>
			</tr>
			<tr>
				<th><?php esc_html_e( 'Featured products', 'easysite-pro' ); ?></th>
				<td><label><input type="checkbox" name="featured_products" value="1" <?php checked( ! empty( $options['featured_products'] ) ); ?> /> <?php esc_html_e( 'Show featured products section', 'easysite-pro' ); ?></label></td>
			</tr>
			<tr>
				<th><?php esc_html_e( 'Sample products', 'easysite-pro' ); ?></th>
				<td><label><input type="checkbox" name="create_sample_products" value="1" <?php checked( ! empty( $options['create_sample_products'] ) ); ?> /> <?php esc_html_e( 'Create 3 demo products (if none exist)', 'easysite-pro' ); ?></label></td>
			</tr>
		</table>
	<?php else : ?>
		<p><?php esc_html_e( 'Install and activate WooCommerce (free) when you\'re ready to sell online. You can skip this step for now.', 'easysite-pro' ); ?></p>
	<?php endif; ?>
	<?php
}

/**
 * Step 5: Finish.
 *
 * @param array $options Saved options.
 */
function easysite_onboarding_step_finish( $options ) {
	?>
	<h2><?php esc_html_e( 'Step 5: You\'re All Set!', 'easysite-pro' ); ?></h2>
	<p><?php esc_html_e( 'Your website is ready to customize. You don\'t need any technical skills. Just follow the steps and type your text.', 'easysite-pro' ); ?></p>

	<div class="easysite-summary">
		<ul>
			<li><strong><?php esc_html_e( 'Site name:', 'easysite-pro' ); ?></strong> <?php echo esc_html( $options['site_name'] ?? get_bloginfo( 'name' ) ); ?></li>
			<li><strong><?php esc_html_e( 'Starter site:', 'easysite-pro' ); ?></strong> <?php echo esc_html( $options['starter_site'] ?? 'business' ); ?></li>
			<li><strong><?php esc_html_e( 'Design preset:', 'easysite-pro' ); ?></strong> <?php echo esc_html( $options['design_preset'] ?? 'modern' ); ?></li>
		</ul>
	</div>

	<?php if ( easysite_is_bundle() ) : ?>
		<h3><?php esc_html_e( 'Launch Checklist', 'easysite-pro' ); ?></h3>
		<ul class="easysite-checklist">
			<li><?php esc_html_e( 'Add logo', 'easysite-pro' ); ?></li>
			<li><?php esc_html_e( 'Add homepage text', 'easysite-pro' ); ?></li>
			<li><?php esc_html_e( 'Add contact info', 'easysite-pro' ); ?></li>
			<li><?php esc_html_e( 'Add services', 'easysite-pro' ); ?></li>
			<li><?php esc_html_e( 'Add products (if shop)', 'easysite-pro' ); ?></li>
			<li><?php esc_html_e( 'Set up payments', 'easysite-pro' ); ?></li>
			<li><?php esc_html_e( 'Click "Edit Page Visually" on your site to change text and images', 'easysite-pro' ); ?></li>
			<li><?php esc_html_e( 'Publish site', 'easysite-pro' ); ?></li>
		</ul>
	<?php endif; ?>

		<p class="easysite-finish-actions">
		<?php if ( easysite_bundle_active() ) : ?>
			<a href="<?php echo esc_url( admin_url( 'admin.php?page=easysite-invite-client' ) ); ?>" class="button button-secondary button-hero"><?php esc_html_e( 'Invite your client', 'easysite-pro' ); ?></a>
		<?php endif; ?>
		<?php
		$front_id = (int) get_option( 'page_on_front' );
		$ve_url   = $front_id ? add_query_arg( 'easysite_edit', '1', get_permalink( $front_id ) ) : add_query_arg( 'easysite_edit', '1', home_url( '/' ) );
		?>
		<a href="<?php echo esc_url( $ve_url ); ?>" class="button button-primary button-hero"><?php esc_html_e( 'Edit your site visually', 'easysite-pro' ); ?></a>
		<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="button button-secondary button-hero" target="_blank"><?php esc_html_e( 'View your site', 'easysite-pro' ); ?></a>
	</p>

	<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
		<?php wp_nonce_field( 'easysite_complete_setup', 'easysite_complete_nonce' ); ?>
		<input type="hidden" name="action" value="easysite_complete_setup" />
		<button type="submit" class="button"><?php esc_html_e( 'Mark setup as complete', 'easysite-pro' ); ?></button>
	</form>
	<?php
}

/**
 * Handle onboarding form save.
 */
function easysite_save_onboarding() {
	if ( ! isset( $_POST['easysite_onboarding_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['easysite_onboarding_nonce'] ) ), 'easysite_onboarding' ) ) {
		wp_die( esc_html__( 'Security check failed.', 'easysite-pro' ) );
	}

	if ( ! current_user_can( 'manage_options' ) ) {
		wp_die( esc_html__( 'Permission denied.', 'easysite-pro' ) );
	}

	$step    = isset( $_POST['easysite_step'] ) ? absint( $_POST['easysite_step'] ) : 1;
	$options = get_option( 'easysite_onboarding', array() );

	$fields = array( 'site_type', 'site_name', 'site_tagline', 'main_color', 'gradient_preset', 'design_preset', 'header_style', 'starter_site' );
	foreach ( $fields as $field ) {
		if ( isset( $_POST[ $field ] ) ) {
			$options[ $field ] = sanitize_text_field( wp_unslash( $_POST[ $field ] ) );
		}
	}

	$options['sticky_header']     = ! empty( $_POST['sticky_header'] );
	$options['highlight_shop']    = ! empty( $_POST['highlight_shop'] );
	$options['featured_products'] = ! empty( $_POST['featured_products'] );
	$options['create_sample_products'] = ! empty( $_POST['create_sample_products'] );

	update_option( 'easysite_onboarding', $options );

	if ( ! empty( $options['site_name'] ) ) {
		update_option( 'blogname', $options['site_name'] );
	}
	if ( isset( $options['site_tagline'] ) ) {
		update_option( 'blogdescription', $options['site_tagline'] );
	}
	if ( ! empty( $options['main_color'] ) ) {
		set_theme_mod( 'easysite_main_color', sanitize_hex_color( $options['main_color'] ) );
	}
	if ( ! empty( $options['gradient_preset'] ) ) {
		set_theme_mod( 'easysite_gradient_preset', sanitize_key( $options['gradient_preset'] ) );
		set_theme_mod( 'easysite_use_gradients', true );
	}
	if ( ! empty( $options['design_preset'] ) ) {
		easysite_apply_design_preset( $options['design_preset'] );
	}
	if ( ! empty( $options['header_style'] ) ) {
		set_theme_mod( 'easysite_header_style', $options['header_style'] );
	}
	set_theme_mod( 'easysite_sticky_header', ! empty( $options['sticky_header'] ) );

	if ( 3 === $step && ! empty( $options['starter_site'] ) ) {
		easysite_import_starter_site( $options['starter_site'] );
	}

	if ( 4 === $step ) {
		set_theme_mod( 'easysite_shop_show', ! empty( $options['highlight_shop'] ) || ! empty( $options['featured_products'] ) );
		if ( ! empty( $options['create_sample_products'] ) && function_exists( 'easysite_create_sample_products' ) ) {
			easysite_create_sample_products();
		}
	}

	$next = min( 5, $step + 1 );
	wp_safe_redirect( admin_url( 'admin.php?page=easysite-setup&step=' . $next ) );
	exit;
}
add_action( 'admin_post_easysite_save_onboarding', 'easysite_save_onboarding' );

/**
 * Mark setup complete.
 */
function easysite_complete_setup() {
	if ( ! isset( $_POST['easysite_complete_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['easysite_complete_nonce'] ) ), 'easysite_complete_setup' ) ) {
		wp_die( esc_html__( 'Security check failed.', 'easysite-pro' ) );
	}
	update_option( 'easysite_setup_complete', true );
	do_action( 'easysite_onboarding_complete' );
	wp_safe_redirect( admin_url( 'admin.php?page=easysite-setup&step=5&done=1' ) );
	exit;
}
add_action( 'admin_post_easysite_complete_setup', 'easysite_complete_setup' );

/**
 * Bundle help page.
 */
function easysite_render_help_page() {
	$guides = array(
		array(
			'title' => __( 'Getting Started', 'easysite-pro' ),
			'desc'  => __( 'Run the setup wizard, then click “Edit Page Visually” on your site to change text and images.', 'easysite-pro' ),
			'steps' => array(
				__( 'Complete all 5 setup steps', 'easysite-pro' ),
				__( 'Click “Edit your site visually” on the homepage', 'easysite-pro' ),
				__( 'Replace placeholder text and images', 'easysite-pro' ),
			),
			'link'  => admin_url( 'admin.php?page=easysite-setup' ),
			'link_label' => __( 'Open setup wizard', 'easysite-pro' ),
		),
		array(
			'title' => __( 'Editing Pages Visually', 'easysite-pro' ),
			'desc'  => __( 'Click any text to edit, images to replace, and use toolbar panels for SEO, forms, and colors.', 'easysite-pro' ),
			'steps' => array(
				__( 'Add sections or quick presets via “Add section”', 'easysite-pro' ),
				__( 'Ctrl+S save, Ctrl+Z undo, Esc close panels', 'easysite-pro' ),
				__( 'Form labels, Page SEO, and brand colors in the toolbar', 'easysite-pro' ),
			),
			'link'  => home_url( '/?easysite_edit=1' ),
			'link_label' => __( 'Open visual editor', 'easysite-pro' ),
		),
		array(
			'title' => __( 'Agency: Hand Off to Clients', 'easysite-pro' ),
			'desc'  => __( 'Create a client login, enable client mode, and white-label the dashboard.', 'easysite-pro' ),
			'steps' => array(
				__( 'EasySite Setup → Invite Client', 'easysite-pro' ),
				__( 'Site Colors & Logo → Agency & white-label', 'easysite-pro' ),
				__( 'Enable “Simplify dashboard for clients”', 'easysite-pro' ),
			),
			'link'  => admin_url( 'admin.php?page=easysite-invite-client' ),
			'link_label' => __( 'Invite a client', 'easysite-pro' ),
		),
		array(
			'title' => __( 'Duplicate Sites with Site Kit', 'easysite-pro' ),
			'desc'  => __( 'Export a full site package and import it on a new WordPress install.', 'easysite-pro' ),
			'steps' => array(
				__( 'Download site kit from Site Kit page', 'easysite-pro' ),
				__( 'On new site: activate theme, run setup, import kit', 'easysite-pro' ),
				__( 'Or import a demo kit for beauty, coach, or shop', 'easysite-pro' ),
			),
			'link'  => admin_url( 'admin.php?page=easysite-site-kit' ),
			'link_label' => __( 'Open Site Kit', 'easysite-pro' ),
		),
		array(
			'title' => __( 'Setting Up a Shop', 'easysite-pro' ),
			'desc'  => __( 'Install WooCommerce, add products, then use Shop Hero and Featured Products sections.', 'easysite-pro' ),
			'steps' => array(
				__( 'Install and activate WooCommerce', 'easysite-pro' ),
				__( 'Add products and mark some as featured', 'easysite-pro' ),
				__( 'Add Shop Hero + Featured Products in the visual editor', 'easysite-pro' ),
			),
			'link'  => admin_url( 'plugin-install.php?s=woocommerce&tab=search&type=term' ),
			'link_label' => __( 'Install WooCommerce', 'easysite-pro' ),
		),
		array(
			'title' => __( 'License & Updates', 'easysite-pro' ),
			'desc'  => __( 'Activate your Ultimate Bundle license key to unlock all agency features.', 'easysite-pro' ),
			'steps' => array(
				__( 'Enter key in ESITE-XXXX-XXXX format', 'easysite-pro' ),
				__( 'Updates appear under Appearance → Themes when configured', 'easysite-pro' ),
				__( 'See docs/guides/LICENSING.md for details', 'easysite-pro' ),
			),
			'link'  => admin_url( 'admin.php?page=easysite-license' ),
			'link_label' => __( 'Manage license', 'easysite-pro' ),
		),
		array(
			'title' => __( 'Client Guide (share with site owners)', 'easysite-pro' ),
			'desc'  => __( 'Non-technical guide for clients: log in, edit visually, change logo and colors.', 'easysite-pro' ),
			'steps' => array(
				__( 'Send docs/CLIENT-GUIDE.md after inviting a client', 'easysite-pro' ),
				__( 'Clients use Edit Page Visually — no wp-admin training needed', 'easysite-pro' ),
				__( 'Set support email under Agency & white-label', 'easysite-pro' ),
			),
			'link'  => get_template_directory_uri() . '/docs/CLIENT-GUIDE.md',
			'link_label' => __( 'Open client guide', 'easysite-pro' ),
		),
	);
	?>
	<div class="wrap easysite-help">
		<h1><?php esc_html_e( 'Help & Tutorials', 'easysite-pro' ); ?></h1>
		<p><?php esc_html_e( 'Step-by-step guides for building, handing off, and selling EasySite Pro sites.', 'easysite-pro' ); ?></p>
		<div class="easysite-help-grid">
			<?php foreach ( $guides as $guide ) : ?>
				<div class="easysite-help-card">
					<h3><?php echo esc_html( $guide['title'] ); ?></h3>
					<p><?php echo esc_html( $guide['desc'] ); ?></p>
					<?php if ( ! empty( $guide['steps'] ) ) : ?>
						<ol>
							<?php foreach ( $guide['steps'] as $step ) : ?>
								<li><?php echo esc_html( $step ); ?></li>
							<?php endforeach; ?>
						</ol>
					<?php endif; ?>
					<?php if ( ! empty( $guide['link'] ) ) : ?>
						<p><a class="button button-secondary" href="<?php echo esc_url( $guide['link'] ); ?>"><?php echo esc_html( $guide['link_label'] ); ?></a></p>
					<?php endif; ?>
				</div>
			<?php endforeach; ?>
		</div>
		<p class="description">
			<?php esc_html_e( 'Agency documentation (not shown to client logins):', 'easysite-pro' ); ?>
			<a href="<?php echo esc_url( get_template_directory_uri() . '/docs/README.md' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'All guides', 'easysite-pro' ); ?></a>
			·
			<a href="<?php echo esc_url( get_template_directory_uri() . '/docs/CLIENT-GUIDE.md' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Client guide (PDF/markdown)', 'easysite-pro' ); ?></a>
			·
			<a href="<?php echo esc_url( get_template_directory_uri() . '/docs/CLIENT-HANDOFF.md' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Handoff checklist', 'easysite-pro' ); ?></a>
		</p>
		<p class="description"><?php esc_html_e( 'Client accounts see Help & Guides in the admin sidebar (with screenshots). Marketing screenshots for ThemeForest live in marketing/screenshots/ in the dev repo — not on client sites.', 'easysite-pro' ); ?></p>
	</div>
	<?php
}
