<?php
/**
 * Template: templates/partials/esp-signup-widget.php
 *
 * Reader Signup Widget Form -- F-026-5
 *
 * Variables injected by mbs_get_template_part():
 *   $post_id      int     Book post ID (0 = no book context).
 *   $consent_text string  Consent checkbox label from settings.
 *
 * @package MyBookShowroom
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div class="mbs-wrapper mbs-esp-signup-widget">
	<h3 class="mbs-esp-signup-heading"><?php esc_html_e( 'Stay in the Loop', 'my-book-showroom' ); ?></h3>
	<form class="mbs-esp-signup-form" data-book-id="<?php echo esc_attr( (string) $post_id ); ?>" novalidate>
		<div class="mbs-esp-field-row">
			<label class="screen-reader-text" for="mbs-esp-email-<?php echo esc_attr( (string) $post_id ); ?>">
				<?php esc_html_e( 'Email address', 'my-book-showroom' ); ?>
			</label>
			<input
				type="email"
				id="mbs-esp-email-<?php echo esc_attr( (string) $post_id ); ?>"
				name="mbs_esp_email"
				class="mbs-esp-email-input"
				placeholder="<?php esc_attr_e( 'Your email address', 'my-book-showroom' ); ?>"
				required
				autocomplete="email"
			/>
		</div>
		<div class="mbs-esp-field-row">
			<label class="screen-reader-text" for="mbs-esp-name-<?php echo esc_attr( (string) $post_id ); ?>">
				<?php esc_html_e( 'First name', 'my-book-showroom' ); ?>
			</label>
			<input
				type="text"
				id="mbs-esp-name-<?php echo esc_attr( (string) $post_id ); ?>"
				name="mbs_esp_name"
				class="mbs-esp-name-input"
				placeholder="<?php esc_attr_e( 'Your first name (optional)', 'my-book-showroom' ); ?>"
				autocomplete="given-name"
			/>
		</div>
		<div class="mbs-esp-field-row mbs-esp-consent-row">
			<label class="mbs-esp-consent">
				<input type="checkbox" name="mbs_esp_consent" value="1" required />
				<span class="mbs-esp-consent-text">
					<?php echo wp_kses( $consent_text, array( 'a' => array( 'href' => array(), 'target' => array() ) ) ); ?>
				</span>
			</label>
		</div>
		<?php wp_nonce_field( 'mbs_esp_subscribe' ); ?>
		<div class="mbs-esp-field-row mbs-esp-submit-row">
			<button type="submit" class="mbs-btn mbs-esp-submit">
				<?php esc_html_e( 'Subscribe', 'my-book-showroom' ); ?>
			</button>
		</div>
		<p class="mbs-esp-msg" aria-live="polite" role="status"></p>
	</form>
</div>
