@import '../../../styles/_partials/index';
@import '../../inputs/FlyDropdown/FlyDropdown';

.FlyTooltip_Container {
	position: relative;
	display: inline-block;

	&:hover,
	&.FlyTooltip_Container__ForceShowState {
		.FlyTooltip {
			transform: scale(1) translateY(0) translateZ(0);
		}
	}

	&.FlyTooltip_Container__HoverIntent:hover {
		.FlyTooltip {
			transition-delay: .65s;
		}
	}
}

@mixin fixRemovedExtendStyles () {
	$ease-in: cubic-bezier(.2,.3,.25,.9);
	$border-radius: 4px;

	position: absolute;
	top: calc(100% - 1px);
	right: -15px;
	left: auto;
	transform: scale(0) translateY(0%) translateZ(0);
	transform-origin: 90% -15px;
	transition: transform 80ms $ease-in 80ms;
	z-index: 6;
	margin-left: 0;
	border-radius: $border-radius;
	box-shadow: 0 0 20px 0 rgba($gray-dark, .15);
	@include theme-background-white-else-graydark50;
	padding: 0;
	width: 160px;
	height: auto;
	list-style-type: none;
	text-align: center;
	line-height: normal;

	&::before,
	&::after {
		content: "";
		pointer-events: none;
		display: block;
		position: absolute;
		top: -6px;
		left: 50%;
		transition: all .05s $ease-in 0s;
		z-index: 2;
		margin-left: -10px;
		border-radius: $border-radius;
		@include theme-background-white-else-graydark50;
		width: 20px;
		height: 20px;
	}

	&::after {
		top: 0;
		right: 7px;
		left: auto;
		margin-left: -15px;
		width: 30px;
		height: 18px;
		border-radius: 0;
		background: $white;
	}

	&::before {
		right: 11px;
		left: auto;
		transform: rotate(45deg);
	}

	&.FlyDropdown_Items__PositionTop {
		top: -10px;

		&::after {
			top: auto;
			bottom: 0;
			right: 10px;
		}

		&::before {
			bottom: -6px;
			top: auto;
			right: 14px;
		}
	}
}

.FlyTooltip {
	@include fixRemovedExtendStyles();

	top: auto;
	z-index: 5;
	right: 50%;
	display: inline-block;
	width: 300px;
	margin-top: -5px;
	margin-right: -20px;
	padding: 10px 30px;
	transform-origin: 95% 0;
	font-weight: 300;
	@include theme-color-graydark50-else-gray25;
	@include theme-input-background-color;
	@include theme-input-border;

	&.FlyTooltip__WidthAuto {
		width: auto;
	}

	&.FlyTooltip__WidthMaxContent {
		width: max-content;
	}

	&::before {
		top: auto;
		right: 10px;
		bottom: -6px;
		@include theme-input-background-color;
		@include theme-input-border;
		z-index: -1;
	}

	&::after {
		top: auto;
		right: 0;
		bottom: 0;
		left: auto;
		width: 40px;
		height: 25px;
		border-radius: 4px;
		@include theme-input-background-color;
		margin-left: 0;
		margin-right: 1px;
		z-index: -1;
	}

	:global(.Spinner) {
		vertical-align: middle;
		width: 14px;
		height: auto;
		animation: rotateSpinner 1s linear infinite;
		margin: -2px 5px 0 0;

		path {
			fill: $gray25;
		}
	}

	&.FlyTooltip__PositionTop {
		margin-top: -5px;
		transform: scale(0) translateY(-100%) translateZ(0);

		@at-root .FlyTooltip_Container:hover & {
			transform: scale(1) translateY(-100%) translateZ(0);
		}
	}

	&.FlyTooltip__PositionBottom {
		transform-origin: 95% 95%;
		top: auto;
		bottom: -12px;
		margin-top: 0;
		transform: scale(0) translateY(100%) translateZ(0);

		@at-root .FlyTooltip_Container:hover & {
			transform: scale(1) translateY(100%) translateZ(0);
		}

		&::before {
			top: -6px;
			bottom: auto;
		}

		&::after {
			top: 0;
		}
	}

	&.FlyTooltip__PositionRight {
		top: 50%;
		right: -5px;
		width: auto;
		margin: -18px 0 0;
		padding: 10px 15px;
		transform-origin: 100% 50%;
		transform: scale(0) translateX(100%) translateY(0) translateZ(0);
		white-space: nowrap;

		&::before {
			top: 50%;
			right: auto;
			bottom: auto;
			left: 5px;
			margin-top: -10px;
		}

		&::after {
			left: 0;
			width: 25px;
			height: 100%;
			border-radius: 4px;
		}

		@at-root .FlyTooltip_Container:hover & {
			transform: scale(1) translateX(100%) translateY(0) translateZ(0);
		}
	}

	&.FlyTooltip__PositionCenter {
		transform-origin: 0 0;
		right: 50%;
		left: 50%;
		margin-right: 0;
		transform: scale(0) translateX(-50%) translateY(-100%) translateZ(0);

		&::before {
			left: 50%;
			right: 50%;
		}

		&::after {
			left: 50%;
			transform: translate(-50%, 0);
		}

		@at-root .FlyTooltip_Container:hover & {
			transform: scale(1) translateX(-50%) translateY(-100%) translateZ(0);
		}
	}

	.FlyTooltip_Exclamation {
		$size: 18px;

		position: absolute;
		top: -1 * calc($size / 2);
		left: -1 * calc($size / 2);
		width: $size;
		height: $size;
		background: $red;
		border-radius: 100%;

		svg {
			width: 2px;
			height: 8px;
			fill: $white;
		}
	}

	> * {
		position: relative;
		z-index: 3;
	}

	p, li, .Title {
		margin: 8px 0;
	}

	a {
		font-weight: 700;
		@include tracking(20);
	}

	.Title {
		font-weight: 700;
		font-size: 14px;
		@include theme-color-graydark-else-white;
	}

	ul {
		padding: 0;
		list-style: none;
	}
}
