<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
/** create_account.php */
if ( isset( $args ) && is_array( $args ) ) {
	extract( $args, EXTR_SKIP );
}
?>
<div class="form-row" style="float: unset;">
	<div id="simplyin-phone-checkbox">
		<div class="simplyin-checkbox-row <?php if ( $checked ) {
			echo 'show';
		} ?>">
			<label class="simplyin-checkbox">
				<input type="checkbox"
					   id="simply-save-checkbox" <?php echo( $checked ? 'checked' : '' ); ?>
					   name="simply-save-checkbox" class="ps-shown-by-js"/>
				<input type="hidden" name="simplyin_create_account_token"
					   value="<?php echo esc_attr( wp_create_nonce( 'simplyin_create_account_nonce' ) ) ?>">
				<span class="simplyin-checkbox-text">
					<strong><?php esc_html_e( 'Remember your details with Simply.IN',
							'simplyin' ); ?></strong>
				</span>
				<div class="simplyin-badge-logo-group">
					<span class="simplyin-badge-new"><?php esc_html_e( 'New',
							'simplyin' ); ?></span>
					<div class="simplyin-logo">
						<img
							src="<?php echo esc_url( plugin_dir_url( __FILE__ ) . '../../../public/img/logo_signet.svg' ); ?>?v=1.0"
							alt="<?php esc_attr_e( 'Simply.IN', 'simplyin' ); ?>"/>
					</div>
				</div>
			</label>
			<ul class="simplyin-benefits-list">
				<li><?php esc_html_e( 'Your purchases and returns from all stores in one place',
						'simplyin' ); ?></li>
				<li><?php esc_html_e( 'Fast checkout with saved details, no passwords required',
						'simplyin' ); ?></li>
			</ul>
		</div>
		<div class="simplyin-phone-input" <?php if ( ! $checked ) {
			echo 'style="display: none;"';
		} ?>>
			<div class="phone-input-container">
				<div class="phone-country-select">
					<select id="simplyin-phone-country"
							name="simplyin-phone-country"
							aria-label="<?php esc_attr_e( 'Select country',
								'simplyin' ); ?>">
						<?php foreach ( $countries as /** @var array $country_item */ $country_item ) : ?>
							<option <?php if ( $country_item['dial_code'] == $selected_prefix ) {
								echo ' selected';
							} ?>
								value="<?php echo esc_attr( $country_item['code'] ); ?>"
								data-flag="<?php echo esc_attr( $country_item['code'] ); ?>"
								data-prefix="<?php echo esc_attr( $country_item['dial_code'] ); ?>">
								<?php echo esc_attr( $country_item['name'] ); ?>
							</option>
						<?php endforeach; ?>
					</select>
					<div class="simplyin-flag-display">
						<img
							src="<?php echo esc_url( plugin_dir_url( __FILE__ ) . '../../../public/img/poland.svg' ); ?>"
							alt="" width="24" height="16"/>
					</div>
					<span
						class="prefix"><?php echo esc_html( $selected_prefix ); ?></span>
				</div>
				<div class="phone-input">
					<input type="tel" id="simplyin-phone-input"
						   name="simplyin-phone"
						   placeholder="<?php esc_attr_e( 'Phone number',
							   'simplyin' ); ?>"
						   autocomplete="off"
						   value="<?php echo esc_attr( $phone ); ?>"/>
				</div>
				<input type="hidden" name="simplyin-phone-prefix"
					   value="<?php echo esc_attr( $selected_prefix ); ?>">
			</div>
			<div class="phone-input-warning"
				 data-invalid="<?php esc_attr_e( 'The phone number is invalid.',
					 'simplyin' ); ?>"
				 data-empty="<?php esc_attr_e( 'The phone number is required.',
					 'simplyin' ); ?>">
				<?php esc_html_e( 'The phone number is required.',
					'simplyin' ); ?>
			</div>
			<div class="simplyin-description">
				<p>
					<?php esc_html_e( "Next time in Simply.IN stores, you'll confirm your details using your phone (SMS/APP)",
						'simplyin' ); ?>
				</p>
			</div>
		</div>
		<div class="simplyin-terms" <?php if ( ! $checked ) {
			echo 'style="display: none;"';
		} ?>>
			<div class='simplyin-terms-inner'>
				<?php
				/** @var string $privacy_anchor */
				$privacy_anchor = sprintf(
					'<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
					esc_url( $privacy_link ),
					esc_html__( 'Privacy Policy', 'simplyin' )
				);

				/** @var string $terms_anchor */
				$terms_anchor = sprintf(
					'<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
					esc_url( $terms_link ),
					esc_html__( 'Terms', 'simplyin' )
				);
				/** @var string $terms_text */
				$terms_text = sprintf(
					/* translators: 1: Privacy Policy link, 2: Terms link. */
					__( 'By purchasing, you agree to Simply.IN’s %1$s and %2$s.', 'simplyin' ),
					$privacy_anchor,
					$terms_anchor
				);

				echo wp_kses_post( $terms_text );
				?>
			</div>
			<div class="simplyin-terms-additional-text">
				<span>🔒 <?php esc_html_e( 'PCI - Bank level security', 'simplyin' ); ?></span>
			</div>
		</div>
	</div>
</div>
