@use 'mixins/mixins';
@use 'mixins/utils';
@use './common/var';
@use 'select-dropdown';
@use 'input';
@use 'tag';
@use 'option';
@use 'option-group';
@use 'scrollbar';

@include mixins.b(select) {
	display: inline-block;
	position: relative;
	width: 100%;

	.el-select__tags {
		overflow-x: scroll;
		scrollbar-width: none;
		-ms-overflow-style: none;
		&::-webkit-scrollbar {
			display: none;
		}
	}

	.el-select__tags > span {
		display: contents;
	}

	.el-select__tags + .el-input {
		input {
			box-sizing: border-box;
			padding: 0 0 0 var(--spacing-2xs);
			text-indent: 0;
		}
	}

	.el-input__inner {
		cursor: pointer;
		padding-right: 35px;

		&:focus {
			border-color: var.$select-input-focus-border-color;
		}
	}

	.el-input {
		& .el-select__caret {
			font-size: var.$select-input-font-size;
			transition: transform 0.3s;
			cursor: pointer;

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

			@include mixins.when(show-close) {
				font-size: var.$select-font-size;
				text-align: center;
				transform: rotateZ(180deg);
				border-radius: var.$border-radius-circle;
				color: var.$select-input-color;
				transition: var.$color-transition-base;

				&:hover {
					color: var.$select-close-hover-color;
				}
			}
		}

		&.is-disabled {
			& .el-input__inner {
				cursor: not-allowed;

				&:hover {
					border-color: var.$select-disabled-border;
				}
			}
		}

		&.is-focus .el-input__inner {
			border-color: var.$select-input-focus-border-color;
		}

		&__prefix {
			left: var(--spacing-2xs);
		}

		&--prefix .el-input__inner {
			padding-left: 26px;
		}
	}

	> .el-input {
		display: block;
	}

	@include mixins.e(input) {
		border: none;
		outline: none;
		padding: 0;
		margin-left: var(--spacing-2xs);
		color: var.$select-multiple-input-color;
		font-size: var.$select-font-size;
		appearance: none;
		height: 28px;
		background-color: transparent;
		@include mixins.when(mini) {
			height: 14px;
		}
	}

	@include mixins.e(close) {
		cursor: pointer;
		position: absolute;
		top: 8px;
		z-index: var.$index-top;
		right: 25px;
		color: var.$select-input-color;
		line-height: 18px;
		font-size: var.$select-input-font-size;

		&:hover {
			color: var.$select-close-hover-color;
		}
	}

	@include mixins.e(tags) {
		position: absolute;
		line-height: normal;
		white-space: normal;
		z-index: var.$index-normal;
		top: 50%;
		transform: translateY(-50%);
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}

	.el-tag__close {
		margin-top: -2px;
	}

	.el-tag {
		box-sizing: border-box;
		margin: 2px 0 2px 6px;
		border-color: var(--color-foreground-base);
		background-color: var(--color-foreground-base);
		color: var(--color-text-dark);
		border-radius: 20px;
		font-weight: var(--font-weight-regular);

		&__close.el-icon-close {
			background-color: var(--color-text-light);
			right: -7px;
			top: 0;
			color: var.$color-white;
			margin-right: 6px;

			&:hover {
				background-color: var(--color-text-base);
			}

			&::before {
				display: block;
				transform: translate(0, 0.5px);
			}
		}
	}

	&--large {
		.el-input__inner {
			height: 42px;
		}
	}
	&--default {
		.el-tag {
			padding: var(--spacing-5xs) var(--spacing-xs);
		}
	}
}
