/* Tom Select dropdown and rich-option overrides. Control visuals live in form-select.css. */
.ts-dropdown .ts-dropdown-content {
    padding-top: 0 !important;
}
.ts-wrapper .ts-dropdown input.dropdown-input,
.ts-dropdown input {
    background: var(--surface-2) !important;
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: 0 !important;
    color: var(--text) !important;
    font-size: 1rem !important;
    padding: .5rem .75rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    outline: none !important;
    /* Tom Select's default inset shadow reads as a smudge on a dark surface. */
    box-shadow: none !important;
}

/* iOS Safari zooms the viewport when a focused input renders below 16px. */
.ts-wrapper .ts-control > input {
    font-size: 1rem !important;
}

.ts-dropdown,
.ts-dropdown.single,
.ts-dropdown.multi {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
}
.ts-wrapper.dropdown-up .ts-dropdown {
    top: auto !important;
    bottom: calc(100% + .25rem) !important;
}
.ts-dropdown .ts-dropdown-content .option,
.ts-dropdown .option {
    color: var(--text) !important;
    background: transparent !important;
}
.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background: var(--surface-2) !important;
    color: var(--text) !important;
}
.ts-dropdown .option.selected,
.ts-dropdown .option.selected.active {
    background: var(--surface-2) !important;
    color: var(--text) !important;
}
.ts-wrapper .ts-control .item {
    color: var(--text) !important;
}

.ts-wrapper.searchable-select-rich .ts-dropdown-content {
    max-height: 320px;
}

.ts-wrapper.searchable-select-rich .ts-dropdown .optgroup-header {
    background: var(--surface) !important;
    color: var(--text-muted) !important;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .04em;
    padding: .65rem .75rem .3rem;
    text-transform: uppercase;
}

.searchable-select-rich__option {
    align-items: center;
    display: flex;
    gap: .65rem;
    min-width: 0;
    padding: .2rem 0;
}

.searchable-select-rich__image {
    flex: 0 0 28px;
    height: 28px;
    object-fit: contain;
    width: 28px;
}

.searchable-select-rich__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.searchable-select-rich__primary,
.searchable-select-rich__secondary,
.searchable-select-rich__item {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.searchable-select-rich__primary {
    color: var(--text);
    font-size: 1rem;
}

.searchable-select-rich__secondary {
    color: var(--text-muted);
    font-size: .8rem;
}

.field-hint {
    font-size: .8rem;
    color: var(--text-muted);
    font-family: monospace;
}

@media (max-width: 600px) {
    .ts-wrapper .ts-dropdown,
    .ts-wrapper .ts-control,
    .ts-wrapper .ts-control input,
    .ts-wrapper .dropdown-input-wrap,
    .ts-wrapper .dropdown-input-wrap input {
        line-height: 24px;
    }
}
