<?php
/**
 * Deactivation feedback modal template.
 *
 * This template displays a feedback modal when the user attempts to deactivate the plugin.
 *
 * @package Limb_Chatbot
 * @since 1.0.0
 *
 * @var array $reasons        Array of deactivation reasons.
 * @var array $localize_data  Localized data for JavaScript.
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div id="lbaic-deactivation-modal">
	<div class="lbaic-deactivation-modal-overlay"></div>
	<div class="lbaic-deactivation-modal-content">
		<div class="lbaic-deactivation-header">
			<div class="lbaic-deactivation-header-title">
				<img src="<?php echo esc_url( Limb_Chatbot()->get_plugin_dir_url() . 'resources/icons/plugin/logo-mini.svg' ); ?>" alt="Limb Chatbot" class="lbaic-logo-mini">
				<h2>
					<?php esc_html_e( 'Quick Feedback', 'limb-chatbot' ); ?>
				</h2>
			</div>
			<button type="button" class="lbaic-deactivation-modal-close" aria-label="<?php esc_attr_e( 'Close', 'limb-chatbot' ); ?>">
                <svg viewBox="0 0 24 24" id="lbaic-settings-close">
                    <path d="M5 17.59L6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59z"></path>
                </svg>
            </button>
		</div>
		<p>
			<?php esc_html_e( 'If you have a moment, please let us know why you are deactivating:', 'limb-chatbot' ); ?>
		</p>
		<form id="lbaic-deactivation-form">
			<ul class="lbaic-primary-reasons">
				<?php foreach ( $reasons as $primary_value => $primary_data ) : ?>
					<li class="lbaic-primary-reason lbaic-reason-<?php echo esc_attr( $primary_value ); ?>">
						<label>
							<input type="radio" name="lbaic_deactivation_reason" value="<?php echo esc_attr( $primary_value ); ?>" />
							<span><?php echo esc_html( $primary_data['label'] ); ?></span>
						</label>
						<?php if ( ! empty( $primary_data['sub_reasons'] ) ) : ?>
							<ul class="lbaic-sub-reasons" data-parent="<?php echo esc_attr( $primary_value ); ?>">
								<?php foreach ( $primary_data['sub_reasons'] as $sub_value => $sub_label ) : ?>
									<li class="lbaic-sub-reason lbaic-sub-reason-<?php echo esc_attr( $sub_value ); ?>">
										<label>
											<input type="radio" name="lbaic_deactivation_sub_reason" value="<?php echo esc_attr( $sub_value ); ?>" />
											<span><?php echo esc_html( $sub_label ); ?></span>
										</label>
										<?php if ( 'other' === $sub_value ) : ?>
											<textarea name="lbaic_deactivation_reason_other" rows="3" placeholder="<?php esc_attr_e( 'Please tell us more details.', 'limb-chatbot' ); ?>" aria-label="<?php esc_attr_e( 'Additional feedback', 'limb-chatbot' ); ?>"></textarea>
										<?php endif; ?>
									</li>
								<?php endforeach; ?>
							</ul>
						<?php endif; ?>
					</li>
				<?php endforeach; ?>
			</ul>
			<div class="lbaic-deactivation-footer">
				<button type="button" id="lbaic-deactivation-submit" class="button button-primary">
					<?php esc_html_e( 'Submit & Deactivate', 'limb-chatbot' ); ?>
				</button>
				<button type="button" id="lbaic-deactivation-skip" class="button button-secondary">
					<?php esc_html_e( 'Skip & Deactivate', 'limb-chatbot' ); ?>
				</button>
			</div>
		</form>
	</div>
</div>


