<?php
/**
 * Manage PDFs page view
 *
 * @package WebEquipe\PDFSearch
 * @since 1.1.0
 */

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

$webequipe_pdf_activity_url = admin_url( 'admin.php?page=webequipe-pdf-search-activity' );
?>
<div class="wrap webequipe-pdf-manage-wrap" id="webequipe-pdf-manage-page">
	<?php \WebEquipe\PDFSearch\Admin_Settings::render_pro_banner(); ?>

	<div class="webequipe-pdf-manage-header">
		<div class="webequipe-pdf-manage-header-text">
			<h1><?php esc_html_e( 'WebEquipe PDF Search — Manage PDFs', 'webequipe-pdf-search' ); ?></h1>
			<p class="webequipe-pdf-manage-subtitle">
				<?php esc_html_e( 'Index, exclude, and bulk-manage PDFs in your media library.', 'webequipe-pdf-search' ); ?>
				<a href="<?php echo esc_url( $webequipe_pdf_activity_url ); ?>"><?php esc_html_e( 'Index Activity', 'webequipe-pdf-search' ); ?></a>
			</p>
		</div>
		<div class="webequipe-pdf-manage-header-actions">
			<button type="button" id="webequipe-pdf-manage-refresh" class="button button-primary">
				<span class="dashicons dashicons-search" aria-hidden="true"></span>
				<span><?php esc_html_e( 'Scan PDFs', 'webequipe-pdf-search' ); ?></span>
			</button>
			<button type="button" id="webequipe-pdf-manage-reindex-all" class="button button-secondary">
				<?php esc_html_e( 'Re-index All PDFs', 'webequipe-pdf-search' ); ?>
			</button>
			<button type="button" id="webequipe-pdf-manage-clear-index" class="button button-secondary webequipe-pdf-manage-btn-danger">
				<?php esc_html_e( 'Clear Entire Index', 'webequipe-pdf-search' ); ?>
			</button>
		</div>
	</div>

	<div id="webequipe-pdf-progress" class="webequipe-pdf-manage-progress" style="display: none;">
		<div class="progress-bar">
			<div class="progress-fill"></div>
		</div>
		<p class="progress-text"></p>
	</div>

	<div class="webequipe-pdf-manage-metrics">
		<div class="webequipe-pdf-manage-metric-card">
			<span class="webequipe-pdf-manage-metric-value" id="manage-stat-total">0</span>
			<span class="webequipe-pdf-manage-metric-label"><?php esc_html_e( 'Total PDFs', 'webequipe-pdf-search' ); ?></span>
		</div>
		<div class="webequipe-pdf-manage-metric-card">
			<span class="webequipe-pdf-manage-metric-value" id="manage-stat-indexed">0</span>
			<span class="webequipe-pdf-manage-metric-label"><?php esc_html_e( 'Indexed', 'webequipe-pdf-search' ); ?></span>
		</div>
		<div class="webequipe-pdf-manage-metric-card">
			<span class="webequipe-pdf-manage-metric-value" id="manage-stat-not-indexed">0</span>
			<span class="webequipe-pdf-manage-metric-label"><?php esc_html_e( 'Not Indexed', 'webequipe-pdf-search' ); ?></span>
		</div>
		<div class="webequipe-pdf-manage-metric-card">
			<span class="webequipe-pdf-manage-metric-value" id="manage-stat-excluded">0</span>
			<span class="webequipe-pdf-manage-metric-label"><?php esc_html_e( 'Excluded', 'webequipe-pdf-search' ); ?></span>
		</div>
		<div class="webequipe-pdf-manage-metric-card">
			<span class="webequipe-pdf-manage-metric-value" id="manage-stat-failed">0</span>
			<span class="webequipe-pdf-manage-metric-label"><?php esc_html_e( 'Failed', 'webequipe-pdf-search' ); ?></span>
		</div>
	</div>

	<div class="webequipe-pdf-manage-library">
		<div class="webequipe-pdf-manage-library-header">
			<h2><?php esc_html_e( 'PDF Library', 'webequipe-pdf-search' ); ?></h2>
			<p class="webequipe-pdf-manage-last-scan" id="webequipe-pdf-manage-last-scan"></p>
		</div>

		<div id="webequipe-pdf-list-container" class="webequipe-pdf-manage-list-container">
			<div class="webequipe-pdf-list-controls webequipe-pdf-manage-list-controls">
				<div class="webequipe-pdf-list-filters">
					<input type="search" id="webequipe-pdf-search-input" class="webequipe-pdf-search-input" placeholder="<?php esc_attr_e( 'Search PDFs by name...', 'webequipe-pdf-search' ); ?>">
					<select id="webequipe-pdf-status-filter" class="webequipe-pdf-status-filter">
						<option value="all"><?php esc_html_e( 'All Statuses', 'webequipe-pdf-search' ); ?></option>
						<option value="indexed"><?php esc_html_e( 'Indexed', 'webequipe-pdf-search' ); ?></option>
						<option value="processing"><?php esc_html_e( 'Processing', 'webequipe-pdf-search' ); ?></option>
						<option value="not_indexed"><?php esc_html_e( 'Not Indexed', 'webequipe-pdf-search' ); ?></option>
						<option value="excluded"><?php esc_html_e( 'Excluded', 'webequipe-pdf-search' ); ?></option>
						<option value="error"><?php esc_html_e( 'Errors', 'webequipe-pdf-search' ); ?></option>
					</select>
					<select id="webequipe-pdf-per-page" class="webequipe-pdf-per-page">
						<option value="25">25</option>
						<option value="50" selected>50</option>
						<option value="100">100</option>
					</select>
					<span class="webequipe-pdf-per-page-label"><?php esc_html_e( 'per page', 'webequipe-pdf-search' ); ?></span>
				</div>
				<div class="webequipe-pdf-list-actions">
					<label class="webequipe-pdf-manage-select-all">
						<input type="checkbox" id="select-all-pdfs"> <?php esc_html_e( 'Select All', 'webequipe-pdf-search' ); ?>
					</label>
					<select id="bulk-action-select" class="bulk-action-select">
						<option value=""><?php esc_html_e( 'Bulk Actions', 'webequipe-pdf-search' ); ?></option>
						<option value="index"><?php esc_html_e( 'Index Selected PDFs', 'webequipe-pdf-search' ); ?></option>
						<option value="unindex"><?php esc_html_e( 'Unindex Selected PDFs', 'webequipe-pdf-search' ); ?></option>
						<option value="include"><?php esc_html_e( 'Include Selected PDFs', 'webequipe-pdf-search' ); ?></option>
						<option value="exclude"><?php esc_html_e( 'Exclude Selected PDFs', 'webequipe-pdf-search' ); ?></option>
					</select>
					<button type="button" id="apply-bulk-action" class="button"><?php esc_html_e( 'Apply', 'webequipe-pdf-search' ); ?></button>
					<button type="button" id="refresh-pdf-list" class="button button-secondary">
						<span class="dashicons dashicons-search" aria-hidden="true"></span>
						<span><?php esc_html_e( 'Scan PDFs', 'webequipe-pdf-search' ); ?></span>
					</button>
				</div>
			</div>

			<div class="webequipe-pdf-list-loading">
				<span class="spinner is-active"></span> <?php esc_html_e( 'Loading PDFs...', 'webequipe-pdf-search' ); ?>
			</div>

			<div class="webequipe-pdf-manage-table-wrap">
				<table class="wp-list-table widefat fixed striped webequipe-pdf-manage-table" id="webequipe-pdf-list-table">
					<thead>
						<tr>
							<th class="check-column"><input type="checkbox" id="select-all-pdfs-header"></th>
							<th class="col-document"><?php esc_html_e( 'Document', 'webequipe-pdf-search' ); ?></th>
							<th class="col-pages"><?php esc_html_e( 'Pages', 'webequipe-pdf-search' ); ?></th>
							<th class="col-visibility"><?php esc_html_e( 'Search Visibility', 'webequipe-pdf-search' ); ?></th>
							<th class="col-extraction"><?php esc_html_e( 'Extraction Type', 'webequipe-pdf-search' ); ?></th>
							<th class="col-status"><?php esc_html_e( 'Status', 'webequipe-pdf-search' ); ?></th>
							<th class="col-actions"><?php esc_html_e( 'Actions', 'webequipe-pdf-search' ); ?></th>
						</tr>
					</thead>
					<tbody id="pdf-list-tbody">
					</tbody>
				</table>
			</div>

			<div class="webequipe-pdf-list-footer webequipe-pdf-manage-list-footer" id="webequipe-pdf-list-footer">
				<div class="pdf-list-summary">
					<?php esc_html_e( 'Showing', 'webequipe-pdf-search' ); ?> <span id="pdf-count-current">0</span> <?php esc_html_e( 'of', 'webequipe-pdf-search' ); ?> <span id="pdf-count-total">0</span> <?php esc_html_e( 'PDFs', 'webequipe-pdf-search' ); ?>
				</div>
				<div class="pdf-list-pagination" id="pdf-list-pagination">
				</div>
			</div>
		</div>
	</div>
</div>
