@use "../../styles/abstract/base" as base;
@use "../../styles/abstract/variables" as v;
@use "../../styles/abstract/mixins" as m;
@use "../../styles/abstract/theme" as t;

$component: "#{base.$prefix}-listbox";

.#{$component} {
@include m.typography("body-medium");
@include m.shape("extra-small");

position: fixed;
inset: auto;
margin: 0;
border: 0;
padding: 8px 0;
box-sizing: border-box;
background-color: t.color("surface-container");
color: t.color("on-surface");
@include m.elevation(2);
overflow-y: auto;
overscroll-behavior: contain;

&__option {
@include m.typography("label-large");
@include m.flex-row;

position: relative;
min-height: 48px;
padding: 12px;
width: 100%;
box-sizing: border-box;
cursor: pointer;
user-select: none;
color: t.color("on-surface");
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;

&:hover {
@include m.state-layer(t.color("on-surface"), "hover");
}

&--active {
@include m.state-layer(t.color("on-surface"), "focus");
outline: 3px solid t.color("secondary");
outline-offset: -3px;
}

&:active {
@include m.state-layer(t.color("on-surface"), "pressed");
}

&[aria-selected="true"] {
background-color: t.color("secondary-container");
color: t.color("on-secondary-container");

&:hover {
@include m.state-layer(t.color("on-secondary-container"), "hover");
}

&.#{$component}__option--active {
@include m.state-layer(t.color("on-secondary-container"), "focus");
}

&:active {
@include m.state-layer(t.color("on-secondary-container"), "pressed");
}

&[aria-disabled="true"] {
background-color: t.alpha("secondary-container", 0.38);
color: t.alpha("on-secondary-container", 0.38);

&:hover,
&:active {
&::before {
opacity: 0;
}
}
}
}

&[aria-disabled="true"] {
cursor: default;
color: t.alpha("on-surface", 0.38);

&:hover,
&:active {
&::before {
opacity: 0;
}
}
}
}

@include m.high-contrast {
border: 1px solid CurrentColor;

.#{$component}__option[aria-selected="true"] {
background-color: Highlight;
color: HighlightText;
}

.#{$component}__option[aria-disabled="true"] {
color: GrayText;
}
}
}
