<?php namespace MeowCrew\CancellationOffers\Offer\CPT\Form\Tabs;

use MeowCrew\CancellationOffers\Offer\CPT\Form\FormTab;
use MeowCrew\CancellationOffers\Offer\Entity\Offer;

class DesignTab extends FormTab {

	public function getId(): string {
		return 'design';
	}

	public function getTitle(): string {
		return __( 'Design', 'cancellation-surveys-offers-woocommerce-subscriptions' );
	}

	public function getDescription(): string {
		return __( 'Customize the look and feel of the offer popup.',
				'cancellation-surveys-offers-woocommerce-subscriptions' );
	}

	public function getIcon(): string {
		return '<span class="dashicons dashicons-admin-customizer"></span>';
	}

	public function render( Offer $offer ) {
		$this->form->renderHint( __( 'Personalize the design of your cancellation offer popup to match your brand and create a cohesive experience for your customers.',
				'cancellation-surveys-offers-woocommerce-subscriptions' ) );
		?>
		<div id="cancellation-offer-design-tab">
			<?php
				FormTab::renderInputRow( array(
						'id'      => 'settings_popup_style',
						'type'    => 'radio',
						'value'   => $offer->getSettings()->getPopupStyle(),
						'label'   => __( 'Popup Style', 'cancellation-surveys-offers-woocommerce-subscriptions' ),
						'options' => array(
								'default' => array(
										'label'       => __( 'Default',
												'cancellation-surveys-offers-woocommerce-subscriptions' ),
										'is_selected' => in_array( $offer->getSettings()->getPopupStyle(),
												array( 'default', 'simple' ), true ),
								),
								'vibrant' => array(
										'label'       => __( 'Vibrant',
												'cancellation-surveys-offers-woocommerce-subscriptions' ),
										'is_selected' => 'vibrant' === $offer->getSettings()->getPopupStyle(),
								),
						),
				) );

				FormTab::renderInputRow( array(
						'id'      => 'settings_popup_layout',
						'type'    => 'radio',
						'value'   => $offer->getSettings()->getPopupLayout(),
						'label'   => __( 'Popup Layout', 'cancellation-surveys-offers-woocommerce-subscriptions' ),
						'options' => array(
								'default' => array(
										'label'       => __( 'Default',
												'cancellation-surveys-offers-woocommerce-subscriptions' ),
										'is_selected' => 'default' === $offer->getSettings()->getPopupLayout(),
								),
								'simple'  => array(
										'label'       => __( 'Narrow',
												'cancellation-surveys-offers-woocommerce-subscriptions' ),
										'is_selected' => 'simple' === $offer->getSettings()->getPopupLayout(),
								),
								'split'   => array(
										'label'       => __( 'Split (Sidebar)',
												'cancellation-surveys-offers-woocommerce-subscriptions' ),
										'is_selected' => 'split' === $offer->getSettings()->getPopupLayout(),
								),
						),
				) );

				FormTab::renderInputRow( array(
						'id'          => 'settings_accent_color',
						'type'        => 'color',
						'value'       => $offer->getSettings()->getAccentColor(),
						'label'       => __( 'Accent Color', 'cancellation-surveys-offers-woocommerce-subscriptions' ),
						'description' => __( 'Choose the color that will be used for the main elements of the offer popup.',
								'cancellation-surveys-offers-woocommerce-subscriptions' ),
				) );

				FormTab::renderInputRow( array(
						'id'          => 'settings_background_image',
						'type'        => 'image',
						'value'       => $offer->getSettings()->getBackgroundImage(),
						'label'       => __( 'Sidebar Image', 'cancellation-surveys-offers-woocommerce-subscriptions' ),
						'description' => __( 'Upload an image for the sidebar (Split Layout only).',
								'cancellation-surveys-offers-woocommerce-subscriptions' ),
				) );
			?>
		</div>
		<?php
	}
}
