<?php
/**
 * File Path: templates/admin/shortcodes-card.php
 *
 * Template partial — Shortcodes card for the Blocks & Shortcodes settings tab.
 *
 * Loaded via mbs_get_template_part( 'admin/shortcodes-card', ... ).
 *
 * Variables injected by caller (MBS_Tab_Shortcodes::render()):
 *   @var array $layouts  Layout slug → label/data map from MBS_Layout_Registry.
 *   @var bool  $is_pro   Whether the active license is PRO.
 *
 * R-05 (2026-04-25): Extracted from MBS_Tab_Shortcodes::render_shortcodes_card().
 *
 * @package    My_Book_Showroom
 * @subpackage Templates/Admin
 * @since      1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- template-scope variables injected by mbs_get_template_part(); not global vars
?>
<div class="mbs-settings-card">
	<h3><?php esc_html_e( 'Shortcodes', 'my-book-showroom' ); ?></h3>
	<p class="mbs-ref-intro">
		<?php esc_html_e( 'Paste shortcodes into any page, post, widget, or Shortcode block. Only attributes that differ from their defaults are included in the output.', 'my-book-showroom' ); ?>
	</p>

	<?php /* ── [mbs_books] ──────────────────────────────────── */ ?>
	<div class="mbs-ref-entry">
		<div class="mbs-ref-header">
			<span class="mbs-ref-tag">[mbs_books]</span>
			<span class="mbs-ref-alias"><?php esc_html_e( 'alias: [mbs_books_archive]', 'my-book-showroom' ); ?></span>
		</div>
		<p class="mbs-ref-desc">
			<?php esc_html_e( 'Displays your book catalog. Filter by taxonomy, choose a layout, and control how many books appear.', 'my-book-showroom' ); ?>
		</p>

		<form class="mbs-builder" data-shortcode="mbs_books">
			<div class="mbs-builder-fields">

				<div class="mbs-builder-row">
					<?php /* Layout */ ?>
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Layout', 'my-book-showroom' ); ?></label>
						<select data-attr="layout" data-default="">
							<option value=""><?php esc_html_e( '— use setting —', 'my-book-showroom' ); ?></option>
							<?php foreach ( $layouts as $slug => $data ) :
								$label    = is_array( $data ) ? $data['label'] : $data;
								$is_pro_l = is_array( $data ) && ! empty( $data['pro'] );
								$suffix   = ( $is_pro_l && ! $is_pro ) ? ' (PRO)' : '';
							?>
								<option value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $label . $suffix ); ?></option>
							<?php endforeach; ?>
						</select>
					</div>

					<?php /* Columns */ ?>
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Columns', 'my-book-showroom' ); ?></label>
						<input type="number" min="1" max="6" value="3"
						       data-attr="columns" data-default="3">
					</div>

					<?php /* Per page */ ?>
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Books per page', 'my-book-showroom' ); ?></label>
						<input type="number" min="1" max="100" value=""
						       placeholder="<?php esc_attr_e( 'use setting', 'my-book-showroom' ); ?>"
						       data-attr="per_page" data-default="">
					</div>
				</div>

				<div class="mbs-builder-row">
					<?php /* Author */ ?>
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Author', 'my-book-showroom' ); ?></label>
						<input type="text" placeholder="<?php esc_attr_e( 'all', 'my-book-showroom' ); ?>"
						       data-attr="author" data-default="">
					</div>

					<?php /* Series */ ?>
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Series', 'my-book-showroom' ); ?></label>
						<input type="text" placeholder="<?php esc_attr_e( 'all', 'my-book-showroom' ); ?>"
						       data-attr="series" data-default="">
					</div>

					<?php /* Genre */ ?>
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Genre', 'my-book-showroom' ); ?></label>
						<input type="text" placeholder="<?php esc_attr_e( 'all', 'my-book-showroom' ); ?>"
						       data-attr="genre" data-default="">
					</div>

					<?php /* Tag */ ?>
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Tag', 'my-book-showroom' ); ?></label>
						<input type="text" placeholder="<?php esc_attr_e( 'all', 'my-book-showroom' ); ?>"
						       data-attr="tag" data-default="">
					</div>
				</div>

				<div class="mbs-builder-row">
					<?php /* Order by */ ?>
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Order by', 'my-book-showroom' ); ?></label>
						<select data-attr="orderby" data-default="date">
							<option value="date"><?php esc_html_e( 'Date added', 'my-book-showroom' ); ?></option>
							<option value="title"><?php esc_html_e( 'Title (A–Z)', 'my-book-showroom' ); ?></option>
							<option value="menu_order"><?php esc_html_e( 'Custom order', 'my-book-showroom' ); ?></option>
						</select>
					</div>

					<?php /* Order */ ?>
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Direction', 'my-book-showroom' ); ?></label>
						<select data-attr="order" data-default="DESC">
							<option value="DESC"><?php esc_html_e( 'Newest first (DESC)', 'my-book-showroom' ); ?></option>
							<option value="ASC"><?php esc_html_e( 'Oldest first (ASC)', 'my-book-showroom' ); ?></option>
						</select>
					</div>
				</div>

			</div>

			<div class="mbs-builder-preview">
				<code class="mbs-builder-output"></code>
				<button type="button" class="button button-primary mbs-copy-btn"><?php esc_html_e( 'Copy', 'my-book-showroom' ); ?></button>
			</div>
		</form>
	</div>

	<hr class="mbs-card-divider">

	<?php /* ── [mbs_book] ────────────────────────────────────── */ ?>
	<div class="mbs-ref-entry">
		<div class="mbs-ref-header">
			<span class="mbs-ref-tag">[mbs_book]</span>
		</div>
		<p class="mbs-ref-desc">
			<?php
			printf(
				/* translators: %s: Books list link */
				esc_html__( 'Embeds a single book by its WordPress post ID. Find IDs by hovering book titles in %s — the ID appears in the URL.', 'my-book-showroom' ),
				'<a href="' . esc_url( admin_url( 'edit.php?post_type=' . MBS_POST_TYPE ) ) . '" target="_blank">' . esc_html__( 'Books', 'my-book-showroom' ) . '</a>'
			);
			?>
		</p>

		<form class="mbs-builder" data-shortcode="mbs_book">
			<div class="mbs-builder-fields">
				<div class="mbs-builder-row">
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Book ID', 'my-book-showroom' ); ?> <span class="mbs-required">*</span></label>
						<input type="number" min="1" value=""
						       placeholder="e.g. 42"
						       data-attr="id" data-default="" data-required="true">
					</div>
				</div>
			</div>

			<div class="mbs-builder-preview">
				<code class="mbs-builder-output"></code>
				<button type="button" class="button button-primary mbs-copy-btn"><?php esc_html_e( 'Copy', 'my-book-showroom' ); ?></button>
			</div>
		</form>
	</div>

	<hr class="mbs-card-divider">

	<?php /* ── [mbs_author_directory] ───────────────────────── */ ?>
	<div class="mbs-ref-entry">
		<div class="mbs-ref-header">
			<span class="mbs-ref-tag">[mbs_author_directory]</span>
		</div>
		<p class="mbs-ref-desc">
			<?php esc_html_e( 'Displays all authors as a responsive card grid, each linking to that author\'s book archive.', 'my-book-showroom' ); ?>
		</p>

		<form class="mbs-builder" data-shortcode="mbs_author_directory">
			<div class="mbs-builder-fields">
				<div class="mbs-builder-row">
					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Columns', 'my-book-showroom' ); ?></label>
						<input type="number" min="1" max="6" value="4"
						       data-attr="columns" data-default="4">
					</div>

					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Order by', 'my-book-showroom' ); ?></label>
						<select data-attr="orderby" data-default="name">
							<option value="name"><?php esc_html_e( 'Name', 'my-book-showroom' ); ?></option>
							<option value="count"><?php esc_html_e( 'Book count', 'my-book-showroom' ); ?></option>
							<option value="slug"><?php esc_html_e( 'Slug', 'my-book-showroom' ); ?></option>
						</select>
					</div>

					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Direction', 'my-book-showroom' ); ?></label>
						<select data-attr="order" data-default="ASC">
							<option value="ASC">ASC</option>
							<option value="DESC">DESC</option>
						</select>
					</div>

					<div class="mbs-builder-field">
						<label><?php esc_html_e( 'Show count', 'my-book-showroom' ); ?></label>
						<select data-attr="show_count" data-default="0">
							<option value="0"><?php esc_html_e( 'No', 'my-book-showroom' ); ?></option>
							<option value="1"><?php esc_html_e( 'Yes', 'my-book-showroom' ); ?></option>
						</select>
					</div>
				</div>
			</div>

			<div class="mbs-builder-preview">
				<code class="mbs-builder-output"></code>
				<button type="button" class="button button-primary mbs-copy-btn"><?php esc_html_e( 'Copy', 'my-book-showroom' ); ?></button>
			</div>
		</form>
	</div>


</div>
