<?php

/**
 * Global Settings Page.
 *
 * Global defaults that apply to all addons unless overridden at the field level.
 *
 * @package    Extra_Product_Options_For_WooCommerce
 * @subpackage Extra_Product_Options_For_WooCommerce/settings
 * @since      4.4.5
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
    // Exit if accessed directly.
}
// Handle form submission.
$epofw_global_submit = ( isset( $_POST['epofw_global_submit'] ) ? sanitize_text_field( wp_unslash( $_POST['epofw_global_submit'] ) ) : '' );
if ( $epofw_global_submit ) {
    $epofw_global_save_nonce = ( isset( $_POST['epofw_global_save_nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['epofw_global_save_nonce'] ) ) : '' );
    if ( empty( $epofw_global_save_nonce ) || !wp_verify_nonce( sanitize_text_field( $epofw_global_save_nonce ), 'epofw_global_save_action' ) ) {
        esc_html_e( 'Error with security check.', 'extra-product-options-for-woocommerce' );
        return false;
    }
    $epofw_global_data = filter_input(
        INPUT_POST,
        'epofw_global_data',
        FILTER_DEFAULT,
        FILTER_REQUIRE_ARRAY
    );
    if ( !empty( $epofw_global_data ) ) {
        $epofw_sanitized_global_data = epofw_sanitize_array( $epofw_global_data );
        /**
         * Filter global settings payload before save.
         *
         * @since 4.4.5
         */
        $epofw_sanitized_global_data = apply_filters( 'epofw_global_settings_save', $epofw_sanitized_global_data );
        update_option( 'epofw_global_settings', $epofw_sanitized_global_data );
        // Clear the global settings cache after saving.
        wp_cache_delete( 'epofw_global_settings_data', 'epofw' );
    }
}
// Get current global settings.
$epofw_global_settings = get_option( 'epofw_global_settings', array() );
// Get individual settings with defaults.
$epofw_global_default_title_position = ( isset( $epofw_global_settings['default_title_position'] ) ? $epofw_global_settings['default_title_position'] : '' );
$epofw_global_label_settings = ( isset( $epofw_global_settings['label'] ) && is_array( $epofw_global_settings['label'] ) ? $epofw_global_settings['label'] : array() );
$epofw_global_field_container = ( isset( $epofw_global_settings['field_container_settings'] ) && is_array( $epofw_global_settings['field_container_settings'] ) ? $epofw_global_settings['field_container_settings'] : array() );
// Get title position options.
$epofw_title_position_options = epofw_field_title_position_data();
// Premium helper data.
$epofw_prem_data = epofw_get_premium_field_data();
$epofw_is_premium_user = $epofw_prem_data['is_premium'];
// Label defaults (free + pro).
// For new installations, default to 'span' for title/subtitle type.
$epofw_global_label_title_type = ( isset( $epofw_global_label_settings['title_type'] ) ? $epofw_global_label_settings['title_type'] : 'span' );
$epofw_global_label_title_color = ( isset( $epofw_global_label_settings['title_color'] ) ? $epofw_global_label_settings['title_color'] : '' );
$epofw_global_label_subtitle_type = ( isset( $epofw_global_label_settings['subtitle_type'] ) ? $epofw_global_label_settings['subtitle_type'] : 'span' );
$epofw_global_label_subtitle_color = ( isset( $epofw_global_label_settings['subtitle_color'] ) ? $epofw_global_label_settings['subtitle_color'] : '' );
$epofw_global_label_class = ( isset( $epofw_global_label_settings['class'] ) ? $epofw_global_label_settings['class'] : '' );
$epofw_global_label_subtitle_class = ( isset( $epofw_global_label_settings['subtitle_class'] ) ? $epofw_global_label_settings['subtitle_class'] : '' );
$epofw_global_label_styling = ( isset( $epofw_global_label_settings['label_styling'] ) && is_array( $epofw_global_label_settings['label_styling'] ) ? $epofw_global_label_settings['label_styling'] : array() );
$epofw_global_label_styling_enabled = ( isset( $epofw_global_label_styling['enabled'] ) && 'on' === $epofw_global_label_styling['enabled'] ? 'on' : '' );
$epofw_global_label_font_size = ( isset( $epofw_global_label_styling['font_size'] ) ? $epofw_global_label_styling['font_size'] : '' );
$epofw_global_label_font_weight = ( isset( $epofw_global_label_styling['font_weight'] ) ? $epofw_global_label_styling['font_weight'] : '' );
$epofw_global_label_font_family = ( isset( $epofw_global_label_styling['font_family'] ) ? $epofw_global_label_styling['font_family'] : '' );
$epofw_global_label_text_align = ( isset( $epofw_global_label_styling['text_align'] ) ? $epofw_global_label_styling['text_align'] : '' );
$epofw_global_label_text_transform = ( isset( $epofw_global_label_styling['text_transform'] ) ? $epofw_global_label_styling['text_transform'] : '' );
$epofw_global_label_letter_spacing = ( isset( $epofw_global_label_styling['letter_spacing'] ) ? $epofw_global_label_styling['letter_spacing'] : '' );
$epofw_global_label_line_height = ( isset( $epofw_global_label_styling['line_height'] ) ? $epofw_global_label_styling['line_height'] : '' );
$epofw_global_label_text_shadow = ( isset( $epofw_global_label_styling['text_shadow'] ) ? $epofw_global_label_styling['text_shadow'] : '' );
$epofw_global_label_custom_css = ( isset( $epofw_global_label_styling['custom_css'] ) ? $epofw_global_label_styling['custom_css'] : '' );
$epofw_label_styling_fields_style = ( 'on' === $epofw_global_label_styling_enabled ? '' : 'display:none;' );
// Field container defaults (free + pro).
$epofw_global_field_container_enabled = ( isset( $epofw_global_field_container['enabled'] ) && 'on' === $epofw_global_field_container['enabled'] ? 'on' : '' );
$epofw_global_field_container_background = ( isset( $epofw_global_field_container['background_color'] ) ? $epofw_global_field_container['background_color'] : '' );
$epofw_global_field_container_custom_css = ( isset( $epofw_global_field_container['custom_css'] ) ? $epofw_global_field_container['custom_css'] : '' );
$epofw_global_padding_value = ( isset( $epofw_global_field_container['padding'] ) ? $epofw_global_field_container['padding'] : '' );
$epofw_global_margin_value = ( isset( $epofw_global_field_container['margin'] ) ? $epofw_global_field_container['margin'] : '' );
$epofw_global_field_container_padding = ( is_array( $epofw_global_padding_value ) ? '' : $epofw_global_padding_value );
$epofw_global_field_container_margin = ( is_array( $epofw_global_margin_value ) ? '' : $epofw_global_margin_value );
$epofw_field_container_fields_style = ( 'on' === $epofw_global_field_container_enabled ? '' : 'display:none;' );
$epofw_global_padding_settings = ( is_array( $epofw_global_padding_value ) ? $epofw_global_padding_value : array() );
$epofw_global_margin_settings = ( is_array( $epofw_global_margin_value ) ? $epofw_global_margin_value : array() );
$epofw_global_field_container_padding_top = ( isset( $epofw_global_padding_settings['top'] ) ? $epofw_global_padding_settings['top'] : '' );
$epofw_global_field_container_padding_right = ( isset( $epofw_global_padding_settings['right'] ) ? $epofw_global_padding_settings['right'] : '' );
$epofw_global_field_container_padding_bottom = ( isset( $epofw_global_padding_settings['bottom'] ) ? $epofw_global_padding_settings['bottom'] : '' );
$epofw_global_field_container_padding_left = ( isset( $epofw_global_padding_settings['left'] ) ? $epofw_global_padding_settings['left'] : '' );
$epofw_global_field_container_padding_units = ( isset( $epofw_global_padding_settings['units'] ) ? $epofw_global_padding_settings['units'] : 'px' );
$epofw_global_field_container_margin_top = ( isset( $epofw_global_margin_settings['top'] ) ? $epofw_global_margin_settings['top'] : '' );
$epofw_global_field_container_margin_right = ( isset( $epofw_global_margin_settings['right'] ) ? $epofw_global_margin_settings['right'] : '' );
$epofw_global_field_container_margin_bottom = ( isset( $epofw_global_margin_settings['bottom'] ) ? $epofw_global_margin_settings['bottom'] : '' );
$epofw_global_field_container_margin_left = ( isset( $epofw_global_margin_settings['left'] ) ? $epofw_global_margin_settings['left'] : '' );
$epofw_global_field_container_margin_units = ( isset( $epofw_global_margin_settings['units'] ) ? $epofw_global_margin_settings['units'] : 'px' );
$epofw_global_field_container_border_color = ( isset( $epofw_global_field_container['border_color'] ) ? $epofw_global_field_container['border_color'] : '' );
$epofw_global_field_container_border_width = ( isset( $epofw_global_field_container['border_width'] ) ? $epofw_global_field_container['border_width'] : '' );
$epofw_global_field_container_border_style = ( isset( $epofw_global_field_container['border_style'] ) ? $epofw_global_field_container['border_style'] : '' );
$epofw_global_field_container_border_radius = ( isset( $epofw_global_field_container['border_radius'] ) ? $epofw_global_field_container['border_radius'] : '' );
$epofw_global_field_container_width = ( isset( $epofw_global_field_container['width'] ) ? $epofw_global_field_container['width'] : '' );
$epofw_global_field_container_max_width = ( isset( $epofw_global_field_container['max_width'] ) ? $epofw_global_field_container['max_width'] : '' );
$epofw_global_field_container_min_width = ( isset( $epofw_global_field_container['min_width'] ) ? $epofw_global_field_container['min_width'] : '' );
$epofw_global_field_container_gap = ( isset( $epofw_global_field_container['gap'] ) ? $epofw_global_field_container['gap'] : '' );
$epofw_global_field_container_box_shadow = ( isset( $epofw_global_field_container['box_shadow'] ) ? $epofw_global_field_container['box_shadow'] : '' );
?>
	<div class="epofw_main_form_section epofw-general-settings-container">
		<div class="epofw_main_left_section epofw-configuration-box">
			<div class="epofw-box-header epofw-accordion-header">
				<div class="epofw-box-header-title">
					<h3><?php 
echo esc_html__( 'Label Global Settings', 'extra-product-options-for-woocommerce' );
?></h3>
					<p class="epofw-box-description"><?php 
echo esc_html__( 'Set global defaults for field labels that apply to all addon fields. These settings serve as defaults and can be overridden at the individual field level in the addon builder.', 'extra-product-options-for-woocommerce' );
?></p>
				</div>
				<button type="button" class="button-link epofw-accordion-toggle" aria-expanded="true" aria-controls="epofw-global-label-settings-content" data-epofw-default-open="true" data-epofw-expand-text="<?php 
echo esc_attr__( 'Expand', 'extra-product-options-for-woocommerce' );
?>" data-epofw-collapse-text="<?php 
echo esc_attr__( 'Collapse', 'extra-product-options-for-woocommerce' );
?>">
					<span class="dashicons dashicons-arrow-down-alt" aria-hidden="true"></span>
				</button>
			</div>
			<div class="epofw_section epofw_field_info epofw-box-content" id="epofw-global-label-settings-content">
				<?php 
/**
 * Fire action before global label settings.
 *
 * @since 4.4.5
 */
do_action( 'epofw_before_global_label_settings' );
?>
				<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
					<div class="epofw-setting-label">
						<label for="epofw_global_default_title_position"><?php 
echo esc_html__( 'Default Title Position', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Set the default label/title position for all fields. This will be used as the default when adding new fields. Individual fields can override this setting.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<select 
						<?php 
?>
						id="epofw_global_default_title_position" class="epofw-form-control">
							<option value=""><?php 
echo esc_html__( '-- No Default (Use Field Setting) --', 'extra-product-options-for-woocommerce' );
?></option>
							<?php 
foreach ( $epofw_title_position_options as $epofw_key => $epofw_value ) {
    $epofw_selected = selected( $epofw_global_default_title_position, $epofw_key, false );
    echo '<option value="' . esc_attr( $epofw_key ) . '"' . esc_attr( $epofw_selected ) . '>' . esc_html( $epofw_value ) . '</option>';
}
?>
						</select>
						<p class="epofw-field-hint">
							<strong><?php 
echo esc_html__( 'Auto (Smart Detection):', 'extra-product-options-for-woocommerce' );
?></strong> <?php 
echo esc_html__( 'Automatically selects the best label display based on field type. Text fields use placeholder mode, selection fields show compact label above, image/color switchers show caption below, and switches/sliders use inline labels.', 'extra-product-options-for-woocommerce' );
?>
						</p>
					</div>
				</div>
				<div class="epofw-setting-field">
					<div class="epofw-setting-label">
						<label for="epofw_global_label_title_type"><?php 
echo esc_html__( 'Default Title Type', 'extra-product-options-for-woocommerce' );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Set the default HTML tag for label titles (e.g., label, span, h3). This applies to all fields where "Use Global" is selected. Individual fields can override this by selecting a specific value.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<select name="epofw_global_data[label][title_type]" id="epofw_global_label_title_type" class="epofw-form-control">
							<option value=""><?php 
echo esc_html__( '-- No Default (Use Field Setting) --', 'extra-product-options-for-woocommerce' );
?></option>
							<?php 
$epofw_heading_type_options = epofw_field_heading_type_options_data();
foreach ( $epofw_heading_type_options as $epofw_key => $epofw_value ) {
    ?>
								<option value="<?php 
    echo esc_attr( $epofw_key );
    ?>" <?php 
    selected( $epofw_global_label_title_type, $epofw_key );
    ?>><?php 
    echo esc_html( $epofw_value );
    ?></option>
								<?php 
}
?>
						</select>
						<p class="epofw-field-hint"><?php 
echo esc_html__( 'Select a value to apply globally. Fields with "Use Global" will inherit this setting.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
				</div>
				<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
					<div class="epofw-setting-label">
						<label for="epofw_global_label_title_color"><?php 
echo esc_html__( 'Default Title Color', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Set the default color for label titles. Fields with empty color will inherit this global color. Set a color on individual fields to override.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<input type="text" class="epofw_colorpicker" 
						<?php 
?>
						id="epofw_global_label_title_color" value="<?php 
echo esc_attr( $epofw_global_label_title_color );
?>"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
					</div>
				</div>
				<div class="epofw-setting-field">
					<div class="epofw-setting-label">
						<label for="epofw_global_label_class"><?php 
echo esc_html__( 'Default Label Class', 'extra-product-options-for-woocommerce' );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Set default CSS classes for label titles. Fields with empty class will inherit this global class. Set a class on individual fields to override.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<input type="text" class="epofw-form-control" name="epofw_global_data[label][class]" id="epofw_global_label_class" value="<?php 
echo esc_attr( $epofw_global_label_class );
?>">
					</div>
				</div>
				<div class="epofw-setting-field">
					<div class="epofw-setting-label">
						<label for="epofw_global_label_subtitle_class"><?php 
echo esc_html__( 'Default Subtitle Class', 'extra-product-options-for-woocommerce' );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Set default CSS classes for label subtitles. Fields with empty class will inherit this global class. Set a class on individual fields to override.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<input type="text" class="epofw-form-control" name="epofw_global_data[label][subtitle_class]" id="epofw_global_label_subtitle_class" value="<?php 
echo esc_attr( $epofw_global_label_subtitle_class );
?>">
					</div>
				</div>
				<div class="epofw-setting-field">
					<div class="epofw-setting-label">
						<label for="epofw_global_label_subtitle_type"><?php 
echo esc_html__( 'Default Subtitle Type', 'extra-product-options-for-woocommerce' );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Set the default HTML tag for label subtitles. This applies to all fields where "Use Global" is selected. Individual fields can override this by selecting a specific value.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<select name="epofw_global_data[label][subtitle_type]" id="epofw_global_label_subtitle_type" class="epofw-form-control">
							<option value=""><?php 
echo esc_html__( '-- No Default (Use Field Setting) --', 'extra-product-options-for-woocommerce' );
?></option>
							<?php 
foreach ( $epofw_heading_type_options as $epofw_key => $epofw_value ) {
    ?>
								<option value="<?php 
    echo esc_attr( $epofw_key );
    ?>" <?php 
    selected( $epofw_global_label_subtitle_type, $epofw_key );
    ?>><?php 
    echo esc_html( $epofw_value );
    ?></option>
								<?php 
}
?>
						</select>
						<p class="epofw-field-hint"><?php 
echo esc_html__( 'Select a value to apply globally. Fields with "Use Global" will inherit this setting.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
				</div>
				<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
					<div class="epofw-setting-label">
						<label for="epofw_global_label_subtitle_color"><?php 
echo esc_html__( 'Default Subtitle Color', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Set the default color for label subtitles. Fields with empty color will inherit this global color. Set a color on individual fields to override.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<input type="text" class="epofw_colorpicker"
						<?php 
?>
						id="epofw_global_label_subtitle_color" value="<?php 
echo esc_attr( $epofw_global_label_subtitle_color );
?>"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
					</div>
				</div>
				<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
					<div class="epofw-setting-label">
						<label for="epofw_global_label_styling_enabled"><?php 
echo esc_html__( 'Enable Label Styling', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Enable global typography settings for labels. These settings apply to all fields where "Use Global" is selected. Individual fields can override by selecting specific values.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<input type="hidden"
						<?php 
?>
						value="">
						<input type="checkbox"
						<?php 
?>
						id="epofw_global_label_styling_enabled" value="on" <?php 
checked( $epofw_global_label_styling_enabled, 'on' );
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
						<label for="epofw_global_label_styling_enabled" class="toggle-switch"></label>
					</div>
				</div>
				<div id="epofw-global-label-styling-fields" class="epofw-dependent-fields" style="<?php 
echo esc_attr( $epofw_label_styling_fields_style );
?>">
				<div class="epofw-setting-field epofw-setting-typography-group<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
					<div class="epofw-setting-label">
						<label><?php 
echo esc_html__( 'Typography', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Configure typography settings for the label text.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<div class="epofw-typography-inputs">
							<div class="epofw-typography-input">
								<label for="epofw_global_label_font_size"><?php 
esc_html_e( 'Font Size (px)', 'extra-product-options-for-woocommerce' );
?></label>
								<input type="number"
								<?php 
?>
								id="epofw_global_label_font_size" value="<?php 
echo esc_attr( $epofw_global_label_font_size );
?>" placeholder="14" min="0" step="1"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
							</div>
							<div class="epofw-typography-input">
								<label for="epofw_global_label_font_weight"><?php 
esc_html_e( 'Font Weight', 'extra-product-options-for-woocommerce' );
?></label>
								<select
								<?php 
?>
								id="epofw_global_label_font_weight" class="epofw-form-control"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
									<?php 
foreach ( epofw_label_styling_font_weight_data() as $epofw_fw_val => $epofw_fw_label ) {
    echo '<option value="' . esc_attr( $epofw_fw_val ) . '" ' . selected( $epofw_global_label_font_weight, $epofw_fw_val, false ) . '>' . esc_html( $epofw_fw_label ) . '</option>';
}
?>
								</select>
							</div>
							<div class="epofw-typography-input">
								<label for="epofw_global_label_font_family"><?php 
esc_html_e( 'Font Family', 'extra-product-options-for-woocommerce' );
?></label>
								<input type="text" class="epofw-form-control"
								<?php 
?>
								id="epofw_global_label_font_family" value="<?php 
echo esc_attr( $epofw_global_label_font_family );
?>" placeholder="Arial, sans-serif"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
							</div>
							<div class="epofw-typography-input">
								<label for="epofw_global_label_text_align"><?php 
esc_html_e( 'Text Align', 'extra-product-options-for-woocommerce' );
?></label>
								<select
								<?php 
?>
								id="epofw_global_label_text_align" class="epofw-form-control"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
									<?php 
foreach ( epofw_label_styling_text_align_data() as $epofw_ta_val => $epofw_ta_label ) {
    echo '<option value="' . esc_attr( $epofw_ta_val ) . '" ' . selected( $epofw_global_label_text_align, $epofw_ta_val, false ) . '>' . esc_html( $epofw_ta_label ) . '</option>';
}
?>
								</select>
							</div>
						</div>
						<div class="epofw-typography-inputs">
							<div class="epofw-typography-input">
								<label for="epofw_global_label_text_transform"><?php 
esc_html_e( 'Text Transform', 'extra-product-options-for-woocommerce' );
?></label>
								<select
								<?php 
?>
								id="epofw_global_label_text_transform" class="epofw-form-control"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
									<?php 
foreach ( epofw_label_styling_text_transform_data() as $epofw_tt_val => $epofw_tt_label ) {
    echo '<option value="' . esc_attr( $epofw_tt_val ) . '" ' . selected( $epofw_global_label_text_transform, $epofw_tt_val, false ) . '>' . esc_html( $epofw_tt_label ) . '</option>';
}
?>
								</select>
							</div>
							<div class="epofw-typography-input">
								<label for="epofw_global_label_letter_spacing"><?php 
esc_html_e( 'Letter Spacing (px)', 'extra-product-options-for-woocommerce' );
?></label>
								<input type="number"
								<?php 
?>
								id="epofw_global_label_letter_spacing" value="<?php 
echo esc_attr( $epofw_global_label_letter_spacing );
?>" placeholder="0" step="0.1" class="epofw-form-control"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
							</div>
							<div class="epofw-typography-input">
								<label for="epofw_global_label_line_height"><?php 
esc_html_e( 'Line Height', 'extra-product-options-for-woocommerce' );
?></label>
								<input type="number"
								<?php 
?>
								id="epofw_global_label_line_height" value="<?php 
echo esc_attr( $epofw_global_label_line_height );
?>" placeholder="1.5" step="0.1" min="0" class="epofw-form-control"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
							</div>
						</div>
					</div>
				</div>
				<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
					<div class="epofw-setting-label">
						<label for="epofw_global_label_text_shadow"><?php 
echo esc_html__( 'Text Shadow', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Enter text shadow CSS value (e.g., "1px 1px 2px rgba(0,0,0,0.5)").', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<input type="text" class="epofw-form-control"
						<?php 
?>
						id="epofw_global_label_text_shadow" value="<?php 
echo esc_attr( $epofw_global_label_text_shadow );
?>" placeholder="1px 1px 2px rgba(0,0,0,0.5)"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
					</div>
				</div>
				<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
					<div class="epofw-setting-label">
						<label for="epofw_global_label_custom_css"><?php 
echo esc_html__( 'Custom CSS', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Add custom CSS styles for labels. These styles will be applied globally.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<textarea
						<?php 
?>
						id="epofw_global_label_custom_css" rows="6" class="epofw-form-control" placeholder="label { /* Your CSS here */ }"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>><?php 
echo esc_textarea( $epofw_global_label_custom_css );
?></textarea>
					</div>
				</div>
				</div>
				<?php 
/**
 * Fire action after global label settings.
 *
 * @since 4.4.5
 */
do_action( 'epofw_after_global_label_settings' );
?>
			</div>
		</div>
		<div class="epofw_main_left_section epofw-configuration-box">
			<div class="epofw-box-header epofw-accordion-header">
				<div class="epofw-box-header-title">
					<h3><?php 
echo esc_html__( 'Field Container Global Settings', 'extra-product-options-for-woocommerce' );
?></h3>
					<p class="epofw-box-description"><?php 
echo esc_html__( 'Set global defaults for field container styling. Individual fields can override these settings in the addon builder.', 'extra-product-options-for-woocommerce' );
?></p>
				</div>
				<button type="button" class="button-link epofw-accordion-toggle" aria-expanded="false" aria-controls="epofw-global-field-container-settings-content" data-epofw-default-open="false" data-epofw-expand-text="<?php 
echo esc_attr__( 'Expand', 'extra-product-options-for-woocommerce' );
?>" data-epofw-collapse-text="<?php 
echo esc_attr__( 'Collapse', 'extra-product-options-for-woocommerce' );
?>">
					<span class="dashicons dashicons-arrow-up-alt" aria-hidden="true"></span>
				</button>
			</div>
			<div class="epofw_section epofw_field_info epofw-box-content" id="epofw-global-field-container-settings-content">
				<div class="epofw-setting-field">
					<div class="epofw-setting-label">
						<label for="epofw_global_field_container_enabled"><?php 
echo esc_html__( 'Enable Field Container Styling', 'extra-product-options-for-woocommerce' );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Enable global field container styling. If disabled, individual field settings still apply.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<input type="hidden" name="epofw_global_data[field_container_settings][enabled]" value="">
						<input type="checkbox" name="epofw_global_data[field_container_settings][enabled]" id="epofw_global_field_container_enabled" value="on" <?php 
checked( $epofw_global_field_container_enabled, 'on' );
?>>
						<label for="epofw_global_field_container_enabled" class="toggle-switch"></label>
					</div>
				</div>
				<div id="epofw-global-field-container-fields" class="epofw-dependent-fields" style="<?php 
echo esc_attr( $epofw_field_container_fields_style );
?>">
				<div class="epofw-setting-field">
					<div class="epofw-setting-label">
						<label for="epofw_global_field_container_background_color"><?php 
echo esc_html__( 'Background Color', 'extra-product-options-for-woocommerce' );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Set the background color for field containers.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<input type="text" class="epofw_colorpicker" name="epofw_global_data[field_container_settings][background_color]" id="epofw_global_field_container_background_color" value="<?php 
echo esc_attr( $epofw_global_field_container_background );
?>">
					</div>
				</div>
				<?php 
if ( !$epofw_is_premium_user ) {
    ?>
					<div class="epofw-setting-field">
						<div class="epofw-setting-label">
							<label for="epofw_global_field_container_padding"><?php 
    echo esc_html__( 'Padding (px)', 'extra-product-options-for-woocommerce' );
    ?></label>
							<p class="epofw-field-description"><?php 
    echo esc_html__( 'Set the inner spacing of field containers.', 'extra-product-options-for-woocommerce' );
    ?></p>
						</div>
						<div class="epofw-setting-input epofw-spacing-input">
							<input type="number" name="epofw_global_data[field_container_settings][padding]" id="epofw_global_field_container_padding" value="<?php 
    echo esc_attr( $epofw_global_field_container_padding );
    ?>" min="0" step="1">
						</div>
					</div>
					<div class="epofw-setting-field">
						<div class="epofw-setting-label">
							<label for="epofw_global_field_container_margin"><?php 
    echo esc_html__( 'Margin (px)', 'extra-product-options-for-woocommerce' );
    ?></label>
							<p class="epofw-field-description"><?php 
    echo esc_html__( 'Set the outer spacing of field containers.', 'extra-product-options-for-woocommerce' );
    ?></p>
						</div>
						<div class="epofw-setting-input epofw-spacing-input">
							<input type="number" name="epofw_global_data[field_container_settings][margin]" id="epofw_global_field_container_margin" value="<?php 
    echo esc_attr( $epofw_global_field_container_margin );
    ?>" min="0" step="1">
						</div>
					</div>
				<?php 
}
?>
				<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
					<div class="epofw-setting-label">
						<label><?php 
echo esc_html__( 'Border', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Configure border styling for field containers.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<div class="epofw-border-inputs">
							<div class="epofw-spacing-input">
								<label for="epofw_global_field_container_border_color"><?php 
esc_html_e( 'Color', 'extra-product-options-for-woocommerce' );
?></label>
								<input type="text" class="epofw_colorpicker"
								<?php 
?>
								id="epofw_global_field_container_border_color" value="<?php 
echo esc_attr( $epofw_global_field_container_border_color );
?>"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
							</div>
							<div class="epofw-spacing-input">
								<label for="epofw_global_field_container_border_width"><?php 
esc_html_e( 'Width (px)', 'extra-product-options-for-woocommerce' );
?></label>
								<input type="number"
								<?php 
?>
								id="epofw_global_field_container_border_width" value="<?php 
echo esc_attr( $epofw_global_field_container_border_width );
?>" min="0" step="1"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
							</div>
							<div class="epofw-spacing-input epofw-border-style-input">
								<label for="epofw_global_field_container_border_style"><?php 
esc_html_e( 'Style', 'extra-product-options-for-woocommerce' );
?></label>
								<select
								<?php 
?>
								id="epofw_global_field_container_border_style" class="epofw-form-control"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
									<?php 
foreach ( epofw_field_container_border_style_data() as $epofw_border_val => $epofw_border_label ) {
    echo '<option value="' . esc_attr( $epofw_border_val ) . '" ' . selected( $epofw_global_field_container_border_style, $epofw_border_val, false ) . '>' . esc_html( $epofw_border_label ) . '</option>';
}
?>
								</select>
							</div>
							<div class="epofw-spacing-input">
								<label for="epofw_global_field_container_border_radius"><?php 
esc_html_e( 'Radius (px)', 'extra-product-options-for-woocommerce' );
?></label>
								<input type="number"
								<?php 
?>
								id="epofw_global_field_container_border_radius" value="<?php 
echo esc_attr( $epofw_global_field_container_border_radius );
?>" min="0" step="1"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
							</div>
						</div>
					</div>
				</div>
					<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
						<div class="epofw-setting-label">
							<label><?php 
echo esc_html__( 'Padding (Advanced)', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
							<p class="epofw-field-description"><?php 
echo esc_html__( 'Set individual padding values for each side.', 'extra-product-options-for-woocommerce' );
?></p>
						</div>
						<div class="epofw-setting-input">
							<div class="epofw-spacing-inputs">
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_padding_top"><?php 
esc_html_e( 'Top', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_padding_top" value="<?php 
echo esc_attr( $epofw_global_field_container_padding_top );
?>" placeholder="0"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_padding_right"><?php 
esc_html_e( 'Right', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_padding_right" value="<?php 
echo esc_attr( $epofw_global_field_container_padding_right );
?>" placeholder="0"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_padding_bottom"><?php 
esc_html_e( 'Bottom', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_padding_bottom" value="<?php 
echo esc_attr( $epofw_global_field_container_padding_bottom );
?>" placeholder="0"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_padding_left"><?php 
esc_html_e( 'Left', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_padding_left" value="<?php 
echo esc_attr( $epofw_global_field_container_padding_left );
?>" placeholder="0"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input epofw-units-input">
									<label for="epofw_global_field_container_padding_units"><?php 
esc_html_e( 'Units', 'extra-product-options-for-woocommerce' );
?></label>
									<select
									<?php 
?>
									id="epofw_global_field_container_padding_units" class="epofw-form-control"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
										<?php 
foreach ( epofw_field_container_spacing_units_data() as $epofw_units_val => $epofw_units_label ) {
    echo '<option value="' . esc_attr( $epofw_units_val ) . '" ' . selected( $epofw_global_field_container_padding_units, $epofw_units_val, false ) . '>' . esc_html( $epofw_units_label ) . '</option>';
}
?>
									</select>
								</div>
							</div>
						</div>
					</div>
					<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
						<div class="epofw-setting-label">
							<label><?php 
echo esc_html__( 'Margin (Advanced)', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
							<p class="epofw-field-description"><?php 
echo esc_html__( 'Set individual margin values for each side.', 'extra-product-options-for-woocommerce' );
?></p>
						</div>
						<div class="epofw-setting-input">
							<div class="epofw-spacing-inputs">
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_margin_top"><?php 
esc_html_e( 'Top', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_margin_top" value="<?php 
echo esc_attr( $epofw_global_field_container_margin_top );
?>" placeholder="0"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_margin_right"><?php 
esc_html_e( 'Right', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_margin_right" value="<?php 
echo esc_attr( $epofw_global_field_container_margin_right );
?>" placeholder="0"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_margin_bottom"><?php 
esc_html_e( 'Bottom', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_margin_bottom" value="<?php 
echo esc_attr( $epofw_global_field_container_margin_bottom );
?>" placeholder="0"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_margin_left"><?php 
esc_html_e( 'Left', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_margin_left" value="<?php 
echo esc_attr( $epofw_global_field_container_margin_left );
?>" placeholder="0"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input epofw-units-input">
									<label for="epofw_global_field_container_margin_units"><?php 
esc_html_e( 'Units', 'extra-product-options-for-woocommerce' );
?></label>
									<select
									<?php 
?>
									id="epofw_global_field_container_margin_units" class="epofw-form-control"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
										<?php 
foreach ( epofw_field_container_spacing_units_data() as $epofw_units_val => $epofw_units_label ) {
    echo '<option value="' . esc_attr( $epofw_units_val ) . '" ' . selected( $epofw_global_field_container_margin_units, $epofw_units_val, false ) . '>' . esc_html( $epofw_units_label ) . '</option>';
}
?>
									</select>
								</div>
							</div>
						</div>
					</div>
					<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
						<div class="epofw-setting-label">
							<label><?php 
echo esc_html__( 'Dimensions', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
							<p class="epofw-field-description"><?php 
echo esc_html__( 'Configure width and spacing for field containers.', 'extra-product-options-for-woocommerce' );
?></p>
						</div>
						<div class="epofw-setting-input">
							<div class="epofw-spacing-inputs">
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_width"><?php 
esc_html_e( 'Width (%)', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_width" value="<?php 
echo esc_attr( $epofw_global_field_container_width );
?>" min="0" step="1"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_max_width"><?php 
esc_html_e( 'Max Width (%)', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_max_width" value="<?php 
echo esc_attr( $epofw_global_field_container_max_width );
?>" min="0" step="1"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_min_width"><?php 
esc_html_e( 'Min Width (px)', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_min_width" value="<?php 
echo esc_attr( $epofw_global_field_container_min_width );
?>" min="0" step="1"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
								<div class="epofw-spacing-input">
									<label for="epofw_global_field_container_gap"><?php 
esc_html_e( 'Gap (px)', 'extra-product-options-for-woocommerce' );
?></label>
									<input type="number"
									<?php 
?>
									id="epofw_global_field_container_gap" value="<?php 
echo esc_attr( $epofw_global_field_container_gap );
?>" min="0" step="1"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
								</div>
							</div>
						</div>
					</div>
					<div class="epofw-setting-field<?php 
echo esc_attr( $epofw_prem_data['class'] );
?>">
						<div class="epofw-setting-label">
							<label for="epofw_global_field_container_box_shadow"><?php 
echo esc_html__( 'Box Shadow', 'extra-product-options-for-woocommerce' );
echo wp_kses( $epofw_prem_data['badge'], $epofw_prem_data['badge_allowed_html'] );
?></label>
							<p class="epofw-field-description"><?php 
echo esc_html__( 'Enter box shadow CSS value (e.g., "0 2px 4px rgba(0,0,0,0.1)").', 'extra-product-options-for-woocommerce' );
?></p>
						</div>
						<div class="epofw-setting-input">
							<input type="text" class="epofw-form-control"
							<?php 
?>
							id="epofw_global_field_container_box_shadow" value="<?php 
echo esc_attr( $epofw_global_field_container_box_shadow );
?>" placeholder="0 2px 4px rgba(0,0,0,0.1)"<?php 
echo esc_attr( $epofw_prem_data['disabled'] );
?>>
						</div>
					</div>
				<div class="epofw-setting-field">
					<div class="epofw-setting-label">
						<label for="epofw_global_field_container_custom_css"><?php 
echo esc_html__( 'Custom CSS', 'extra-product-options-for-woocommerce' );
?></label>
						<p class="epofw-field-description"><?php 
echo esc_html__( 'Add custom CSS styles for field containers.', 'extra-product-options-for-woocommerce' );
?></p>
					</div>
					<div class="epofw-setting-input">
						<textarea name="epofw_global_data[field_container_settings][custom_css]" id="epofw_global_field_container_custom_css" rows="6" class="epofw-form-control" placeholder=".epofw-field-container { /* Your CSS here */ }"><?php 
echo esc_textarea( $epofw_global_field_container_custom_css );
?></textarea>
					</div>
				</div>
				</div>
			</div>
		</div>

		<?php 
/**
 * Fire action for additional global settings sections (separate boxes).
 *
 * Use this hook to add new settings sections as separate configuration boxes.
 *
 * @since 4.4.5
 */
do_action( 'epofw_global_settings_sections' );
?>
	</div>
	<p class="submit">
			<input type="submit"
			class="button button-primary"
			name="epofw_global_submit"
			value="<?php 
esc_attr_e( 'Save Changes', 'extra-product-options-for-woocommerce' );
?>">
		</p>
<?php 
wp_nonce_field( 'epofw_global_save_action', 'epofw_global_save_nonce' );