<?php

/**
 * Progress bar related code goes here
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
$sapmfly_sitewide_progress_bar = get_option( 'sapmfly_enable_progress_bar', 'no' );
// Localize nonce for AJAX
wp_localize_script( 'sapmfly-admin-script', 'sapmfly_pb_data', [
    'nonce' => wp_create_nonce( 'sapmfly_pb_save' ),
] );
?>

<!-- site-wide progress bar code goes here -->
<div class="progress-bar-wrap toggle-block-bg">

    <label class="sapmfly-switch-update">
        <div class="progress-bar-header toggle-header">
            <?php 
echo esc_html__( 'Add site-wide progress bar', 'minifly' );
?>
            <input type="checkbox" class="sapmfly-setting-toggle" name="sapmfly_enable_progress_bar" <?php 
checked( $progress_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-reading-progress-bar-wordpress-site/" target="_blank">
                    <?php 
echo esc_html__( 'Docs', 'minifly' );
?>
                </a>
            </p>
        </div>
        <div class="sapmfly-tags">
            <p><?php 
echo esc_html__( 'New Feature', 'minifly' );
?></p>
        </div>
        <?php 
?>
            <div class="sapmfly-adjust sapmfly-open-pb-popup">
                <p><?php 
echo esc_html__( 'Pro Customization', 'minifly' );
?></p>
            </div>
        <?php 
?>
    </div>
</div>


<!-- Popup Overlay -->
<div class="sapmfly-pb-popup-overlay" style="display: none;">
    <div class="sapmfly-pb-popup-modal">
        <?php 
if ( $sapmfly_sitewide_progress_bar == 'yes' ) {
    ?>
            <?php 
    ?>

                <div class="sapmfly-pro-available-label">
                    <a href="https://brainywp.com/minifly/pricing/" target="_blank">

                        <!-- Reply Text -->
                        <h4><?php 
    echo esc_html__( 'Progress bar enabled! Customization feature available at pro subscription only.', 'minifly' );
    ?></h4>

                        <p class="pro-label-href"><?php 
    echo esc_html__( 'Click here to unlock the feature with PRO plan', 'minifly' );
    ?></p>

                        <div class="sapmfly-pb-input-group">
                            <label for="sapmfly_pb_color"><?php 
    echo esc_html__( 'Color (hex):', 'minifly' );
    ?></label>
                            <input type="text" id="sapmfly_pb_color" placeholder="#ff0000" disabled />
                        </div>

                        <div class="sapmfly-pb-input-group">
                            <label for="sapmfly_pb_height"><?php 
    echo esc_html__( 'Height (px):', 'minifly' );
    ?></label>
                            <input type="number" id="sapmfly_pb_height" min="0" placeholder="5" disabled />
                        </div>
                        <br /><br />

                        <button type="button" class="sapmfly-save-pb sapmfly-popup-btn" disabled><?php 
    echo esc_html__( 'Save', 'minifly' );
    ?></button>
                        <button type="button" class="sapmfly-clear-pb sapmfly-popup-btn" disabled><?php 
    echo esc_html__( 'Clear', 'minifly' );
    ?></button>
                        <button type="button" class="sapmfly-close-popup sapmfly-popup-btn" disabled><?php 
    echo esc_html__( 'Close', 'minifly' );
    ?></button>
                    </a>
                </div>
            <?php 
    ?>
        <?php 
} else {
    ?>
            <div class="sapmfly-toggle-blocked">

                <!-- Section title -->
                <h3><?php 
    echo esc_html__( 'Please toggle ON and save changes to use the feature.', 'minifly' );
    ?></h3>

                <a href="https://brainywp.com/minifly/pricing/" target="_blank">

                    <p class="pro-label-href"><?php 
    echo esc_html__( 'The customization available only at PRO plan', 'minifly' );
    ?></p>
                </a>

                <div class="sapmfly-pb-input-group">
                    <label for="sapmfly_pb_color"><?php 
    echo esc_html__( 'Color (hex):', 'minifly' );
    ?></label>
                    <input type="text" id="sapmfly_pb_color" placeholder="#ff0000" disabled />
                </div>

                <div class="sapmfly-pb-input-group">
                    <label for="sapmfly_pb_height"><?php 
    echo esc_html__( 'Height (px):', 'minifly' );
    ?></label>
                    <input type="number" id="sapmfly_pb_height" min="0" placeholder="5" disabled />
                </div>
                <br /><br />

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