<?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: ISBN Bulk Lookup -->
		<div id="mbs-panel-isbn"
		     class="mbs-imp-exp-panel"
		     role="tabpanel"
		     hidden>
			<h3><?php esc_html_e( 'ISBN Bulk Lookup', 'my-book-showroom' ); ?></h3>
			<p class="mbs-panel-lead"><?php esc_html_e( 'Paste one ISBN per line. Books will be fetched from the selected source and previewed before import.', 'my-book-showroom' ); ?></p>

			<input type="hidden" id="mbs-isbn-panel-nonce" value="<?php echo esc_attr( $nonce ); ?>" />

			<label for="mbs-isbn-list" class="screen-reader-text"><?php esc_html_e( 'ISBNs, one per line', 'my-book-showroom' ); ?></label>
			<textarea id="mbs-isbn-list"
			          class="mbs-imp-exp-isbn-list"
			          placeholder="9780385737951&#10;9780062316097&#10;9780525559474"
			          spellcheck="false"></textarea>

			<div class="mbs-imp-exp-source-row">
				<label>
					<input type="radio" name="mbs_isbn_source" value="google" checked />
					<?php esc_html_e( 'Google Books', 'my-book-showroom' ); ?>
				</label>
				<label>
					<input type="radio" name="mbs_isbn_source" value="openlibrary" />
					<?php esc_html_e( 'Open Library', 'my-book-showroom' ); ?>
				</label>
			</div>

			<?php if ( $is_pro ) : ?>
			<!-- API-KEY-1: Google Books API key save — shown only on PRO to match importer gate. -->
			<div id="mbs-google-books-key-section" style="margin-top:10px; padding:10px 12px; background:#f6f7f7; border:1px solid #dcdcde; border-radius:4px;">
				<strong style="font-size:0.875rem;"><?php esc_html_e( 'Google Books API Key', 'my-book-showroom' ); ?></strong>
				<p style="margin:4px 0 8px; font-size:0.8125rem; color:#646970;">
					<?php esc_html_e( 'Required for reliable lookups. Anonymous requests share a small daily quota that is quickly exhausted.', 'my-book-showroom' ); ?>
					<a href="https://console.cloud.google.com/apis/credentials" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Get a free key at Google Cloud Console &rarr;', 'my-book-showroom' ); ?></a>
				</p>
				<?php if ( '' !== get_option( 'mbs_setting_import_google_books_api_key_encrypted', '' ) ) : ?>
					<p style="margin:0 0 6px; font-size:0.8125rem; color:#46b450;">
						<span class="dashicons dashicons-yes-alt" style="vertical-align:middle;"></span>
						<?php esc_html_e( 'API key saved. Enter a new value to replace it.', 'my-book-showroom' ); ?>
					</p>
				<?php endif; ?>
				<input type="password"
				       id="mbs-google-api-key"
				       class="regular-text"
				       placeholder="AIzaSy..."
				       autocomplete="new-password" />
				<button type="button"
				        id="mbs-save-google-api-key-btn"
				        class="button"
				        style="margin-left:6px;">
					<?php esc_html_e( 'Save Key', 'my-book-showroom' ); ?>
				</button>
				<div id="mbs-google-api-key-message" style="display:none; margin-top:8px;"></div>
			</div>
			<?php endif; // $is_pro ?>

			<button type="button"
			        id="mbs-isbn-fetch-btn"
			        class="button button-primary">
				<?php esc_html_e( 'Look Up ISBNs', 'my-book-showroom' ); ?>
			</button>

			<div id="mbs-isbn-message" style="display:none; margin-top:12px;"></div>

			<!-- Progress bar (shown during confirm-import step) -->
			<div id="mbs-isbn-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-isbn-bar" style="height:100%;background:#2271b1;width:0%;border-radius:4px;transition:width 0.45s ease;"></div>
				</div>
			</div>
			<div id="mbs-isbn-msgarea" style="display:none;margin:0 0 0.5rem;font-size:0.875rem;color:#555;"></div>
			<p id="mbs-isbn-status" style="display:none;margin:0.5rem 0;font-size:0.875rem;"></p>

			<div id="mbs-isbn-candidates-preview"></div>
		</div><!-- #mbs-panel-isbn -->
