<?php
/**
 * Help / setup view.
 *
 * @package AetherisAIChat
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
$aetheris_dashboard_url = AETHERIS_AI_CHAT_DEFAULT_DASHBOARD;
?>
<div class="wrap aetheris-wrap">
	<?php Aetheris_AI_Chat_Admin::render_header( __( 'Setup guide', 'aetheris-ai-chat' ) ); ?>

	<div class="aetheris-card">
		<ol class="aetheris-steps">
			<li>
				<strong><?php esc_html_e( 'Create your Aetheris account', 'aetheris-ai-chat' ); ?></strong>
				<p>
					<?php
					printf(
						/* translators: %s: link to the Aetheris dashboard. */
						esc_html__( 'Sign up at %s. Free tier includes up to 100 conversations / month.', 'aetheris-ai-chat' ),
						'<a href="' . esc_url( $aetheris_dashboard_url ) . '" target="_blank" rel="noopener">'
						. esc_html( $aetheris_dashboard_url ) . '</a>'
					);
					?>
				</p>
			</li>
			<li>
				<strong><?php esc_html_e( 'Copy your Public Key', 'aetheris-ai-chat' ); ?></strong>
				<p>
					<?php esc_html_e( 'In the dashboard, open Settings → Embed code. Copy the value after ?client=. It starts with ac_.', 'aetheris-ai-chat' ); ?>
				</p>
			</li>
			<li>
				<strong><?php esc_html_e( 'Paste it into the plugin', 'aetheris-ai-chat' ); ?></strong>
				<p>
					<?php
					printf(
						/* translators: %s: link to the plugin Settings page. */
						esc_html__( 'Go to %s, paste the public key, and toggle the chatbot on. The widget appears on every page in seconds.', 'aetheris-ai-chat' ),
						'<a href="' . esc_url( admin_url( 'admin.php?page=' . Aetheris_AI_Chat_Admin::SLUG ) ) . '">'
						. esc_html__( 'Aetheris Chat → Settings', 'aetheris-ai-chat' ) . '</a>'
					);
					?>
				</p>
			</li>
			<li>
				<strong><?php esc_html_e( 'Add an API key (optional)', 'aetheris-ai-chat' ); ?></strong>
				<p>
					<?php
					printf(
						/* translators: %s: API key prefix shown in code formatting (e.g. <code>aks_live_</code>). */
						esc_html__( 'In the dashboard, open Settings → API keys → Generate. Copy the key (it starts with %1$s) and paste it into the API Key field on the plugin Settings page. This unlocks the in-WordPress Knowledge Base and Dashboard tabs.', 'aetheris-ai-chat' ),
						'<code>aks_live_</code>'
					);
					?>
				</p>
			</li>
			<li>
				<strong><?php esc_html_e( 'Train it on your content', 'aetheris-ai-chat' ); ?></strong>
				<p>
					<?php esc_html_e( 'Open Knowledge Base and ingest your homepage plus a few key pages. The bot answers best with 5–20 well-chosen sources, not your entire site.', 'aetheris-ai-chat' ); ?>
				</p>
			</li>
		</ol>
	</div>

	<div class="aetheris-card">
		<h2><?php esc_html_e( 'Hide the widget on specific pages', 'aetheris-ai-chat' ); ?></h2>
		<p>
			<?php esc_html_e( 'Add this snippet to your theme’s functions.php to suppress the widget on the checkout page:', 'aetheris-ai-chat' ); ?>
		</p>
		<pre class="aetheris-snippet"><code>add_filter( 'aetheris_ai_chat_should_load', function ( $load ) {
    if ( function_exists( 'is_checkout' ) && is_checkout() ) {
        return false;
    }
    return $load;
} );</code></pre>
	</div>

	<div class="aetheris-card">
		<h2><?php esc_html_e( 'Troubleshooting', 'aetheris-ai-chat' ); ?></h2>
		<ul class="aetheris-list">
			<li><?php esc_html_e( 'Widget not showing? Confirm the public key is set, the toggle is on, and your theme calls wp_footer().', 'aetheris-ai-chat' ); ?></li>
			<li><?php esc_html_e( 'KB upload errors? Check the API key in Settings — uploads require it. Free tier files are limited to 20 MB.', 'aetheris-ai-chat' ); ?></li>
			<li><?php esc_html_e( 'Caching plugin? Bypass cache for the script tag, or clear your cache after toggling settings.', 'aetheris-ai-chat' ); ?></li>
		</ul>
	</div>
</div>
