@use "../../styles/abstracts" as *;

.select {
	position: relative;
	width: 100%;
}

.trigger {
	@include input-base;

	display: flex;
	align-items: center;
	justify-content: space-between;
	border: var(--dev-panel-input-border-width) solid var(--dev-panel-input-border-color);
	cursor: pointer;

	&:hover:not(:disabled) {
		border-color: var(--dev-panel-input-border-color-hover);
	}

	&:focus {
		outline: none;
		border-color: var(--dev-panel-input-border-color-focus);
		box-shadow: 0 0 0 3px color-mix(in srgb, var(--dev-panel-accent-color) 20%, transparent);
	}

	&:disabled {
		cursor: not-allowed;
		opacity: var(--dev-panel-opacity-50);
		background-color: var(--dev-panel-surface-color);
	}

	&.open {
		border-color: var(--dev-panel-input-border-color-focus);
	}
}

.value {
	flex: 1;
	text-align: left;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--dev-panel-input-text-color);
	font-size: var(--dev-panel-font-size-sm);

	&.placeholder {
		color: var(--dev-panel-input-placeholder-color);
	}
}

.arrow {
	display: block;
	width: 16px;
	height: 16px;
	margin-left: var(--dev-panel-spacing-sm);
	transition: var(--dev-panel-transition);
	flex-shrink: 0;

	.open & {
		transform: rotate(180deg);
	}

	path {
		fill: var(--dev-panel-text-color-muted);
	}
}

// Portal dropdown container
.dropdownPortal {
	position: fixed;
	z-index: 9999;
	& * {
		box-sizing: border-box;
	}
}

.dropdown {
	@include scrollbar;

	max-height: 200px;
	background-color: var(--dev-panel-foreground-color);
	border: 1px solid var(--dev-panel-border-color);
	border-radius: var(--dev-panel-border-radius);
	overflow-y: auto;
	box-shadow: var(--dev-panel-shadow-lg);
	animation: dropdown-fade-in 0.15s ease-out;
}

.option {
	position: relative;
	display: flex;
	align-items: center;
	padding: var(--dev-panel-spacing-sm) var(--dev-panel-spacing-md);
	transition: var(--dev-panel-transition);
	background-color: var(--dev-panel-foreground-color);
	color: var(--dev-panel-text-color);
	border: none;
	width: 100%;
	text-align: left;
	font-family: var(--dev-panel-font-family);
	font-size: var(--dev-panel-font-size-sm);
	cursor: pointer;
	overflow-wrap: anywhere;

	&:hover {
		background-color: var(--dev-panel-surface-color-hover);
	}

	&.selected {
		background-color: var(--dev-panel-accent-color);
		color: var(--dev-panel-text-color-on-accent);
	}

	&:focus {
		outline: none;
		background-color: var(--dev-panel-surface-color-hover);
	}
}

// Multi-select specific styles
.checkbox {
	appearance: none;
	width: 16px;
	height: 16px;
	border: 1px solid var(--dev-panel-border-color);
	border-radius: 3px;
	margin-right: var(--dev-panel-spacing-sm);
	position: relative;
	background-color: var(--dev-panel-input-background-color);
	flex-shrink: 0;
	cursor: pointer;

	&:checked {
		background-color: var(--dev-panel-accent-color);
		border-color: var(--dev-panel-accent-color);
	}

	&:focus {
		outline: none;
		box-shadow: 0 0 0 2px color-mix(in srgb, var(--dev-panel-accent-color) 20%, transparent);
	}
}

.label {
	flex: 1;
	pointer-events: none;
}

@keyframes dropdown-fade-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}
