<?php
/**
 * Customer Downloads Widget - Style Controls
 *
 * @package GGM_Commerce
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// $this is the GGM_Commerce_Widget_Customer_Downloads instance.

// ── Title ─────────────────────────────────────────────────────────────────────

$this->start_controls_section(
	'section_style_title',
	array(
		'label' => 'Title',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	)
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	array(
		'name'     => 'title_typography',
		'selector' => '{{WRAPPER}} .ggmc-downloads-title',
	)
);

$this->add_control(
	'title_color',
	array(
		'label'     => 'Title Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .ggmc-downloads-title' => 'color: {{VALUE}};',
		),
	)
);

$this->add_responsive_control(
	'title_margin',
	array(
		'label'      => 'Title Margin',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', 'em', '%' ),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-downloads-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
	)
);

$this->end_controls_section();

// ── Download Items ─────────────────────────────────────────────────────────────

$this->start_controls_section(
	'section_style_items',
	array(
		'label' => 'Download Items',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	)
);

$this->add_control(
	'item_background',
	array(
		'label'     => 'Background Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .ggmc-download-item' => 'background-color: {{VALUE}};',
		),
	)
);

$this->add_control(
	'item_border_color',
	array(
		'label'     => 'Border Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .ggmc-download-item' => 'border-color: {{VALUE}};',
		),
	)
);

$this->add_responsive_control(
	'item_padding',
	array(
		'label'      => 'Padding',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', 'em', '%' ),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-download-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
	)
);

$this->add_control(
	'item_border_radius',
	array(
		'label'      => 'Border Radius',
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => array( 'px', '%' ),
		'range'      => array(
			'px' => array(
				'min'  => 0,
				'max'  => 20,
				'step' => 1,
			),
		),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-download-item' => 'border-radius: {{SIZE}}{{UNIT}};',
		),
	)
);

$this->add_responsive_control(
	'item_gap',
	array(
		'label'      => 'Gap Between Items',
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => array( 'px', 'em' ),
		'range'      => array(
			'px' => array(
				'min'  => 0,
				'max'  => 40,
				'step' => 2,
			),
		),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-downloads-list' => 'gap: {{SIZE}}{{UNIT}};',
		),
	)
);

$this->end_controls_section();

// ── Download Button ────────────────────────────────────────────────────────────

$this->start_controls_section(
	'section_style_button',
	array(
		'label' => 'Download Button',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	)
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	array(
		'name'     => 'button_typography',
		'selector' => '{{WRAPPER}} .ggmc-download-button',
	)
);

$this->add_control(
	'button_background',
	array(
		'label'     => 'Background Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .ggmc-download-button' => 'background-color: {{VALUE}};',
		),
	)
);

$this->add_control(
	'button_text_color',
	array(
		'label'     => 'Text Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .ggmc-download-button' => 'color: {{VALUE}};',
		),
	)
);

$this->add_control(
	'button_hover_background',
	array(
		'label'     => 'Hover Background',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .ggmc-download-button:hover' => 'background-color: {{VALUE}};',
		),
	)
);

$this->add_responsive_control(
	'button_padding',
	array(
		'label'      => 'Padding',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', 'em', '%' ),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-download-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
	)
);

$this->add_control(
	'button_border_radius',
	array(
		'label'      => 'Border Radius',
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => array( 'px', '%' ),
		'range'      => array(
			'px' => array(
				'min'  => 0,
				'max'  => 20,
				'step' => 1,
			),
		),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-download-button' => 'border-radius: {{SIZE}}{{UNIT}};',
		),
	)
);

$this->end_controls_section();

// ── Status Badges ──────────────────────────────────────────────────────────────

$this->start_controls_section(
	'section_style_status',
	array(
		'label' => 'Status Badges',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	)
);

$this->add_control(
	'expired_background',
	array(
		'label'     => 'Expired Background',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'default'   => '#ffebee',
		'selectors' => array(
			'{{WRAPPER}} .ggmc-download-status.expired' => 'background-color: {{VALUE}};',
		),
	)
);

$this->add_control(
	'expired_text_color',
	array(
		'label'     => 'Expired Text Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'default'   => '#c62828',
		'selectors' => array(
			'{{WRAPPER}} .ggmc-download-status.expired' => 'color: {{VALUE}};',
		),
	)
);

$this->add_control(
	'limit_reached_background',
	array(
		'label'     => 'Limit Reached Background',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'default'   => '#fff3e0',
		'selectors' => array(
			'{{WRAPPER}} .ggmc-download-status.limit-reached' => 'background-color: {{VALUE}};',
		),
	)
);

$this->add_control(
	'limit_reached_text_color',
	array(
		'label'     => 'Limit Reached Text Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'default'   => '#e65100',
		'selectors' => array(
			'{{WRAPPER}} .ggmc-download-status.limit-reached' => 'color: {{VALUE}};',
		),
	)
);

$this->end_controls_section();
