/* SafariPilot — select2.css
 *
 * How Select2 looks everywhere (§6.31): the public site, the sign-in screens and both portals link this file straight
 * after the Select2 theme. It used to be a section of frontend.css and again of portal.css, the same rules twice.
 */

:root {
    --s2-line: #ced4da;
    --s2-focus: #80bdff;
    --s2-focus-ring: rgba(0, 123, 255, .25);
    --s2-muted: #6c757d;
    --s2-ink: #343a40;
    --s2-surface: #fff;
    --s2-hover: #f8f9fa;
}

.select2-container--bootstrap4 .select2-selection {
    border-color: #ced4da;
    border-radius: .25rem;
}

/* ── The single control, at its normal size ──────────────────────
   No `padding` here, and no `line-height` on the rendered span. The theme already locks the height
   (`calc(1.5em + .75rem + 2px)`) and centres the text with `line-height: calc(1.5em + .75rem)` on
   the rendered span, which is also where a `.form-control`'s 12px inset comes from. A `padding` on
   the box on top of that inset the text *twice* over, and a `line-height` of our own took the text
   back out of the middle of a fixed-height box — the two things that made a select look unlike the
   input beside it.

   What this file adds is only what the theme never had:
     • room on the right for the arrow;
     • centring for the arrow, which the theme leaves sitting low (below);
     • the small-control sizing, which the theme does not know about. */

.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
    padding-right: 2rem;
    /* room for the arrow, so text cannot run under it */
    ;
}

/* The theme positions the arrow at `top: 50%` and gives it no height, so the triangle it draws
   lands below the middle of the control. A height plus a translate puts it back in the centre at
   both sizes. */

.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow {
    top: 50%;
    height: 1.5em;
    transform: translateY(-50%);
}

.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b {
    top: 50%;
}

/* The clear ×: left of the arrow rather than on top of it, quiet, and
   red only when a pointer is actually on it. */

.select2-container--bootstrap4 .select2-selection--single .select2-selection__clear {
    position: absolute;
    top: 50%;
    right: 1.6rem;
    float: none;
    width: 1rem;
    height: 1rem;
    margin: 0;
    padding: 0;
    line-height: 1rem;
    text-align: center;
    font-size: .8rem;
    color: var(--s2-muted);
    background: transparent;
    transform: translateY(-50%);
}

.select2-container--bootstrap4 .select2-selection--single .select2-selection__clear:hover {
    color: #dc3545;
    background: transparent;
}

/* ── The small controls: filter bars, table heads, report panels ──
   Select2 inserts its own container as a sibling *after* the `<select>`
   it replaces, which is why the sizing is keyed off the class on that
   select — the same way the theme keys its `is-invalid` border off it. */

.input-group-sm .select2-container--bootstrap4 .select2-selection--single,
.form-control-sm~.select2-container--bootstrap4 .select2-selection--single {
    height: calc(1.5em + .5rem + 2px) !important;
    padding: 0;
    /* the rendered span below carries the inset;
    padding here as well pushed the text off-centre */
    font-size: .875rem;
}

.input-group-sm .select2-container--bootstrap4 .select2-selection__rendered,
.form-control-sm~.select2-container--bootstrap4 .select2-selection__rendered {
    padding-left: .5rem;
    padding-right: 1.75rem;
    line-height: calc(1.5em + .5rem);
    font-size: .875rem;
}

.input-group-sm .select2-container--bootstrap4 .select2-selection--multiple,
.form-control-sm~.select2-container--bootstrap4 .select2-selection--multiple {
    min-height: calc(1.5em + .5rem + 2px) !important;
}

.input-group-sm .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice,
.form-control-sm~.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
    margin-top: 1px;
    font-size: .75rem;
}

.select2-container--bootstrap4.select2-container--focus .select2-selection,
.select2-container--bootstrap4.select2-container--open .select2-selection {
    border-color: #80bdff;
    box-shadow: 0 0 0 .2rem rgba(0, 123, 255, .25);
}

.select2-container--bootstrap4 .select2-selection--multiple {
    min-height: calc(1.5em + .75rem + 2px) !important;
    padding: .1rem .35rem;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
    float: none;
    display: inline-block;
    background-color: var(--s2-hover);
    border: 1px solid var(--s2-line);
    border-radius: .25rem;
    color: var(--s2-ink);
    font-size: .8125rem;
    line-height: 1.4;
    padding: .1rem .4rem;
    margin: .15rem .25rem .15rem 0;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove {
    float: none;
    color: var(--s2-muted);
    margin: 0 .2rem 0 0;
    padding: 0;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #dc3545;
}

/* The typed-ahead field inside a multiple control: no border of its own, sized like the pills beside it. */

.select2-container--bootstrap4 .select2-selection--multiple .select2-search__field {
    height: 1.6rem;
    padding: 0 .25rem;
    font-size: .8125rem;
}

/* ── The dropdown ──────────────────────────────────────────────── */

/* Above the app's own overlays — the admin sidebar sits at 1020 and a Bootstrap modal at 1055 — because a
   search field that opens under the thing it is filtering is worse than no search field. */

.select2-dropdown {
    border-color: var(--s2-line);
    box-shadow: 0 10px 24px rgba(17, 24, 39, .08);
    z-index: 1060;
}

/* Long option lists are the point of Select2, so the dropdown scrolls at a readable height rather than the
   theme's 15em. */

.select2-container--bootstrap4 .select2-results>.select2-results__options {
    max-height: 17.5rem;
}

.select2-container--bootstrap4 .select2-results__option {
    padding: .3rem .5rem;
    font-size: .875rem;
}

/* The app's accent is ink rather than Bootstrap blue: a highlighted option should look like a hovered menu
   row, which is what the rest of the interface uses (§6.13). */

.select2-container--bootstrap4 .select2-results__option--highlighted,
.select2-container--bootstrap4 .select2-results__option--highlighted.select2-results__option[aria-selected="true"] {
    background-color: var(--s2-ink);
    color: #fff;
}

.select2-container--bootstrap4 .select2-results__option[aria-selected="true"] {
    background-color: var(--s2-hover);
    color: var(--s2-ink);
    font-weight: 600;
}

/* A group heading, from an `<optgroup>` in the select it replaced. */

.select2-container--bootstrap4 .select2-results__group {
    display: block;
    padding: .35rem .5rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--s2-muted);
    background: var(--s2-surface);
}

.select2-container--bootstrap4 .select2-results__option--group .select2-results__option {
    padding-left: .9rem;
}

/* "No results found", and the field that produced it. */

.select2-results__message {
    padding: .5rem .75rem;
    font-size: .875rem;
    color: var(--s2-muted);
}

.select2-search--dropdown {
    padding: .4rem;
}

.select2-search--dropdown .select2-search__field {
    padding: .3rem .5rem;
    font-size: .875rem;
    border-color: var(--s2-line);
}

.select2-search--dropdown .select2-search__field:focus {
    border-color: var(--s2-focus);
    box-shadow: 0 0 0 .2rem var(--s2-focus-ring);
    outline: 0;
}

/* A select that is disabled should look like every other disabled control in the form. */

select[disabled]+.select2-container--bootstrap4 .select2-selection {
    background-color: #e9ecef;
    opacity: 1;
}

/* ── Where the control has to fill its container ───────────────── */

/* Select2 writes `width: 100%` on the container inline, so these only
   matter where the container's own width is wrong. */

.form-group .select2-container--bootstrap4 {
    width: 100% !important;
}

/* Inside an input group the control flex-grows against the buttons
   beside it (the theme's `flex-grow: 1`), which an inline width of
   100% would fight. */

.input-group>.select2-container--bootstrap4,
.input-group-prepend~.select2-container--bootstrap4,
.input-group-append~.select2-container--bootstrap4 {
    width: 1% !important;
}

