:host {
	--input-padding-side: .5rem;
	--input-value-padding-top: 1.25rem;
	--input-value-padding-bottom: .25rem;
	--input-min-height: 3rem;
	min-height: var(--input-min-height);
	box-sizing: border-box;
	border-radius: var(--smoothly-input-border-radius);
}

:host[looks="border"] {
	border: rgb(var(--smoothly-input-border)) solid 1px;
}
:host([looks="border"]:not([readonly]):not([disabled]):focus-within) {
	outline: 2px solid rgb(var(--smoothly-input-border-focus));
}
:host[looks="border"][readonly] {
	border: transparent solid 1px;
}

:host[looks="line"] {
	border-bottom: rgb(var(--smoothly-input-border)) solid 1px;
	position: relative;
}
:host[looks="line"][readonly] {
	border-bottom: transparent solid 1px;
}
:host([looks="line"]:not([readonly]):not([disabled]):focus-within)::before {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	border-bottom: 2px solid rgb(var(--smoothly-input-border-focus));
	z-index: 10;
}

:host[looks="grid"] {
  flex-grow: 1;
  flex-basis: 40%;
  box-shadow: 0px 0px 0px 1px rgb(var(--smoothly-input-border));
  border: none;
}
:host[looks="grid"][readonly] {
	box-shadow: 0px 0px 0px 1px rgba(var(--smoothly-input-border-readonly));
}
:host[looks="grid"]:not([readonly]):not([disabled]):focus-within {
	position: relative;
	box-shadow: 0px 0px 0px 2px rgb(var(--smoothly-input-border-focus));
	outline: none;
	z-index: 10;
}

:host[looks="transparent"] {
	border: none;
}

:host[looks="transparent"][readonly],
:host[looks="transparent"]:not(:focus-within) {
	background-color: transparent;
}

:host[looks="transparent"][readonly]>input,
:host[looks="transparent"]:not(:focus-within)>input {
	background-color: transparent;
}

:host[looks="transparent"]:not([readonly]):focus-within {
	outline: 1px solid rgb(var(--smoothly-input-border));
}

:host([disabled]) {
	cursor: not-allowed;
	--smoothly-input-foreground: var(--smoothly-input-disabled-foreground);
	--smoothly-input-background: var(--smoothly-input-disabled-background);
	--smoothly-input-border: var(--smoothly-input-disabled-border);
}

/* --- label --- */

:host ::slotted([slot=label]),
:host .label {
	position: absolute;
	top: .6rem;
	opacity: 0.8;
	user-select: none;
	cursor: inherit;
	transform-origin: top left;
	transition: transform 100ms ease;
}

:host.floating-label ::slotted([slot=label]),
:host.has-value ::slotted([slot=label]),
:host[placeholder] ::slotted([slot=label]),
:host[readonly] ::slotted([slot=label]),
:host.floating-label .label,
:host.has-value .label,
:host.has-text .label,
:host[placeholder] .label,
:host[readonly] .label,
:host:not([readonly]):focus-within .label.float-on-focus {
	top: .2rem;
	transform: scale(0.8);
}

:host:not([show-label]):not(.show-label) .label {
	display: none;
}
:host smoothly-icon.smoothly-invalid {
	fill: rgb(var(--smoothly-input-invalid-icon, var(--smoothly-danger-color)));
}


:host {
	display: flex;
	justify-content: space-between;
	flex-direction: row;
	position: relative;
	background-color: rgb(var(--smoothly-input-background));
	color: rgb(var(--smoothly-input-foreground));
	fill: rgb(var(--smoothly-input-foreground));
	stroke: rgb(var(--smoothly-input-foreground));
	padding-left: var(--input-padding-side);
}

:host.open {
	border-radius: var(--smoothly-input-border-radius) var(--smoothly-input-border-radius) 0 0;
}


:host>.select-display {
	box-sizing: border-box;
	display: flex;
	padding: var(--input-value-padding-top) .8rem var(--input-value-padding-bottom) 0;
	overflow: hidden;
	width: 100%;
	white-space: nowrap;
	gap: 1rem;
	text-overflow: ellipsis;
}
:host:not([readonly]):not([disabled])>.select-display {
	cursor: pointer;
}

:host:not(:has([slot=label]))>.select-display,
:host:not([show-label])>.select-display  {
	padding: .6rem .8rem .6rem 0;
	align-items: center;
}

:host>.select-display smoothly-icon {
	color: rgb(var(--smoothly-input-foreground));
	fill: rgb(var(--smoothly-input-foreground));
	stroke: rgb(var(--smoothly-input-foreground));
}

:host>div.icons {
	display: flex;
	flex-direction: row;
	align-items: center;
}

:host:hover>div.icons::slotted(smoothly-icon) {
	filter: opacity(100%);
}

:host>div.icons>smoothly-icon[name=caret-down-outline],
:host>div.icons>smoothly-icon[name=caret-forward-outline] {
	opacity: .7;
	height: 100%;
	padding-inline: var(--input-padding-side);
}
:host:not([readonly]):not([disabled])>div.icons>smoothly-icon[name=caret-down-outline],
:host:not([readonly]):not([disabled])>div.icons>smoothly-icon[name=caret-forward-outline] {
	cursor: pointer;
}

:host[invalid]>div>smoothly-icon.smoothly-invalid {
	display: block;
	padding: 0.5rem;
}

:host>div>smoothly-icon.smoothly-invalid {
	display: none
}


:host.has-value:has([slot=label]:not(:empty))>.select-display,
:host:not(.has-value)[placeholder]>.select-display {
	overflow: hidden;
	width: 100%;
}


:host>.dropdown {
	display: flex;
	flex-direction: column;
	position: absolute;
	top: var(--element-height);
	z-index: 20;
	max-height: var(--menu-height, unset);
	overflow-x: hidden;
	overflow-y: auto;
	background-color: rgb(var(--smoothly-input-background));
	inset-inline: 0;
	border-radius: 0 0 var(--smoothly-input-border-radius) var(--smoothly-input-border-radius);
	border: rgb(var(--smoothly-input-border, var(--smoothly-color-contrast))) solid 1px;
	border-top: rgba(var(--smoothly-input-border, var(--smoothly-color-contrast)), .4) solid 1px;
}
:host:not(.open)>.dropdown {
	border: 0;
}
:host[looks="grid"]>.dropdown,
:host[looks=border]>.dropdown,
:host[looks="transparent"]>.dropdown {
	inset-inline: -1px;
}

:host>.dropdown>.search {
	display: flex;
	position: sticky;
	align-items: center;
	top: 0;
	gap: 1rem;
	padding: .7rem .7rem .7rem .25rem;
	background-color: rgb(var(--smoothly-input-background));
	color: rgb(var(--smoothly-input-foreground, var(--smoothly-color-contrast)));
	fill: rgb(var(--smoothly-input-foreground, var(--smoothly-color-contrast)));
	stroke: rgb(var(--smoothly-input-foreground, var(--smoothly-color-contrast)));
}
:host:not(.has-filter)>.dropdown>.search {
	/* hide search */
	/* search cant be display: none, since it is the focus element */
	height: 0;
	padding: 0;
	overflow: hidden;
	pointer-events: none;
}
:host>.dropdown>.search::before {
	/* search have opacity without showing what is underneath */
	content: "";
	position: absolute;
	inset: 0;
	background-color: rgba(var(--smoothly-primary-tint), 0.5);
	z-index: -1;
}
:host>.dropdown>.search>.search-input {
	width: 100%;
	background-color: transparent;
	border: none;
	outline: none;
}
:host>.dropdown>.search>smoothly-icon[name="search-outline"],
:host>.dropdown>.search>smoothly-icon[name="backspace-outline"] {
	color: rgb(var(--smoothly-input-foreground, var(--smoothly-color-contrast)));
	fill: rgb(var(--smoothly-input-foreground, var(--smoothly-color-contrast)));
	stroke: rgb(var(--smoothly-input-foreground, var(--smoothly-color-contrast)));
}


/* --- multiple options --- */
:host([multiple])::slotted(.dropdown>.menu>smoothly-item) {
	position: relative;
}
:host([multiple])::slotted(.dropdown>.menu>smoothly-item::before) {
	content: "";
	display: inline-block;
	width: 1rem;
	height: 1rem;
	margin-right: 0.5rem;
	border: 1px solid rgb(var(--smoothly-input-foreground));
	border-radius: 0.15rem;
	vertical-align: middle;
}
:host([multiple])::slotted(.dropdown>.menu>smoothly-item[selected]::before) {
	border-color: rgb(var(--smoothly-item-selected-foreground));
}
:host([multiple])::slotted(.dropdown>.menu>smoothly-item:hover::before) {
	border: 1px solid rgb(var(--smoothly-item-hover-foreground));
}
:host([multiple])::slotted(.dropdown>.menu>smoothly-item[selected]::after) {
	content: "✔";
	position: absolute;
	left: 0.65rem; 
	color: rgb(var(--smoothly-item-selected-foreground));
}
:host([multiple])::slotted(.dropdown>.menu>smoothly-item:hover::after) {
	color: rgb(var(--smoothly-item-hover-foreground));
}
:host>.dropdown {
	min-width: fit-content;
}
:host>.dropdown>.menu[hidden] {
	display: none;
}


