@use 'mixins/mixins';
@use './common/var';

@mixin genTheme() {
	background-color: var.$color-primary-lighter;
	border-color: var.$color-primary-light-5;
	color: var.$color-primary-light-1;
	font-weight: var(--font-weight-regular);

	@include mixins.when(hit) {
		border-color: var.$tag-primary-color;
	}

	.el-tag__close {
		color: var.$color-primary-light-1;
		&:hover {
			color: var.$color-white;
			background-color: var.$color-primary-light-1;
		}
	}

	&.el-tag--info {
		background-color: var.$color-info-lighter;
		border-color: var.$color-info-light-5;
		color: var.$color-info-light-3;

		@include mixins.when(hit) {
			border-color: var.$tag-info-color;
		}

		.el-tag__close {
			color: var.$color-info-light-1;
			&:hover {
				color: var.$color-white;
				background-color: var.$color-info-light-1;
			}
		}
	}

	&.el-tag--success {
		background-color: var(--color-success-tint-2);
		border-color: var(--color-success-tint-1);
		color: var(--color-success);

		@include mixins.when(hit) {
			border-color: var.$tag-success-color;
		}

		.el-tag__close {
			color: var.$color-success-light-1;
			&:hover {
				color: var.$color-white;
				background-color: var.$color-success-light-1;
			}
		}
	}

	&.el-tag--warning {
		background-color: var.$color-warning-lighter;
		border-color: var.$color-warning-light-5;
		color: var.$color-warning-light-3;

		@include mixins.when(hit) {
			border-color: var.$tag-warning-color;
		}

		.el-tag__close {
			color: var.$color-warning-light-1;
			&:hover {
				color: var.$color-white;
				background-color: var.$color-warning-light-1;
			}
		}
	}

	&.el-tag--danger {
		background-color: var.$color-danger-lighter;
		border-color: var.$color-danger-light-5;
		color: var.$color-danger-light-3;

		@include mixins.when(hit) {
			border-color: var.$tag-danger-color;
		}

		.el-tag__close {
			color: var.$color-danger-light-1;
			&:hover {
				color: var.$color-white;
				background-color: var.$color-danger-light-1;
			}
		}
	}
}

@include mixins.b(tag) {
	@include genTheme();
	display: inline-block;
	padding: var.$tag-padding;
	font-size: var.$tag-font-size;
	color: var.$tag-primary-color;
	border-width: 1px;
	border-style: solid;
	border-radius: var.$tag-border-radius;
	box-sizing: border-box;
	white-space: nowrap;

	.el-icon-close {
		border-radius: 50%;
		text-align: center;
		position: relative;
		cursor: pointer;
		font-size: 12px;
		height: 16px;
		width: 16px;
		line-height: 16px;
		vertical-align: middle;
		top: -1px;
		right: -5px;

		&::before {
			display: block;
		}
	}

	@include mixins.m(dark) {
		@include genTheme();
	}

	@include mixins.m(plain) {
		@include genTheme();
	}

	@include mixins.m(medium) {
		padding: 12px;

		.el-icon-close {
			transform: scale(0.8);
		}
	}

	@include mixins.m(small) {
		height: 24px;
		padding: 0 8px;
		line-height: 22px;

		.el-icon-close {
			transform: scale(0.8);
		}
	}

	@include mixins.m(mini) {
		height: 20px;
		padding: 0 5px;
		line-height: 18px;

		.el-icon-close {
			margin-left: -3px;
			transform: scale(0.7);
		}
	}
}
