<?php
/**
 * Export Wizard - Step 4 (Run Export) - Categories.
 *
 * @package PrimeLink
 */

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

$export_id = isset( $_GET['export_id'] ) ? absint( $_GET['export_id'] ) : 0;
$mt_primelink_settings = get_option( 'mt_primelink_settings', array() );
?>
<div class="mt_primelink-summary-eyebrow"><?php esc_html_e( 'Step 4 · Run Export', 'primelink' ); ?></div>
<h2><?php esc_html_e( 'Run Export', 'primelink' ); ?></h2>
<input type="hidden" id="mt-primelink-step" value="4">

<div class="mt_primelink-step mt_primelink-export-step-4" data-export-id="<?php echo esc_attr( $export_id ); ?>">

    <section class="mt_primelink-card mt_primelink-card--glass">
        <div class="mt_primelink-card-header">
            <!-- Removed duplicate "Run Export" heading -->
        </div>

        <div class="mt_primelink-card-body">
            <div class="mt_primelink-run-header">
                <div>
                    <div class="mt_primelink-summary-eyebrow"><?php esc_html_e( 'Status', 'primelink' ); ?></div>
                    <div class="mt_primelink-run-status" id="mt_primelink-export-status-pill"><?php esc_html_e( 'Idle', 'primelink' ); ?></div>
                </div>
                <div class="mt_primelink-run-actions">
                    <button type="button" class="button button-primary" id="mt_primelink-start-export">
                        <?php esc_html_e( 'Start Export', 'primelink' ); ?>
                    </button>
                    <button type="button" class="button" id="mt_primelink-start-export-bg">
                        <?php esc_html_e( 'Run in Background', 'primelink' ); ?>
                    </button>
                    <button type="button" class="button" id="mt_primelink-pause-export" style="display:none;">
                        <?php esc_html_e( 'Pause', 'primelink' ); ?>
                    </button>
                    <button type="button" class="button" id="mt_primelink-resume-export" style="display:none;">
                        <?php esc_html_e( 'Resume', 'primelink' ); ?>
                    </button>
                    <button type="button" class="button" id="mt_primelink-schedule-export">
                        <?php esc_html_e( 'Schedule', 'primelink' ); ?>
                    </button>
                </div>
            </div>

            <label class="mt_primelink-check" style="margin:6px 0 12px;">
                <input type="checkbox" id="mt_primelink-export-bg-notify" checked>
                <?php esc_html_e( 'Show a quick toast when background run starts', 'primelink' ); ?>
            </label>
            <div class="muted" id="mt_primelink-export-bg-note" style="margin-bottom:12px; display:none;">
                <?php esc_html_e( 'Running in background. You can navigate away; progress will continue.', 'primelink' ); ?>
            </div>

            <div class="mt_primelink-run-shell">
                <div class="mt_primelink-progress-wrap">
                    <div class="mt_primelink-progress-bar">
                        <div class="mt_primelink-progress-bar__inner" id="mt_primelink-export-progress-bar" style="width:0%;"></div>
                    </div>
                    <div class="mt_primelink-progress-meta">
                        <span class="mt_primelink-progress-pill" id="mt_primelink-export-progress-text">0%</span>
                        <span class="mt_primelink-progress-pill" id="mt_primelink-export-progress-count">0 / 0</span>
                        <span class="mt_primelink-progress-pill" id="mt_primelink-export-progress-status"><?php esc_html_e( 'Idle', 'primelink' ); ?></span>
                    </div>
                </div>

                <div class="mt_primelink-run-stats">
                    <div class="mt_primelink-run-stat">
                        <div class="mt_primelink-stat-label"><?php esc_html_e( 'Total categories', 'primelink' ); ?></div>
                        <div class="mt_primelink-stat-value" id="mt_primelink-export-total">0</div>
                    </div>
                    <div class="mt_primelink-run-stat">
                        <div class="mt_primelink-stat-label"><?php esc_html_e( 'Exported', 'primelink' ); ?></div>
                        <div class="mt_primelink-stat-value" id="mt_primelink-export-current">0</div>
                    </div>
                </div>
            </div>

            <div class="mt_primelink-run-log glass" id="mt_primelink-export-log">
                <div class="mt_primelink-run-log__placeholder"><?php esc_html_e( 'Logs will appear here as the export runs.', 'primelink' ); ?></div>
            </div>

            <!-- Destination Options -->
            <div class="mt_primelink-card mt_primelink-card--glass" style="margin-top:16px;">
                <div class="mt_primelink-card-header">
                    <h3><?php esc_html_e( 'Export Destination', 'primelink' ); ?></h3>
                </div>
                <div class="mt_primelink-card-body">
                    <label class="mt-primelink-choice-row glass">
                        <input type="radio" name="destination" value="download" checked>
                        <div>
                            <strong><?php esc_html_e( 'Download Locally', 'primelink' ); ?></strong>
                            <p class="muted"><?php esc_html_e( 'Download the export file directly to your computer', 'primelink' ); ?></p>
                        </div>
                    </label>

                    <label class="mt-primelink-choice-row glass">
                        <input type="radio" name="destination" value="ftp">
                        <div>
                            <strong><?php esc_html_e( 'Upload to FTP', 'primelink' ); ?></strong>
                            <p class="muted"><?php esc_html_e( 'Upload the export file to an FTP server', 'primelink' ); ?></p>
                        </div>
                    </label>

                    <label class="mt-primelink-choice-row glass">
                        <input type="radio" name="destination" value="dropbox">
                        <div>
                            <strong><?php esc_html_e( 'Upload to Dropbox', 'primelink' ); ?></strong>
                            <p class="muted"><?php esc_html_e( 'Upload the export file to Dropbox', 'primelink' ); ?></p>
                        </div>
                    </label>

                    <label class="mt-primelink-choice-row glass">
                        <input type="radio" name="destination" value="gdrive">
                        <div>
                            <strong><?php esc_html_e( 'Upload to Google Drive', 'primelink' ); ?></strong>
                            <p class="muted"><?php esc_html_e( 'Upload the export file to Google Drive', 'primelink' ); ?></p>
                        </div>
                    </label>

                    <label class="mt-primelink-choice-row glass">
                        <input type="radio" name="destination" value="onedrive">
                        <div>
                            <strong><?php esc_html_e( 'Upload to OneDrive', 'primelink' ); ?></strong>
                            <p class="muted"><?php esc_html_e( 'Upload the export file to OneDrive', 'primelink' ); ?></p>
                        </div>
                    </label>

                    <div id="mt_primelink-export-download-link" style="margin-top:16px;display:none;">
                        <a href="#" class="button button-primary" id="mt_primelink-download-export-file" download>
                            <?php esc_html_e( 'Download Export File', 'primelink' ); ?>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>

