<?php
/**
 * MenuBar.
 *
 * @package pawfect
 */

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

if ( ! class_exists( 'pawfect_Customize_Menu_Bar_Option' ) ) :

	/**
	 * Menu option.
	 */
	class pawfect_Customize_Menu_Bar_Option extends pawfect_Customize_Base_Option {

		public function elements() {

			return array(
			
			    'pawfect_main_menu_heading'     => array(
					'setting' => array(),
					'control' => array(
						'type'    => 'heading',
				   		'priority'        => 1,
						'label'   => esc_html__( 'Menu Settings', 'pawfect' ),
						'section' => 'pawfect_theme_menu_bar',
					),
				),
				
				/* 'pawfect_menu_overlap'            => array(
					'setting' => array(
						'default'           => true,
						'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
					),
					'control' => array(
						'type'     => 'toggle',
						'priority' => 3,
						'label'    => esc_html__( 'Menu Overlap', 'pawfect' ),
						'description'    => esc_html__( 'Note: This Setting Will Work With Page Header. Enable Page Header for Overlaping Menu. Go To Theme Options > Page Header then Enable Page Header Setting.', 'pawfect' ),
						'section'  => 'pawfect_theme_menu_bar',
					),
				), */

				'pawfect_menu_style'     => array('setting' => array(
					'default'           => 'static',
					'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
					'transport'         => 'refresh',
					),
					'control' => array(
						'type'            => 'radio-switch',
						'priority'        => 5,
						'is_default_type' => true,
						'label'           => esc_html__( 'Menu Style', 'pawfect' ),
						'section'         => 'pawfect_theme_menu_bar',
						'choices'         => array(
							'sticky'  => esc_html__( 'Sticky', 'pawfect' ),
							'static' => esc_html__( 'Static', 'pawfect' ),
						),
					),
				),

				/**
				 * Sticky Bar Logo
				 * This logo appears only when the sticky menu style is selected.
				 */
				'pawfect_sticky_bar_logo' => array(
					'setting' => array(
						'default' => '',
						'sanitize_callback' => 'esc_url_raw',
						'transport' => 'postMessage',
					),
					'control' => array(
						'type'        => 'image',
						'priority'    => 6,
						'section'     => 'pawfect_theme_menu_bar',
						'label'       => esc_html__( 'Set Sticky Menu Logo', 'pawfect' ),
						'description' => esc_html__( 'You can Upload the Standard size of logo (220x40px)', 'pawfect' ),
						'active_callback' => 'pawfect_is_sticky_menu_active',
					),
				),

				/**
				 * Sticky Menu Logo Width - Responsive
				 */
				'pawfect_sticky_logo_width' => array(
					'setting' => array(
						'default' => json_encode(array(
							'desktop' => 220,
							'tablet' => 180,
							'mobile' => 150,
						)),
						'sanitize_callback' => array('Pawfect_Responsive_Range_Control', 'sanitize_responsive_range'),
						'transport' => 'postMessage',
					),
					'control' => array(
						'type' => 'pawfect-responsive-range',
						'priority' => 7,
						'section' => 'pawfect_theme_menu_bar',
						'label' => esc_html__('Sticky Menu Logo Width', 'pawfect'),
						'description' => esc_html__('Set the width of the logo when sticky menu is active.', 'pawfect'),
						'media_query' => true,
						'suffix' => 'px',
						'input_attrs' => array(
							'min' => 50,
							'max' => 500,
							'step' => 1,
						),
						'active_callback' => 'pawfect_is_sticky_menu_active',
					),
				),
				/**
				 * Language Switcher Settings
				 */
				'pawfect_header_language_enabled' => array(
					'setting' => array(
						'default'           => true,
						'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
					),
					'control' => array(
						'type'     => 'toggle',
						'priority' => 7,
						'label'    => esc_html__( 'Language Switcher Enable/Disable', 'pawfect' ),
						'section'  => 'pawfect_theme_menu_bar',
					),
				),

				'pawfect_header_language_shortcode' => array(
					'setting' => array(
						'default' => '[gtranslate]',
						'sanitize_callback' => 'wp_kses_post',
						'transport' => 'refresh',
					),
					'control' => array(
						'type' => 'text',
						'priority' => 8,
						'section' => 'pawfect_theme_menu_bar',
						'label' => esc_html__('Language Switcher Shortcode', 'pawfect'),
						'description' => esc_html__('Enter the shortcode provided by your translation plugin (e.g., [gtranslate], [polylang], etc.)', 'pawfect'),
						'active_callback' => 'pawfect_is_language_switcher_active',
					),
				),
					
				'pawfect_menu_container_size'     => array(
					'setting' => array(
						'default'           => 'container',
						'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
						'transport'         => 'refresh',
					),
					'control' => array(
						'type'            => 'radio-switch',
						'priority'        => 8,
						'is_default_type' => true,
						'label'           => esc_html__( 'Menu Width', 'pawfect' ),
						'section'         => 'pawfect_theme_menu_bar',
						'choices'         => array(
							'container'  => esc_html__( 'Container', 'pawfect' ),
							'container-fluid' => esc_html__( 'Container Full', 'pawfect' ),
							'full-width' => esc_html__( 'Full Width', 'pawfect' ),
						),
					),
			    ),
			);

		}

	}

	// Remove automatic instantiation - let main customizer class handle this
	// new pawfect_Customize_Menu_Bar_Option();

endif;

/**
 * Check if sticky menu is active
 */
if (!function_exists('pawfect_is_sticky_menu_active')) {
	function pawfect_is_sticky_menu_active($control) {
		return get_theme_mod('pawfect_menu_style', 'static') === 'sticky';
	}
}

/**
 * Check if language switcher is active
 */
if (!function_exists('pawfect_is_language_switcher_active')) {
	function pawfect_is_language_switcher_active($control) {
		return get_theme_mod('pawfect_header_language_enabled', true);
	}
}