/* Dropdowns of the portal and the LMS (ua-select.js, common\assets\UaSelectAsset).
   Colours and sizes are --uas-* variables. The defaults below are the dark portal look; they are declared
   with :where() (no specificity), so any `.ua-select { --uas-...: ... }` in an app stylesheet wins. */

:where(.ua-select) {
    --uas-h: 46px;
    --uas-radius: 999px;
    --uas-pad-x: 18px;
    --uas-font-size: 16px;
    --uas-font: var(--ua-font, 'Gilroy-Regular', sans-serif);

    --uas-bg: rgba(255, 255, 255, .05);
    --uas-bg-hover: rgba(255, 255, 255, .08);
    --uas-border: rgba(255, 255, 255, .18);
    --uas-border-hover: #959C6D;
    --uas-color: #ffffff;
    --uas-muted: rgba(255, 255, 255, .55);
    --uas-caret: #C4C8A2;
    --uas-ring: rgba(149, 156, 109, .45);
    --uas-invalid: #E57373;

    --uas-panel-bg: rgba(32, 32, 30, .97);
    --uas-panel-bg-blur: rgba(32, 32, 30, .88);
    --uas-panel-border: rgba(255, 255, 255, .1);
    --uas-panel-shadow: 0 28px 60px -20px rgba(0, 0, 0, .85), 0 0 0 1px rgba(0, 0, 0, .25);
    --uas-panel-radius: 18px;
    --uas-option: rgba(255, 255, 255, .85);
    --uas-option-hover-bg: rgba(255, 255, 255, .08);
    --uas-option-hover: #ffffff;
    --uas-selected-bg: rgba(149, 156, 109, .16);
    --uas-selected-active-bg: rgba(149, 156, 109, .26);
    --uas-selected: #C4C8A2;
    --uas-search-bg: rgba(255, 255, 255, .06);
    --uas-search-border: rgba(255, 255, 255, .1);
    --uas-search-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23C4C8A2' stroke-width='2' stroke-linecap='round'%3e%3ccircle cx='11' cy='11' r='7'/%3e%3cpath d='m20 20-3.5-3.5'/%3e%3c/svg%3e");
    --uas-scroll: rgba(196, 200, 162, .5);
}

/* the real <select> stays in the form but out of sight (page CSS often sizes selects by id, hence !important).
   Fixed, not absolute: inside a sideways-scrolling table an absolute one widened the page. */
select.ua-select-native {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 1px !important;
    height: 1px !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    pointer-events: none !important;
}

.ua-select {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    max-width: 100%;
    font-family: var(--uas-font);
    text-align: left;
}

.ua-select[hidden] {
    display: none !important;
}

.ua-select--block {
    display: block;
    width: 100%;
}

.input-group > .ua-select {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

/* ---------- button ---------- */

.ua-select-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    height: var(--uas-h);
    margin: 0;
    padding: 0 calc(var(--uas-pad-x) - 2px) 0 var(--uas-pad-x);
    border: 1px solid var(--uas-border);
    border-radius: var(--uas-radius);
    background: var(--uas-bg);
    color: var(--uas-color);
    font: inherit;
    font-size: var(--uas-font-size);
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
    transition: border-color .25s ease, background-color .25s ease, box-shadow .25s ease;
}

.ua-select-button:hover {
    border-color: var(--uas-border-hover);
    background: var(--uas-bg-hover);
}

.ua-select-button:focus-visible,
.ua-select.is-open .ua-select-button {
    outline: none;
    border-color: var(--uas-border-hover);
    box-shadow: 0 0 0 3px var(--uas-ring);
}

.ua-select-button:disabled {
    opacity: .55;
    cursor: default;
}

/* pages style plain spans (e.g. LMS profile: 24px): the value always follows the button */
.ua-select-value {
    font-size: inherit !important;
    font-weight: inherit !important;
    line-height: inherit !important;
    color: inherit;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ua-select.is-placeholder .ua-select-value {
    color: var(--uas-muted);
}

.ua-select-caret {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    margin-top: -4px;
    border-right: 2px solid var(--uas-caret);
    border-bottom: 2px solid var(--uas-caret);
    transform: rotate(45deg);
    transition: transform .25s cubic-bezier(.22, .8, .24, 1), margin .25s ease;
}

.ua-select.is-open .ua-select-caret {
    margin-top: 4px;
    transform: rotate(-135deg);
}

.ua-select.is-invalid .ua-select-button {
    border-color: var(--uas-invalid);
}

.ua-select.is-invalid .ua-select-button:focus-visible,
.ua-select.is-invalid.is-open .ua-select-button {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--uas-invalid) 35%, transparent);
}

/* sizes taken over from form-select-sm / -lg */
.ua-select--sm {
    --uas-h: 32px;
    --uas-pad-x: 11px;
    --uas-font-size: 14px;
}

.ua-select--sm .ua-select-button {
    gap: 8px;
}

.ua-select--sm .ua-select-caret {
    width: 7px;
    height: 7px;
}

.ua-select--sm .ua-select-option {
    min-height: 36px;
    padding-top: 7px;
    padding-bottom: 7px;
    font-size: 14px;
}

.ua-select--lg {
    --uas-h: 52px;
    --uas-font-size: 18px;
}

/* language switcher (#lang-switcher in the headers): a compact pill, list aligned right */
.ua-select--lang {
    --uas-h: 40px;
    --uas-pad-x: 16px;
    --uas-font-size: 15px;
    min-width: 0 !important;
}

.ua-select--lang .ua-select-button {
    gap: 10px;
}

.ua-select--lang .ua-select-caret {
    width: 7px;
    height: 7px;
}

.ua-select--lang .ua-select-panel {
    left: auto;
    right: 0;
    min-width: 170px;
}

/* ---------- panel ---------- */

.ua-select-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: max-content;
    min-width: 100%;
    max-width: min(420px, calc(100vw - 32px));
    padding: 6px;
    border: 1px solid var(--uas-panel-border);
    border-radius: var(--uas-panel-radius);
    background: var(--uas-panel-bg);
    box-shadow: var(--uas-panel-shadow);
    color: var(--uas-color);
    font-size: var(--uas-font-size);
    transform-origin: top center;
    animation: ua-select-in .18s cubic-bezier(.22, .8, .24, 1);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .ua-select-panel {
        background: var(--uas-panel-bg-blur);
        -webkit-backdrop-filter: saturate(150%) blur(18px);
        backdrop-filter: saturate(150%) blur(18px);
    }
}

.ua-select-panel[hidden] {
    display: none;
}

.ua-select.opens-up .ua-select-panel {
    top: auto;
    bottom: calc(100% + 8px);
    transform-origin: bottom center;
}

@keyframes ua-select-in {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.ua-select-search {
    width: 100%;
    height: 42px;
    margin: 0;
    padding: 0 14px 0 38px;
    border: 1px solid var(--uas-search-border);
    border-radius: 12px;
    background: var(--uas-search-bg) var(--uas-search-icon) 12px center / 16px no-repeat;
    color: var(--uas-color);
    font: inherit;
    font-size: 16px; /* iOS zooms into smaller fields */
}

.ua-select-search::placeholder {
    color: var(--uas-muted);
}

.ua-select-search:focus {
    outline: none;
    border-color: var(--uas-border-hover);
}

.ua-select-list {
    max-height: 300px;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
    outline: none;
    scrollbar-width: thin;
    scrollbar-color: var(--uas-scroll) transparent;
}

.ua-select-list::-webkit-scrollbar {
    width: 4px;
    height: 0;
}

.ua-select-list::-webkit-scrollbar-track {
    background: transparent;
}

.ua-select-list::-webkit-scrollbar-thumb {
    border: 0;
    border-radius: 4px;
    background: var(--uas-scroll);
}

.ua-select-option {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 42px;
    margin: 0;
    padding: 9px 40px 9px 14px;
    border-radius: 12px;
    color: var(--uas-option);
    font-size: calc(var(--uas-font-size) - 1px);
    line-height: 1.35;
    cursor: pointer;
    user-select: none;
    transition: background-color .15s ease, color .15s ease;
}

.ua-select-option[hidden] {
    display: none;
}

.ua-select-option.is-prompt {
    color: var(--uas-muted);
}

.ua-select-option.is-active {
    background: var(--uas-option-hover-bg);
    color: var(--uas-option-hover);
}

.ua-select-option[aria-selected="true"] {
    background: var(--uas-selected-bg);
    color: var(--uas-selected);
    font-weight: 600;
}

.ua-select-option[aria-selected="true"].is-active {
    background: var(--uas-selected-active-bg);
}

/* tick on the chosen item */
.ua-select-option[aria-selected="true"]::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    width: 6px;
    height: 11px;
    margin-top: -7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
}

.ua-select-option[aria-disabled="true"] {
    opacity: .4;
    cursor: default;
}

.ua-select-empty {
    padding: 14px;
    color: var(--uas-muted);
    font-size: 15px;
    text-align: center;
}

.ua-select-empty[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .ua-select-panel {
        animation: none;
    }
    .ua-select-caret,
    .ua-select-button,
    .ua-select-option {
        transition: none;
    }
}

@media screen and (max-width: 800px) {
    .ua-select-list {
        max-height: min(300px, 50vh);
    }
    .ua-select-option {
        min-height: 46px;
    }
}
