<?php
/**
 * Export Wizard - Step 3 (Export Options) - Orders.
 *
 * @package PrimeLink
 */

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

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

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

    <!-- Export Format -->
    <section class="mt_primelink-card mt_primelink-card--glass">
        <div class="mt_primelink-card-header">
            <div>
                <h3><?php esc_html_e( 'Export Format', 'primelink' ); ?></h3>
                <p class="description" style="margin:4px 0 0;">
                    <?php esc_html_e( 'Choose the file format for your export and configure format-specific options.', 'primelink' ); ?>
                </p>
            </div>
        </div>
        <div class="mt_primelink-card-body">
            <div class="mt_primelink-form-row">
                <label for="mt_primelink-export-format"><?php esc_html_e( 'File Format', 'primelink' ); ?></label>
                <select id="mt_primelink-export-format" name="format" class="widefat">
                    <option value="csv"><?php esc_html_e( 'CSV (Comma Separated Values)', 'primelink' ); ?></option>
                    <option value="xml"><?php esc_html_e( 'XML (Extensible Markup Language)', 'primelink' ); ?></option>
                    <option value="xlsx"><?php esc_html_e( 'XLSX (Excel Spreadsheet)', 'primelink' ); ?></option>
                </select>
                <p class="description">
                    <?php esc_html_e( 'Select the format for your export file. CSV is recommended for most use cases.', 'primelink' ); ?>
                </p>
            </div>

            <div id="mt_primelink-csv-options" class="mt_primelink-format-options" style="margin-top:16px;padding-top:16px;border-top:1px solid rgba(255,255,255,0.1);">
                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-csv-delimiter"><?php esc_html_e( 'CSV Delimiter', 'primelink' ); ?></label>
                    <select id="mt_primelink-csv-delimiter" name="csv_delimiter" class="widefat">
                        <option value=","><?php esc_html_e( 'Comma (,)', 'primelink' ); ?></option>
                        <option value=";"><?php esc_html_e( 'Semicolon (;)', 'primelink' ); ?></option>
                        <option value="\t"><?php esc_html_e( 'Tab', 'primelink' ); ?></option>
                    </select>
                    <p class="description">
                        <?php esc_html_e( 'Choose the character used to separate values in the CSV file.', 'primelink' ); ?>
                    </p>
                </div>
                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-csv-encoding"><?php esc_html_e( 'Character Encoding', 'primelink' ); ?></label>
                    <select id="mt_primelink-csv-encoding" name="csv_encoding" class="widefat">
                        <option value="UTF-8">UTF-8</option>
                        <option value="UTF-8-BOM">UTF-8 with BOM</option>
                        <option value="ISO-8859-1">ISO-8859-1 (Latin-1)</option>
                    </select>
                    <p class="description">
                        <?php esc_html_e( 'Select the character encoding. UTF-8 is recommended for international characters.', 'primelink' ); ?>
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Order Filters -->
    <section class="mt_primelink-card mt_primelink-card--glass">
        <div class="mt_primelink-card-header">
            <div>
                <h3><?php esc_html_e( 'Order Filters', 'primelink' ); ?></h3>
                <p class="description" style="margin:4px 0 0;">
                    <?php esc_html_e( 'Filter which orders to include in the export based on status and date range.', 'primelink' ); ?>
                </p>
            </div>
        </div>
        <div class="mt_primelink-card-body">
            <div class="mt_primelink-form-row">
                <label for="mt_primelink-export-status"><?php esc_html_e( 'Order Status', 'primelink' ); ?></label>
                <select id="mt_primelink-export-status" name="filters[status]" class="widefat">
                    <option value="any"><?php esc_html_e( 'All Statuses', 'primelink' ); ?></option>
                    <?php
                    $order_statuses = wc_get_order_statuses();
                    foreach ( $order_statuses as $status_key => $status_label ) :
                        ?>
                        <option value="<?php echo esc_attr( $status_key ); ?>">
                            <?php echo esc_html( $status_label ); ?>
                        </option>
                    <?php endforeach; ?>
                </select>
                <p class="description">
                    <?php esc_html_e( 'Select which order statuses to include in the export.', 'primelink' ); ?>
                </p>
            </div>

            <div class="mt_primelink-form-row" style="margin-top:16px;">
                <label for="mt_primelink-export-date-from"><?php esc_html_e( 'Date From', 'primelink' ); ?></label>
                <input type="date" id="mt_primelink-export-date-from" name="filters[date_from]" class="widefat" />
                <p class="description">
                    <?php esc_html_e( 'Export orders created from this date onwards. Leave empty for no start date.', 'primelink' ); ?>
                </p>
            </div>

            <div class="mt_primelink-form-row" style="margin-top:16px;">
                <label for="mt_primelink-export-date-to"><?php esc_html_e( 'Date To', 'primelink' ); ?></label>
                <input type="date" id="mt_primelink-export-date-to" name="filters[date_to]" class="widefat" />
                <p class="description">
                    <?php esc_html_e( 'Export orders created up to this date. Leave empty for no end date.', 'primelink' ); ?>
                </p>
            </div>
        </div>
    </section>

    <!-- Advanced Options -->
    <section class="mt_primelink-card mt_primelink-card--glass">
        <div class="mt_primelink-card-header">
            <div>
                <h3><?php esc_html_e( 'Advanced Options', 'primelink' ); ?></h3>
                <p class="description" style="margin:4px 0 0;">
                    <?php esc_html_e( 'Configure additional export settings and limits.', 'primelink' ); ?>
                </p>
            </div>
        </div>
        <div class="mt_primelink-card-body">
            <div class="mt_primelink-form-row">
                <label class="mt_primelink-check">
                    <input type="checkbox" id="mt_primelink-export-include-headers" name="include_headers" checked />
                    <strong><?php esc_html_e( 'Include Column Headers', 'primelink' ); ?></strong>
                </label>
                <p class="description" style="margin-top:4px;">
                    <?php esc_html_e( 'Include a header row with column names as the first line of the export file.', 'primelink' ); ?>
                </p>
            </div>

            <div class="mt_primelink-form-row" style="margin-top:16px;padding-top:16px;border-top:1px solid rgba(255,255,255,0.1);">
                <label for="mt_primelink-export-limit"><?php esc_html_e( 'Limit Number of Orders', 'primelink' ); ?></label>
                <input type="number" id="mt_primelink-export-limit" name="limit" min="0" value="0" class="widefat" style="max-width:200px;" />
                <p class="description">
                    <?php esc_html_e( 'Set to 0 to export all matching orders. Enter a number to limit the export to that many orders.', 'primelink' ); ?>
                </p>
            </div>

            <div class="mt_primelink-form-row" style="margin-top:16px;padding-top:16px;border-top:1px solid rgba(255,255,255,0.1);">
                <label class="mt_primelink-check">
                    <input type="checkbox" id="mt_primelink-export-speed-optimization" />
                    <?php esc_html_e( 'Export Speed Optimization', 'primelink' ); ?>
                </label>
                <p class="description" style="margin-top:4px;">
                    <?php esc_html_e( 'Enable optimizations to speed up large exports. May use more server resources.', 'primelink' ); ?>
                </p>
            </div>

            <div class="mt_primelink-form-row" style="margin-top:12px;">
                <label class="mt_primelink-check">
                    <input type="checkbox" id="mt_primelink-export-iterative-processing" checked />
                    <?php esc_html_e( 'Iterative, Piece-by-Piece Processing', 'primelink' ); ?>
                </label>
                <p class="description" style="margin-top:4px;">
                    <?php esc_html_e( 'Process export in chunks for better performance and memory management.', 'primelink' ); ?>
                </p>
            </div>

            <div class="mt_primelink-form-row" style="margin-top:12px;">
                <label for="mt_primelink-export-iteration-size"><?php esc_html_e( 'Records per iteration', 'primelink' ); ?></label>
                <input type="number" id="mt_primelink-export-iteration-size" min="1" max="500" value="20" style="max-width:200px;" />
                <p class="description">
                    <?php esc_html_e( 'Default: process 20 records per iteration in background.', 'primelink' ); ?>
                </p>
            </div>
        </div>
    </section>

    <!-- Incremental Export -->
    <section class="mt_primelink-card mt_primelink-card--glass">
        <div class="mt_primelink-card-header">
            <div>
                <h3><?php esc_html_e( 'Incremental Export', 'primelink' ); ?></h3>
                <p class="description" style="margin:4px 0 0;">
                    <?php esc_html_e( 'Export only orders that have been modified since the last export, saving time and bandwidth.', 'primelink' ); ?>
                </p>
            </div>
        </div>
        <div class="mt_primelink-card-body">
            <label class="mt_primelink-check">
                <input type="checkbox" id="mt_primelink-export-incremental-enabled" />
                <strong><?php esc_html_e( 'Enable Incremental Export', 'primelink' ); ?></strong>
            </label>
            <p class="description" style="margin-top:4px;">
                <?php esc_html_e( 'Skip exporting orders that haven\'t changed since last export. Uses date_modified to detect changes.', 'primelink' ); ?>
            </p>

            <div id="mt_primelink-export-incremental-options" style="display:none;margin-top:12px;padding-top:12px;border-top:1px solid rgba(255,255,255,0.1);">
                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-incremental-since"><?php esc_html_e( 'Export orders modified since', 'primelink' ); ?></label>
                    <input type="datetime-local" id="mt_primelink-export-incremental-since" />
                    <p class="description">
                        <?php esc_html_e( 'Leave empty to use the last export date. Only orders modified after this date will be exported.', 'primelink' ); ?>
                    </p>
                </div>

                <div class="mt_primelink-form-row" style="margin-top:12px;">
                    <label class="mt_primelink-check">
                        <input type="checkbox" id="mt_primelink-export-incremental-skip-unchanged" />
                        <?php esc_html_e( 'Skip unchanged orders completely', 'primelink' ); ?>
                    </label>
                    <p class="description">
                        <?php esc_html_e( 'If enabled, unchanged orders won\'t be processed at all (faster). If disabled, they\'ll be marked as skipped in logs.', 'primelink' ); ?>
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Test Mode -->
    <section class="mt_primelink-card mt_primelink-card--glass">
        <div class="mt_primelink-card-header">
            <div>
                <h3><?php esc_html_e( 'Test Mode', 'primelink' ); ?></h3>
                <p class="description" style="margin:4px 0 0;">
                    <?php esc_html_e( 'Test your export configuration without generating a full export file.', 'primelink' ); ?>
                </p>
            </div>
        </div>
        <div class="mt_primelink-card-body">
            <label class="mt_primelink-check">
                <input type="checkbox" id="mt_primelink-export-test-mode" />
                <strong><?php esc_html_e( 'Enable Test Mode (Dry Run)', 'primelink' ); ?></strong>
            </label>
            <p class="description" style="margin-top:4px;">
                <?php esc_html_e( 'When enabled, the export will simulate all operations and show preview without generating the actual file. Perfect for testing your configuration.', 'primelink' ); ?>
            </p>

            <div id="mt_primelink-export-test-mode-options" style="display:none;margin-top:12px;padding-top:12px;border-top:1px solid rgba(255,255,255,0.1);">
                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-test-limit"><?php esc_html_e( 'Test Records Limit', 'primelink' ); ?></label>
                    <input type="number" id="mt_primelink-export-test-limit" min="1" max="1000" value="10" style="max-width:200px;" />
                    <p class="description">
                        <?php esc_html_e( 'Number of records to process in test mode (for faster testing).', 'primelink' ); ?>
                    </p>
                </div>

                <div class="mt_primelink-form-row" style="margin-top:12px;">
                    <button type="button" class="button button-primary" id="mt_primelink-run-test-export">
                        <?php esc_html_e( 'Run Test Export', 'primelink' ); ?>
                    </button>
                    <p class="description" style="margin-top:4px;">
                        <?php esc_html_e( 'Click to run a test export and see preview results without generating the actual file.', 'primelink' ); ?>
                    </p>
                </div>

                <div id="mt_primelink-export-test-results" style="display:none;margin-top:16px;padding:12px;background:rgba(0,0,0,0.2);border-radius:4px;">
                    <h4 style="margin-top:0;"><?php esc_html_e( 'Test Results', 'primelink' ); ?></h4>
                    <div id="mt_primelink-export-test-results-content"></div>
                </div>
            </div>
        </div>
    </section>

    <!-- Notifications -->
    <section class="mt_primelink-card mt_primelink-card--glass">
        <div class="mt_primelink-card-header">
            <h3><?php esc_html_e( 'Notifications (this export only)', 'primelink' ); ?></h3>
        </div>
        <div class="mt_primelink-card-body">
            <label class="mt_primelink-check">
                <input type="checkbox" id="mt_primelink-export-notify-override" />
                <?php esc_html_e( 'Use custom notification settings for this export', 'primelink' ); ?>
            </label>
            <div id="mt_primelink-export-notify-override-wrap" style="display:none;margin-top:10px;">
                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-notify-email-override"><?php esc_html_e( 'Notify email', 'primelink' ); ?></label>
                    <input type="email" id="mt_primelink-export-notify-email-override" placeholder="<?php esc_attr_e( 'you@example.com', 'primelink' ); ?>" />
                </div>
                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-notify-finish-override"><?php esc_html_e( 'Email template (finish)', 'primelink' ); ?></label>
                    <textarea id="mt_primelink-export-notify-finish-override" rows="3" placeholder="<?php esc_attr_e( 'Export #{export_id} finished. Status: {status}. Orders exported: {total}', 'primelink' ); ?>"></textarea>
                    <p class="description"><?php esc_html_e( 'Placeholders: {export_id}, {status}, {total}, {file_url}', 'primelink' ); ?></p>
                </div>
                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-notify-error-override"><?php esc_html_e( 'Email template (error)', 'primelink' ); ?></label>
                    <textarea id="mt_primelink-export-notify-error-override" rows="3" placeholder="<?php esc_attr_e( 'Export #{export_id} finished with errors: {errors}', 'primelink' ); ?>"></textarea>
                </div>
                <div class="mt_primelink-form-row">
                    <label class="mt_primelink-check">
                        <input type="checkbox" id="mt_primelink-export-email-attachment" />
                        <?php esc_html_e( 'Attach export file to email', 'primelink' ); ?>
                    </label>
                    <p class="description">
                        <?php esc_html_e( 'Send the exported file as an email attachment when export completes.', 'primelink' ); ?>
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Scheduling -->
    <section class="mt_primelink-card mt_primelink-card--glass">
        <div class="mt_primelink-card-header">
            <h3><?php esc_html_e( 'Automatic Scheduling with Background Export', 'primelink' ); ?></h3>
        </div>

        <div class="mt_primelink-card-body">

            <label class="mt_primelink-check">
                <input type="checkbox" id="mt_primelink-export-enable-schedule" />
                <?php esc_html_e( 'Enable Background Export Schedule', 'primelink' ); ?>
            </label>

            <div id="mt_primelink-export-schedule-wrap" style="display:none;margin-top:10px;">

                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-schedule-name"><?php esc_html_e( 'Friendly Name', 'primelink' ); ?></label>
                    <input type="text" id="mt_primelink-export-schedule-name" placeholder="<?php esc_attr_e( 'e.g. Daily Order Export', 'primelink' ); ?>" />
                </div>

                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-schedule-type"><?php esc_html_e( 'Schedule Type', 'primelink' ); ?></label>
                    <select id="mt_primelink-export-schedule-type" class="widefat">
                        <option value="preset"><?php esc_html_e( 'Preset Intervals', 'primelink' ); ?></option>
                        <option value="custom"><?php esc_html_e( 'Custom Cron Expression', 'primelink' ); ?></option>
                        <option value="advanced"><?php esc_html_e( 'Advanced Options', 'primelink' ); ?></option>
                    </select>
                </div>

                <!-- Preset Intervals -->
                <div id="mt_primelink-export-schedule-preset-wrap" class="mt_primelink-export-schedule-type-wrap">
                    <div class="mt_primelink-form-row">
                        <label for="mt_primelink-export-schedule-interval"><?php esc_html_e( 'Export Interval', 'primelink' ); ?></label>
                        <select id="mt_primelink-export-schedule-interval" class="widefat">
                            <option value="hourly"><?php esc_html_e( 'Hourly', 'primelink' ); ?></option>
                            <option value="twicedaily"><?php esc_html_e( 'Twice Daily', 'primelink' ); ?></option>
                            <option value="daily" selected><?php esc_html_e( 'Daily', 'primelink' ); ?></option>
                            <option value="weekly"><?php esc_html_e( 'Weekly', 'primelink' ); ?></option>
                            <option value="monthly"><?php esc_html_e( 'Monthly', 'primelink' ); ?></option>
                        </select>
                    </div>

                    <div class="mt_primelink-form-row" id="mt_primelink-export-schedule-weekly-options" style="display:none;">
                        <label><?php esc_html_e( 'Days of Week', 'primelink' ); ?></label>
                        <div style="display:grid;grid-template-columns:repeat(7, 1fr);gap:4px;margin-top:4px;">
                            <label class="mt_primelink-check"><input type="checkbox" class="mt_primelink-export-schedule-day" value="1" /> <?php esc_html_e( 'Mon', 'primelink' ); ?></label>
                            <label class="mt_primelink-check"><input type="checkbox" class="mt_primelink-export-schedule-day" value="2" /> <?php esc_html_e( 'Tue', 'primelink' ); ?></label>
                            <label class="mt_primelink-check"><input type="checkbox" class="mt_primelink-export-schedule-day" value="3" /> <?php esc_html_e( 'Wed', 'primelink' ); ?></label>
                            <label class="mt_primelink-check"><input type="checkbox" class="mt_primelink-export-schedule-day" value="4" /> <?php esc_html_e( 'Thu', 'primelink' ); ?></label>
                            <label class="mt_primelink-check"><input type="checkbox" class="mt_primelink-export-schedule-day" value="5" /> <?php esc_html_e( 'Fri', 'primelink' ); ?></label>
                            <label class="mt_primelink-check"><input type="checkbox" class="mt_primelink-export-schedule-day" value="6" /> <?php esc_html_e( 'Sat', 'primelink' ); ?></label>
                            <label class="mt_primelink-check"><input type="checkbox" class="mt_primelink-export-schedule-day" value="0" /> <?php esc_html_e( 'Sun', 'primelink' ); ?></label>
                        </div>
                        <p class="description"><?php esc_html_e( 'Select specific days. Leave all unchecked to use all days.', 'primelink' ); ?></p>
                    </div>

                    <div class="mt_primelink-form-row" id="mt_primelink-export-schedule-monthly-options" style="display:none;">
                        <label><?php esc_html_e( 'Days of Month', 'primelink' ); ?></label>
                        <input type="text" id="mt_primelink-export-schedule-month-days" placeholder="1,15,30" />
                        <p class="description"><?php esc_html_e( 'Comma-separated list (e.g. 1,15,30) or leave empty for first day of month.', 'primelink' ); ?></p>
                    </div>

                    <div class="mt_primelink-form-row">
                        <label for="mt_primelink-export-schedule-start"><?php esc_html_e( 'Start Time', 'primelink' ); ?></label>
                        <input type="time" id="mt_primelink-export-schedule-start" value="00:00" />
                        <p class="description">
                            <?php esc_html_e( 'Default: current time if left empty.', 'primelink' ); ?>
                        </p>
                    </div>
                </div>

                <!-- Custom Cron Expression -->
                <div id="mt_primelink-export-schedule-custom-wrap" class="mt_primelink-export-schedule-type-wrap" style="display:none;">
                    <div class="mt_primelink-form-row">
                        <label for="mt_primelink-export-schedule-cron"><?php esc_html_e( 'Cron Expression', 'primelink' ); ?></label>
                        <input type="text" id="mt_primelink-export-schedule-cron" placeholder="0 2 * * *" style="font-family:monospace;" />
                        <p class="description">
                            <?php esc_html_e( 'Format: minute hour day month weekday (e.g. "0 2 * * *" = daily at 2:00 AM).', 'primelink' ); ?>
                            <a href="https://crontab.guru/" target="_blank"><?php esc_html_e( 'Cron expression helper', 'primelink' ); ?></a>
                        </p>
                    </div>
                </div>

                <!-- Advanced Options -->
                <div id="mt_primelink-export-schedule-advanced-wrap" class="mt_primelink-export-schedule-type-wrap" style="display:none;">
                    <div class="mt_primelink-form-row">
                        <label><?php esc_html_e( 'Multiple Time Slots', 'primelink' ); ?></label>
                        <div id="mt_primelink-export-schedule-times-wrap">
                            <div class="mt_primelink-export-schedule-time-row" style="display:grid;grid-template-columns:1fr auto;gap:8px;margin-bottom:4px;">
                                <input type="time" class="mt_primelink-export-schedule-time-slot" value="00:00" />
                                <button type="button" class="button mt_primelink-export-schedule-time-remove" style="display:none;"><?php esc_html_e( 'Remove', 'primelink' ); ?></button>
                            </div>
                        </div>
                        <button type="button" class="button" id="mt_primelink-export-schedule-time-add" style="margin-top:4px;"><?php esc_html_e( 'Add Time Slot', 'primelink' ); ?></button>
                        <p class="description"><?php esc_html_e( 'Run export at multiple times per day.', 'primelink' ); ?></p>
                    </div>

                    <div class="mt_primelink-form-row">
                        <label><?php esc_html_e( 'Weekday Filter', 'primelink' ); ?></label>
                        <select id="mt_primelink-export-schedule-weekday-filter" class="widefat">
                            <option value=""><?php esc_html_e( 'All days', 'primelink' ); ?></option>
                            <option value="weekdays"><?php esc_html_e( 'Weekdays only (Mon-Fri)', 'primelink' ); ?></option>
                            <option value="weekends"><?php esc_html_e( 'Weekends only (Sat-Sun)', 'primelink' ); ?></option>
                        </select>
                    </div>
                </div>

                <!-- Common Advanced Options -->
                <div class="mt_primelink-form-row" style="margin-top:12px;padding-top:12px;border-top:1px solid rgba(255,255,255,0.1);">
                    <label for="mt_primelink-export-schedule-timezone"><?php esc_html_e( 'Timezone', 'primelink' ); ?></label>
                    <select id="mt_primelink-export-schedule-timezone" class="widefat">
                        <?php
                        $timezones = timezone_identifiers_list();
                        $wp_timezone = wp_timezone_string();
                        foreach ( $timezones as $tz ) {
                            $selected = ( $tz === $wp_timezone ) ? 'selected' : '';
                            echo '<option value="' . esc_attr( $tz ) . '" ' . $selected . '>' . esc_html( $tz ) . '</option>';
                        }
                        ?>
                    </select>
                    <p class="description"><?php esc_html_e( 'Timezone for scheduled times. Default: WooCommerce timezone.', 'primelink' ); ?></p>
                </div>

                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-schedule-start-date"><?php esc_html_e( 'Start Date', 'primelink' ); ?></label>
                    <input type="date" id="mt_primelink-export-schedule-start-date" />
                    <p class="description"><?php esc_html_e( 'Optional: Schedule will start from this date. Leave empty to start immediately.', 'primelink' ); ?></p>
                </div>

                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-schedule-end-date"><?php esc_html_e( 'End Date', 'primelink' ); ?></label>
                    <input type="date" id="mt_primelink-export-schedule-end-date" />
                    <p class="description"><?php esc_html_e( 'Optional: Schedule will stop after this date. Leave empty for no end date.', 'primelink' ); ?></p>
                </div>

                <div class="mt_primelink-form-row">
                    <label for="mt_primelink-export-schedule-max-runs"><?php esc_html_e( 'Maximum Runs', 'primelink' ); ?></label>
                    <input type="number" id="mt_primelink-export-schedule-max-runs" min="1" placeholder="<?php esc_attr_e( 'Unlimited', 'primelink' ); ?>" />
                    <p class="description"><?php esc_html_e( 'Optional: Stop schedule after this many runs. Leave empty for unlimited.', 'primelink' ); ?></p>
                </div>

                <div class="mt_primelink-form-row">
                    <label class="mt_primelink-check">
                        <input type="checkbox" id="mt_primelink-export-schedule-retry-failure" />
                        <?php esc_html_e( 'Retry on failure', 'primelink' ); ?>
                    </label>
                    <div id="mt_primelink-export-schedule-retry-options" style="display:none;margin-top:8px;margin-left:24px;">
                        <label for="mt_primelink-export-schedule-retry-attempts"><?php esc_html_e( 'Max retry attempts', 'primelink' ); ?></label>
                        <input type="number" id="mt_primelink-export-schedule-retry-attempts" min="1" max="10" value="3" style="width:80px;" />
                        <label for="mt_primelink-export-schedule-retry-delay" style="margin-left:12px;"><?php esc_html_e( 'Delay (minutes)', 'primelink' ); ?></label>
                        <input type="number" id="mt_primelink-export-schedule-retry-delay" min="1" value="30" style="width:80px;" />
                    </div>
                </div>

                <div class="mt_primelink-form-row">
                    <label class="mt_primelink-check">
                        <input type="checkbox" id="mt_primelink-export-schedule-pause-on-error" />
                        <?php esc_html_e( 'Pause schedule on error', 'primelink' ); ?>
                    </label>
                    <p class="description"><?php esc_html_e( 'Automatically pause schedule if export fails with errors.', 'primelink' ); ?></p>
                </div>

            </div>
        </div>
    </section>
</div>
