<?php



//-------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------//
// STYLES
//-------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------//

$this->start_controls_section(
    'style_menu_general',
    [
        'label' => __('Allmänt', 'webien'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'view' => 'menu',
        ],
    ]
);


$this->end_controls_section();

$this->start_controls_section(
    'style_menu_items',
    [
        'label' => __('Menyalternativ', 'webien'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'view' => 'menu',
        ],
    ],

);


$this->add_responsive_control(
    'style_align_text',
    [
        'label' 		=> __( 'Textjustering', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::CHOOSE,
        'default' 		=> 'left',
        'options' 		=> [
            'left' 			=> [
                'title' 	=> __( 'Vänster', 'webien' ),
                'icon' 		=> 'eicon-h-align-left',
            ],
            'center' 		=> [
                'title' 	=> __( 'Centrera', 'webien' ),
                'icon' 		=> 'eicon-h-align-center',
            ],
            'right' 		=> [
                'title' 	=> __( 'Höger', 'webien' ),
                'icon' 		=> 'eicon-h-align-right',
            ],
        ],
        'selectors' => [
            '{{WRAPPER}} .menu-item a' => 'text-align: {{VALUE}};',
        ],
    ]
);

$this->start_controls_tabs( 'menu_item_states' );

$this->start_controls_tab( 'menu_item_normal', [ 'label' => __( 'Normal', 'webien' ) ] );

$this->add_control(
    'menu_item_color',
    [
        'label' 	=> __( 'Textfärg', 'webien' ),
        'type' 		=> \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .menu-item a' => 'color: {{VALUE}};',
        ],
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Background::get_type(),
    [
        'name' => 'menu_item_background',
        'types' => [ 'classic', 'gradient' ],
        'selector' => '{{WRAPPER}} .menu-item a',
    ]
);


$this->add_responsive_control(
    'menu_item_margin',
    [
        'label' 		=> __( 'Marginal', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        //'allowed_dimensions' => [ 'right', 'left' ],
    ]
);

$this->add_responsive_control(
    'menu_item_padding',
    [
        'label' 		=> __( 'Padding', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        //'allowed_dimensions' => [ 'right', 'left' ],
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' 		=> 'menu_item_border',
        'label' 	=> __( 'Border', 'webien' ),
        'selector' 	=> '{{WRAPPER}} .menu-item a',
    ]
);

$this->add_responsive_control(
    'menu_item_border_radius',
    [
        'label' 		=> __( 'Border Radius', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' 		=> 'menu_item_typography',
        'label' 	=> __( 'Typography', 'webien' ),
        'global' => [
            'default' => \Elementor\Group_Control_Typography::get_type(),
        ],
        'selector' 	=> '{{WRAPPER}} .menu-item a',
    ]
);
$this->end_controls_tab();

$this->start_controls_tab( 'menu_item_hover', [ 'label' => __( 'Hover', 'webien' ) ] );

$this->add_control(
    'menu_item_color_hover',
    [
        'label' 	=> __( 'Textfärg', 'webien' ),
        'type' 		=> \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .menu-item a:hover' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Background::get_type(),
    [
        'name' => 'menu_item_background_hover',
        'types' => [ 'classic', 'gradient' ],
        'selector' => '{{WRAPPER}} .menu-item a:hover',
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' 		=> 'menu_item_border_hover',
        'label' 	=> __( 'Border', 'webien' ),
        'selector' 	=> '{{WRAPPER}} .menu-item a:hover',
    ]
);

$this->add_responsive_control(
    'menu_item_border_radius_hover',
    [
        'label' 		=> __( 'Border Radius', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item a:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' 		=> 'menu_item_typography_hover',
        'label' 	=> __( 'Typography', 'webien' ),
        'global' => [
            'default' => \Elementor\Group_Control_Typography::get_type(),
        ],
        'selector' 	=> '{{WRAPPER}} .menu-item a:hover',
    ]
);
$this->end_controls_tab();



$this->start_controls_tab( 'menu_item_active', [ 'label' => __( 'Aktiv sida', 'webien' ) ] );

$this->add_control(
    'menu_item_color_active',
    [
        'label' 	=> __( 'Textfärg', 'webien' ),
        'type' 		=> \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .menu-item a.current-menu-item' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Background::get_type(),
    [
        'name' => 'menu_item_background_active',
        'types' => [ 'classic', 'gradient' ],
        'selector' => '{{WRAPPER}} .menu-item a.current-menu-item',
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' 		=> 'menu_item_border_active',
        'label' 	=> __( 'Border', 'webien' ),
        'selector' 	=> '{{WRAPPER}} .menu-item a.current-menu-item',
    ]
);

$this->add_responsive_control(
    'menu_item_border_radius_active',
    [
        'label' 		=> __( 'Border Radius', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item a.current-menu-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' 		=> 'menu_item_typography_active',
        'label' 	=> __( 'Typography', 'webien' ),
        'global' => [
            'default' => \Elementor\Group_Control_Typography::get_type(),
        ],
        'selector' 	=> '{{WRAPPER}} .menu-item a.current-menu-item',
    ]
);
$this->end_controls_tab();


$this->end_controls_tabs();

$this->end_controls_section();




//-------------------------------------------------------------------------------//
// SUB MENU TOGGLE
//-------------------------------------------------------------------------------//

$this->start_controls_section(
    'style_menu_toggle',
    [
        'label' => __('Undermeny toggle', 'webien'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'view' => 'menu',
        ],
    ]
);


$this->add_control(
    'menu_toggle_icon',
    [
        'label' => __( 'Ikon', 'webien' ),
        'type' => \Elementor\Controls_Manager::ICONS,
        'default' => [],
        'recommended' => [

        ],
    ]
);

$this->add_control(
    'menu_toggle_size',
    [
        'label' 	=> __( 'Storlek', 'webien' ),
        'type' 		=> \Elementor\Controls_Manager::SLIDER,
        'default'	=> [
            'size'	=> 18
        ],
        'range' 	=> [
            'px' 	=> [
                'min' => 5,
                'max' => 100,
            ],
        ],
        'selectors' => [
            '{{WRAPPER}} button.toggle-childs svg' => 'width: {{SIZE}}{{UNIT}};',
            '{{WRAPPER}} button.toggle-childs i' => 'font-size: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->start_controls_tabs('menu_toggle_tabs');
$this->start_controls_tab( 'menu_toggle_normal', [ 'label' => __( 'Normal', 'webien' ) ] );

$this->add_control(
    'menu_toggle_color',
    [
        'label' 	=> __( 'Färg', 'webien' ),
        'type' 		=> \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} button.toggle-childs' => 'color: {{VALUE}};',
        ],
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Background::get_type(),
    [
        'name' => 'menu_toggle_background',
        'types' => [ 'classic', 'gradient' ],
        'selector' => '{{WRAPPER}} button.toggle-childs',
    ]
);


$this->add_responsive_control(
    'menu_toggle_margin',
    [
        'label' 		=> __( 'Marginal', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} button.toggle-childs' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        //'allowed_dimensions' => [ 'right', 'left' ],
    ]
);

$this->add_responsive_control(
    'menu_toggle_padding',
    [
        'label' 		=> __( 'Padding', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} button.toggle-childs' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        //'allowed_dimensions' => [ 'right', 'left' ],
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' 		=> 'menu_toggle_border',
        'label' 	=> __( 'Border', 'webien' ),
        'selector' 	=> '{{WRAPPER}} button.toggle-childs',
    ]
);

$this->add_responsive_control(
    'menu_toggle_border_radius',
    [
        'label' 		=> __( 'Border Radius', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} button.toggle-childs' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_tab();

$this->start_controls_tab( 'menu_toggle_hover', [ 'label' => __( 'Hover', 'webien' ) ] );


$this->add_control(
    'menu_toggle_color_hover',
    [
        'label' 	=> __( 'Textfärg', 'webien' ),
        'type' 		=> \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} button.toggle-childs:hover' => 'color: {{VALUE}};',
        ],
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Background::get_type(),
    [
        'name' => 'menu_toggle_background_hover',
        'types' => [ 'classic', 'gradient' ],
        'selector' => '{{WRAPPER}} button.toggle-childs:hover',
    ]
);




$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' 		=> 'menu_toggle_border_hover',
        'label' 	=> __( 'Border', 'webien' ),
        'selector' 	=> '{{WRAPPER}} button.toggle-childs:hover',
    ]
);

$this->add_responsive_control(
    'menu_toggle_border_radius_hover',
    [
        'label' 		=> __( 'Border Radius', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} button.toggle-childs:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_tab();

$this->end_controls_tabs();



$this->end_controls_section();







//-------------------------------------------------------------------------------//
// SUB MENU
//-------------------------------------------------------------------------------//


$this->start_controls_section(
    'sub_menu_style',
    [
        'label' => __( 'Undermeny', 'webien' ),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'view' => 'menu',
        ],
    ]
);


$this->add_responsive_control(
    'sub_menu_padding',
    [
        'label' 		=> __( 'Padding', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item > .sub-menu' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        //'allowed_dimensions' => [ 'right', 'left' ],
    ]
);


$this->start_controls_tabs( 'sub_menu_item_states' );

$this->start_controls_tab( 'sub_menu_item_normal', [ 'label' => __( 'Normal', 'webien' ) ] );

$this->add_control(
    'sub_menu_item_color',
    [
        'label' 	=> __( 'Textfärg', 'webien' ),
        'type' 		=> \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .menu-item .sub-menu a' => 'color: {{VALUE}};',
        ],
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Background::get_type(),
    [
        'name' => 'sub_menu_item_background',
        'types' => [ 'classic', 'gradient' ],
        'selector' => '{{WRAPPER}} .menu-item .sub-menu a',
    ]
);


$this->add_responsive_control(
    'sub_menu_item_margin',
    [
        'label' 		=> __( 'Marginal', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item .sub-menu' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        //'allowed_dimensions' => [ 'right', 'left' ],
    ]
);

$this->add_responsive_control(
    'sub_menu_item_padding',
    [
        'label' 		=> __( 'Padding', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item .sub-menu a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        //'allowed_dimensions' => [ 'right', 'left' ],
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' 		=> 'sub_menu_item_border',
        'label' 	=> __( 'Border', 'webien' ),
        'selector' 	=> '{{WRAPPER}} .menu-item .sub-menu a',
    ]
);

$this->add_responsive_control(
    'sub_menu_item_border_radius',
    [
        'label' 		=> __( 'Border Radius', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item .sub-menu a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' 		=> 'sub_menu_item_typography',
        'label' 	=> __( 'Typography', 'webien' ),
        'global' => [
            'default' => \Elementor\Group_Control_Typography::get_type(),
        ],
        'selector' 	=> '{{WRAPPER}} .menu-item .sub-menu a',
    ]
);
$this->end_controls_tab();

$this->start_controls_tab( 'sub_menu_item_hover', [ 'label' => __( 'Hover', 'webien' ) ] );

$this->add_control(
    'sub_menu_item_color_hover',
    [
        'label' 	=> __( 'Textfärg', 'webien' ),
        'type' 		=> \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .menu-item .sub-menu a:hover' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Background::get_type(),
    [
        'name' => 'sub_menu_item_background_hover',
        'types' => [ 'classic', 'gradient' ],
        'selector' => '{{WRAPPER}} .menu-item .sub-menu a:hover',
    ]
);





$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' 		=> 'sub_menu_item_border_hover',
        'label' 	=> __( 'Border', 'webien' ),
        'selector' 	=> '{{WRAPPER}} .menu-item .sub-menu a:hover',
    ]
);

$this->add_responsive_control(
    'sub_menu_item_border_radius_hover',
    [
        'label' 		=> __( 'Border Radius', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item .sub-menu a:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' 		=> 'sub_menu_item_typography_hover',
        'label' 	=> __( 'Typography', 'webien' ),
        'global' => [
            'default' => \Elementor\Group_Control_Typography::get_type(),
        ],
        'selector' 	=> '{{WRAPPER}} .menu-item .sub-menu a:hover',
    ]
);
$this->end_controls_tab();



$this->start_controls_tab( 'sub_menu_item_active', [ 'label' => __( 'Aktiv sida', 'webien' ) ] );

$this->add_control(
    'sub_menu_item_color_active',
    [
        'label' 	=> __( 'Textfärg', 'webien' ),
        'type' 		=> \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .menu-item .sub-menu a.current-menu-item' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Background::get_type(),
    [
        'name' => 'sub_menu_item_background_active',
        'types' => [ 'classic', 'gradient' ],
        'selector' => '{{WRAPPER}} .menu-item .sub-menu a.current-menu-item',
    ]
);


$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' 		=> 'sub_menu_item_border_active',
        'label' 	=> __( 'Border', 'webien' ),
        'selector' 	=> '{{WRAPPER}} .menu-item .sub-menu a.current-menu-item',
    ]
);

$this->add_responsive_control(
    'sub_menu_item_border_radius_active',
    [
        'label' 		=> __( 'Border Radius', 'webien' ),
        'type' 			=> \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' 	=> [ 'px', 'em', 'rem', '%', 'deg', 'vh', 'custom' ],
        'selectors' 	=> [
            '{{WRAPPER}} .menu-item .sub-menu a.current-menu-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' 		=> 'sub_menu_item_typography_active',
        'label' 	=> __( 'Typography', 'webien' ),
        'global' => [
            'default' => \Elementor\Group_Control_Typography::get_type(),
        ],
        'selector' 	=> '{{WRAPPER}} .menu-item .sub-menu a.current-menu-item',
    ]
);
$this->end_controls_tab();
$this->end_controls_tabs();

$this->end_controls_section();