<?php
/**
 * Normal Search Options
 *
 * @package CosmosWP
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

global $cosmoswp_customize_control;

/*Normal Search section*/
$wp_customize->add_section(
	$this->normal_search,
	array(
		'title' => esc_html__( 'Normal Search', 'cosmoswp' ),
		'panel' => $this->panel,
	)
);

/*Search Placeholder*/
$wp_customize->add_setting(
	'normal-search-placeholder',
	array(
		'default'           => $header_defaults['normal-search-placeholder'],
		'sanitize_callback' => 'sanitize_text_field',
		'transport'         => 'postMessage',
	)
);
$cosmoswp_customize_control->add(
	'normal-search-placeholder',
	array(
		'label'    => esc_html__( 'Placeholder', 'cosmoswp' ),
		'section'  => $this->normal_search,
		'settings' => 'normal-search-placeholder',
		'type'     => 'text',
	)
);

/*Margin and Padding msg*/
$wp_customize->add_setting(
	'normal-search-margin-padding-msg',
	array(
		'sanitize_callback' => 'wp_kses_post',
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Heading(
		$wp_customize,
		'normal-search-margin-padding-msg',
		array(
			'label'   => esc_html__( 'Icon ( Margin and Padding )', 'cosmoswp' ),
			'section' => $this->normal_search,
		)
	)
);

/*Margin*/
$wp_customize->add_setting(
	'normal-search-margin',
	array(
		'sanitize_callback' => 'cosmoswp_sanitize_field_default_css_box',
		'default'           => $header_defaults['normal-search-margin'],
		'transport'         => 'postMessage',
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Cssbox(
		$wp_customize,
		'normal-search-margin',
		array(
			'label'    => esc_html__( 'Margin (px)', 'cosmoswp' ),
			'section'  => $this->normal_search,
			'settings' => 'normal-search-margin',
		),
		array(),
		array()
	)
);

/*Padding*/
$wp_customize->add_setting(
	'normal-search-padding',
	array(
		'sanitize_callback' => 'cosmoswp_sanitize_field_default_css_box',
		'default'           => $header_defaults['normal-search-padding'],
		'transport'         => 'postMessage',
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Cssbox(
		$wp_customize,
		'normal-search-padding',
		array(
			'label'    => esc_html__( 'Padding (px)', 'cosmoswp' ),
			'section'  => $this->normal_search,
			'settings' => 'normal-search-padding',
		),
		array(),
		array()
	)
);

/*Normal Search Styling*/
$wp_customize->add_setting(
	'normal-search-icon-styling-msg',
	array(
		'sanitize_callback' => 'wp_kses_post',
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Heading(
		$wp_customize,
		'normal-search-icon-styling-msg',
		array(
			'label'   => esc_html__( 'Search Icon Styling', 'cosmoswp' ),
			'section' => $this->normal_search,
		)
	)
);

/*Search Form height*/
$wp_customize->add_setting(
	'normal-search-icon-size',
	array(
		'default'           => $header_defaults['normal-search-icon-size'],
		'sanitize_callback' => 'cosmoswp_sanitize_number',
		'transport'         => 'postMessage',
	)
);
$cosmoswp_customize_control->add(
	'normal-search-icon-size',
	array(
		'label'       => esc_html__( 'Icon Size (px)', 'cosmoswp' ),
		'section'     => $this->normal_search,
		'settings'    => 'normal-search-icon-size',
		'type'        => 'number',
		'input_attrs' => array(
			'min'  => 0,
			'max'  => 4000,
			'step' => 1,
		),
	)
);

/*Tabs*/
$wp_customize->add_setting(
	'normal-search-icon-styling',
	array(
		'sanitize_callback' => 'cosmoswp_sanitize_field_tabs',
		'default'           => $header_defaults['normal-search-icon-styling'],
		'transport'         => 'postMessage',
	)
);
$border_style_choices = cosmoswp_header_border_style();
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Tabs(
		$wp_customize,
		'normal-search-icon-styling',
		array(
			'label'    => esc_html__( 'Icon Styling', 'cosmoswp' ),
			'section'  => $this->normal_search,
			'settings' => 'normal-search-icon-styling',
		),
		array(
			'tabs'   => array(
				'search-icon-normal' => array(
					'label' => esc_html__( 'Normal', 'cosmoswp' ),
				),
				'search-icon-hover'  => array(
					'label' => esc_html__( 'Hover', 'cosmoswp' ),
				),
			),
			'fields' => array(
				'normal-text-color'       => array(
					'type'  => 'color',
					'label' => esc_html__( 'Text Color', 'cosmoswp' ),
					'tab'   => 'search-icon-normal',
				),
				'normal-bg-color'         => array(
					'type'  => 'color',
					'label' => esc_html__( 'Background Color', 'cosmoswp' ),
					'tab'   => 'search-icon-normal',
				),
				'normal-border-style'     => array(
					'type'    => 'select',
					'label'   => esc_html__( 'Border Style', 'cosmoswp' ),
					'options' => $border_style_choices,
					'tab'     => 'search-icon-normal',
				),
				'normal-border-width'     => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Width (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'search-icon-normal',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'normal-border-color'     => array(
					'type'  => 'color',
					'label' => esc_html__( 'Border Color', 'cosmoswp' ),
					'tab'   => 'search-icon-normal',
				),
				'normal-border-radius'    => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Radius (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'search-icon-normal',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'normal-box-shadow-color' => array(
					'type'  => 'color',
					'label' => esc_html__( 'Box Shadow Color', 'cosmoswp' ),
					'tab'   => 'search-icon-normal',
				),
				'normal-box-shadow-css'   => array(
					'type'       => 'cssbox',
					'label'      => esc_html__( 'Box Shadow', 'cosmoswp' ),
					'tab'        => 'search-icon-normal',
					'class'      => 'cwp-element-show',
					'box_fields' => array(
						'x'      => true,
						'Y'      => true,
						'BLUR'   => true,
						'SPREAD' => true,
					),
					'attr'       => array(
						'min'         => 0,
						'max'         => 1000,
						'step'        => 1,
						'link'        => 1,
						'link_toggle' => false,
						'devices'     => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text'   => esc_html__( 'INSET', 'cosmoswp' ),
					),
				),
				'hover-text-color'        => array(
					'type'  => 'color',
					'label' => esc_html__( ' Text Color', 'cosmoswp' ),
					'tab'   => 'search-icon-hover',
				),
				'hover-bg-color'          => array(
					'type'  => 'color',
					'label' => esc_html__( 'Background Color', 'cosmoswp' ),
					'tab'   => 'search-icon-hover',
				),
				'hover-border-style'      => array(
					'type'    => 'select',
					'label'   => esc_html__( 'Border Style', 'cosmoswp' ),
					'options' => $border_style_choices,
					'tab'     => 'search-icon-hover',
				),
				'hover-border-width'      => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Width (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'search-icon-hover',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'hover-border-color'      => array(
					'type'  => 'color',
					'label' => esc_html__( 'Border Color', 'cosmoswp' ),
					'tab'   => 'search-icon-hover',
				),
				'hover-border-radius'     => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Radius (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'search-icon-hover',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'hover-box-shadow-color'  => array(
					'type'  => 'color',
					'label' => esc_html__( 'Box Shadow Color', 'cosmoswp' ),
					'tab'   => 'search-icon-hover',
				),
				'hover-box-shadow-css'    => array(
					'type'       => 'cssbox',
					'label'      => esc_html__( 'Box Shadow', 'cosmoswp' ),
					'tab'        => 'search-icon-hover',
					'class'      => 'cwp-element-show',
					'box_fields' => array(
						'x'      => true,
						'Y'      => true,
						'BLUR'   => true,
						'SPREAD' => true,
					),
					'attr'       => array(
						'min'         => 0,
						'max'         => 1000,
						'step'        => 1,
						'link'        => 1,
						'link_toggle' => false,
						'devices'     => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text'   => esc_html__( 'INSET', 'cosmoswp' ),
					),
				),
			),
		)
	)
);

/*Normal Styling*/
$wp_customize->add_setting(
	'normal-search-styling-msg',
	array(
		'sanitize_callback' => 'wp_kses_post',
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Heading(
		$wp_customize,
		'normal-search-styling-msg',
		array(
			'label'   => esc_html__( 'Search Form Styling', 'cosmoswp' ),
			'section' => $this->normal_search,
		)
	)
);

/*Search Form height*/
$wp_customize->add_setting(
	'normal-search-input-height',
	array(
		'default'           => $header_defaults['normal-search-input-height'],
		'sanitize_callback' => 'cosmoswp_sanitize_number',
		'transport'         => 'postMessage',
	)
);
$cosmoswp_customize_control->add(
	'normal-search-input-height',
	array(
		'label'       => esc_html__( 'Form Input Height (px)', 'cosmoswp' ),
		'section'     => $this->normal_search,
		'settings'    => 'normal-search-input-height',
		'type'        => 'number',
		'input_attrs' => array(
			'min'  => 0,
			'max'  => 4000,
			'step' => 1,
		),
	)
);

/*Form Styling*/
$wp_customize->add_setting(
	'normal-search-form-styling',
	array(
		'sanitize_callback' => 'cosmoswp_sanitize_field_tabs',
		'default'           => $header_defaults['normal-search-form-styling'],
		'transport'         => 'postMessage',
	)
);
$border_style_choices = cosmoswp_header_border_style();
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Tabs(
		$wp_customize,
		'normal-search-form-styling',
		array(
			'label'    => esc_html__( 'Form Styling', 'cosmoswp' ),
			'section'  => $this->normal_search,
			'settings' => 'normal-search-form-styling',
		),
		array(
			'tabs'   => array(
				'search-icon-normal' => array(
					'label' => esc_html__( 'Normal', 'cosmoswp' ),
				),
				'search-icon-hover'  => array(
					'label' => esc_html__( 'Hover', 'cosmoswp' ),
				),
			),
			'fields' => array(
				'normal-text-color'       => array(
					'type'  => 'color',
					'label' => esc_html__( 'Text Color', 'cosmoswp' ),
					'tab'   => 'search-icon-normal',
				),
				'normal-bg-color'         => array(
					'type'  => 'color',
					'label' => esc_html__( 'Background Color', 'cosmoswp' ),
					'tab'   => 'search-icon-normal',
				),
				'normal-border-style'     => array(
					'type'    => 'select',
					'label'   => esc_html__( 'Border Style', 'cosmoswp' ),
					'options' => $border_style_choices,
					'tab'     => 'search-icon-normal',
				),
				'normal-border-width'     => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Width (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'search-icon-normal',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'normal-border-color'     => array(
					'type'  => 'color',
					'label' => esc_html__( 'Border Color', 'cosmoswp' ),
					'tab'   => 'search-icon-normal',
				),
				'normal-border-radius'    => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Radius (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'search-icon-normal',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'normal-box-shadow-color' => array(
					'type'  => 'color',
					'label' => esc_html__( 'Box Shadow Color', 'cosmoswp' ),
					'tab'   => 'search-icon-normal',
				),
				'normal-box-shadow-css'   => array(
					'type'       => 'cssbox',
					'label'      => esc_html__( 'Box Shadow', 'cosmoswp' ),
					'tab'        => 'search-icon-normal',
					'class'      => 'cwp-element-show',
					'box_fields' => array(
						'x'      => true,
						'Y'      => true,
						'BLUR'   => true,
						'SPREAD' => true,
					),
					'attr'       => array(
						'min'         => 0,
						'max'         => 1000,
						'step'        => 1,
						'link'        => 1,
						'link_toggle' => false,
						'devices'     => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text'   => esc_html__( 'INSET', 'cosmoswp' ),
					),
				),
				'hover-text-color'        => array(
					'type'  => 'color',
					'label' => esc_html__( ' Text Color', 'cosmoswp' ),
					'tab'   => 'search-icon-hover',
				),
				'hover-bg-color'          => array(
					'type'  => 'color',
					'label' => esc_html__( 'Background Color', 'cosmoswp' ),
					'tab'   => 'search-icon-hover',
				),
				'hover-border-style'      => array(
					'type'    => 'select',
					'label'   => esc_html__( 'Border Style', 'cosmoswp' ),
					'options' => $border_style_choices,
					'tab'     => 'search-icon-hover',
				),
				'hover-border-width'      => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Width (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'search-icon-hover',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'hover-border-color'      => array(
					'type'  => 'color',
					'label' => esc_html__( 'Border Color', 'cosmoswp' ),
					'tab'   => 'search-icon-hover',
				),
				'hover-border-radius'     => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Radius (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'search-icon-hover',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'hover-box-shadow-color'  => array(
					'type'  => 'color',
					'label' => esc_html__( 'Box Shadow Color', 'cosmoswp' ),
					'tab'   => 'search-icon-hover',
				),
				'hover-box-shadow-css'    => array(
					'type'       => 'cssbox',
					'label'      => esc_html__( 'Box Shadow', 'cosmoswp' ),
					'tab'        => 'search-icon-hover',
					'class'      => 'cwp-element-show',
					'box_fields' => array(
						'x'      => true,
						'Y'      => true,
						'BLUR'   => true,
						'SPREAD' => true,
					),
					'attr'       => array(
						'min'         => 0,
						'max'         => 1000,
						'step'        => 1,
						'link'        => 1,
						'link_toggle' => false,
						'devices'     => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text'   => esc_html__( 'INSET', 'cosmoswp' ),
					),
				),
			),
		)
	)
);

/*Typography Options*/
$wp_customize->add_setting(
	'normal-search-typography-options',
	array(
		'default'           => $header_defaults['normal-search-typography-options'],
		'sanitize_callback' => 'cosmoswp_sanitize_select',
		'transport'         => 'postMessage',
	)
);
$choices = cosmoswp_inherit_options();
$cosmoswp_customize_control->add(
	'normal-search-typography-options',
	array(
		'label'    => esc_html__( 'Typography Options', 'cosmoswp' ),
		'type'     => 'select',
		'section'  => $this->normal_search,
		'settings' => 'normal-search-typography-options',
		'choices'  => $choices,
	)
);

/*Typography data*/
$wp_customize->add_setting(
	'normal-search-typography',
	array(
		'sanitize_callback' => 'cosmoswp_sanitize_field_typography',
		'default'           => $header_defaults['normal-search-typography'],
		'transport'         => 'postMessage',
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Group(
		$wp_customize,
		'normal-search-typography',
		array(
			'label'           => esc_html__( 'Typography', 'cosmoswp' ),
			'section'         => $this->normal_search,
			'active_callback' => 'cosmoswp_normal_search_typography_if_custom',
			'settings'        => 'normal-search-typography',
		),
		cosmoswp_typography_group_fields()
	)
);
