<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Geroz
 * @since 1.0.0
 */ 
 
class Footer_Style6 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-style6-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 6', '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() {


		$this->start_controls_section(
			'footer_style6_content',
			[
				'label' => esc_html__( 'Footer Content', 'geroz-core' ),
			]
		);	

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

		$this->add_control(
			'button',
			[
				'label'       => __( 'Button', 'geroz-core' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => esc_html__( 'Enter your button text', 'geroz-core' ),
				'default' => esc_html__('Read More', 'geroz-core'),
			]
		);	

		$this->add_control(
			'button_link',
			[
			  'label' => __( 'Button Url', 'geroz-core' ),
			  'type' => Controls_Manager::URL,
			  'placeholder' => __( 'https://your-link.com', 'geroz-core' ),
			  'show_external' => true,
			  'default' => [
				'url' => '',
				'is_external' => true,
				'nofollow' => true,
			  ],
			
		   ]
		);

		$this->add_control(
			'subtitle',
			[
				'label'       => __( 'Sub Title', 'geroz-core' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default' => esc_html__('Get specialist cargo services worldwide', 'geroz-core'),
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		
		$this->add_control(
			'title',
			[
				'label'       => __( 'Title', 'geroz-core' ),
				'type'        => Controls_Manager::TEXTAREA,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter your title', 'geroz-core' ),
				'default'     => __( 'Default Title', 'geroz-core' ),
			]
		);	

		$this->add_control(
			'email',
			[
				'label'       => __( 'Email', 'geroz-core' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => esc_html__( 'Enter your text', 'geroz-core' ),
				'default' => esc_html__('Read More', 'geroz-core'),
			]
		);	

		$this->add_control(
			'email_link',
			[
			  'label' => __( 'Email Url', 'geroz-core' ),
			  'type' => Controls_Manager::URL,
			  'placeholder' => __( 'https://your-link.com', 'geroz-core' ),
			  'show_external' => true,
			  'default' => [
				'url' => '',
				'is_external' => true,
				'nofollow' => true,
			  ],
			
		   ]
		);

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

		$this->end_controls_section();


		$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_title'=> [
							'name' => 'section_title',
							'label' => esc_html__('Title', 'geroz-core'),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__('Hello World', 'geroz-core'),
							'placeholder' => esc_html__('Type your title here', 'geroz-core'),
						],

						'section_subtitle'=> [
							'name' => 'section_subtitle',
							'label' => esc_html__('Sub Title', 'geroz-core'),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__('Hello World', 'geroz-core'),
							'placeholder' => esc_html__('Type your title here', 'geroz-core'),
						],	
						
					],
				'title_field' => '{{section_title}}',
			 ]
		);
		
		
		$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-3 section-padding pb-0">
		<div class="container">
			<div class="section-title tp_fade_bottom">
				<a href="<?php echo esc_url($settings['button_link']['url']);?>" class="circle">
					<div class="dot"></div>
					<div class="circle-icon"><i class="fal fa-arrow-right"></i></div>
					<div class="circle-text">
						<p>
							<?php echo $settings['button'];?>
						</p>
					</div>
				</a>
				<div class="sub-title">
					<div class="dot"></div> <span><?php echo $settings['subtitle'];?></span>
				</div>
				<h2><?php echo $settings['title'];?></h2>
				<div class="infu">
					<a href="<?php echo esc_url($settings['email_link']['url']);?>"><i class="fal fa-envelope"></i> <?php echo $settings['email'];?></a>
				</div>
			</div>
			<div class="footer-widgets-inner mt-xl-5 pt-3">
				<div class="desh">
					<svg class="scroll-line" height="7" viewBox="0 0 1320 7" fill="none"
						xmlns="http://www.w3.org/2000/svg">
						<line class="line-1" y1="0.5" x2="1308.11" y2="0.5" stroke="white" stroke-opacity="0.24"
							stroke-dasharray="12 12" />
						<line class="line-2" x1="11.8916" y1="6.5" x2="1320" y2="6.5" stroke="white"
							stroke-opacity="0.24" stroke-dasharray="12 12" />
					</svg>
				</div>
				<div class="row align-items-center my-xl-5 g-5">
					<div class="col-xl-3 col-lg-3 col-md-6 wow fadeInDown" data-wow-delay="200ms">
						<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>
					<?php foreach($settings['repeat'] as $item):?>
					<div class="col-xl-3 col-lg-3 col-md-6 d-flex justify-content-lg-center justify-content-sm-start wow fadeInDown" data-wow-delay="400ms">
						<div class="signle-footer-widgets">
							<span><?php echo wp_kses($item['section_title'], $allowed_tags);?></span>
							<h5><?php echo wp_kses($item['section_subtitle'], $allowed_tags);?></h5>
						</div>
					</div>
					<?php endforeach; ?>
				</div>
				<div class="desh">
					<svg class="scroll-line" height="7" viewBox="0 0 1320 7" fill="none"
						xmlns="http://www.w3.org/2000/svg">
						<line class="line-1" y1="0.5" x2="1308.11" y2="0.5" stroke="white" stroke-opacity="0.24"
							stroke-dasharray="12 12" />
					</svg>

				</div>
			</div>
		</div>
		<div class="footer-bottom">
			<div class="inner">
				<div class="container">
					<p class="text-center text-white">
						<?php echo $settings['copyright'];?>
					</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_Style6());