<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Categorygridsecondstkaveh extends Widget_Base{

  public function get_name(){
    return 'categorygridsecondstkaveh';
  }

  public function get_title(){
    return esc_html__( 'Category Grid Style Two', 'kavehTheme' );
  }

  public function get_icon(){
    return 'eicon-archive-posts';
  }

  public function get_categories(){
    return ['kavehelements'];
  }

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'titlecategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'default' => 'Categories',
  
        ]
      );
      $this->add_control(
        'tagheadingtcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'H2',
          'options' => [
            'H1'  => esc_html__( 'H1', 'kavehTheme' ),
            'H2' => esc_html__( 'H2', 'kavehTheme' ),
            'H3' => esc_html__( 'H3', 'kavehTheme' ),
            'H4' => esc_html__( 'H4', 'kavehTheme' ),
            'H5' => esc_html__( 'H5', 'kavehTheme' ),
            'H6' => esc_html__( 'H6', 'kavehTheme' ),
            'p' => esc_html__( 'p', 'kavehTheme' ),
            'div' => esc_html__( 'div', 'kavehTheme' ),
            'span' => esc_html__( 'span', 'kavehTheme' ),
          ],
        ]
      );
      $repeater = new \Elementor\Repeater();
      $repeater->add_control(
        'imgcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Choose Your Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
        ]
      );
      $repeater->add_control(
      'title1categorygridsecondstkaveh',
      [
        'label' => esc_html__( 'Title', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => 'Category',

      ]
    );
    $repeater->add_control(
      'tagheadingccategorygridsecondstkaveh',
      [
        'label' => esc_html__( 'Category Title Tag', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'H3',
        'options' => [
          'H1'  => esc_html__( 'H1', 'kavehTheme' ),
          'H2' => esc_html__( 'H2', 'kavehTheme' ),
          'H3' => esc_html__( 'H3', 'kavehTheme' ),
          'H4' => esc_html__( 'H4', 'kavehTheme' ),
          'H5' => esc_html__( 'H5', 'kavehTheme' ),
          'H6' => esc_html__( 'H6', 'kavehTheme' ),
          'p' => esc_html__( 'p', 'kavehTheme' ),
          'div' => esc_html__( 'div', 'kavehTheme' ),
          'span' => esc_html__( 'span', 'kavehTheme' ),
        ],
      ]
    );
    $repeater->add_control(
      'linkcategorygridsecondstkaveh',
      [
        'label' => esc_html__( 'Link', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '#',
      ]
    );
    $this->add_control(
      'listcategorygridsecondstkaveh',
      [
        'label' => esc_html__( 'Categories', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::REPEATER,
        'fields' => $repeater->get_controls(),
        'default' => [
          [
            'title1categorygridsecondstkaveh' => esc_html__( 'Title', 'kavehTheme' ),
            'linkcategorygridsecondstkaveh' => esc_html__( '#', 'kavehTheme' ),
          ],
      ]
      ]
    
    );  
       $this->end_controls_section();
       $this->start_controls_section(
        'content2categorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Background Image', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'imgbgcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Background Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
          'selectors' => [
            '{{WRAPPER}} .price-day::after' =>
                'background-image: url({{URL}})',
        ],
        ]
      );
      
      $this->end_controls_section();
      $this->start_controls_section(
        'content3categorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Display Settings', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'colcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Number of Columns', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => '4',
          'options' => [
            '1'  => esc_html__( '1', 'kavehTheme' ),
            '2' => esc_html__( '2', 'kavehTheme' ),
            '3' => esc_html__( '3', 'kavehTheme' ),
            '4' => esc_html__( '4', 'kavehTheme' ),
            '6' => esc_html__( '6', 'kavehTheme' ),
  
          ],
        ]
      );
      $this->end_controls_section();
       $this->start_controls_section(
        'style_categorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Title Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'textcolorcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .price-day-title' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'title_categorygridsecondstkaveh',
          'label' => esc_html__( 'Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .price-day-title',
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style2_categorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Category Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'imgsizecategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Category Image Size', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px', '%' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
            '%' => [
              'min' => 0,
              'max' => 100,
            ],
          ],
          'default' => [
            'unit' => 'px',
            'size' =>64,
          ],
          'selectors' => [
            '{{WRAPPER}} .imgcatg2' => 'width: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'bgcolorcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Box Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .price-day-item' => 'background-color: {{VALUE}}',
          ],
        ]
      );
      $this->add_control(
        'boxradiuscategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Outer Box Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .price-day-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'boxradius2categorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Inner Box Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .price-day-item::before' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'title_categorygridsecondstkaveh',
          'label' => esc_html__( 'Category Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .price-day-item .tcatg2',
        ]
      );
      $this->add_control(
        'tccolorcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Category Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .price-day-item .tcatg2' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_control(
        'tcbgcolorcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Category Title Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .price-day-item .tcatg2' => 'background-color: {{VALUE}}',
          ],
        ]
      );
      $this->add_control(
        'tbradius2categorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Title Background Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .price-day-item .tcatg2' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'buttonpaddingcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Inner Spacing', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .price-day-item .tcatg2' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'tcmtcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Distance from Top of Category Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px', '%' ],
          'range' => [
            'px' => [
              'min' => -300,
              'max' => 300,
              'step' => 1,
            ],
            '%' => [
              'min' => -50,
              'max' => 50,
            ],
          ],
          'default' => [
            'unit' => 'px',
            'size' =>15,
          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style3_categorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Element Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'tcbgcolorrowcategorygridsecondstkaveh',
        [
          'label' => esc_html__( 'Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .price-day' => 'background-color: {{VALUE}}',
          ],
        ]
      );
      $this->end_controls_section();
 
        }


  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
    ?>

<section class="price-day position-relative overflow-hidden">
      <div class="container">
        <<?php echo  esc_attr($settings['tagheadingtcategorygridsecondstkaveh']); ?> class="price-day-title text-center"><?php echo  esc_html($settings['titlecategorygridsecondstkaveh']); ?></<?php echo  esc_attr($settings['tagheadingtcategorygridsecondstkaveh']); ?>>
        <!-- Start Items -->
        <div class="row">
        <?php
              if ( $settings['listcategorygridsecondstkaveh'] ) {
              foreach (  $settings['listcategorygridsecondstkaveh'] as $item ) {
              ?>
          <!-- Start Item -->
          <div class="<?php if('1'===$settings['colcategorygridsecondstkaveh']){ ?>col-lg-12<?php }elseif('2'===$settings['colcategorygridsecondstkaveh']){?>col-lg-6<?php }elseif('3'===$settings['colcategorygridsecondstkaveh']){?>col-lg-4<?php }elseif('4'===$settings['colcategorygridsecondstkaveh']){?>col-lg-3<?php }elseif('6'===$settings['colcategorygridsecondstkaveh']){?>col-lg-2<?php } ?> col-md-4">
            <div class="price-day-item position-relative text-center">
              <a href="<?php echo  esc_url($item['linkcategorygridsecondstkaveh']); ?>" class="stretched-link"></a>
              <img src="<?php echo esc_url($item['imgcategorygridsecondstkaveh']['url']); ?>" alt="<?php echo esc_attr(\Elementor\Control_Media::get_image_alt( $item['imgcategorygridsecondstkaveh'] )); ?>" class="d-block mx-auto imgcatg2" />
              <<?php echo  esc_attr($item['tagheadingccategorygridsecondstkaveh']); ?> class="tcatg2"><?php echo  esc_html($item['title1categorygridsecondstkaveh']); ?></<?php echo  esc_attr($item['tagheadingccategorygridsecondstkaveh']); ?>>
            </div>
          </div>
          <!-- Start Item -->
          <?php 
            }
              }
            ?>
        </div>
        <!-- End Items -->
      </div>
    </section>
    <style>
<?php echo '.elementor-element-' . $clsid . ''; ?> .price-day-item .tcatg2 {
    -webkit-transform: translateY(<?php echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['size']); echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['unit']); ?>);
    -moz-transform: translateY(<?php echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['size']); echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['unit']); ?>);
    -ms-transform: translateY(<?php echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['size']); echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['unit']); ?>);
    -o-transform: translateY(<?php echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['size']); echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['unit']); ?>);
    transform: translateY(<?php echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['size']); echo  esc_html($settings['tcmtcategorygridsecondstkaveh']['unit']); ?>);
}
<?php echo '.elementor-element-' . $clsid . ''; ?> .price-day::after {
    background-color: #2b5d5e;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    object-fit: cover;
}
    </style>
    <?php
  }


}
