<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Buttonfirststkaveh extends Widget_Base{

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

  public function get_title(){
    return esc_html__( 'Button Style One', 'kavehTheme' );
  }

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'iconbtnkavehcore',
        [
          'label' => esc_html__( 'Icon', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::ICONS,
          'skin' => 'inline',

          'exclude_inline_options' => [ 'svg' ],
          'default' => [
            'value' => 'icon-direct',
          ],
        ]
      );
      $this->add_control(
        'ftagti1buttonfirststkaveh',
        [
          'label' => esc_html__( 'Subtitle Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'div',
          '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' ),
          ],
        ]
      );
      $this->add_control(
        'fwigti2buttonfirststkaveh',
        [
          'label' => esc_html__( 'Subtitle', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'default' => 'Bestseller',
        ]
      );


      $this->add_control(
        'titlebtn_link',
        [
          'label' => esc_html__( 'Title Link', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::URL,
          'options' => [ 'url', 'is_external', 'nofollow' ],
          'default' => [
            'url' => '',
            'is_external' => true,
            'nofollow' => true,
            // 'custom_attributes' => '',
          ],
          'label_block' => true,
        ]
      );
      $this->add_control(
        'tagti1buttonfirststkaveh',
        [
          'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'div',
          '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' ),
          ],
        ]
      );
      $this->add_control(
        'widgtibuttonfirststkaveh',
        [
          'label' => esc_html__( 'Number in Box', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'default' => '255',
  
        ]
      );
  
  $this->end_controls_section();

       $this->start_controls_section(
        'stylet_buttonfirststkaveh',
        [
          'label' => esc_html__( 'Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'iconsizenchbbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Icon Size', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 200,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales i' => 'font-size: {{SIZE}}{{UNIT}};',
            '{{WRAPPER}} .header-hot-sales i svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'textbutton1colorbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Icon Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales i' => 'color: {{VALUE}}',
            '{{WRAPPER}} .header-hot-sales i svg' => 'fill: {{VALUE}}',
          ],
        ]
      );


      $this->add_control(
        'catimg1widthbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Icon Background Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales i' => 'width: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'catimg1height2buttonfirststkaveh',
        [
          
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales i' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'textbg1colorbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Icon Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales i' => 'background-color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttonradiusbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Icon Background Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales i' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            

          ],
        ]
      );
      
      $this->add_control(
        'borderbg1colorbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Box Border Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales' => 'border-color: {{VALUE}}',
          ],
        ]
      ); 


      $this->add_control(
        'backgroundhoverboxrbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Box Hover Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales:hover' => 'background-color: {{VALUE}}',
          ],
        ]
      ); 


      $this->add_control(
        'hoverborderbg1colorbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Box Hover Border Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales:hover' => 'border-color: {{VALUE}}',
          ],
        ]
      ); 


      $this->add_control(
        'hr1buttonfirststkaveh',
        [
          'type' => \Elementor\Controls_Manager::DIVIDER,
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'ftitletyt_buttonfirststkaveh',
          'label' => esc_html__( 'Main Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .header-hot-sales',
        ]
      );
      $this->add_control(
        'textcolortbolbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Main Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales' => 'color: {{VALUE}} !important',
          ],
        ]
      );


      $this->add_control(
        'textnumcolortbolbuttonfirststkaveh',
        [
          'label' => esc_html__( 'Number Box Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales span' => 'background-color: {{VALUE}} !important',
          ],
        ]
      );


      $this->add_control(
        'numcolortbolbuttonfirststkaveh',
        [
          
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .header-hot-sales span' => 'color: {{VALUE}} !important',
          ],
        ]
      );
      $this->end_controls_section();
        }
 

        protected function render(){
          $settings = $this->get_settings_for_display();
          $clsid = $this->get_id();
          ?>
          <a href="<?php echo esc_attr($settings['titlebtn_link']); ?>" class="header-hot-sales d-flex align-items-center rounded-pill">
            <i class="rounded-circle d-flex align-items-center justify-content-center lh-1 position-relative text-white">
              <?php \Elementor\Icons_Manager::render_icon( $settings['iconbtnkavehcore'], [ 'aria-hidden' => 'true' ] ); ?>
            </i>
            <?php echo esc_attr($settings['fwigti2buttonfirststkaveh']); ?>
            <span class="rounded-pill text-center text-white"><?php echo esc_attr($settings['widgtibuttonfirststkaveh']); ?> </span>
          </a>
          <?php
        }
      }
