/**
 * Compatibilidad Elementor + LearnDash + temas agresivos.
 * Debe cargarse lo más tarde posible (footer) para ganar en cascada.
 */

/* Contenedor: no heredar flex/grid raros del widget padre */
body .elementor-widget-container .autofile-viewer-wrapper,
body .elementor-widget-html .autofile-viewer-wrapper,
body .ld-tabs-content .autofile-viewer-wrapper,
body .ld-tab-content .autofile-viewer-wrapper,
body .learndash .autofile-viewer-wrapper,
body #learndash_lessons .autofile-viewer-wrapper {
	display: block !important;
	width: 100% !important;
	max-width: 100% !important;
}

body .autofile-viewer-container {
	display: flex !important;
	flex-direction: column !important;
	align-items: stretch !important;
	contain: layout style;
}

/* Elementor a veces fuerza columnas en TODO button */
body .elementor .autofile-viewer-container button.autofile-btn,
body .elementor-widget .autofile-viewer-container button.autofile-btn,
body .ld-content .autofile-viewer-container button.autofile-btn {
	display: inline-flex !important;
	flex-direction: row !important;
	flex-wrap: nowrap !important;
	align-items: center !important;
	justify-content: center !important;
	align-content: center !important;
	vertical-align: middle !important;
	width: auto !important;
	min-width: 28px !important;
	height: 28px !important;
	min-height: 28px !important;
	max-height: none !important;
	padding: 3px !important;
	margin: 0 !important;
	line-height: 1 !important;
	text-align: center !important;
	white-space: nowrap !important;
	background-image: none !important;
	box-shadow: none !important;
	transform: none !important;
	border-radius: 4px !important;
	position: relative !important;
	z-index: 2 !important;
	overflow: visible !important;
}

/* Quitar capas decorativas típicas de Elementor en botones */
body .autofile-viewer-container button.autofile-btn::before,
body .autofile-viewer-container button.autofile-btn::after,
body .elementor .autofile-viewer-container button.autofile-btn::before,
body .elementor .autofile-viewer-container button.autofile-btn::after {
	content: none !important;
	display: none !important;
	width: 0 !important;
	height: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	border: none !important;
	background: none !important;
	box-shadow: none !important;
	position: static !important;
	opacity: 0 !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

/* Barra principal: una fila, scroll horizontal */
body .elementor .autofile-viewer-container .autofile-main-toolbar,
body .ld-content .autofile-viewer-container .autofile-main-toolbar {
	display: flex !important;
	flex-direction: row !important;
	flex-wrap: nowrap !important;
	align-items: center !important;
	justify-content: space-between !important;
	width: 100% !important;
	overflow-x: auto !important;
	-webkit-overflow-scrolling: touch;
}

body .autofile-viewer-container .autofile-toolbar-group {
	display: flex !important;
	flex-direction: row !important;
	flex-wrap: nowrap !important;
	align-items: center !important;
	flex-shrink: 0 !important;
}

/* SVG: sin relleno sólido del tema (bloques azules/morados) */
body .autofile-viewer-container svg.autofile-icon,
body .autofile-viewer-container .autofile-btn svg {
	display: block !important;
	width: 18px !important;
	height: 18px !important;
	flex: 0 0 auto !important;
	fill: none !important;
	stroke: currentColor !important;
	color: inherit !important;
	position: relative !important;
	z-index: 3 !important;
}

body .autofile-viewer-container svg.autofile-icon *,
body .autofile-viewer-container .autofile-btn svg * {
	fill: none !important;
	stroke: currentColor !important;
}

body .autofile-viewer-container .autofile-floating-toolbar svg.autofile-icon,
body .autofile-viewer-container .autofile-floating-toolbar .autofile-btn svg {
	width: 24px !important;
	height: 24px !important;
}

/* Evitar contornos rojos/azules de focus del tema (mantener accesible con :focus-visible suave) */
body .autofile-viewer-container .autofile-btn:focus {
	outline: none !important;
	box-shadow: none !important;
}

body .autofile-viewer-container .autofile-btn:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.65) !important;
	outline-offset: 2px !important;
}

/* Mobile: viewer fits screen width and toolbar scrolls horizontally */
@media (max-width: 768px) {
	body .elementor-widget-container .autofile-viewer-wrapper,
	body .elementor-widget-html .autofile-viewer-wrapper,
	body .ld-tabs-content .autofile-viewer-wrapper,
	body .ld-tab-content .autofile-viewer-wrapper,
	body .learndash .autofile-viewer-wrapper,
	body #learndash_lessons .autofile-viewer-wrapper {
		width: min(90vh, 100vw) !important;
		max-width: min(90vh, 100vw) !important;
		margin-left: auto !important;
		margin-right: auto !important;
	}

	body .autofile-viewer-container {
		width: 100% !important;
		max-width: 100% !important;
		min-width: 0 !important;
	}

	body .elementor .autofile-viewer-container .autofile-main-toolbar,
	body .ld-content .autofile-viewer-container .autofile-main-toolbar {
		justify-content: flex-start !important;
		overflow-x: auto !important;
		overflow-y: hidden !important;
		white-space: nowrap !important;
		-webkit-overflow-scrolling: touch !important;
		scrollbar-width: thin;
	}

	body .autofile-viewer-container .autofile-toolbar-group {
		flex: 0 0 auto !important;
	}
}
