<?php

/**
 * Back to top features related code goes here
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
// Enqueue nonce for JS
wp_localize_script( 'sapmfly-admin-script', 'sapmfly_ajax', [
    'nonce' => wp_create_nonce( 'sapmfly_color_save' ),
] );
?>

<div class="back-top-top-wrap toggle-block-bg">

    <label class="sapmfly-switch-update">
        <div class="back-to-top-header toggle-header">
            <?php 
echo esc_html__( 'Enable back to top button', 'minifly' );
?>
            <input type="checkbox" class="sapmfly-setting-toggle" name="sapmfly_enable_back_top_button" <?php 
checked( $back_top_enabled, 'yes' );
?> />
            <span class="sapmfly-slider"></span>
        </div>
    </label>

    <div class="sapmfly-toggle-resource-body">
        <div class="sapmfly-docs">
            <p>
                <a href="https://brainywp.com/blog/how-to-add-wordpress-back-to-top-button-free/" target="_blank">
                    <?php 
echo esc_html__( 'Docs', 'minifly' );
?>
                </a>
            </p>
        </div>
        <div class="sapmfly-tags">
            <p><?php 
echo esc_html__( 'Popular', 'minifly' );
?></p>
        </div>
        <?php 
?>
            <div class="sapmfly-adjust" onclick="miniflyShowPopup(); return false;">
                <p><?php 
echo esc_html__( 'Pro Customization', 'minifly' );
?></p>
            </div>
        <?php 
?>
    </div>

    <?php 
do_action( 'sapmfly_after_back_to_top_option' );
?>
</div>

<!-- Popup Overlay -->
<div class="sapmfly-popup-overlay" style="display: none;">
    <div class="sapmfly-popup-modal">
        <div class="sapmfly-popup-notice" style="display: none;">
            <?php 
echo esc_html__( 'Settings saved successfully!', 'minifly' );
?>
        </div>

        <h3><?php 
echo esc_html__( 'Customize Back to Top Color', 'minifly' );
?></h3>

        <label for="sapmfly_bg_color"><?php 
echo esc_html__( 'Background Color:', 'minifly' );
?></label>
        <input type="text" id="sapmfly_bg_color" name="sapmfly_bg_color"
            value="<?php 
echo esc_attr( get_option( 'sapmfly_back_top_bg_color', '#4CAF50' ) );
?>"
            placeholder="#4CAF50" />

        <label for="sapmfly_hv_color"><?php 
echo esc_html__( 'Hover Color:', 'minifly' );
?></label>
        <input type="text" id="sapmfly_hv_color" name="sapmfly_hv_color"
            value="<?php 
echo esc_attr( get_option( 'sapmfly_back_top_hv_color', '#4CAF50' ) );
?>"
            placeholder="#4CAF50" />

        <button type="button" class="sapmfly-save-customization"><?php 
echo esc_html__( 'Save', 'minifly' );
?></button>
        <button type="button" class="sapmfly-clear-customization"><?php 
echo esc_html__( 'Clear', 'minifly' );
?></button>
        <button type="button" class="sapmfly-close-popup"><?php 
echo esc_html__( 'Close', 'minifly' );
?></button>
    </div>
</div>


<!-- Hidden Modal Popup -->
<div id="minifly-premium-popup" class="minifly-pro-popup">
    <p>Unlock the feature with <a href="https://brainywp.com/minifly-pricing/" target="_blank" style="color: #288acb; text-decoration: underline; font-weight: bold;">pro version</a></p>
    <button type="button" onclick="miniflyClosePopup()"><?php 
echo esc_html__( 'Close', 'minifly' );
?></button>
</div>

<!-- Overlay -->
<div id="minifly-premium-overlay" class="minifly-pro-overlay" onclick="miniflyClosePopup()"></div>