/**
 * Popover Text Component
 *
 * Styles for text popovers that appear on hover (desktop) or tap (mobile)
 */

/* Popover trigger text */
.popover-text {
	border-bottom: 2px dotted var(--color-primary, #e2422a);
	cursor: help;
	position: relative;
	text-decoration: none;
}

.popover-text:hover {
	background-color: rgba(226, 66, 42, 0.05);
}

/* Popover box */
.popover-box {
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-bottom: 8px;
	background: white;
	border: 2px solid var(--color-secondary-cyan, #67d3e4);
	border-radius: 8px;
	padding: 12px 16px;
	min-width: 200px;
	max-width: 300px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--color-text-dark, rgba(0, 0, 0, 0.8));
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	z-index: 1000;
	display: none;
	pointer-events: none;
}

/* Arrow for popover */
.popover-box::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 8px solid transparent;
	border-top-color: var(--color-secondary-cyan, #67d3e4);
}

.popover-box::before {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-top: -2px;
	border: 8px solid transparent;
	border-top-color: white;
	z-index: 1;
}

/* Show popover on hover (desktop) */
.popover-text:hover .popover-box {
	display: block;
}

/* Active state for mobile tap */
.popover-text.active .popover-box {
	display: block;
	pointer-events: auto;
}

/* Close button (mobile only) */
.popover-close {
	position: absolute;
	top: 8px;
	right: 8px;
	background: transparent;
	border: none;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	color: var(--color-text-dark, rgba(0, 0, 0, 0.8));
	padding: 0;
	width: 20px;
	height: 20px;
	display: none;
	align-items: center;
	justify-content: center;
	opacity: 0.6;
	transition: opacity 0.2s ease;
}

.popover-close:hover {
	opacity: 1;
}

/* Responsive styles */
@media (max-width: 991px) {
	.popover-box {
		max-width: 250px;
		font-size: 13px;
	}
}

@media (max-width: 576px) {
	/* Show close button on mobile */
	.popover-close {
		display: flex;
	}

	/* Adjust popover positioning for mobile */
	.popover-box {
		position: fixed;
		left: 50% !important;
		bottom: auto !important;
		top: 50% !important;
		transform: translate(-50%, -50%) !important;
		margin: 0;
		max-width: calc(100vw - 40px);
		width: 280px;
	}

	.popover-box::after,
	.popover-box::before {
		display: none;
	}

	/* Add padding for close button */
	.popover-box {
		padding-right: 35px;
	}

	/* Disable hover on mobile */
	.popover-text:hover .popover-box {
		display: none;
	}

	/* Backdrop for mobile popover */
	.popover-backdrop {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.5);
		z-index: 999;
		display: none;
	}

	.popover-backdrop.active {
		display: block;
	}
}

/* Position adjustments when popover would go off-screen horizontally */
/* When overflowing LEFT edge: align popover's RIGHT edge to trigger's RIGHT edge */
.popover-text.popover-align-left .popover-box {
	left: auto;
	right: 0;
	transform: translateX(0);
}

/* When overflowing RIGHT edge: align popover's LEFT edge to trigger's LEFT edge */
.popover-text.popover-align-right .popover-box {
	left: 0;
	right: auto;
	transform: translateX(0);
}

.popover-text.popover-align-left .popover-box::after,
.popover-text.popover-align-left .popover-box::before {
	left: auto;
	right: 20px;
	transform: translateX(0);
}

.popover-text.popover-align-right .popover-box::after,
.popover-text.popover-align-right .popover-box::before {
	left: 20px;
	right: auto;
	transform: translateX(0);
}

/* Position adjustment when popover needs to appear below (vertical flip) */
.popover-text.popover-align-bottom .popover-box {
	bottom: auto;
	top: 100%;
	margin-bottom: 0;
	margin-top: 8px;
}

/* Flip arrow to point upward when popover is below */
.popover-text.popover-align-bottom .popover-box::after {
	top: auto;
	bottom: 100%;
	border-top-color: transparent;
	border-bottom-color: var(--color-secondary-cyan, #67d3e4);
}

.popover-text.popover-align-bottom .popover-box::before {
	top: auto;
	bottom: 100%;
	margin-top: 0;
	margin-bottom: -2px;
	border-top-color: transparent;
	border-bottom-color: white;
}
