/**
 * Kit Digital · Auditor de Accesibilidad — Estilos frontend
 * Version: 4.0.0
 *
 * Incluye:
 *  - Correcciones visuales WCAG 1.4.1 (enlaces subrayados)
 *  - Foco visible WCAG 2.4.7
 *  - Barra inferior de administrador
 *  - Sidebar lateral de auditoría
 *  - UI de preview IA y estados de carga / éxito / error
 */

/* =============================================================
   1. CORRECCIONES VISUALES WCAG 1.4.1 — Uso del color
   ============================================================= */

/* Los enlaces en contenido deben distinguirse más allá del color */
.entry-content a,
.elementor-widget-text-editor a,
.elementor-text-editor a,
main p a,
main li a,
article p a,
article li a {
	text-decoration: underline !important;
	text-underline-offset: 0.16em;
	text-decoration-thickness: 0.08em;
	word-break: break-word;
}

/* Hover y foco más perceptibles */
.entry-content a:hover,
.entry-content a:focus,
.elementor-widget-text-editor a:hover,
.elementor-widget-text-editor a:focus,
.elementor-text-editor a:hover,
.elementor-text-editor a:focus,
main p a:hover,
main p a:focus,
main li a:hover,
main li a:focus {
	text-decoration-thickness: 0.12em;
}

/* =============================================================
   2. FOCO VISIBLE WCAG 2.4.7
   ============================================================= */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
	outline: 3px solid #005fcc !important;
	outline-offset: 3px !important;
	box-shadow: none !important;
}

/* Clase informativa sin impacto visual */
.lua-kd-patched { }

/* =============================================================
   3. BARRA INFERIOR DE ADMINISTRADOR
   ============================================================= */

#lua-kd-audit-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 999999;
	background: #1d2327;
	color: #fff;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	font: 13px/1.4 sans-serif;
	box-shadow: 0 -2px 10px rgba(0, 0, 0, .18);
}

#lua-kd-audit-bar button {
	background: #2271b1;
	border: 0;
	color: #fff;
	padding: 8px 12px;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
	line-height: 1.4;
	transition: background 0.15s ease;
}

#lua-kd-audit-bar button:hover {
	background: #135e96;
}

/* =============================================================
   4. OVERLAY
   ============================================================= */

#lua-kd-audit-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .35);
	z-index: 999998;
	opacity: 0;
	visibility: hidden;
	transition: opacity .22s ease, visibility .22s ease;
}

#lua-kd-audit-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

/* =============================================================
   5. SIDEBAR DE AUDITORÍA
   ============================================================= */

#lua-kd-audit-sidebar {
	position: fixed;
	top: 0;
	right: 0;
	height: 100vh;
	width: 520px;
	min-width: 320px;
	max-width: 90vw;
	background: #fff;
	color: #1d2327;
	z-index: 1000000;
	box-shadow: -8px 0 30px rgba(0, 0, 0, .22);
	transform: translateX(100%);
	transition: transform .25s ease;
	display: flex;
	flex-direction: row;
}

#lua-kd-audit-sidebar.is-open {
	transform: translateX(0);
}

/* Asa para redimensionar */
#lua-kd-audit-resizer {
	width: 10px;
	cursor: col-resize;
	background: linear-gradient(to right, rgba(0, 0, 0, .02), rgba(0, 0, 0, .08));
	flex: 0 0 10px;
	position: relative;
}

#lua-kd-audit-resizer::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 2px;
	transform: translateY(-50%);
	width: 6px;
	height: 56px;
	border-radius: 10px;
	background: repeating-linear-gradient(
		to bottom,
		#9aa0a6 0,
		#9aa0a6 4px,
		transparent 4px,
		transparent 8px
	);
	opacity: .8;
}

#lua-kd-audit-panel {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	height: 100%;
}

#lua-kd-audit-sidebar-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	padding: 18px 20px;
	border-bottom: 1px solid #dcdcde;
	background: #fff;
	position: sticky;
	top: 0;
	z-index: 2;
}

#lua-kd-audit-sidebar-header h2 {
	margin: 0;
	font-size: 18px;
	line-height: 1.2;
	color: #1d2327;
}

#lua-kd-audit-sidebar-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

#lua-kd-audit-sidebar-close {
	background: #f0f0f1;
	border: 1px solid #c3c4c7;
	color: #1d2327;
	padding: 6px 10px;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
}

#lua-kd-audit-sidebar-close:hover {
	background: #dcdcde;
}

#lua-kd-audit-results {
	flex: 1;
	overflow: auto;
	padding: 16px 20px;
}

/* Scroll interno sin cortar el contenido */
body.lua-kd-audit-open {
	overflow: hidden;
}

/* =============================================================
   6. TARJETAS DE INCIDENCIA
   ============================================================= */

.lua-kd-ok {
	background: #edfaef;
	border-left: 4px solid #00a32a;
	padding: 10px 14px;
	margin-bottom: 12px;
	border-radius: 0 4px 4px 0;
	font-size: 13px;
	line-height: 1.5;
}

.lua-kd-issue {
	background: #fff5f5;
	border-left: 4px solid #d63638;
	padding: 12px 14px;
	margin-bottom: 14px;
	border-radius: 0 4px 4px 0;
	font-size: 13px;
	line-height: 1.5;
}

.lua-kd-issue.is-fixed {
	background: #edfaef;
	border-left-color: #00a32a;
	opacity: .85;
}

.lua-kd-issue-type {
	font-weight: 700;
	color: #8a1f1f;
	display: block;
	margin-bottom: 3px;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .04em;
}

.lua-kd-issue.is-fixed .lua-kd-issue-type {
	color: #00641a;
}

.lua-kd-issue-msg {
	margin: 0 0 6px;
	font-size: 13px;
}

.lua-kd-issue-sample {
	display: block;
	font-size: 11px;
	color: #646970;
	background: rgba(0, 0, 0, .04);
	padding: 4px 6px;
	border-radius: 3px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 100%;
	margin-bottom: 8px;
	font-family: monospace;
}

/* =============================================================
   7. BOTONES DE ACCIÓN POR INCIDENCIA
   ============================================================= */

.lua-kd-issue-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 8px;
}

.lua-kd-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	border: none;
	padding: 5px 10px;
	border-radius: 4px;
	font-size: 12px;
	line-height: 1.4;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.lua-kd-btn:disabled {
	opacity: .5;
	cursor: not-allowed;
}

.lua-kd-btn-goto {
	background: #f0f0f1;
	border: 1px solid #c3c4c7;
	color: #1d2327;
}

.lua-kd-btn-goto:hover:not(:disabled) {
	background: #dcdcde;
}

.lua-kd-btn-preview {
	background: #2271b1;
	color: #fff;
}

.lua-kd-btn-preview:hover:not(:disabled) {
	background: #135e96;
}

.lua-kd-btn-apply {
	background: #00a32a;
	color: #fff;
}

.lua-kd-btn-apply:hover:not(:disabled) {
	background: #007a1f;
}

.lua-kd-btn-dismiss {
	background: transparent;
	border: 1px solid #c3c4c7;
	color: #646970;
}

.lua-kd-btn-dismiss:hover:not(:disabled) {
	color: #d63638;
	border-color: #d63638;
}

/* =============================================================
   8. PANEL DE PREVIEW IA
   ============================================================= */

.lua-kd-preview-panel {
	margin-top: 10px;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	overflow: hidden;
	font-size: 12px;
}

.lua-kd-preview-block {
	padding: 8px 10px;
}

.lua-kd-preview-block + .lua-kd-preview-block {
	border-top: 1px solid #dcdcde;
}

.lua-kd-preview-label {
	display: block;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	margin-bottom: 4px;
	color: #646970;
}

.lua-kd-preview-label.is-original {
	color: #8a1f1f;
}

.lua-kd-preview-label.is-proposed {
	color: #007a1f;
}

.lua-kd-preview-code {
	background: #f0f0f1;
	padding: 6px 8px;
	border-radius: 3px;
	font-family: monospace;
	font-size: 11px;
	word-break: break-all;
	white-space: pre-wrap;
	margin: 0;
	color: #1d2327;
}

.lua-kd-preview-explanation {
	font-size: 12px;
	color: #3c434a;
	margin: 0;
	font-style: italic;
}

/* =============================================================
   9. ESTADOS: CARGA, ÉXITO, ERROR
   ============================================================= */

/* Loading spinner inline */
.lua-kd-loading {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: #646970;
	margin-top: 8px;
}

.lua-kd-spinner {
	width: 14px;
	height: 14px;
	border: 2px solid #dcdcde;
	border-top-color: #2271b1;
	border-radius: 50%;
	animation: lua-kd-spin .7s linear infinite;
	flex-shrink: 0;
}

@keyframes lua-kd-spin {
	to { transform: rotate(360deg); }
}

/* Mensajes inline */
.lua-kd-inline-msg {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	padding: 6px 8px;
	border-radius: 4px;
	font-size: 12px;
	margin-top: 8px;
	line-height: 1.4;
}

.lua-kd-inline-msg.is-success {
	background: #edfaef;
	color: #007a1f;
	border: 1px solid #a0d9ae;
}

.lua-kd-inline-msg.is-error {
	background: #fff5f5;
	color: #8a1f1f;
	border: 1px solid #f0a3a3;
}

.lua-kd-inline-msg.is-info {
	background: #f0f6fc;
	color: #135e96;
	border: 1px solid #a5c9e8;
}

/* =============================================================
   10. HIGHLIGHT DE ELEMENTO EN PÁGINA
   ============================================================= */

.lua-kd-highlight {
	outline: 3px solid #d63638 !important;
	outline-offset: 2px !important;
	scroll-margin-top: 100px;
}

/* =============================================================
   11. SECCIÓN DE RESUMEN (parte superior del panel)
   ============================================================= */

.lua-kd-summary {
	background: #f0f6fc;
	border: 1px solid #a5c9e8;
	border-radius: 4px;
	padding: 10px 14px;
	margin-bottom: 16px;
	font-size: 12px;
	line-height: 1.6;
}

.lua-kd-summary strong {
	display: block;
	font-size: 13px;
	margin-bottom: 4px;
	color: #1d2327;
}

/* =============================================================
   12. HEADING DE SECCIÓN DE INCIDENCIAS
   ============================================================= */

.lua-kd-section-title {
	font-size: 13px;
	font-weight: 700;
	color: #1d2327;
	margin: 0 0 12px;
	padding-bottom: 8px;
	border-bottom: 1px solid #dcdcde;
}

/* =============================================================
   13. RESPONSIVE
   ============================================================= */

@media (max-width: 600px) {
	#lua-kd-audit-sidebar {
		width: 100vw !important;
		max-width: 100vw;
	}

	#lua-kd-audit-resizer {
		display: none;
	}

	.lua-kd-issue-actions {
		flex-direction: column;
	}

	.lua-kd-btn {
		width: 100%;
		justify-content: center;
	}
}

/* =============================================================
   14. MODO BATCH — PROGRESO Y RESUMEN
   ============================================================= */

/* Contenedor principal del modo batch */
#lua-kd-batch-ui {
	padding: 20px;
}

/* Cabecera */
.lua-kd-batch-title {
	font-size: 15px;
	font-weight: 700;
	color: #1d2327;
	margin: 0 0 16px;
	display: flex;
	align-items: center;
	gap: 8px;
}

/* Barra de progreso */
.lua-kd-progress-wrap {
	background: #f0f0f1;
	border-radius: 6px;
	height: 10px;
	overflow: hidden;
	margin-bottom: 10px;
}

.lua-kd-progress-bar {
	height: 100%;
	background: linear-gradient(90deg, #2271b1, #00a32a);
	border-radius: 6px;
	transition: width 0.3s ease;
	width: 0%;
}

/* Contador de progreso */
.lua-kd-progress-count {
	font-size: 12px;
	color: #646970;
	margin-bottom: 12px;
	display: flex;
	justify-content: space-between;
}

/* Item actual procesándose */
.lua-kd-batch-current {
	font-size: 12px;
	color: #3c434a;
	background: #f9f9f9;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	padding: 8px 12px;
	margin-bottom: 16px;
	min-height: 38px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.lua-kd-batch-current-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex: 1;
}

/* Log de resultados parciales durante el proceso */
.lua-kd-batch-log {
	max-height: 220px;
	overflow-y: auto;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	font-size: 12px;
	line-height: 1.5;
}

.lua-kd-batch-log-item {
	padding: 6px 10px;
	border-bottom: 1px solid #f0f0f1;
	display: flex;
	align-items: flex-start;
	gap: 6px;
}

.lua-kd-batch-log-item:last-child {
	border-bottom: none;
}

.lua-kd-batch-log-item.is-ok {
	color: #007a1f;
}

.lua-kd-batch-log-item.is-error {
	color: #8a1f1f;
}

.lua-kd-batch-log-item.is-skip {
	color: #646970;
}

.lua-kd-batch-log-icon {
	flex-shrink: 0;
	font-style: normal;
}

.lua-kd-batch-log-text {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Resumen final */
.lua-kd-batch-summary {
	border-radius: 4px;
	overflow: hidden;
	margin-top: 4px;
}

.lua-kd-batch-summary-header {
	padding: 14px 16px;
	font-weight: 700;
	font-size: 14px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.lua-kd-batch-summary-header.all-ok {
	background: #edfaef;
	color: #007a1f;
	border: 1px solid #a0d9ae;
	border-radius: 4px 4px 0 0;
}

.lua-kd-batch-summary-header.has-errors {
	background: #fff8e5;
	color: #7a4f00;
	border: 1px solid #f5c040;
	border-radius: 4px 4px 0 0;
}

.lua-kd-batch-summary-stats {
	display: flex;
	gap: 0;
	border: 1px solid #dcdcde;
	border-top: none;
	border-radius: 0 0 4px 4px;
	overflow: hidden;
}

.lua-kd-batch-stat {
	flex: 1;
	padding: 10px 8px;
	text-align: center;
	font-size: 12px;
	line-height: 1.3;
}

.lua-kd-batch-stat + .lua-kd-batch-stat {
	border-left: 1px solid #dcdcde;
}

.lua-kd-batch-stat-num {
	display: block;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.1;
	margin-bottom: 2px;
}

.lua-kd-batch-stat.is-ok    .lua-kd-batch-stat-num { color: #00a32a; }
.lua-kd-batch-stat.is-error .lua-kd-batch-stat-num { color: #d63638; }
.lua-kd-batch-stat.is-skip  .lua-kd-batch-stat-num { color: #646970; }

/* Errores expandibles en el resumen */
.lua-kd-batch-errors {
	margin-top: 12px;
	font-size: 12px;
}

.lua-kd-batch-errors summary {
	cursor: pointer;
	color: #646970;
	padding: 4px 0;
	user-select: none;
}

.lua-kd-batch-errors ul {
	margin: 6px 0 0;
	padding-left: 16px;
	color: #8a1f1f;
}

.lua-kd-batch-errors li {
	margin-bottom: 4px;
	line-height: 1.4;
}

/* Acciones post-batch */
.lua-kd-batch-actions {
	display: flex;
	gap: 8px;
	margin-top: 16px;
	flex-wrap: wrap;
}

/* Botón "Corregir todo" deshabilitado durante proceso */
#lua-kd-audit-batch-btn:disabled {
	opacity: .5;
	cursor: not-allowed;
}
