/* Tom Select: the artists field of the tube form (tomselect.js) and the prototype /admin/test/tomselect.
   Loaded on every page after styles.css, the tube form opens in the modal from any page. The box and focus of
   .form-control, chips and menu like the tag input. tom-select.bootstrap5.css has fixed light colors and Bootstrap's
   blue focus, these rules replace them. */

:root {
    --mt-border-chip:   rgba(255, 255, 255, 0.7); /* chips in the selection fields, clearly stronger than the field (0.4) */
    --mt-option-active: #391f2a;                  /* highlighted option in their lists (accent-dim on surface-2) */
}

.ts-wrapper {
    padding: 0;
    border: 0;
    background: none;
    min-height: 0;
}

.ts-wrapper .ts-control,
.ts-wrapper.single .ts-control,
.ts-wrapper.multi.has-items .ts-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    min-height: calc(1.5em + .75rem + 2px);
    padding: .375rem 2.25rem .375rem .75rem;
    background: var(--mt-surface);
    background-image: none;
    border: 1px solid var(--mt-border-input);
    border-radius: var(--mt-radius-sm);
    color: var(--mt-text);
    box-shadow: none;
    cursor: text;
    transition: border-color var(--mt-ease), box-shadow var(--mt-ease), background-color var(--mt-ease);
}

/* The same as .form-control:focus (as specific as the rule above, so it wins) */
.ts-wrapper.focus .ts-control,
.ts-wrapper.single.focus .ts-control,
.ts-wrapper.multi.has-items.focus .ts-control {
    background-color: var(--mt-surface-2);
    border-color: rgba(230, 57, 80, 0.5);
    box-shadow: 0 0 0 3px var(--mt-accent-dim);
}

.ts-wrapper.dropdown-active .ts-control {
    border-radius: var(--mt-radius-sm);
}

.ts-wrapper .ts-control input {
    flex: 1 0 8rem;
    min-width: 8rem !important;
    margin: 0 !important;
    padding: 0;
    color: inherit;
    line-height: 1.5;
}

.ts-wrapper .ts-control input::placeholder {
    color: var(--mt-text-subtle);
}

/* Chips: the same as .ti-chip */
.ts-wrapper.multi .ts-control > .item {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin: 0;
    padding: .1rem .2rem .1rem .55rem;
    border-radius: 1rem;
    background: var(--bs-secondary-bg);
    border: 1px solid var(--mt-border-chip);
    color: var(--bs-body-color);
    font-size: .875rem;
    line-height: 1.4;
}

.ts-wrapper.multi .ts-control > .item.active {
    background: var(--mt-accent-dim);
    border-color: rgba(230, 57, 80, 0.5);
    color: var(--mt-text);
}

/* × like .ti-remove (the theme adds a border on its left, :not(.rtl) is as specific) */
.ts-wrapper.plugin-remove_button .item .remove,
.ts-wrapper.plugin-remove_button:not(.rtl) .item .remove {
    margin: 0;
    padding: 0 .3rem;
    border: 0;
    border-radius: 50%;
    color: var(--bs-secondary-color);
    font-size: 1rem;
    line-height: 1;
}

.ts-wrapper.plugin-remove_button .item .remove:hover {
    background: transparent;
    color: var(--bs-danger);
}

/* The clear button is a <div> in .ts-control too, so the theme's ".ts-wrapper.multi .ts-control > div" for the chips
   (gray text, padding, overflow: auto with scrollbars) would win over a shorter selector */
.ts-wrapper.plugin-clear_button .ts-control > .clear-button {
    right: .75rem;
    margin: 0;
    overflow: visible;
    padding: 0 .25rem;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--bs-secondary-color);
}

/* Red on hover, like the × of the chips */
.ts-wrapper.plugin-clear_button .ts-control > .clear-button:hover {
    color: var(--bs-danger);
}

/* Menu: the same as .ti-menu */
.ts-dropdown {
    margin-top: .2rem;
    padding: 0;
    background: var(--mt-surface-2);
    border: 1px solid var(--mt-border-hover);
    border-radius: var(--mt-radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    color: var(--mt-text);
    z-index: 1060;
}

/* The theme pads the list by 5px at the top and bottom, the tag input menu has no padding */
.ts-dropdown .ts-dropdown-content {
    padding: 0;
}

.ts-dropdown .option,
.ts-dropdown .create,
.ts-dropdown .no-results {
    padding: .35rem .75rem;
    color: var(--mt-text);
}

.ts-dropdown .active,
.ts-dropdown .create.active {
    background: var(--mt-option-active);
    color: var(--mt-text);
}

/* Matched text in bold, like the tag input */
.ts-dropdown .highlight,
.ts-dropdown [data-selectable] .highlight {
    background: transparent;
    font-weight: 700;
    color: inherit;
}

.ts-dropdown .spinner::after {
    border-color: var(--bs-secondary-color) transparent;
}

/* CREATE in the menu: dark text on yellow (.create-badge in styles.css has no text color) */
.ts-dropdown .create-badge {
    margin-left: .5rem;
    color: #1a1a1f;
    font-weight: 600;
}

/* Validation error: tube/_addForm and tube/edit put is-invalid on .artists-wrapper */
.artists-wrapper.is-invalid .ts-wrapper .ts-control {
    border-color: var(--bs-form-invalid-border-color);
}

.artists-wrapper.is-invalid .ts-wrapper.focus .ts-control {
    border-color: var(--bs-form-invalid-border-color);
    box-shadow: 0 0 0 3px rgba(var(--bs-danger-rgb), 0.25);
}
