/* The field owns the available width; Select2's 100% never includes Add. */
.ot-watcher-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.5rem;
}

.ot-watcher-select-field,
.ot-watcher-identity {
    min-width: 0;
    overflow-wrap: anywhere;
}

.ot-watcher-add > button {
    white-space: nowrap;
}

/* Keep the native control clipped whenever Select2 has inserted its replacement.
   HTMX swaps can leave the replacement beside a select without Select2's class,
   and the vendor stylesheet may fail to load. Without the replacement, the
   native select remains available. */
.ot-watcher-select-field > select:has(+ .select2-container) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    white-space: nowrap !important;
}

.ot-watcher-select-field > .select2-container {
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
}

.ot-watcher-select-field .select2-selection--single {
    height: auto;
}

.ot-watcher-select-field .select2-selection--single .select2-selection__rendered {
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
}

.ot-user-select-dropdown .select2-results__options {
    overscroll-behavior: contain;
}

.ot-user-select-dropdown .select2-results__option {
    white-space: normal;
    overflow-wrap: anywhere;
}

.ot-saved-filter-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.375rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--bs-border-color, #dee2e6);
    min-width: 0;
    max-width: 100%;
}

.ot-saved-filter-controls #saved-filter-select {
    max-width: min(18rem, 100%);
}

.ot-saved-filter-controls #saved-filter-state {
    flex-basis: 100%;
    text-align: right;
}

#watchers-section button:focus-visible,
.ot-saved-filter-controls :is(button, select):focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.ot-inline-save-error {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.375rem;
    overflow-wrap: anywhere;
    flex: 0 1 100%;
    flex-wrap: wrap;
    min-width: 0;
    white-space: normal;
}

.ot-watcher-feedback {
    overflow-wrap: anywhere;
}

.ot-inline-edit:has(> .ot-inline-save-error) {
    flex-wrap: wrap;
}

.ot-inline-save-error > button {
    flex: 0 0 auto;
}

.ot-user-identity,
.ot-user-identity-name,
.ot-user-identity-email {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
}

.ot-user-identity-email {
    font-size: 0.875em;
    color: #526070;
}

.select2-results__option--highlighted .ot-user-identity-email {
    color: inherit;
}

.select2-container--bootstrap .select2-selection--single:has(.ot-user-identity-email) {
    height: auto;
}
