<?php
/**
 * Dashboard page view.
 *
 * Renders the EAA scope questionnaire and the scan form.
 * All output is escaped. No business logic here.
 *
 * @package AccessLens
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div class="wrap accesslens-dashboard">
	<h1><?php esc_html_e( 'AccessLens - Web Accessibility Audit', 'accesslens' ); ?></h1>

	<div class="accesslens-notice-disclaimer notice notice-info inline">
		<p>
			<strong><?php esc_html_e( 'Aviso importante:', 'accesslens' ); ?></strong>
			<?php esc_html_e( 'Este escaner detecta aproximadamente el 25-40% de los problemas de accesibilidad. La conformidad completa con la Directiva EAA requiere revision manual adicional por parte de un experto. Los resultados tienen caracter orientativo y no constituyen una declaracion de conformidad.', 'accesslens' ); ?>
		</p>
	</div>

	<!-- EAA Scope Questionnaire -->
	<div class="accesslens-card accesslens-scope-checker">
		<h2><?php esc_html_e( 'Comprueba si tu empresa esta en el ambito de la EAA', 'accesslens' ); ?></h2>
		<p class="description">
			<?php esc_html_e( 'Responde estas preguntas para obtener una orientacion inicial. Este diagnostico no tiene validez legal.', 'accesslens' ); ?>
		</p>

		<table class="form-table accesslens-scope-table" role="presentation">
			<tr>
				<th scope="row">
					<label for="accesslens_employees"><?php esc_html_e( 'Numero de empleados', 'accesslens' ); ?></label>
				</th>
				<td>
					<select id="accesslens_employees" class="accesslens-scope-input">
						<option value=""><?php esc_html_e( '-- Selecciona --', 'accesslens' ); ?></option>
						<option value="micro"><?php esc_html_e( 'Menos de 10', 'accesslens' ); ?></option>
						<option value="small"><?php esc_html_e( '10 a 49', 'accesslens' ); ?></option>
						<option value="medium"><?php esc_html_e( '50 a 249', 'accesslens' ); ?></option>
						<option value="large"><?php esc_html_e( '250 o mas', 'accesslens' ); ?></option>
					</select>
				</td>
			</tr>
			<tr>
				<th scope="row">
					<label for="accesslens_revenue"><?php esc_html_e( 'Facturacion anual', 'accesslens' ); ?></label>
				</th>
				<td>
					<select id="accesslens_revenue" class="accesslens-scope-input">
						<option value=""><?php esc_html_e( '-- Selecciona --', 'accesslens' ); ?></option>
						<option value="micro"><?php esc_html_e( 'Menos de 2 millones EUR', 'accesslens' ); ?></option>
						<option value="small"><?php esc_html_e( '2 a 10 millones EUR', 'accesslens' ); ?></option>
						<option value="medium"><?php esc_html_e( '10 a 50 millones EUR', 'accesslens' ); ?></option>
						<option value="large"><?php esc_html_e( 'Mas de 50 millones EUR', 'accesslens' ); ?></option>
					</select>
				</td>
			</tr>
			<tr>
				<th scope="row">
					<label for="accesslens_service_type"><?php esc_html_e( 'Tipo de servicio o producto', 'accesslens' ); ?></label>
				</th>
				<td>
					<select id="accesslens_service_type" class="accesslens-scope-input">
						<option value=""><?php esc_html_e( '-- Selecciona --', 'accesslens' ); ?></option>
						<option value="ecommerce"><?php esc_html_e( 'Comercio electronico (tienda online)', 'accesslens' ); ?></option>
						<option value="banking"><?php esc_html_e( 'Servicios bancarios o financieros', 'accesslens' ); ?></option>
						<option value="transport"><?php esc_html_e( 'Transporte de viajeros', 'accesslens' ); ?></option>
						<option value="media"><?php esc_html_e( 'Medios de comunicacion audiovisual', 'accesslens' ); ?></option>
						<option value="telecom"><?php esc_html_e( 'Servicios de telecomunicaciones', 'accesslens' ); ?></option>
						<option value="ereader"><?php esc_html_e( 'Libros electronicos / e-readers', 'accesslens' ); ?></option>
						<option value="other_digital"><?php esc_html_e( 'Otro servicio digital', 'accesslens' ); ?></option>
						<option value="not_digital"><?php esc_html_e( 'No vendo productos/servicios digitales', 'accesslens' ); ?></option>
					</select>
				</td>
			</tr>
		</table>

		<div id="accesslens-scope-verdict" class="accesslens-scope-verdict hidden" role="alert" aria-live="polite"></div>

		<button type="button" id="accesslens-check-scope" class="button button-secondary">
			<?php esc_html_e( 'Ver diagnostico orientativo', 'accesslens' ); ?>
		</button>
	</div>

	<!-- Scan Form -->
	<div class="accesslens-card accesslens-scan-form">
		<h2><?php esc_html_e( 'Nueva auditoria', 'accesslens' ); ?></h2>

		<table class="form-table" role="presentation">
			<tr>
				<th scope="row">
					<label for="accesslens_scan_url"><?php esc_html_e( 'URL a auditar', 'accesslens' ); ?></label>
				</th>
				<td>
					<input
						type="url"
						id="accesslens_scan_url"
						name="accesslens_scan_url"
						class="regular-text"
						value="<?php echo esc_attr( home_url() ); ?>"
						required
					/>
				</td>
			</tr>
			<tr>
				<th scope="row">
					<label for="accesslens_scan_mode"><?php esc_html_e( 'Modo de escaneo', 'accesslens' ); ?></label>
				</th>
				<td>
					<select id="accesslens_scan_mode" name="accesslens_scan_mode">
						<option value="single"><?php esc_html_e( 'Pagina unica', 'accesslens' ); ?></option>
						<option value="sitemap"><?php esc_html_e( 'Sitemap', 'accesslens' ); ?></option>
						<option value="crawl"><?php esc_html_e( 'Rastreo completo', 'accesslens' ); ?></option>
					</select>
				</td>
			</tr>
		</table>

		<div class="accesslens-scan-actions">
			<button type="button" id="accesslens-start-scan" class="button button-primary">
				<?php esc_html_e( 'Iniciar auditoria', 'accesslens' ); ?>
			</button>
		</div>
	</div>

	<!-- Progress & Status -->
	<div id="accesslens-scan-status" class="accesslens-card hidden">
		<h2><?php esc_html_e( 'Estado del escaneo', 'accesslens' ); ?></h2>
		<div id="accesslens-status-text" class="accesslens-status-badge"></div>
		<div class="accesslens-progress-wrap">
			<progress id="accesslens-progress-bar" value="0" max="100"></progress>
			<span id="accesslens-progress-label"></span>
		</div>
	</div>

	<!-- Results Table -->
	<div id="accesslens-results-wrap" class="accesslens-card hidden">
		<h2><?php esc_html_e( 'Resultados por pagina', 'accesslens' ); ?></h2>

		<div id="accesslens-results-summary" class="accesslens-results-summary"></div>

		<table id="accesslens-results-table" class="widefat striped accesslens-results-table">
			<thead>
				<tr>
					<th><?php esc_html_e( 'Pagina', 'accesslens' ); ?></th>
					<th><?php esc_html_e( 'Titulo', 'accesslens' ); ?></th>
					<th class="accesslens-col-critical"><?php esc_html_e( 'Critico', 'accesslens' ); ?></th>
					<th class="accesslens-col-serious"><?php esc_html_e( 'Serio', 'accesslens' ); ?></th>
					<th class="accesslens-col-moderate"><?php esc_html_e( 'Moderado', 'accesslens' ); ?></th>
					<th class="accesslens-col-minor"><?php esc_html_e( 'Menor', 'accesslens' ); ?></th>
					<th><?php esc_html_e( 'Total', 'accesslens' ); ?></th>
					<th><?php esc_html_e( 'Top reglas', 'accesslens' ); ?></th>
				</tr>
			</thead>
			<tbody id="accesslens-results-body">
			</tbody>
		</table>

		<!-- Report Download -->
		<div class="accesslens-report-section">
			<h3><?php esc_html_e( 'Descargar informe de conformidad', 'accesslens' ); ?></h3>
			<p class="description">
				<?php esc_html_e( 'El informe lo genera el servicio AccessLens. El analisis avanzado con IA (texto alternativo y sugerencias) requiere una suscripcion Pro al servicio; sin ella se genera la version basica.', 'accesslens' ); ?>
			</p>
			<table class="form-table accesslens-report-meta" role="presentation">
				<tr>
					<th><label for="accesslens_report_site_name"><?php esc_html_e( 'Nombre del sitio', 'accesslens' ); ?></label></th>
					<td><input type="text" id="accesslens_report_site_name" class="regular-text" value="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" /></td>
				</tr>
				<tr>
					<th><label for="accesslens_report_entity_type"><?php esc_html_e( 'Tipo de entidad', 'accesslens' ); ?></label></th>
					<td>
						<select id="accesslens_report_entity_type">
							<option value="private"><?php esc_html_e( 'Privada', 'accesslens' ); ?></option>
							<option value="public"><?php esc_html_e( 'Publica', 'accesslens' ); ?></option>
						</select>
					</td>
				</tr>
				<tr>
					<th><label for="accesslens_report_contact_email"><?php esc_html_e( 'Email de contacto accesibilidad', 'accesslens' ); ?></label></th>
					<td><input type="email" id="accesslens_report_contact_email" class="regular-text" /></td>
				</tr>
				<tr>
					<th><label for="accesslens_report_contact_url"><?php esc_html_e( 'URL formulario de contacto', 'accesslens' ); ?></label></th>
					<td><input type="url" id="accesslens_report_contact_url" class="regular-text" value="<?php echo esc_attr( home_url( '/contacto' ) ); ?>" /></td>
				</tr>
				<tr>
					<th><label for="accesslens_report_prepared_by"><?php esc_html_e( 'Preparado por', 'accesslens' ); ?></label></th>
					<td><input type="text" id="accesslens_report_prepared_by" class="regular-text" /></td>
				</tr>
			</table>
			<button type="button" id="accesslens-download-report" class="button button-primary">
				<?php esc_html_e( 'Descargar informe PDF', 'accesslens' ); ?>
			</button>
		</div>
	</div>
</div>
