@use "colors" as *;
@use "fonts" as *;
@use 'sass:color';

@mixin rtl {
	@at-root [dir="rtl"] #{&} {
		@content
	}
}


$ng-select-highlight: $dekra-400 !default;
$ng-select-primary-text: rgba(0, 0, 0, 0.65) !default;
$ng-select-disabled-text: #8C8C8C !default;
$ng-select-disabled-bg: #f5f5f5 !default;
$ng-select-border: $cool-grey !default;
$ng-select-bg: $white !default;
$ng-select-selected: rgba(24, 144, 255, 0.2);
$ng-select-marked: #e6f7ff !default;

.ng-select {
	&.small-selection {
		.ng-select-container {
			.ng-value-container {
				.ng-placeholder {
					left: 15px !important;
				}
			}
		}

		.ng-arrow-wrapper {
			right: 10px !important;
		}
	}

	position: relative;

	&.ng-select-opened {
		&.ng-select-clearable .ng-select-container.ng-has-value:hover {
			.ng-clear-wrapper {
				opacity: 0;
				pointer-events: none;
			}

			.ng-arrow-wrapper {
				opacity: 1;
			}
		}

		> .ng-select-container {
			background: $ng-select-bg;
			border-color: $ng-select-highlight;

			.ng-arrow-wrapper {
				transform: rotate(180deg);
				opacity: 1;
				@include rtl {
					transform: rotate(-180deg);
				}
			}
		}
	}

	&.ng-select-focused {
		.ng-select-container {
			border-color: $ng-select-highlight;

			.ng-value-container {
				background-color: $white;
			}
		}
	}

	&.ng-select-disabled {
		> .ng-select-container {
			background-color: $ng-select-disabled-bg;

			&:hover {
				border: 1px solid $ng-select-border;
				cursor: not-allowed;
			}

			.ng-value-container {
				.ng-value {
					color: $ng-select-disabled-text;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.ng-placeholder {
					color: $ng-select-disabled-text !important;
					font-weight: bold !important;
				}
			}
		}
	}

	.ng-has-value .ng-placeholder {
		display: none;
	}

	&.ng-select-clearable .ng-select-container.ng-has-value:hover {
		.ng-clear-wrapper {
			opacity: 1;
		}

		.ng-arrow-wrapper {
			opacity: 0;
			pointer-events: none;
		}
	}

	.ng-select-container {
		background-color: $ng-select-bg;
		border-radius: 0;
		border: 1px solid $ng-select-border;
		align-items: center;
		transition: all 0.3s;
		box-sizing: border-box;

		&:hover {
			border-color: $dekra-500;
			background-color: $ice-blue-two;
		}

		.ng-input {
			position: relative !important;
			font-family: Arial, sans-serif;
			line-height: 1.33;
			width: 10% !important;

			input {
				color: $ng-select-primary-text;
				box-sizing: border-box !important;
				height: 26px !important;
				cursor: text;
			}
		}

		&:not(.ng-has-value) {
			max-height: 40px;
		}

		.ng-value-container {
			min-height: 38px !important;
			padding: 3px 18px 0 0;

			.ng-value {
				font-family: Arial, sans-serif;
				font-size: 15px;
				font-weight: bold;
				color: #193338;
			}

			.ng-placeholder {
				font-family: Arial, sans-serif;
				font-size: 15px;
				color: $cool-grey;
				position: absolute;
				left: 20px;
				top: 9px;

			}
		}
	}

	&.ng-select-single {
		&.ng-select-opened .ng-select-container .ng-value {
			opacity: 0.4;
		}

		.ng-select-container {
			.ng-value-container {
				.ng-value {
					margin-top: auto;
					margin-bottom: auto;
				}
			}
		}
	}

	&.ng-select-multiple {
		&.ng-select-disabled {
			> .ng-select-container .ng-value-container .ng-value {
				background-color: $ng-select-disabled-bg;

				.ng-value-label {
					padding: 0 5px;
					left: 4px !important;
					max-width: 6.2rem !important;
				}
			}
		}

		.ng-select-container {
			min-height: 40px;
			padding-left: 5px;

			@include rtl {
				padding-right: 5px;
				padding-left: 11px;
				.ng-value-container .ng-placeholder {
					margin-left: 0;
					margin-right: 6px;
				}
			}

			.ng-value-container {

				.ng-value {
					position: relative;
					margin-right: 4px;
					font-size: 0.9em;
					background-color: $white;
					border: 1px solid rgba(0, 0, 0, 0.12);
					border-radius: 0;
					height: 32px;
					line-height: 22px;
					width: 7.5rem;
					@include rtl {
						margin-right: 0;
						margin-left: 4px;
					}

					&.ng-value-disabled {
						background-color: $ng-select-disabled-bg;
						color: $ng-select-disabled-text;

						.ng-value-label {
							padding-left: 5px;
							@include rtl {
								padding-left: 0;
								padding-right: 5px;
							}
						}
					}

					.ng-value-label {
						@include Button-Aa2-12px---Small1-Center6-Default;
						display: inline-block;
						max-width: 5.5rem;
						overflow: hidden;
						text-overflow: ellipsis;
						vertical-align: bottom;
						position: relative;
						left: -10px;
						text-align: left !important;
						margin-top: 8px;
					}

					.ng-value-icon {
						display: inline-block;
						border-radius: 0;
						line-height: 1;
						font-size: 16px;
						width: 15px;
						height: 15px;
						color: #fff;
						background-color: $dekra-500;
						vertical-align: bottom;
						position: relative;
						left: 80%;
						margin-right: 3px;
						margin-bottom: 2px;
						text-align: center;

						&:hover {
							background: $dekra-400;
						}
					}
				}

				.ng-placeholder {
					top: 50%;
					height: 20px;
					margin-top: -10px;
					margin-left: 6px;
				}

				.ng-input {
					height: 24px;
					margin-top: 3px;
				}
			}
		}
	}

	&.ng-select-single .ng-select-container.ng-has-value .ng-value-container {
		padding-left: 18px;
		padding-bottom: 4px;
	}

	.ng-clear-wrapper {
		opacity: 0;
		color: $dekra-500;
		background: $dekra-500;
		width: 17px;
		height: 17px;
		text-align: center;
		border-radius: 0;
		vertical-align: middle;
		transition: color .3s ease;
		position: relative;
		@include rtl {
			left: 13px;
			right: auto;
		}

		&:hover {
			background: $dekra-400;
		}

		.ng-clear {
			color: #fff;
			font-size: 9px;
			position: relative;
			line-height: 12px;
			vertical-align: top;
		}
	}

	.ng-spinner-zone {
		padding: 5px 5px 0 0;

		@include rtl {
			padding: 5px 0 0 5px;
		}
	}

	.ng-arrow-wrapper {
		width: 16px;
		height: 26px;
		transition: transform 0.3s;
		right: 18px;

		.ng-arrow {
			border-style: solid;
			border-width: 0.1rem 0.1rem 0 0;
			height: 8px !important;
			width: 8px !important;
			transform: rotate(135deg);
			color: $dekra-500;
		}
	}

	&.ng-invalid {
		&:not(.ng-pristine) {
			.ng-select-container {
				border: 1px solid red !important;
				background-color: $light-pink-two !important;
			}
		}
	}
}

.ng-dropdown-panel {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	border-radius: 0;
	margin-top: 4px;
	margin-bottom: 4px;
	left: 0;
	font-family: Arial, sans-serif;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.80;
	z-index: 1001 !important;

	&.ng-select-bottom {
		top: 100%;
		border-top-color: color.adjust($ng-select-border, $lightness: 10%);
	}

	&.ng-select-top {
		bottom: 100%;
		border-bottom-color: color.adjust($ng-select-border, $lightness: 10%);
	}

	.ng-dropdown-header {
		border-bottom: 1px solid $ng-select-border;
		padding: 5px 7px;
	}

	.ng-dropdown-footer {
		background-color: #ffffff;
		border-top: 1px solid $ng-select-border;
		padding: 5px 7px;
	}

	.ng-dropdown-panel-items {
		z-index: 10000 !important;

		.ng-optgroup {
			user-select: none;
			padding: 4px 12px;
			color: rgba(0, 0, 0, .45);
			cursor: pointer;

			&.ng-option-disabled {
				cursor: default;
				color: rgba(0, 0, 0, .45);
			}

			&.ng-option-marked {
				background-color: $ng-select-marked;
			}

			&.ng-option-selected {
				background-color: #fafafa;
				font-weight: 600;
			}

			&.ng-option-selected.ng-option-marked {
				background-color: $ng-select-marked;
			}
		}

		.ng-option {
			background-color: $white;
			color: $ng-select-primary-text;
			padding: 5px 12px;
			transition: background .3s ease;

			&:first-child {
				border-top-right-radius: 4px;
				border-top-left-radius: 4px;
			}

			&:last-child {
				border-bottom-right-radius: 4px;
				border-bottom-left-radius: 4px;
			}

			&.ng-option-selected {
				background-color: #fafafa;
				font-weight: 600;
			}

			&.ng-option-selected.ng-option-marked {
				color: $ng-select-primary-text;
				background-color: $ng-select-marked;
			}

			&.ng-option-marked {
				background-color: $ng-select-marked;
				color: $ng-select-primary-text;
			}

			&.ng-option-disabled {
				color: $ng-select-disabled-text;
				cursor: not-allowed;
			}

			&.ng-option-child {
				padding-left: 20px;
				@include rtl {
					padding-right: 20px;
					padding-left: 0;
				}
			}

			.ng-option-label {
				font-size: 14px;
			}

			.ng-tag-label {
				font-size: 80%;
				font-weight: bold;
				padding-right: 5px;
				color: $dark-sea-green;
				@include rtl {
					padding-left: 5px;
					padding-right: 0;
				}
			}
		}
	}

	@include rtl {
		direction: rtl;
		text-align: right;
	}
}

.small-select {
	.ng-select-container {
		.ng-value-container {
			max-height: 30px !important;
			min-height: 30px !important;
			width: 80px;
		}
	}
}

.green-select {
	.ng-select-container {
		color: $dekra-500 !important;

		.ng-value-container {
			color: $dekra-500 !important;

			.ng-placeholder {
				color: $dekra-500 !important;
			}

			.ng-value {
				color: $dekra-500 !important;
			}
		}
	}

	.ng-dropdown-panel .ng-dropdown-panel-items .ng-option {
		color: $dekra-500 !important;
	}
}

//only for IE11
@media all and (-ms-high-contrast: none) {
	*::-ms-backdrop, .ng-value {
		margin-top: 7px !important;
		margin-bottom: 7px !important;
	}
}

@media screen and (max-width: 479px) {
	.ng-select .ng-select-container {
		.ng-value-container .ng-placeholder {
			left: 15px;
		}

		.ng-arrow-wrapper {
			right: 5px;
		}
	}
}
