<?php

use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Imageboxstkaveh extends Widget_Base{

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

  public function get_title(){
    return esc_html__( 'Image Box', 'kavehTheme' );
  }

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentimageboxstkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );

      $this->add_control(
        'brandlogoimageboxstkaveh',
        [
          'label' => esc_html__( 'Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
          'default' => [
            'url' => \Elementor\Utils::get_placeholder_image_src(),
          ],
        ]
        );
        $this->add_control(
          'titleimageboxstkaveh',
          [
              'label' => esc_html__( 'Main Title', 'kavehTheme' ),
              'type' => \Elementor\Controls_Manager::TEXT,
              'default' => esc_html__( 'Kaveh Store', 'kavehTheme' ),   
          ]
      );
    $this->add_control(
      'tagheading1imageboxstkaveh',
      [
        'label' => esc_html__( 'Main 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' ),
        ],
      ]
    );
        $this->add_control(
          'linkimageboxstkaveh',
          [
              'label' => esc_html__( 'Link', 'kavehTheme' ),
              'type' => \Elementor\Controls_Manager::TEXT,
              'default' => esc_html__( '#', 'kavehTheme' ),
      
          ]
      );

    $this->add_control(
      'pti2imageboxstkavehh',
      [
          'label' => esc_html__( 'Button Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXTAREA,
          'default' => esc_html__( 'Products can be returned within 7 days out of respect for customer choice.', 'kavehTheme' ),
  
      ]
  );

       $this->end_controls_section();

      $this->start_controls_section(
        'style0_imageboxstkaveh',
        [
          'label' => esc_html__( 'Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'catimg1widthimageboxstkaveh',
        [
          'label' => esc_html__( 'Image Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 500,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .options-bani-item img' => 'width: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'catimg1height2imageboxstkaveh',
        [
          'label' => esc_html__( 'Image Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 500,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .options-bani-item img' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'textcolor1imageboxstkaveh',
        [
          'label' => esc_html__( 'Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .options-bani-item .content .title' => 'color: {{VALUE}} !important',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titlety1_imageboxstkaveh',
          'label' => esc_html__( 'Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .options-bani-item .content .title',
        ]
      );
      $this->add_control(
        'ptextcolor1imageboxstkaveh',
        [
          'label' => esc_html__( 'Text Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .options-bani-item .content p' => 'color: {{VALUE}} !important',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'ptitlety1_imageboxstkaveh',
          'label' => esc_html__( 'Text Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .options-bani-item .content p',
        ]
      );
      $this->end_controls_section();
        }


  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
    ?>
           <div class="options-bani-item position-relative">
              <a href="<?php echo  esc_html($settings['linkimageboxstkaveh']); ?>" class="stretched-link" aria-label="name"></a>
              <img src="<?php echo esc_url($settings['brandlogoimageboxstkaveh']['url']); ?>" alt="" width="100" height="98"
                class="d-block mx-auto">
              <div class="content">
                <<?php echo  esc_attr($settings['tagheading1imageboxstkaveh']); ?> class="title fw-bold w-100 mt-3 mb-2 mx-auto text-center"> <?php echo  esc_attr($settings['titleimageboxstkaveh']); ?></<?php echo  esc_attr($settings['tagheading1imageboxstkaveh']); ?>>
                <p class="mx-auto mb-0 w-100 text-center d-none d-lg-block"> <?php echo  esc_attr($settings['pti2imageboxstkavehh']); ?> </p>
              </div>
            </div>
            <style>
              .options-bani-item img {
                max-height: unset;
                object-fit: contain;
            }
            </style>

    <?php
  }


}
