/**
 * Enfoque Floating Button - Frontend.
 *
 * Todo el CSS queda encapsulado bajo .efb-root / .efb-floating-button /
 * .efb-popup. No se usan selectores genéricos (body, a, button, div, *)
 * ni selectores de otros plugins/temas.
 */

.efb-root {
	/* Contenedor raíz sin efectos visuales propios: solo agrupa. */
	all: initial;
}

.efb-floating-button {
	margin: 0;
	outline: none;
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	text-align: left;
	list-style: none;
	box-sizing: border-box;
	position: fixed;
	z-index: var(--efb-z-index, 999);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--efb-icon-gap, 8px);
	min-width: var(--efb-min-width, 0);
	min-height: var(--efb-min-height, 48px);
	max-width: calc(100vw - 24px);
	padding: var(--efb-padding-y, 14px) var(--efb-padding-x, 20px);
	background-color: var(--efb-bg, #1c1c1c);
	background-image: none;
	color: var(--efb-color, #fff);
	border-style: solid;
	border-width: var(--efb-border-width, 0);
	border-color: var(--efb-border-color, transparent);
	border-radius: var(--efb-border-radius, 999px);
	box-shadow: var(--efb-shadow, none);
	font-family: var(--efb-font-family, inherit);
	font-size: var(--efb-font-size, 15px);
	font-weight: var(--efb-font-weight, 600);
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
	transition-property: background-color, color, border-color, box-shadow;
	transition-duration: var(--efb-transition-duration, 200ms);
	transition-timing-function: var(--efb-transition-easing, ease);
	-webkit-tap-highlight-color: transparent;
}

/* Respetar el "notch"/safe-area en móviles sin complicar la implementación. */
@media screen and (max-width: 767px) {
	.efb-floating-button {
		margin-right: env(safe-area-inset-right, 0px);
		margin-left: env(safe-area-inset-left, 0px);
		margin-bottom: env(safe-area-inset-bottom, 0px);
	}
}

.efb-floating-button:hover,
.efb-floating-button:focus-visible {
	background-color: var(--efb-bg-hover, #3a3a3a) !important;
	color: var(--efb-color-hover, #fff) !important;
	border-color: var(--efb-border-color-hover, transparent) !important;
	box-shadow: var(--efb-shadow-hover, none) !important;
}

.efb-floating-button:hover .efb-floating-button__icon,
.efb-floating-button:focus-visible .efb-floating-button__icon {
	color: var(--efb-icon-color-hover, #fff) !important;
}

.efb-floating-button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.efb-floating-button__variant {
	display: none;
	align-items: center;
	gap: var(--efb-icon-gap, 8px);
}

.efb-floating-button__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--efb-icon-size, 20px);
	height: var(--efb-icon-size, 20px);
	color: var(--efb-icon-color, currentColor);
	flex: 0 0 auto;
}

.efb-floating-button__icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.efb-floating-button__icon img {
	width: var(--efb-icon-width, 24px);
	height: var(--efb-icon-height, 24px);
	object-fit: contain;
	display: block;
}

.efb-floating-button__text {
	display: inline-block;
}

/* ------------------------------------------------------------------ *
 * Popup
 * ------------------------------------------------------------------ */

.efb-popup {
	all: unset;
	position: fixed;
	inset: 0;
	z-index: var(--efb-popup-z-index, 1000);
	display: flex;
}

.efb-popup[hidden] {
	display: none;
}

.efb-popup__backdrop {
	position: absolute;
	inset: 0;
	background: var(--efb-popup-backdrop-color, #000);
	opacity: var(--efb-popup-backdrop-opacity, 0.55);
}

.efb-popup__dialog {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	width: min(var(--efb-popup-max-width, 560px), calc(100vw - 32px));
	max-height: calc(100vh - 64px);
	margin: 32px auto;
	overflow: hidden;
	background: var(--efb-popup-bg, #fff);
	color: var(--efb-popup-color, #1c1c1c);
	border: var(--efb-popup-border-width, 0) solid var(--efb-popup-border-color, transparent);
	border-radius: var(--efb-popup-border-radius, 16px);
	box-shadow: var(--efb-popup-shadow, none);
}

.efb-popup__content {
	padding: var(--efb-popup-padding, 32px);
	overflow-y: auto;
}

.efb-popup__title {
	margin-top: 0;
}

.efb-popup__close {
	all: unset;
	box-sizing: border-box;
	position: absolute;
	top: 12px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 6px;
	color: inherit;
	cursor: pointer;
	border-radius: 999px;
}

.efb-popup__close:hover,
.efb-popup__close:focus-visible {
	background: rgba(0, 0, 0, 0.06);
}

.efb-popup__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.efb-popup__close svg {
	width: 100%;
	height: 100%;
	display: block;
}

/* Animaciones: solo aplicadas mediante la clase que añade el JS al abrir. */
.efb-popup[data-efb-animation="fade"] .efb-popup__dialog,
.efb-popup[data-efb-animation="scale"] .efb-popup__dialog {
	transition: opacity 180ms ease, transform 180ms ease;
	opacity: 0;
}

.efb-popup[data-efb-animation="scale"] .efb-popup__dialog {
	transform: scale(0.96);
}

.efb-popup.efb-is-open[data-efb-animation="fade"] .efb-popup__dialog,
.efb-popup.efb-is-open[data-efb-animation="scale"] .efb-popup__dialog {
	opacity: 1;
	transform: none;
}

/* prefers-reduced-motion: sin transiciones/animaciones largas. */
@media (prefers-reduced-motion: reduce) {
	.efb-floating-button {
		transition-duration: 0ms !important;
	}

	.efb-popup[data-efb-animation="fade"] .efb-popup__dialog,
	.efb-popup[data-efb-animation="scale"] .efb-popup__dialog {
		transition: none !important;
		opacity: 1 !important;
		transform: none !important;
	}
}
