@import "../common/mixin.scss";

@include b(cascader) {
	display: inline-block;
	position: relative;
	font-size: $--font-size-base;
	line-height: $--input-height;
	width: 100%;

	&:not(.is-disabled):hover {
		.tu-input__inner {
			cursor: pointer;
		}
	}

	.tu-input {
		cursor: pointer;

		.tu-input__inner {
			text-overflow: ellipsis;
		}

		.tu-icon-down {
			transition: transform 0.3s;
			font-size: 14px;

			@include when(reverse) {
				transform: rotateZ(180deg);
			}
		}

		.tu-icon-close-circle-fill:hover {
			color: $--color-primary;
		}

		@include when(focus) {
			.tu-input__inner {
				box-shadow: $--box-shadow-convex;
			}
		}
	}

	@include when(disabled) {
		.tu-cascader__label {
			z-index: #{$--index-normal + 1};
			color: $--color-text-disabled;
		}
	}

	@include e(dropdown) {
		margin: 5px 0;
		box-shadow: $--box-shadow-convex;
		background-color: $--color-background;
	}

	@include e(tags) {
		position: absolute;
		left: 0;
		right: 30px;
		top: 50%;
		transform: translateY(-50%);
		display: flex;
		flex-wrap: wrap;
		line-height: normal;
		text-align: left;
		box-sizing: border-box;

		.tu-tag,
		.tu-tag:last-child {
			margin: 4px 0 4px 6px;
			text-overflow: ellipsis;
		}
	}

	@include e(suggestion-panel) {
		border-radius: $--cascader-menu-radius;
	}

	@include e(suggestion-list) {
		max-height: 204px;
		margin: 0;
		padding: 6px 0;
		font-size: $--font-size-base;
		color: $--cascader-menu-font-color;
		text-align: center;
	}

	@include e(suggestion-item) {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 36px;
		padding: 0 15px;
		text-align: left;
		outline: none;
		cursor: pointer;
		transition: background-color 0.3s;

		&:hover,
		&:focus {
			background-color: $--color-hover-background;
		}

		&.is-checked {
			color: $--cascader-menu-selected-font-color;
			font-weight: bold;
		}

		> span {
			margin-right: 10px;
		}
	}

	@include e(empty-text) {
		margin: 10px 0;
		color: $--cascader-color-empty;
	}

	@include e(search-input) {
		flex: 1;
		height: 24px;
		min-width: 60px;
		margin: 1px 0 1px 12px;
		padding: 0;
		border: none;
		outline: none;
		box-sizing: border-box;
		background-color: transparent;
		color: $--color-text-primary;
		font-size: $--font-size-base;

		&::placeholder {
			color: $--color-text-disabled;
		}
	}
}
