/*
 * Chosen → .form-control bridge.
 *
 * js/autobiz/chosen_theme.js adds .form-control to every .chosen-container, so the
 * field box (border, radius, colours, font size, horizontal padding) comes from the
 * same rules as other inputs: template_new/css/style.css plus the tenant's backend
 * theme (themes/*.css). chosen.min.css is loaded before both so .form-control wins.
 *
 * This file only handles layout: it strips Chosen's own inner box and keeps the
 * height equal to a normal .form-control while letting multi-selects grow.
 */
.chosen-container.form-control {
    display: inline-flex;
    align-items: center;
    height: auto;
    min-height: calc(2.25rem + 2px);
    padding-top: 2px;
    padding-bottom: 2px;
    cursor: text;
}

/* Inner box: no border/background of its own — the container is the field. */
.chosen-container.form-control .chosen-single,
.chosen-container.form-control .chosen-choices {
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: inherit;
    font: inherit;
    line-height: 1.5;
}

/* Single */
.chosen-container.form-control .chosen-single span {
    margin-right: 1.5rem;
}

.chosen-container.form-control .chosen-single div {
    display: flex;
    align-items: center;
}

.chosen-container.form-control .chosen-single div b {
    /* Keep Chosen's sprite offsets (open/closed arrows); just centre a 16px cell. */
    height: 16px;
}

.chosen-container.form-control .chosen-single abbr {
    top: 50%;
    transform: translateY(-50%);
}

/* Multi */
.chosen-container.form-control .chosen-choices {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}

/* Chosen 1.4.2 sizes the search input inline as min(text width + 25, container width - 10).
   A select initialised while hidden (closed modal, inactive tab) has a 0px container, so the
   input gets ~0px and can't be clicked or typed into until a pick re-measures it. Let the
   search field fill the rest of the row instead of trusting that inline width. */
.chosen-container.form-control .chosen-choices li.search-field {
    flex: 1 1 6rem;
    min-width: 6rem;
}

.chosen-container.form-control .chosen-choices li.search-field input[type="text"] {
    width: 100% !important;
    text-overflow: ellipsis;
    height: 1.5em;
    margin: 0;
    padding: 0;
    font: inherit;
    color: inherit;
}

.chosen-container.form-control .chosen-choices li.search-choice {
    margin: 0;
    padding: 0 1.4rem 0 0.5rem;
    line-height: calc(1.5em - 2px);
    font-size: 0.875em;
    background: rgba(var(--bs-primary-rgb, 70, 128, 255), 0.08);
    border: 1px solid rgba(var(--bs-primary-rgb, 70, 128, 255), 0.25);
    border-radius: 4px;
    box-shadow: none;
    color: inherit;
}

.chosen-container.form-control .chosen-choices li.search-choice .search-choice-close {
    top: 50%;
    transform: translateY(-50%);
}

/* Focus / open — Chosen's own blue glow is replaced by the brand colour. */
.chosen-container.form-control.chosen-container-active {
    border-color: var(--primary, var(--bs-primary, #4680ff));
}

.chosen-container.form-control.chosen-container-active .chosen-choices li.search-field input[type="text"] {
    color: inherit !important;
}

/* Dropdown — align with the container's outer border. */
.chosen-container.form-control.chosen-with-drop .chosen-drop {
    left: -1px;
    width: calc(100% + 2px);
    margin-top: 1px;
    border-color: var(--primary, var(--bs-primary, #4680ff));
    font-size: 0.875em;
}

.chosen-container.form-control .chosen-search input[type="text"] {
    font: inherit;
}

.chosen-container.form-control .chosen-results li {
    padding: 0.45rem 0.75rem;
    line-height: 1.4;
}

.chosen-container.form-control .chosen-results li.highlighted {
    background: var(--primary, var(--bs-primary, #4680ff));
    color: #ffffff;
}
