<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Geroz
 * @since 1.0.0
 */ 
 
class Footer_Style_2 extends Widget_Base {

	/**
	 * Get widget name.
	 * Retrieve button widget name.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'geroz-footer-style-2-widget';
	}

	/**
	 * Get widget title.
	 * Retrieve button widget title.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Footer Style 2', 'geroz-core' );
	}

	/**
	 * Get widget icon.
	 * Retrieve button widget icon.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'eicon-flash';
	}

	/**
	 * Get widget categories.
	 * Retrieve the list of categories the button widget belongs to.
	 * Used to determine where to display the widget in the editor.
	 *
	 * @since  2.0.0
	 * @access public
	 * @return array Widget categories.
	 */
	public function get_categories()
    {
        return ['geroz_widgets'];
    }
	
	/**
	 * Register button widget controls.
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since  1.0.0
	 * @access protected
	 */
	protected function register_controls() {

		// Tab Start - 1

		$this->start_controls_section(
			'footer-content',
			[
				'label' => esc_html__( 'Footer Content', 'geroz-core' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);	

		$this->add_control(
			'logo_image',
			[
				'label' => esc_html__( 'Logo Image', 'geroz-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
			]
		);

		$this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Get in Touch', 'geroz-core' ),
				'label_block' => true,
			]
		);

		$this->add_control(
			'contact_form',
			[
				'label' => esc_html__( 'Contact Form 7 Shortcode', 'geroz-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => '[contact-form-7 id="123" title="Contact form 1"]',
				'description' => esc_html__( 'Enter the Contact Form 7 shortcode here.', 'geroz-core' ),
			]
		);


		$this->add_control(
			'big_image',
			[
				'label' => esc_html__( 'Big Image', 'geroz-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
			]
		);

		$this->add_control(
			'copyright_text',
			[
				'label' => esc_html__( 'Copyright Text', 'geroz-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( '© 2025 Geroz. All rights reserved.', 'geroz-core' ),
				'label_block' => true,
			]
		);


		$this->end_controls_section();

		// Tab Start - 2

		$this->start_controls_section(
			'content_section',
			[
				'label' => __( 'Block', 'geroz-core' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);
		$this->add_control(
		  'repeat', 
			[
				'type' => Controls_Manager::REPEATER,
				'separator' => 'before',
				'default' => 
					[
						['section_title' => esc_html__('Hello World', 'geroz-core')],
					],
				'fields' => 
					[	
						'section_phone_text' =>
						[
							'name' => 'section_phone_text',
							'label' => esc_html__('Phone Text', 'geroz-core'),
							'type' => Controls_Manager::TEXT,
							'default' => esc_html__('Call Us', 'geroz-core'),
							'label_block' => true,
						],

						'section_phone' =>
						[
							'name' => 'section_phone',
							'label' => esc_html__('Phone Number', 'geroz-core'),
							'type' => Controls_Manager::TEXT,
							'default' => esc_html__('+123 456 7890', 'geroz-core'),
							'label_block' => true,
						],

						'section_phone_link' =>
						[
							'name' => 'section_phone_link',
							'label' => esc_html__('Phone Link', 'geroz-core'),
							'type' => Controls_Manager::URL,
							'default' => 
								[
									'url' => '#',
									'is_external' => '',
									'nofollow' => '',
								],
						],
					],
				'title_field' => '{{section_phone}}',
			 ]
		);

		$this->add_control(
		  'repeat_1', 
			[
				'type' => Controls_Manager::REPEATER,
				'separator' => 'before',
				'default' => 
					[
						['section_icons_socials' => esc_html__('Facebook', 'geroz-core')],
					],
				'fields' => 
					[

						'section_icons' =>
						[
							'name' => 'section_icons',
							'label' => esc_html__('Social Icon', 'geroz-core'),
							'type' => Controls_Manager::ICONS,
							'default' => 
								[
									'value' => 'fab fa-facebook-f',
									'library' => 'fa-brands',
								],
						],

						'section_icons_link' =>
						[
							'name' => 'section_icons_link',
							'label' => esc_html__('Social Link', 'geroz-core'),
							'type' => Controls_Manager::URL,
							'default' => 
								[
									'url' => '#',
									'is_external' => '',
									'nofollow' => '',
								],
						],
						
					],
				'title_field' => '{{section_icons.value}}',
			 ]
		);
		

			$this->add_control(
			'repeat_2', 
				[
					'type' => Controls_Manager::REPEATER,
					'separator' => 'before',
					'default' => 
						[
							['section_menu' => esc_html__('Facebook', 'geroz-core')],
						],
					'fields' => 
						[

							'section_menu' =>
							[
								'name' => 'section_menu',
								'label' => esc_html__('Menu Text', 'geroz-core'),
								'type' => Controls_Manager::TEXT,
								'default' => esc_html__('About Us', 'geroz-core'),
								'label_block' => true,
							],

							'section_menu_link' =>
							[
								'name' => 'section_menu_link',
								'label' => esc_html__('Menu Link', 'geroz-core'),
								'type' => Controls_Manager::URL,
								'default' => 
									[
										'url' => '#',
										'is_external' => '',
										'nofollow' => '',
									],
							],
							
						],
					'title_field' => '{{section_menu}}',
				]
			);

			$this->add_control(
			'repeat_3', 
				[
					'type' => Controls_Manager::REPEATER,
					'separator' => 'before',
					'default' => 
						[
							['section_slide_text' => esc_html__('Facebook', 'geroz-core')],
						],
					'fields' => 
						[

							'section_slide_text' =>
							[
								'name' => 'section_slide_text',
								'label' => esc_html__('Slide Text', 'geroz-core'),
								'type' => Controls_Manager::TEXTAREA,
								'default' => esc_html__('Your slide text here', 'geroz-core'),
								'label_block' => true,
							],
							
						],
					'title_field' => '{{section_slide_text}}',
				]
			);
		
		$this->end_controls_section();	

	
		}

	/**
	 * Render button widget output on the frontend.
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since  1.0.0
	 * @access protected
	 */
	protected function render() {
		$settings = $this->get_settings_for_display();
		$allowed_tags = wp_kses_allowed_html('post');
		?>


     <footer class="footer-wrapper footer-2 section-padding pb-0 ">
		<div class="container">
			<div class="footer-widgets-inner">
				<div class="footer-logo">
				<?php  if ( !empty(esc_url($settings['logo_image']['id']) )) : ?>   
					<img src="<?php echo wp_get_attachment_url($settings['logo_image']['id']);?>" alt=""/>
				<?php endif;?>
				</div>
				<div class="row g-4">
					<div class="col-xl-4 col-lg-4 col-md-6 wow fadeInUp" data-wow-delay="200ms">
						<div class="signle-footer-widgets mt-4 pt-3">
							<h3><?php echo $settings['title'];?></h3>
							<div class="infu-area d-flex">
								<?php foreach($settings['repeat'] as $item):?>	
								<div class="infu">
									<p><?php echo wp_kses($item['section_phone_text'], $allowed_tags);?></p>
									<h5><a href="<?php echo esc_url($item['section_phone_link']['url']);?>"><?php echo wp_kses($item['section_phone'], $allowed_tags);?></a></h5>
								</div>
								<?php endforeach; ?>
							</div>
						</div>
					</div>
					<div class="col-xl-5 col-lg-4 col-md-6 wow fadeInUp" data-wow-delay="400ms">
						<div class="signle-footer-widgets newsletter mt-4 pt-3 ">
							<h3>Stay in Touch</h3>
							
									<?php echo do_shortcode( $settings['contact_form'] );?>

							<p class="pt-3"><i class="fal fa-check pe-2"></i>Get updated information and daily news & tips</p>
							<div class="social-icon mt-4 pt-2">
								<?php foreach($settings['repeat_1'] as $item):?>	
								<a href="<?php echo esc_url($item['section_icons_link']['url']);?>"><i class="<?php echo str_replace("icon ", " ", esc_attr( $item['section_icons']['value']));?>"></i></a>
								<?php endforeach; ?>
							</div>
						</div>
					</div>
					<div class="col-xl-3 col-lg-4 col-md-6">
						<div class="image tp_img_reveal">
						<?php  if ( !empty(esc_url($settings['big_image']['id']) )) : ?>   
							<img src="<?php echo wp_get_attachment_url($settings['big_image']['id']);?>" alt=""/>
						<?php endif;?>
						</div>
					</div>
				</div>
				<div class="row mt-5 pt-4 g-4">
					<?php foreach($settings['repeat_2'] as $item):?>	
					<div class="col-xl-4 col-lg-4 col-md-4 wow fadeInUp" data-wow-delay="600ms">
						<div class="signle-footer-widgets me-lg-4 pe-lg-3">
							<div class="list-area">
								<div class="link"> <a href="<?php echo esc_url($item['section_menu_link']['url']);?>"><?php echo wp_kses($item['section_menu'], $allowed_tags);?></a></div>
								<div class="icon"><i class="fal fa-long-arrow-right"></i></div>
							</div>
						</div>
					</div>
					<?php endforeach; ?>
				</div>
			</div>
		</div>
		<div class="text-wrapper section-padding pb-0">
			<div class="swiper text-slider">
				<div class="swiper-wrapper">
					<?php foreach($settings['repeat_3'] as $item):?>	
					<div class="swiper-slide">
						<h2 class="text">
							<?php echo wp_kses($item['section_slide_text'], $allowed_tags);?>
							<span></span>
						</h2>					
					</div>
					<?php endforeach; ?>
				</div>
			</div>
		</div>
		<div class="footer-bottom pb-0">
			<div class="inner">
				<div class="container">
					<p class="text-center text-white">
						<?php echo $settings['copyright_text'];?>
					</p>
				</div>
			</div>
		</div>
	</footer>



	<?php
	$back_top_enable = cs_get_option('back_top_enable') !== null ? cs_get_option('back_top_enable') : true;
	?>
        
    <?php if ($back_top_enable) :?>
	<div class="scroll-up">
		<svg class="scroll-circle svg-content" width="100%" height="100%" viewBox="-1 -1 102 102">
			<path d="M50,1 a49,49 0 0,1 0,98 a49,49 0 0,1 0,-98" />
		</svg>
	</div>
	<?php endif;?>





             
		<?php 
	}


}

Plugin::instance()->widgets_manager->register_widget_type(new Footer_Style_2());