.legend {

	&--horizontal {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		gap: 16px;
	}

	&--vertical {
		display: flex;
		flex-direction: column;
		gap: 8px;

		&.legend--alignment-start {
			align-items: flex-start;
		}

		&.legend--alignment-center {
			align-items: center;
		}

		&.legend--alignment-end {
			align-items: flex-end;
		}
	}

	// Position-based styles
	&--position-top {
		position: relative;

		&.legend--alignment-start {
			justify-content: flex-start;
		}

		&.legend--alignment-center {
			justify-content: center;
		}

		&.legend--alignment-end {
			justify-content: flex-end;
		}
	}

	&--position-bottom {
		position: relative;

		&.legend--alignment-start {
			justify-content: flex-start;
		}

		&.legend--alignment-center {
			justify-content: center;
		}

		&.legend--alignment-end {
			justify-content: flex-end;
		}
	}
}

.legend-item {
	display: flex;
	align-items: center;
	font-size: 0.875rem;
}

.legend-item-label {
	display: flex;
	align-items: center;
	gap: 0.5rem;

	/* Text wrapping is handled at the text level, not the label container */
}

.legend-item-text {

	&--wrap {
		word-wrap: break-word;
		overflow-wrap: break-word;
		white-space: normal;
		hyphens: auto;
	}

	&--ellipsis {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		flex-shrink: 1;
		min-width: 0;
	}
}

.legend-item-value {
	font-weight: 500;
	flex-shrink: 0; // Prevent value from shrinking when text is ellipsized
}
