/**
 * Custom Dropdown
 *
 * Provides a list of options to the user, mainly controlled thru JavaScript.
 *
 * @author Salustiano Silva <salustiano.silva@magicbrain.pt>
 * @since 1.0.0 | 2025-05-05 | Salustiano Silva | First time this was introduced.
 * @since 1.0.0 | 2025-07-08 | Salustiano Silva | Preventing text overflow on the toggler by using a span element with ellipsis.
 */
.custom-dropdown {
    position: relative;
    border-radius: .25rem;
}

.custom-dropdown-toggler {
    position: relative;
    white-space: nowrap;
    display: -webkit-inline-box;
    display: -webkit-inline-flex;
    display: -ms-inline-flexbox;
    display: inline-flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
}

.custom-dropdown-toggler:after {
    margin-top: -1px;
    display: inline-block;
    margin-left: .255em;
    vertical-align: .255em;
    content: "";
    border-top: .3em solid;
    border-right: .3em solid transparent;
    border-bottom: 0;
    border-left: .3em solid transparent;
}

.custom-dropdown-toggler>span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-dropdown-toggler>span.text-placeholder {
    opacity: 0.5;
}

.custom-dropdown-content {
    position: absolute;
    background-color: #FFFFFF;
    width: 100%;
    height: 340px;
    margin-top: 5px;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: .25rem;
    z-index: 1;
}

.custom-dropdown-filter {
    padding: .375rem .75rem;
    margin: 0;
    width: 100%;
}

.custom-dropdown-filter::placeholder {
    color: lightgray;
}
.custom-dropdown-filter:placeholder-shown {
    font-style: italic;
}

.custom-dropdown-option-list {
    width: 100%;
    overflow: auto;
    height: calc(100% - 10px);
}

.custom-dropdown-option {
    padding: 1rem 1.5rem;
    cursor: pointer;
}

.custom-dropdown-option:hover {
    color: #16181b;
    background-color: #f8f9fa;
}

.custom-dropdown-option-active {
    color: #fff;
    background-color: #5CA6BD;
}

.custom-dropdown-option-active:hover {
    color: #fff;
    background-color: #477f91;
}

.custom-dropdown-option:disabled,
.custom-dropdown-option-disabled {
    pointer-events: none;
    opacity: 0.5;
    background-color: #f2f2f2;
    color: #999;
    cursor: not-allowed;
}

/* OPENED or CLOSED */

.custom-dropdown-toggler[data-status="closed"] {
    display: -webkit-inline-box;
    display: -webkit-inline-flex;
    display: -ms-inline-flexbox;
    display: inline-flex;
}

.custom-dropdown-toggler[data-status="opened"] {
    display: none;
}

.custom-dropdown-toggler[data-status="closed"] + .custom-dropdown-filter,
.custom-dropdown-toggler[data-status="closed"] ~ .custom-dropdown-content {
    display: none;
}

.custom-dropdown-toggler[data-status="opened"] + .custom-dropdown-filter,
.custom-dropdown-toggler[data-status="opened"] ~ .custom-dropdown-content {
    display: block;
}

.custom-dropdown-toggler[data-status="closed"] > span.text-placeholder {
    color: #999;
}

.custom-dropdown-toggler[data-status="opened"] > span.text-placeholder {
    color: #FFF;
}
