<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

$hcaptcha_data = SftcyWordformBase::wordform_settings_page_hcaptcha_config();
?>
<div class="wrap sc-wordform-setting-page-gcaptcha-tab-table-wrapper">
	<div class="sc-wordform-general-toolbar sc-wordform-upload-toolbar">
		<div class="sc-wordform-general-toolbar-copy">
			<label><?php esc_html_e( 'hCaptcha Settings', 'wordform-pro' ); ?></label>
			<p><?php esc_html_e( 'Add your hCaptcha site credentials and choose the widget theme that fits your frontend forms.', 'wordform-pro' ); ?></p>
		</div>
	</div>

	<div class="google-recaptcha-create-hints-div-wrapper">
		<i class="fa-solid fa-circle-info"></i>
		<?php echo wp_kses_post( __( 'If you do not have hCaptcha keys yet then you can <a href="https://dashboard.hcaptcha.com/sites/new" target="_blank" rel="noopener noreferrer">create a new hCaptcha site</a>. You can also <a href="https://docs.hcaptcha.com/" target="_blank" rel="noopener noreferrer">read the official hCaptcha docs</a> for setup help.', 'wordform-pro' ) ); ?>
	</div>

	<form id="scWordformSettingshCaptchaTabForm" method="post">
		<table class="sc-wordform-general-settings-table wordform-grecaptcha-settings-tbl">
			<tbody>
				<tr class="sc-wordform-general-section-row">
					<td colspan="2">
						<div class="sc-wordform-general-section-head">
							<h4><?php esc_html_e( 'API Keys', 'wordform-pro' ); ?></h4>
							<p><?php esc_html_e( 'Use the keys from your hCaptcha dashboard for widget rendering and server-side verification.', 'wordform-pro' ); ?></p>
						</div>
					</td>
				</tr>

				<tr class="sc-wordform-general-setting-row">
					<td class="sc-wordform-settings-general-tab-label-td sc-wordform-settings-gcaptcha-tab-label-td">
						<h4><i class="fa-solid fa-key"></i><?php esc_html_e( 'Site Key', 'wordform-pro' ); ?></h4>
					</td>
					<td>
						<input type="text" value="<?php echo esc_attr( $hcaptcha_data['hcaptcha-site-key'] ); ?>" name="wordform-hcaptcha-site-key" class="wordform-hcaptcha-site-key" placeholder="Site Key" />
						<small><?php echo wp_kses_post( __( 'Find this in your hCaptcha site settings. <a href="https://docs.hcaptcha.com/#add-the-hcaptcha-widget-to-your-webpage" target="_blank" rel="noopener noreferrer">How to get Site Key</a>', 'wordform-pro' ) ); ?></small>
					</td>
				</tr>

				<tr class="sc-wordform-general-setting-row">
					<td class="sc-wordform-settings-general-tab-label-td sc-wordform-settings-gcaptcha-tab-label-td">
						<h4><i class="fa-solid fa-key"></i><?php esc_html_e( 'Secret Key', 'wordform-pro' ); ?></h4>
					</td>
					<td>
						<input type="text" value="<?php echo esc_attr( $hcaptcha_data['hcaptcha-secret-key'] ); ?>" name="wordform-hcaptcha-secret-key" class="wordform-hcaptcha-secret-key" placeholder="Secret Key" />
						<small><?php echo wp_kses_post( __( 'Use the secret key from your hCaptcha dashboard for server-side verification. <a href="https://docs.hcaptcha.com/#verify-the-user-response-server-side" target="_blank" rel="noopener noreferrer">How to get Secret Key</a>', 'wordform-pro' ) ); ?></small>
					</td>
				</tr>

				<tr class="sc-wordform-general-section-row">
					<td colspan="2">
						<div class="sc-wordform-general-section-head">
							<h4><?php esc_html_e( 'Widget Theme', 'wordform-pro' ); ?></h4>
							<p><?php esc_html_e( 'Choose how the hCaptcha challenge should look on the frontend when the widget is visible.', 'wordform-pro' ); ?></p>
						</div>
					</td>
				</tr>

				<tr class="sc-wordform-general-setting-row">
					<td class="sc-wordform-settings-general-tab-label-td sc-wordform-settings-gcaptcha-tab-label-td">
						<h4><?php esc_html_e( 'Theme', 'wordform-pro' ); ?></h4>
					</td>
					<td>
						<div class="sc-wordform-general-radio-inline">
							<label>
								<input type="radio" value="light" name="wordform-hcaptcha-theme" class="wordform-hcaptcha-theme" <?php checked( 'light', $hcaptcha_data['hcaptcha-theme'], true ); ?> />
								<?php esc_html_e( 'Light', 'wordform-pro' ); ?>
							</label>
							<label>
								<input type="radio" value="dark" name="wordform-hcaptcha-theme" class="wordform-hcaptcha-theme" <?php checked( 'dark', $hcaptcha_data['hcaptcha-theme'], true ); ?> />
								<?php esc_html_e( 'Dark', 'wordform-pro' ); ?>
							</label>
						</div>
					</td>
				</tr>
			</tbody>
		</table>

		<div class="sc-wordform-general-actions">
			<button type="submit" class="button button-primary button-large"><?php esc_html_e( 'Save', 'wordform-pro' ); ?></button>
			<span class="sc-wordform-hcaptcha-message-settings-info"></span>
		</div>
	</form>
</div>
