<?php
namespace ThemeAtelier\EventfulForElementor\Admin\Widgets\Options;

class EventfulForElementorStyleBox
{
    public static function ppfe_style_box_options($widget)
    {

        // Box.
        $widget->start_controls_section(
            'section_box',
            [
                'label'     => esc_html__('Box', 'eventful-for-elementor'),
                'tab'       => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );

        $widget->add_control(
            'box_widget_name',
            [
                'label' => esc_html__('Widget Name', 'eventful-for-elementor'),
                'type' => \Elementor\Controls_Manager::HIDDEN,
                'default' => $widget->get_name(),
            ]
        );

        // Image border radius.
        $widget->add_control(
            'grid_box_border_width',
            [
                'label'      => esc_html__('Border Widget', 'eventful-for-elementor'),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .eventful .eventful__item .efpe-post' => 'border-style: solid; border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
                ],
            ]
        );

        // Border Radius.
        $widget->add_control(
            'grid_style_border_radius',
            [
                'label'     => esc_html__('Border Radius', 'eventful-for-elementor'),
                'type'      => \Elementor\Controls_Manager::SLIDER,
                'default'   => [
                    'size' => 0,
                ],
                'range'     => [
                    'px' => [
                        'min' => 0,
                        'max' => 200,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .eventful .eventful__item .efpe-post' => 'border-radius: {{SIZE}}{{UNIT}}',
                    '{{WRAPPER}} .eventful .ta-overlay.eventful__item' => 'border-radius: {{SIZE}}{{UNIT}}',
                ],
            ]
        );

        // Box internal padding.
        $widget->add_responsive_control(
            'grid_items_style_padding',
            [
                'label'      => esc_html__('Padding', 'eventful-for-elementor'),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'default' => [
                    'top' => 15,
                    'right' => 15,
                    'bottom' => 15,
                    'left' => 15,
                    'unit' => 'px',
                ],
                'selectors'  => [
                    '{{WRAPPER}} .eventful .eventful__item .efpe-post' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
                ],
            ]
        );
        // Box internal margin.
        $widget->add_responsive_control(
            'grid_items_style_margin',
            [
                'label'      => esc_html__('Margin', 'eventful-for-elementor'),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .eventful .swiper-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
                    '{{WRAPPER}} .eventful .eventful__item.left-thumb' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
                    '{{WRAPPER}} .eventful .eventful__item.right-thumb' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
                ],
                'condition' => [
                    'box_widget_name' => 'eventful-post-list-widget'
                ]
            ]
        );

        $widget->start_controls_tabs('grid_button_style');

        // Normal tab.
        $widget->start_controls_tab(
            'grid_button_style_normal',
            [
                'label'     => esc_html__('Normal', 'eventful-for-elementor'),
            ]
        );

        // Normal background color.
        $widget->add_control(
            'grid_button_style_normal_bg_color',
            [
                'type'      => \Elementor\Controls_Manager::COLOR,
                'label'     => esc_html__('Background Color', 'eventful-for-elementor'),
                'separator' => '',
                'selectors' => [
                    '{{WRAPPER}} .eventful .eventful__item .efpe-post' => 'background-color: {{VALUE}};',
                ],
            ]
        );

        // Normal border color.
        $widget->add_control(
            'grid_button_style_normal_border_color',
            [
                'type'      => \Elementor\Controls_Manager::COLOR,
                'label'     => esc_html__('Border Color', 'eventful-for-elementor'),
                'separator' => '',
                'selectors' => [
                    '{{WRAPPER}} .eventful .eventful__item .efpe-post' => 'border-color: {{VALUE}};',
                ],
            ]
        );

        // Normal box shadow.
        $widget->add_group_control(
            \Elementor\Group_Control_Box_Shadow::get_type(),
            [
                'name'      => 'grid_button_style_normal_box_shadow',
                'selector'  => '{{WRAPPER}} .eventful .eventful__item .efpe-post',
                'fields_options' => [
                    'box_shadow' => [
                        'default' => [
                            'horizontal' => 0,
                            'vertical'   => 0,
                            'blur'       => 6,
                            'spread'     => -2,
                            'color'      => 'rgb(187,187,187)',
                        ],
                    ],
                ],
            ]
        );

        $widget->end_controls_tab();

        // Hover tab.
        $widget->start_controls_tab(
            'grid_button_style_hover',
            [
                'label'     => esc_html__('Hover', 'eventful-for-elementor'),
            ]
        );

        // Hover background color.
        $widget->add_control(
            'grid_button_style_hover_bg_color',
            [
                'type'      => \Elementor\Controls_Manager::COLOR,
                'label'     => esc_html__('Background Color', 'eventful-for-elementor'),
                'separator' => '',
                'selectors' => [
                    '{{WRAPPER}} .eventful .eventful__item .efpe-post:hover' => 'background-color: {{VALUE}};',
                ],
            ]
        );

        // Hover border color.
        $widget->add_control(
            'grid_button_style_hover_border_color',
            [
                'type'      => \Elementor\Controls_Manager::COLOR,
                'label'     => esc_html__('Border Color', 'eventful-for-elementor'),
                'separator' => '',
                'selectors' => [
                    '{{WRAPPER}} .eventful .eventful__item .efpe-post:hover' => 'border-color: {{VALUE}};',
                ],
            ]
        );

        // Hover box shadow.
        $widget->add_group_control(
            \Elementor\Group_Control_Box_Shadow::get_type(),
            [
                'name'      => 'grid_button_style_hover_box_shadow',
                'selector'  => '{{WRAPPER}} .eventful .eventful__item .efpe-post:hover',
                'fields_options' => [
                    'box_shadow' => [
                        'default' => [
                            'horizontal' => 0,
                            'vertical'   => 0,
                            'blur'       => 6,
                            'spread'     => -2,
                            'color'      => 'rgb(187,187,187)',
                        ],
                    ],
                ],
            ]
        );

        $widget->end_controls_tab();

        $widget->end_controls_tabs();

        // Overlay Background.
        $widget->add_control(
            'overlay_background',
            [
                'type'      => \Elementor\Controls_Manager::COLOR,
                'label'     => esc_html__('Overlay Background', 'eventful-for-elementor'),
                'separator' => '',
                'selectors' => [
                    '{{WRAPPER}} .eventful__item.ta-overlay::after' => 'background-color: {{VALUE}};',
                ],
                'condition' => [
                    'content_orientation' => 'overlay',
                ]
            ]
        );

        // Background Opacity.
        $widget->add_control(
            'background_opacity',
            [
                'label'     => esc_html__('Background Opacity', 'eventful-for-elementor'),
                'type'      => \Elementor\Controls_Manager::SLIDER,
                'default'   => [
                    'size' => 7,
                ],
                'range'     => [
                    'px' => [
                        'min' => 0,
                        'max' => 9,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .eventful__item.ta-overlay::after' => 'opacity: 0.{{SIZE}}',
                ],
                'condition' => [
                    'content_orientation' => 'overlay',
                ]
            ]
        );

        $widget->end_controls_section();
    }
}
