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

$upload_options         = SftcyWordformBase::wordform_settings_page_upload_config();
$wordform_upgrade_url   = class_exists( 'SftcyWordformFeatures' ) ? SftcyWordformFeatures::wordform_get_upgrade_url() : 'https://softcoy.com/products/wordform-pro/checkout';
$upload_limits          = class_exists( 'SftcyWordformFeatures' ) ? SftcyWordformFeatures::wordform_get_feature_limits( 'upload' ) : array();
$upload_limit_label     = ! empty( $upload_limits['label'] ) ? $upload_limits['label'] : __( 'Image uploads only', 'wordform' );
?>
<div class="sc-wordform-setting-page-general-tab-table-wrapper sc-wordform-setting-page-upload-tab-table-wrapper">
	<div class="wordform-pro-locked-panel">
		<div class="wordform-pro-locked-panel-head">
			<div>
				<h3><?php esc_html_e( 'Upload settings are customizable in WordForm Pro', 'wordform' ); ?></h3>
				<p><?php esc_html_e( 'Free uses safe default upload rules. Upgrade to change file count, size limits, progress UI, and the full set of allowed file types.', 'wordform' ); ?></p>
			</div>
			<span class="wordform-pro-preview-badge"><?php esc_html_e( 'Pro', 'wordform' ); ?></span>
		</div>

		<div class="wordform-tier-option-hint">
			<strong><?php esc_html_e( 'Free version limit:', 'wordform' ); ?></strong>
			<?php echo esc_html( $upload_limit_label ); ?>
			<a class="button button-small wordform-pro-locked-button" href="<?php echo esc_url( $wordform_upgrade_url ); ?>" target="_blank" rel="noopener" data-upgrade-url="<?php echo esc_url( $wordform_upgrade_url ); ?>" title="<?php esc_attr_e( 'Get Pro', 'wordform' ); ?>"><?php esc_html_e( 'Get Pro', 'wordform' ); ?></a>
		</div>

		<div class="wordform-pro-preview-frame">
			<form enctype="multipart/form-data" method="post" id="scWordformSettingsUploadTabForm" class="wordform-pro-demo-shell wordform-pro-demo-upload-form">
				<div class="sc-wordform-general-toolbar sc-wordform-upload-toolbar">
					<div class="sc-wordform-general-toolbar-copy">
						<label><?php esc_html_e( 'Upload Settings', 'wordform-pro' ); ?></label>
						<p><?php esc_html_e( 'These upload rules apply across your forms so visitors get consistent file limits, validation, and progress feedback.', 'wordform-pro' ); ?></p>
					</div>
				</div>

				<table class="sc-wordform-general-settings-table sc-wordform-upload-settings-table">
					<tbody>
						<tr class="sc-wordform-general-section-row">
							<td colspan="2">
								<div class="sc-wordform-general-section-head">
									<h4><?php esc_html_e( 'Upload Limits', 'wordform-pro' ); ?></h4>
									<p><?php esc_html_e( 'Control how many files users can upload and how large each upload can be.', 'wordform-pro' ); ?></p>
								</div>
							</td>
						</tr>

						<tr class="sc-wordform-general-setting-row">
							<td class="sc-wordform-settings-general-tab-label-td">
								<h4><i class="fa-solid fa-layer-group"></i><?php esc_html_e( 'Max Number Of Files Limit', 'wordform-pro' ); ?></h4>
							</td>
							<td>
								<div class="wordform-upload-input-element-wrapper-div">
									<input type="hidden" name="sc-wordform-upload-max-numof-files" class="sc-wordform-upload-max-numof-files" value="<?php echo esc_attr( $upload_options['upload_max_numof_files'] ); ?>" readonly />
								</div>
								<p class="sc-wordform-upload-max-numof-files-slider wordform-demo-disabled-slider"></p>
								<span class="slider-value-display"><?php echo esc_html( $upload_options['upload_max_numof_files'] ); ?></span>
								<small><i class="fa-solid fa-circle-info setting-upload-tab-page-info-icon"></i>
									<?php
									echo wp_kses(
										sprintf(
											'Server allows up to <strong class="wordform-server-upload-limit-info">%d files</strong> per upload.',
											$upload_options['server_max_num_files_allowed']
										),
										array( 'strong' => array( 'class' => array() ) ),
										'wordform-pro'
									);
									?>
								</small>
							</td>
						</tr>

						<tr class="sc-wordform-general-setting-row">
							<td class="sc-wordform-settings-general-tab-label-td">
								<h4><i class="fa-solid fa-file-circle-plus"></i><?php esc_html_e( 'Each File Max Size (MB)', 'wordform-pro' ); ?></h4>
							</td>
							<td>
								<div class="wordform-upload-input-element-wrapper-div">
									<input type="hidden" name="sc-wordform-upload-each-file-max-size" class="sc-wordform-upload-each-file-max-size" value="<?php echo esc_attr( $upload_options['upload_each_file_max_size'] ); ?>" readonly />
								</div>
								<p class="sc-wordform-upload-each-file-max-size-slider wordform-demo-disabled-slider"></p>
								<span class="slider-value-display"><?php echo esc_html( $upload_options['upload_each_file_max_size'] ); ?> MB</span>
								<small><i class="fa-solid fa-circle-info setting-upload-tab-page-info-icon"></i>
									<?php
									echo wp_kses(
										sprintf(
											'Server allows <strong class="wordform-server-upload-limit-info">%d MB</strong> per file.',
											$upload_options['server_each_file_max_size_allowed']
										),
										array( 'strong' => array( 'class' => array() ) ),
										'wordform-pro'
									);
									?>
								</small>
							</td>
						</tr>

						<tr class="sc-wordform-general-setting-row">
							<td class="sc-wordform-settings-general-tab-label-td">
								<h4><i class="fa-solid fa-box-archive"></i><?php esc_html_e( 'All Files Combined Max Size (MB)', 'wordform-pro' ); ?></h4>
							</td>
							<td>
								<div class="wordform-upload-input-element-wrapper-div">
									<input type="hidden" name="sc-wordform-upload-all-files-max-size" class="sc-wordform-upload-all-files-max-size" value="<?php echo esc_attr( $upload_options['upload_all_files_max_size'] ); ?>" readonly />
								</div>
								<p class="sc-wordform-upload-all-files-max-size-slider wordform-demo-disabled-slider"></p>
								<span class="slider-value-display"><?php echo esc_html( $upload_options['upload_all_files_max_size'] ); ?> MB</span>
								<small><i class="fa-solid fa-circle-info setting-upload-tab-page-info-icon"></i>
									<?php
									echo wp_kses(
										sprintf(
											'Server allows <strong class="wordform-server-upload-limit-info">%d MB</strong> total for all files per upload.',
											$upload_options['server_all_files_max_size_allowed']
										),
										array( 'strong' => array( 'class' => array() ) ),
										'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( 'Upload Feedback', 'wordform-pro' ); ?></h4>
									<p><?php esc_html_e( 'Tune how upload progress is shown while files are moving to the server.', 'wordform-pro' ); ?></p>
								</div>
							</td>
						</tr>

						<tr class="sc-wordform-general-setting-row">
							<td class="sc-wordform-settings-general-tab-label-td">
								<h4><i class="fa-solid fa-chart-line"></i><?php esc_html_e( 'Show Upload Progress Bar', 'wordform-pro' ); ?></h4>
							</td>
							<td>
								<div class="sc-wordform-general-toggle-option">
									<input type="checkbox" id="scWordformUploadProgressBarShowHide" class="sc-wordform-upload-progress-bar-show-hide" name="sc-wordform-upload-progress-bar-show-hide" <?php checked( 'yes', $upload_options['upload_show_hide_progress_bar'] ); ?> disabled>
									<label for="scWordformUploadProgressBarShowHide"><?php esc_html_e( 'Show uploading progress bar', 'wordform-pro' ); ?></label>
								</div>
								<small><?php esc_html_e( 'Recommended for larger files so users can clearly see the upload is in progress.', 'wordform-pro' ); ?></small>
							</td>
						</tr>

						<tr class="sc-wordform-general-setting-row">
							<td class="sc-wordform-settings-general-tab-label-td">
								<h4><i class="fa-solid fa-palette"></i><?php esc_html_e( 'Progress Bar Color', 'wordform-pro' ); ?></h4>
							</td>
							<td>
								<input type="text" value="<?php echo esc_attr( $upload_options['upload_progress_bar_color'] ); ?>" class="sc-wordform-upload-progress-bar-color" name="sc-wordform-upload-progress-bar-color" disabled>
							</td>
						</tr>
					</tbody>
				</table>

				<div class="sc-wordform-general-actions sc-wordform-upload-actions">
					<button type="submit" class="button button-primary button-large" disabled><?php esc_html_e( 'Save', 'wordform-pro' ); ?></button>
					<button type="button" class="button button-secondary button-large sc-wordform-settings-upload-tab-reset" disabled><?php esc_html_e( 'Reset', 'wordform-pro' ); ?></button>
					<div class="sc-wordform-upload-tab-update-info"></div>
				</div>
			</form>
			<a class="wordform-pro-preview-overlay wordform-pro-locked-button" href="<?php echo esc_url( $wordform_upgrade_url ); ?>" target="_blank" rel="noopener" data-upgrade-url="<?php echo esc_url( $wordform_upgrade_url ); ?>" title="<?php esc_attr_e( 'Get Pro', 'wordform' ); ?>">
				<span class="wordform-pro-preview-overlay-chip"><?php esc_html_e( 'Get Pro', 'wordform' ); ?></span>
				<strong><?php esc_html_e( 'Unlock upload customization', 'wordform' ); ?></strong>
				<small><?php esc_html_e( 'Control limits, file rules, and richer upload behavior with the full WordForm Pro upload settings.', 'wordform' ); ?></small>
			</a>
		</div>
	</div>
</div>
