<?php
namespace Sifency\Traits;

if ( ! defined( 'ABSPATH' ) ) {
	exit;  }
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
trait Sifency_Post_Navigator_Controls {

	protected function add_sifency_post_navigator_controls( $args = array() ) {
		$this->start_controls_section(
			'section_content',
			array( 'label' => esc_html__( 'Labels & Icons', 'sifency-addons' ) )
		);
		$this->add_control(
			'prev_text',
			array(
				'label'   => esc_html__( 'Previous Label', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXT,
				'default' => esc_html__( 'Previous Post', 'sifency-addons' ),
			)
		);
		$this->add_control(
			'prev_icon',
			array(
				'label'   => esc_html__( 'Previous Icon', 'sifency-addons' ),
				'type'    => Controls_Manager::ICONS,
				'default' => array(
					'value'   => 'fas fa-arrow-left',
					'library' => 'fa-solid',
				),
			)
		);
		$this->add_control(
			'next_text',
			array(
				'label'     => esc_html__( 'Next Label', 'sifency-addons' ),
				'type'      => Controls_Manager::TEXT,
				'default'   => esc_html__( 'Next Post', 'sifency-addons' ),
				'separator' => 'before',
			)
		);
		$this->add_control(
			'next_icon',
			array(
				'label'   => esc_html__( 'Next Icon', 'sifency-addons' ),
				'type'    => Controls_Manager::ICONS,
				'default' => array(
					'value'   => 'fas fa-arrow-right',
					'library' => 'fa-solid',
				),
			)
		);
		$this->add_control(
			'show_post_title',
			array(
				'label'        => esc_html__( 'Show Post Titles', 'sifency-addons' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Show', 'sifency-addons' ),
				'label_off'    => esc_html__( 'Hide', 'sifency-addons' ),
				'return_value' => 'yes',
				'default'      => 'yes',
				'separator'    => 'before',
			)
		);
		$this->end_controls_section();

		// --- Section: Query ---
		$this->start_controls_section(
			'section_query',
			array( 'label' => esc_html__( 'Query', 'sifency-addons' ) )
		);
		$this->add_control(
			'in_same_term',
			array(
				'label'       => esc_html__( 'In Same Taxonomy', 'sifency-addons' ),
				'type'        => Controls_Manager::SWITCHER,
				'description' => esc_html__( 'Only show posts from the same taxonomy term (e.g., category).', 'sifency-addons' ),
				'default'     => 'no',
			)
		);
		$this->add_control(
			'taxonomy',
			array(
				'label'     => esc_html__( 'Taxonomy', 'sifency-addons' ),
				'type'      => Controls_Manager::SELECT,
				'options'   => get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' ),
				'default'   => 'category',
				'condition' => array( 'in_same_term' => 'yes' ),
			)
		);
		$this->end_controls_section();

		// --- Section: Style Layout ---
		$this->start_controls_section(
			'section_style_layout',
			array(
				'label' => esc_html__( 'Layout', 'sifency-addons' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_control(
			'layout_justify',
			array(
				'label'     => esc_html__( 'Justify', 'sifency-addons' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'space-between' => array(
						'title' => 'Space Between',
						'icon'  => 'eicon-justify-space-between-h',
					),
					'flex-start'    => array(
						'title' => 'Start',
						'icon'  => 'eicon-h-align-left',
					),
					'center'        => array(
						'title' => 'Center',
						'icon'  => 'eicon-h-align-center',
					),
					'flex-end'      => array(
						'title' => 'End',
						'icon'  => 'eicon-h-align-right',
					),
				),
				'default'   => 'space-between',
				'selectors' => array( '{{WRAPPER}} .sifency-post-navigation' => 'justify-content: {{VALUE}};' ),
			)
		);
		$this->add_responsive_control(
			'layout_gap',
			array(
				'label'      => esc_html__( 'Gap', 'sifency-addons' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 200,
					),
				),
				'selectors'  => array( '{{WRAPPER}} .sifency-post-navigation' => 'gap: {{SIZE}}{{UNIT}};' ),
				'condition'  => array( 'layout_justify!' => 'space-between' ),
			)
		);
		$this->end_controls_section();
	}
}
