/* tgSelect (static/js/app/tg_select.js): select2 drawn like a Bootstrap 3 button and dropdown menu,
   with the button colours in theme.css. */

/* The box. Without a size class it is a default-size button; tg-select-box alone is
   btn-secondary-clear. */
.select2-container--default .select2-selection.tg-select-box {
    height: 38px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background-color: white;
    color: #545454;
}
.select2-container--default .select2-selection.tg-select-box:hover,
.select2-container--default.select2-container--open .select2-selection.tg-select-box,
.select2-container--default.select2-container--focus .select2-selection.tg-select-box {
    background-color: #e0e0e0;
}
/* The box keeps its corners while the menu is open; the menu sits 2px away. */
.select2-container--default.select2-container--open .select2-selection.tg-select-box {
    border-radius: 4px;
}
.select2-container--default .tg-select-box .select2-selection__rendered {
    padding-left: 12px;
    padding-right: 24px;
    line-height: 36px;
    color: inherit;
}
.select2-container--default .tg-select-box .select2-selection__arrow {
    height: 36px;
    right: 7px;
}
/* A Bootstrap caret: 8px by 4px, in the text colour, pointing down while open too. */
.select2-container--default .tg-select-box .select2-selection__arrow b,
.select2-container--default.select2-container--open .tg-select-box .select2-selection__arrow b {
    border-color: currentColor transparent transparent;
    border-width: 4px 4px 0;
}
/* Bootstrap's .btn .label: labels sit 1px above the baseline, as in a button. */
.select2-container--default .tg-select-box .select2-selection__rendered .label {
    position: relative;
    top: -1px;
}
.select2-container--default .tg-select-box .select2-selection__placeholder {
    color: #999;
}
.select2-container--default .tg-select-box:has(.select2-selection__placeholder) .select2-selection__arrow b {
    border-top-color: #999;
}

.select2-container--default .select2-selection.tg-select-box.tg-select--sm,
.select2-container--default.select2-container--open .select2-selection.tg-select-box.tg-select--sm {
    height: 30px;
    border-radius: 3px;
    font-size: 12px;
}
.select2-container--default .tg-select-box.tg-select--sm .select2-selection__rendered {
    padding-left: 10px;
    line-height: 28px;
}
.select2-container--default .tg-select-box.tg-select--sm .select2-selection__arrow {
    height: 28px;
}

.select2-container--default .select2-selection.tg-select-box.tg-select--xs,
.select2-container--default.select2-container--open .select2-selection.tg-select-box.tg-select--xs {
    height: 22px;
    border-radius: 3px;
    font-size: 12px;
}
.select2-container--default .tg-select-box.tg-select--xs .select2-selection__rendered {
    padding-left: 5px;
    line-height: 20px;
}
.select2-container--default .tg-select-box.tg-select--xs .select2-selection__arrow {
    height: 20px;
}

/* btn-primary-clear: filled on hover and focus; white while its menu is open. */
.select2-container--default .select2-selection.tg-select-box.tg-select--primary {
    border-color: #5e89b4;
    color: #5e89b4;
}
.select2-container--default .select2-selection.tg-select-box.tg-select--primary:hover,
.select2-container--default.select2-container--focus .select2-selection.tg-select-box.tg-select--primary {
    background-color: #5e89b4;
    color: white;
}
.select2-container--default.select2-container--open .select2-selection.tg-select-box.tg-select--primary {
    background-color: white;
    color: #5e89b4;
}

/* btn-default-clear. */
.select2-container--default .select2-selection.tg-select-box.tg-select--default-clear {
    border-color: transparent;
    background-color: #efefef;
    color: #666;
}
.select2-container--default .select2-selection.tg-select-box.tg-select--default-clear:hover,
.select2-container--default.select2-container--focus .select2-selection.tg-select-box.tg-select--default-clear {
    background-color: #efefef;
    color: white;
}
.select2-container--default.select2-container--open .select2-selection.tg-select-box.tg-select--default-clear {
    background-color: #efefef;
    color: #666;
}

/* No data-style: Bootstrap's btn-default in this theme. */
.select2-container--default .select2-selection.tg-select-box.tg-select--default {
    border-color: #2e2f2f;
    background-color: #474949;
    color: white;
}
.select2-container--default .select2-selection.tg-select-box.tg-select--default:hover {
    border-color: #242525;
    background-color: #2e2f2f;
}
.select2-container--default.select2-container--focus .select2-selection.tg-select-box.tg-select--default {
    border-color: #080808;
    background-color: #2e2f2f;
}
.select2-container--default.select2-container--open .select2-selection.tg-select-box.tg-select--default {
    border-color: #292a2a;
    background-color: #2e2f2f;
}

.select2-container--disabled .select2-selection.tg-select-box {
    opacity: 0.65;
    cursor: not-allowed;
}

/* The menu: a Bootstrap .dropdown-menu. */
.select2-container--default.tg-select-dropdown {
    min-width: 160px;
    /* The menu grows to fit its options, but not off the page; long options wrap. */
    max-width: calc(100vw - 32px);
}
.select2-container--default.tg-select-dropdown .select2-dropdown,
.select2-container--default.tg-select-dropdown .select2-dropdown--below,
.select2-container--default.tg-select-dropdown .select2-dropdown--above {
    padding: 5px 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
    color: #666;
    font-size: 14px;
}
.select2-container--default.tg-select-dropdown .select2-dropdown--below {
    margin-top: 2px;
}
.select2-container--default.tg-select-dropdown .select2-dropdown--above {
    margin-top: -2px;
}
.select2-container--default.tg-select-dropdown .select2-results > .select2-results__options {
    max-height: none;
}

.select2-container--default.tg-select-dropdown .select2-results__option {
    padding: 3px 20px;
    color: #333;
    line-height: 1.42857143;
}
/* An option's content is one inline block, so its subtext and icon do not change the row height. */
.select2-container--default.tg-select-dropdown .select2-results__option--selectable > span {
    display: inline-block;
}
.select2-container--default.tg-select-dropdown .select2-results__option--group {
    padding: 0;
}
.select2-container--default.tg-select-dropdown .select2-results__option .select2-results__option {
    padding-left: 2.25em;
}
/* A data-icon sits 1px low, as Bootstrap's .glyphicon does. */
.select2-container--default.tg-select-dropdown .select2-results__option > span > i:first-child,
.select2-container--default .tg-select-box .select2-selection__rendered > span > i:first-child {
    position: relative;
    top: 1px;
}
/* An optgroup label is a .dropdown-header, with a .divider above it unless it comes first. */
.select2-container--default.tg-select-dropdown .select2-results__group {
    padding: 3px 20px;
    color: #999;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.42857143;
}
.select2-container--default.tg-select-dropdown .select2-results__option--group:not(:first-child)::before {
    content: "";
    display: block;
    height: 1px;
    margin: 9px 0;
    background-color: #e5e5e5;
}
.select2-container--default.tg-select-dropdown .select2-results__option .text-muted {
    padding-left: 0.5em;
    color: #999;
}
.select2-container--default.tg-select-dropdown .select2-results__option--highlighted.select2-results__option--selectable,
.select2-container--default.tg-select-dropdown .select2-results__option--selected {
    background-color: #446e9b;
    color: white;
}
.select2-container--default.tg-select-dropdown .select2-results__option--selected .text-muted {
    color: rgba(255, 255, 255, 0.5);
}
.select2-container--default.tg-select-dropdown .select2-results__option.select2-results__option--disabled {
    color: #999;
    cursor: not-allowed;
}
.select2-container--default.tg-select-dropdown .select2-results__message {
    margin: 0 5px;
    padding: 3px;
    background-color: #f5f5f5;
    white-space: nowrap;
}

/* Multi-select: a tick on the right of each selected option, which keeps its normal colours. */
.select2-container--default.tg-select-dropdown--multi .select2-results__option--selectable {
    position: relative;
    padding-right: 54px;
}
.select2-container--default.tg-select-dropdown--multi .select2-results__option--selected {
    background-color: transparent;
    color: #333;
}
.select2-container--default.tg-select-dropdown--multi
    .select2-results__option--selected.select2-results__option--highlighted {
    background-color: #446e9b;
    color: white;
}
.select2-container--default.tg-select-dropdown--multi .select2-results__option--selected .text-muted {
    color: #999;
}
.select2-container--default.tg-select-dropdown--multi .select2-results__option--selected::after {
    content: "\e013";
    position: absolute;
    top: 5px;
    right: 15px;
    font-family: "Glyphicons Halflings";
    font-size: 14px;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
}

/* The search box: a .form-control with 4px 8px around it. */
.select2-container--default.tg-select-dropdown .select2-search--dropdown {
    padding: 4px 8px;
}
.select2-container--default.tg-select-dropdown .select2-search--dropdown .select2-search__field {
    height: 38px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
    color: #666;
    font-size: 14px;
    line-height: 1.42857143;
    transition:
        border-color ease-in-out 0.15s,
        box-shadow ease-in-out 0.15s;
}
.select2-container--default.tg-select-dropdown .select2-search--dropdown .select2-search__field:focus {
    border-color: #66afe9;
    outline: 0;
    box-shadow:
        inset 0 1px 1px rgba(0, 0, 0, 0.075),
        0 0 8px rgba(102, 175, 233, 0.6);
}

/* Select All / Deselect All: below the search box, half the width each. */
.tg-select-actions {
    padding: 4px 8px;
}
.select2-search--dropdown + .tg-select-actions {
    padding: 0 8px 4px;
}
.tg-select-actions .btn {
    width: 50%;
}
