//
// _choices.scss
//

@use "../variables" as *;
@use "../utils/mixins" as *;

.choices {
    box-shadow: $box-shadow;
    margin-bottom: 0;
    // data-type = select-one
    &[data-type*="select-one"] {
        cursor: pointer;

        .choices__input {
            padding: .5rem 1.1rem !important;
            background-color: $white;
            border: 1px solid $border-color;
            font-size: $font-size-base;
            border-radius: $border-radius;
            color: $body-color;
            margin-bottom: 10px;
        }

        &:after {
            content: "\ea5f";
            position: absolute;
            border: 0;
            top: 18px;
            right: 12px;
            left: auto;
            font-size: 20px;
            font-family: tabler-icons;
            width: auto;
            height: auto;
            margin-top: 0;
            transform: translateY(-50%);
            transition: transform 0.2s ease-in-out;
            pointer-events: none;
        }

        &.is-open:after {
            margin-top: 0;
            transform: translateY(-50%) rotate(-180deg);
        }

        .choices__button {
            right: 20px;
        }
    }

    // data-type = select- multiple & text
    &[data-type*="select-multiple"],
    &[data-type*="text"] {
        .choices__inner {
            cursor: text;
            padding: .5rem 1.1rem * 0.5 !important;
            min-height: 38px;
            display: flex;
            align-items: center;
            overflow-x: auto;
            box-shadow: $box-shadow;
            margin-bottom: 5px;
        }

        .choices__button {
            border-left: 0;
            border-right: 0;
            filter: invert(100%);
        }

        .choices__list--dropdown {
            padding-bottom: 10px;

            .choices__list {
                margin-bottom: 0;
            }
        }
    }

    &[data-type*="select-multiple"] {
        .choices__input {
            padding-top: 0;
        }
    }
}

// Select Light
.input-light {
    .choices__inner {
        background-color: $light;
        border: none;
    }
}

.choices__inner {
    display: inline-block;
    padding: .5rem 1.1rem !important;
    vertical-align: middle;
    background-color: $white;
    border: 1px solid $border-color;
    border-radius: $border-radius !important;
    font-size: $font-size-base;
    min-height: auto;
    overflow: hidden;
    .choices__list--single {
        padding: 0 !important;
    }
}

.is-focused,
.is-open {
    .choices__inner {
        border-color: $border-color;
    }
}

.choices__list--multiple {
    display: inline-flex;
    .choices__item {
        display: inline-block;
        vertical-align: initial;
        border-radius: 7px;
        padding: 2px 7px;
        font-size: 10px;
        font-weight: $font-weight-normal;
        margin: 0 5px 0 0;
        background-color: $border-color;
        border: 1px solid $border-color;
        color: $heading-color;
        word-break: break-all;
		box-sizing: border-box;
        white-space: nowrap;
        &.is-highlighted {
            background-color: $primary;
            border: 1px solid $primary;
        }
    }
    .choices__item[data-deletable] {
		padding-right: 5px;
	}
}

.is-disabled {
    .choices__list--multiple {
        .choices__item {
            background-color: $secondary;
            border: 1px solid $secondary;
        }
    }
}

.choices.is-disabled .choices__inner, .choices.is-disabled .choices__input {
    background-color: $light;
    cursor: not-allowed;
	-webkit-user-select: none;
	user-select: none;
}

.choices__list--dropdown {
    padding: 10px 10px 20px 10px;
    background-color: $white !important;
    border: 1px solid transparent !important;
    box-shadow: $box-shadow;
    margin-top: 0 !important;
    border-radius: $border-radius;
    animation-duration: 0.3s;
    animation-fill-mode: both;
    transform: translateY(1px);
    z-index: 1056;

    &.is-active {
        animation-name: DropDownSlide;
    }
    .choices__item--selectable.is-highlighted {
        background-color: $light !important;
    }

    .choices__list {
        margin: 0 -10px -16px;

        &::-webkit-scrollbar {
            -webkit-appearance: none;
        }

        &::-webkit-scrollbar-thumb {
            background-color: rgba($dark-rgb, 0.1);
            border-radius: 10px;
            border: 2px solid $white;
        }

        &::-webkit-scrollbar-track {
            border-radius: 10px;
            background-color: $white;
        }
    }

    .has-no-results {
        font-style: italic;
        font-weight: $font-weight-medium;
    }

    .choices__item--selectable:after {
        display: none;
    }
}

.is-open {
    .choices__list--dropdown {
        border-color: transparent;
    }
}

.is-flipped {
    .choices__list--dropdown {
        &.is-active {
            border-radius: $border-radius;
            animation-name: DropDownSlideDown;
            transform: translateY(-1px);
        }
    }
}

.choices__list--dropdown {
    .choices__list {
        max-height: 300px;
    }

    .choices__item {
        font-size: $font-size-base;
        padding: 0.4rem 0.9375rem 0.4rem 16px;
    }
}

.choices__heading {
    font-weight: $font-weight-semibold;
    padding: 10px 16px;
    border-bottom: 1px solid $border-color;
    color: $gray-400;
    font-size: 12px;
}

.choices__input {
    display: inline-block;
    background-color: $white;
    color: $body-color;
    font-size: $font-size-base;
    margin-bottom: 0;
    padding: 0 0 0 2px;
    vertical-align: baseline;	
	border: 0;
	border-radius: 0;
	max-width: 100%;
    &::placeholder {
        color: $gray-400;
    }
}

.choices__placeholder {
    color: $gray-400;
    opacity: 1;
}

[data-bs-theme="dark"] {
    .choices[data-type*="select-one"] {
        .choices__button {
            filter: invert(1) grayscale(100%) brightness(200%);
        }
    }
}

[dir="rtl"] {
    .choices[data-type*=select-one]:after {
        left: 12px;
        right: auto;
    }
}

// Fallback for a `.select` that Choices has not enhanced. Once Choices runs it
// sets `hidden` on the original element (`.choices [hidden]` -> display none),
// so this only ever shows if the plugin did not initialise - it keeps such a
// select looking like the rest of the form instead of a bare browser select.
select.select:not([hidden]) {
    display: block;
    width: 100%;
    padding: .5rem 1.1rem;
    background-color: $white;
    border: 1px solid $border-color;
    border-radius: $border-radius;
    font-size: $font-size-base;
    color: $body-color;
    min-height: 39px;

    &:focus,
    &:hover {
        border-color: $border-color;
        outline: 0;
        box-shadow: none;
    }
}



    .choices__list--dropdown, .choices__list[aria-expanded] {
        z-index: 111;
    }
