<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Variables in scope (injected via mbs_get_template_part from imp-exp-ui.php).
 * @var bool   $is_registered
 * @var bool   $is_pro
 * @var string $nonce
 * @var string $template_url
 */
?>

		<!-- Panel: Migrate from Another Plugin -->
		<div id="mbs-panel-migrate"
		     class="mbs-imp-exp-panel"
		     role="tabpanel"
		     hidden>
			<h3><?php esc_html_e( 'Migrate from Another Plugin', 'my-book-showroom' ); ?></h3>
			<p class="mbs-panel-lead"><?php esc_html_e( 'Choose your current plugin below. Your books, authors, series, and covers move across in one upload.', 'my-book-showroom' ); ?></p>

			<div class="mbs-migrate-paths">

				<!-- Path A: MyBookTable (fully functional) -->
				<div class="mbs-migrate-path">
					<div class="mbs-migrate-path-header">
						<span class="mbs-migrate-path-icon dashicons dashicons-book-alt"></span>
						<strong><?php esc_html_e( 'MyBookTable', 'my-book-showroom' ); ?></strong>
						<span class="mbs-imp-exp-badge mbs-imp-exp-badge--free"><?php esc_html_e( 'FREE', 'my-book-showroom' ); ?></span>
					</div>
					<p class="mbs-migrate-path-what"><?php esc_html_e( 'Migrates: books, authors, series, genres, cover images, and affiliate link settings.', 'my-book-showroom' ); ?></p>
					<ol class="mbs-migrate-steps">
						<li><?php esc_html_e( 'In MyBookTable, go to Books &rarr; Export and download your JSON file.', 'my-book-showroom' ); ?></li>
						<li><?php esc_html_e( 'Upload it below — MBS detects the format and migrates everything automatically.', 'my-book-showroom' ); ?></li>
					</ol>
					<div id="mbs-migrate-mbt-area">
						<input type="file"
						       id="mbs-migrate-mbt-file"
							       data-nonce="<?php echo esc_attr( $nonce ); ?>" />
						<button type="button"
						        id="mbs-migrate-mbt-btn"
						        class="button button-primary">
							<?php esc_html_e( 'Upload &amp; Migrate', 'my-book-showroom' ); ?>
						</button>
					</div>
					<!-- Progress bar (shown during MyBookTable migration) -->
					<div id="mbs-migrate-progress-bar" style="display:none;margin-top:1rem;margin-bottom:0.4rem;">
						<div style="background:#e9ecef;border-radius:4px;height:8px;overflow:hidden;">
							<div id="mbs-migrate-bar" style="height:100%;background:#2271b1;width:0%;border-radius:4px;transition:width 0.45s ease;"></div>
						</div>
					</div>
					<div id="mbs-migrate-msgarea" style="display:none;margin:0 0 0.5rem;font-size:0.875rem;color:#555;"></div>
					<p id="mbs-migrate-status" style="display:none;margin:0.5rem 0;font-size:0.875rem;"></p>
				</div><!-- .mbs-migrate-path (MyBookTable) -->

				<!-- Path B: WXR (Novelist, WP Books Gallery, Other) — Story 14-2 -->
				<div class="mbs-migrate-path" id="mbs-migrate-wxr-path">
					<div class="mbs-migrate-path-header">
						<span class="mbs-migrate-path-icon dashicons dashicons-excerpt-view"></span>
						<strong><?php esc_html_e( 'Novelist &bull; WP Books Gallery &bull; Other', 'my-book-showroom' ); ?></strong>
					</div>
					<p class="mbs-migrate-path-what"><?php esc_html_e( 'Migrate from any WordPress-based book plugin via WXR export with guided field mapping.', 'my-book-showroom' ); ?></p>
					<ol class="mbs-migrate-steps">
						<li><?php esc_html_e( 'In your current site, go to Tools &rarr; Export, choose your book post type, and download the .xml file.', 'my-book-showroom' ); ?></li>
						<li><?php esc_html_e( 'Upload the .xml file here. MBS will analyze it and show you a field-mapping screen.', 'my-book-showroom' ); ?></li>
						<li><?php esc_html_e( 'Map each field from your old plugin to the matching MBS field, then click Import.', 'my-book-showroom' ); ?></li>
					</ol>

					<!-- Step 1: Upload area -->
					<div id="mbs-wxr-upload-area">
						<input type="file"
						       id="mbs-wxr-file"
						       accept=".xml"
						       data-nonce="<?php echo esc_attr( $nonce ); ?>" />
						<button type="button"
						        id="mbs-wxr-analyze-btn"
						        class="button button-primary">
							<?php esc_html_e( 'Upload &amp; Analyze', 'my-book-showroom' ); ?>
						</button>
					</div>

					<!-- Step 2: Field mapping (shown after analyze) -->
					<div id="mbs-wxr-mapping-area" style="display:none;">
						<h4 style="margin-top:16px;"><?php esc_html_e( 'Map Your Fields', 'my-book-showroom' ); ?></h4>
						<p class="description">
							<?php esc_html_e( 'For each field found in your export, choose the matching MBS field. Fields set to "Skip" are ignored.', 'my-book-showroom' ); ?>
						</p>
						<table class="mbs-wxr-mapping-table widefat" style="margin-top:8px;">
							<thead>
								<tr>
									<th><?php esc_html_e( 'Field in your export', 'my-book-showroom' ); ?></th>
									<th><?php esc_html_e( 'MBS field', 'my-book-showroom' ); ?></th>
								</tr>
							</thead>
							<tbody id="mbs-wxr-mapping-rows">
								<!-- Rows injected by mbs-import-wxr.js -->
							</tbody>
						</table>
						<p style="margin-top:12px;">
							<button type="button"
							        id="mbs-wxr-import-btn"
							        class="button button-primary">
								<?php esc_html_e( 'Import Books', 'my-book-showroom' ); ?>
							</button>
							<button type="button"
							        id="mbs-wxr-back-btn"
							        class="button"
							        style="margin-left:8px;">
								<?php esc_html_e( '← Choose a Different File', 'my-book-showroom' ); ?>
							</button>
						</p>
					</div><!-- #mbs-wxr-mapping-area -->

					<!-- Progress bar (shown during WXR analyze and import steps) -->
					<div id="mbs-wxr-progress-bar" style="display:none;margin-top:1rem;margin-bottom:0.4rem;">
						<div style="background:#e9ecef;border-radius:4px;height:8px;overflow:hidden;">
							<div id="mbs-wxr-bar" style="height:100%;background:#2271b1;width:0%;border-radius:4px;transition:width 0.45s ease;"></div>
						</div>
					</div>
					<div id="mbs-wxr-msgarea" style="display:none;margin:0 0 0.5rem;font-size:0.875rem;color:#555;"></div>
					<p id="mbs-wxr-status" style="display:none;margin:0.5rem 0;font-size:0.875rem;"></p>

				</div><!-- .mbs-migrate-path (WXR) -->

			</div><!-- .mbs-migrate-paths -->
		</div><!-- #mbs-panel-migrate -->
