<?php
namespace Sifency\Traits;
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
use Elementor\Controls_Manager;
trait Sifency_Blog_Controls {

	/**
	 *
	 * @param array $args Optional customization.
	 */
	protected function add_sifency_blog_controls( $args = [] ) {
        // --- Layout Section ---
        $this->start_controls_section(
            'section_layout',
            [
                'label' => esc_html__( 'Layout', 'sifency-addons' ),
            ]
        );
        
        $this->add_control(
            'layout_style',
            [
                'label'   => esc_html__( 'Layout', 'sifency-addons' ),
                'type'    => Controls_Manager::SELECT,
                'options' => [
                    'grid'     => esc_html__( 'Grid', 'sifency-addons' ),
                    'carousel' => esc_html__( 'Carousel', 'sifency-addons' ),
                ],
                'default' => 'grid',
            ]
        );
        
        $this->add_responsive_control(
            'columns',
            [
                'label'     => esc_html__( 'Columns', 'sifency-addons' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => '3',
                'tablet_default' => '2',
                'mobile_default' => '1',
                'options'   => [ '1' => '1', '2' => '2', '3' => '3', '4' => '4' ],
                'selectors' => [ '{{WRAPPER}} .sifency-addons-blog-grid' => 'grid-template-columns: repeat({{VALUE}}, 1fr);' ],
                'condition' => [ 'layout_style' => 'grid' ],
            ]
        );
        
        $this->add_responsive_control(
            'gap',
            [
                'label'     => esc_html__( 'Gap', 'sifency-addons' ),
                'type'      => Controls_Manager::SLIDER,
                'default'   => [ 'size' => 30 ],
                'range'     => [ 'px' => [ 'min' => 0, 'max' => 100 ] ],
                'selectors' => [ '{{WRAPPER}} .sifency-addons-blog-grid' => 'gap: {{SIZE}}{{UNIT}};' ],
                'condition' => [ 'layout_style' => 'grid' ],
            ]
        );
        
        $this->add_control(
            'show_thumbnail',
            [
                'label'     => esc_html__( 'Show Image', 'sifency-addons' ),
                'type'      => Controls_Manager::SWITCHER,
                'default'   => 'yes',
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'show_date',
            [
                'label'     => esc_html__( 'Show date', 'sifency-addons' ),
                'type'      => Controls_Manager::SWITCHER,
                'default'   => 'yes',
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'show_excerpt',
            [
                'label'     => esc_html__( 'Show Excerpt', 'sifency-addons' ),
                'type'      => Controls_Manager::SWITCHER,
                'default'   => 'yes',
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'show_read_more',
            [
                'label'     => esc_html__( 'Show Read More', 'sifency-addons' ),
                'type'      => Controls_Manager::SWITCHER,
                'default'   => 'yes',
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'read_more_text',
            [
                'label'     => esc_html__( 'Read More Text', 'sifency-addons' ),
                'type'      => Controls_Manager::TEXT,
                'default'   => esc_html__( 'Read More', 'sifency-addons' ),
                'condition' => [ 'show_read_more' => 'yes' ],
            ]
        );
        
        $this->end_controls_section();
	}
}