@import '../variables.less';
@import '../mixins.less';

.orion-select {
	&__carret {
		transition: transform 0.3s;

		&.open {
			transform: scaleY(-1);
		}
	}

	.orion-input--disabled {
		cursor: not-allowed;
	}

	&__selected-item {
		display: inline-flex;
		align-items: stretch;
		border-radius: 0.25rem;
		line-height: 1;
		padding-top: 0.125rem;
		padding-bottom: 0.125rem;
		padding-left: calc(5px + 0.125rem); // 7px
		margin: 0.125rem 0.25rem 0.125rem 0;
		background: rgba(var(--rgb-grey-light), 0.6);

		[data-orion-theme='dark'] & {
			background: var(--grey);
		}

		.orion-input--disabled &,
		.orion-input--readonly & {
			padding-right: calc(5px + 0.125rem); // 7px
		}

		&:last-of-type {
			margin-right: 0;
		}

		&-remove {
			.flex-align();
			font-size: 1rem;
			margin-left: 0.125rem;
			padding: 0 var(--fluid-5px);
			border-radius: 0 0.25rem 0.25rem 0;
			color: var(--grey-dark);
			cursor: pointer;

			body:not(.istouch) & {
				&:hover {
					background: rgba(var(--rgb-danger), 0.1);
					color: var(--danger);
				}
			}

			.orion-input--disabled &,
			.orion-input--readonly & {
				pointer-events: none;
				cursor: not-allowed;
			}
		}
	}

	&:not(.orion-select--multiple) {
		.orion-input__input {
			.ellipsis();
			padding-right: var(--fluid-40px);
		}
	}

	&__autocomplete {
		display: inline-block;

		&--single,
		&--multiple:only-child {
			position: absolute;
			top: 0;
			bottom: 0;
			left: 0;
			right: 0;
		}
	}

	&__popover {
		overflow-y: auto;
		overscroll-behavior: contain;
		max-height: 20rem;
		max-width: calc(100vw - 2rem);
		min-width: 10rem;

		@media @phone {
			max-height: 75vh; // dvh support fallback
			max-height: 75dvh;
		}

		.favorite-separator{
			margin: .5rem 0rem;
			border-image: unset;
			border-color: var(--grey);
		}

		&-item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			gap: 1.25rem;
			padding: var(--fluid-5px) var(--fluid-15px);
			font-size: 0.875rem;
			transition: background 0.3s, color 0.3s;
			color: var(--grey-dark);
			cursor: pointer;

			.orion-select__icon--internal {
				display: none;
			}

			&:first-child {
				border-top-left-radius: 0.25rem;
				border-top-right-radius: 0.25rem;
			}

			&:last-child {
				border-bottom-left-radius: 0.25rem;
				border-bottom-right-radius: 0.25rem;
			}

			body:not(.istouch) & {
				&.hover,
				&:hover {
					color: var(--grey-darker);
					background: var(--grey-lighter);
				}
			}

			& .favorite-icon {
				display: none;
				color: var(--grey);
			}

			&.favorite > .favorite-icon {
				display: unset;
			}

			&.selected {
				background: var(--info);
				color: white;

				.orion-select-multiple__popover & {
					color: var(--info);
					background: rgba(var(--rgb-info), 0.1);

					.icon--selected {
						display: block;
					}

					body:not(.istouch) & {
						&.hover,
						&:hover {
							color: var(--danger);
							background: rgba(var(--rgb-danger), 0.1);

							.icon--selected {
								display: none;
							}

							.icon--delete {
								display: block;
							}
						}
					}
				}
			}

			&.disabled {
				opacity: 0.5;
				cursor: not-allowed;
			}

			&--noresult {
				text-align: center;
				opacity: 1 !important;
			}
		}

		&-actions {
			display: flex;
			align-items: center;
			gap: 0.5rem;
			margin-top: 1rem;

			> .orion-button {
				flex: 1;
			}
		}
	}

	&--multiple.orion-input {
		// enhance selector strengh
		height: auto;
		min-height: 2.5rem;

		.orion-input__input:not(.orion-select__autocomplete) {
			display: flex;
			align-items: center;
			flex-wrap: wrap;
			min-height: 2.5rem;
			height: auto;
			padding: 0.375rem var(--fluid-40px) 0.375rem var(--fluid-15px);
		}

		.orion-select__autocomplete:not(:only-child) {
			margin: 0.125rem 0.25rem;
			padding: 0 !important;
			min-width: 2rem;
			min-height: 1.25rem;
			width: auto;
			height: auto;
		}
	}

	&--default-slot {
		outline: none;
	}
}
