<?php
/**
 * Step 3: Scan Results.
 *
 * @package CoffeeWP_Media_Cleanup
 */

defined( 'ABSPATH' ) || exit;
?>
<section class="cwpm-step" id="cwpm-step-results" data-step="3">
	<h4 class="cwpm-step__title">
		<span class="badge badge-primary">3</span>
		<?php esc_html_e( 'Results', 'coffeewp-media-cleanup' ); ?>
		<span class="cwpm-scan-date" id="cwpm-scan-date"></span>
	</h4>
	<p class="cwpm-step__desc" id="cwpm-results-desc">
		<?php esc_html_e( 'Review scan results, select items, and run cleanup actions.', 'coffeewp-media-cleanup' ); ?>
	</p>

	<div id="cwpm-no-results-message" style="display: none;">
		<p class="text-muted">
			<?php esc_html_e( 'No scan results yet.', 'coffeewp-media-cleanup' ); ?>
			<a href="#" id="cwpm-go-to-scan"><?php esc_html_e( 'Start a scan', 'coffeewp-media-cleanup' ); ?></a>
			<?php esc_html_e( 'to see results here.', 'coffeewp-media-cleanup' ); ?>
		</p>
	</div>

	<div id="cwpm-results-content" class="cwpm-scan-results">

		<!-- Stats summary -->
		<div class="cwpm-stats-grid" id="cwpm-stats-grid" style="display: none;">
			<div class="cwpm-stat-card">
				<span class="cwpm-stat-card__icon icon" aria-hidden="true"><i class="fa-solid fa-images"></i></span>
				<div class="cwpm-stat-card__body">
					<span class="cwpm-stat-card__value" id="cwpm-stat-total-files">—</span>
					<span class="cwpm-stat-card__label"><?php esc_html_e( 'Total Files', 'coffeewp-media-cleanup' ); ?></span>
				</div>
			</div>
			<div class="cwpm-stat-card">
				<span class="cwpm-stat-card__icon icon text-success" aria-hidden="true"><i class="fa-solid fa-check-circle"></i></span>
				<div class="cwpm-stat-card__body">
					<span class="cwpm-stat-card__value" id="cwpm-stat-used-thumbs">—</span>
					<span class="cwpm-stat-card__label"><?php esc_html_e( 'Used Thumbnails', 'coffeewp-media-cleanup' ); ?></span>
				</div>
			</div>
			<div class="cwpm-stat-card">
				<span class="cwpm-stat-card__icon icon text-warning" aria-hidden="true"><i class="fa-solid fa-triangle-exclamation"></i></span>
				<div class="cwpm-stat-card__body">
					<span class="cwpm-stat-card__value" id="cwpm-stat-unused-thumbs">—</span>
					<span class="cwpm-stat-card__label"><?php esc_html_e( 'Unused Thumbnails', 'coffeewp-media-cleanup' ); ?></span>
				</div>
			</div>
			<div class="cwpm-stat-card">
				<span class="cwpm-stat-card__icon icon text-error" aria-hidden="true"><i class="fa-solid fa-database"></i></span>
				<div class="cwpm-stat-card__body">
					<span class="cwpm-stat-card__value" id="cwpm-stat-orphaned">—</span>
					<span class="cwpm-stat-card__label"><?php esc_html_e( 'Orphaned Files', 'coffeewp-media-cleanup' ); ?></span>
				</div>
			</div>
			<div class="cwpm-stat-card">
				<span class="cwpm-stat-card__icon icon text-warning" aria-hidden="true"><i class="fa-solid fa-link-slash"></i></span>
				<div class="cwpm-stat-card__body">
					<span class="cwpm-stat-card__value" id="cwpm-stat-broken">—</span>
					<span class="cwpm-stat-card__label"><?php esc_html_e( 'Broken Media', 'coffeewp-media-cleanup' ); ?></span>
				</div>
			</div>
			<?php
			/**
			 * Extension point — extension plugins may render extra stat cards
			 * here. The core plugin emits no default cards.
			 *
			 * @since 1.3.0
			 */
			do_action( 'cwpm_results_extra_stat_cards' );
			?>
			<div class="cwpm-stat-card">
				<span class="cwpm-stat-card__icon icon" aria-hidden="true"><i class="fa-solid fa-hard-drive"></i></span>
				<div class="cwpm-stat-card__body">
					<span class="cwpm-stat-card__value" id="cwpm-stat-total-size">—</span>
					<span class="cwpm-stat-card__label"><?php esc_html_e( 'Scanned Media Size', 'coffeewp-media-cleanup' ); ?></span>
				</div>
			</div>
			<div class="cwpm-stat-card">
				<span class="cwpm-stat-card__icon icon text-success" aria-hidden="true"><i class="fa-solid fa-broom"></i></span>
				<div class="cwpm-stat-card__body">
					<span class="cwpm-stat-card__value" id="cwpm-stat-savings">—</span>
					<span class="cwpm-stat-card__label"><?php esc_html_e( 'Potential Savings', 'coffeewp-media-cleanup' ); ?></span>
				</div>
			</div>
		</div>

		<!-- Sticky action bar (shared partial) -->
		<?php
		$cwpm_bar_config = array(
			'id_prefix'         => 'cwpm',
			'search'            => true,
			'status_filter'     => true,
			'actions_button'    => true,
			'primary_cta'       => true,
			'primary_cta_label' => __( 'Run Actions', 'coffeewp-media-cleanup' ),
			'primary_cta_id'    => 'cwpm-bar-clean',
			'primary_cta_title' => __( 'Run selected actions', 'coffeewp-media-cleanup' ),
			'primary_cta_class' => 'btn--primary',
			'primary_cta_icon'  => 'fa-play',
			'compact_toggle'    => true,
			'group_toggle'      => true,
			'pagination'        => true,
			'select_visible'    => true,
			'select_all'        => true,
			'clean_progress'    => true,
		);
		require CWPM_PATH . 'templates/partials/action-bar.php';
		?>

		<!-- Year accordion: populated by JS -->
		<ul class="accordion" id="cwpm-folder-list">
		</ul>

		<!-- Clean progress (hidden until Start Cleaning runs) -->
		<div class="cwpm-clean-progress" id="cwpm-clean-progress" style="display: none;">
			<div class="cwpm-progress">
				<div class="cwpm-progress__bar" id="cwpm-clean-progress-bar" style="width: 0%;"></div>
			</div>
			<p class="cwpm-scan-progress__status" id="cwpm-clean-progress-status"><?php esc_html_e( 'Deleting files...', 'coffeewp-media-cleanup' ); ?></p>
		</div>
		<div class="cwpm-step__footer cwpm-step__footer--center" id="cwpm-results-footer">
			<button type="button" class="btn btn--outline cwpm-prev-step" data-prev="1">
				<span class="icon icon--xs"><i class="fa-solid fa-arrow-left"></i></span>
				<?php esc_html_e( 'Back', 'coffeewp-media-cleanup' ); ?>
			</button>
			<button type="button" class="btn btn--primary" id="cwpm-start-clean">
				<span class="icon icon--xs"><i class="fa-solid fa-play"></i></span>
				<?php esc_html_e( 'Run Actions', 'coffeewp-media-cleanup' ); ?>
			</button>
		</div>
		<div style="height: 300px;" aria-hidden="true"></div>
	</div>
</section>
