/* Keep the native control hidden whenever it has been enhanced into a widget.
   The component also sets inline display:none, but that inline style can be lost
   when htmx swaps/settles a fragment containing the select -- which would leave the
   raw <select> showing next to the widget (a "duplicate" control). Keying the hide
   on the persistent data-searchable-initialized attribute makes it stick. */
select.searchable-select[data-searchable-initialized] {
    display: none !important;
}

.searchable-select-wrapper {
    position: relative;
    width: 100%;
}

.searchable-select-wrapper.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.searchable-select-display {
    width: 100%;
    padding: 8px;
    border: var(--border-width) solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-base);
    background: var(--color-surface);
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.searchable-select-display:hover {
    border-color: var(--color-border-hover);
}

.searchable-select-wrapper.open .searchable-select-display {
    border-color: var(--color-accent);
    box-shadow: var(--focus-ring);
}

.searchable-select-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.searchable-select-arrow {
    margin-left: 8px;
    font-size: var(--font-size-xs);
    transition: transform 0.2s;
    color: var(--color-text-muted);
}

.searchable-select-wrapper.open .searchable-select-arrow {
    transform: rotate(180deg);
}

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: var(--border-width) solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    margin-top: 4px;
    max-height: 300px;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

.searchable-select-wrapper.open .searchable-select-dropdown {
    display: flex;
}

.searchable-select-search {
    width: 100%;
    padding: 8px;
    border: none;
    border-bottom: var(--border-width) solid var(--color-border-strong);
    font-size: var(--font-size-base);
    background: var(--color-surface);
    outline: none;
}

.searchable-select-search:focus {
    border-bottom-color: var(--color-accent);
}

.searchable-select-options {
    overflow-y: auto;
    max-height: 250px;
}

.searchable-select-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: var(--font-size-base);
    transition: background 0.1s;
}

.searchable-select-option:hover {
    background: var(--color-surface-hover);
}

.searchable-select-option.selected {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-weight: 500;
}

.searchable-select-option.highlighted {
    background: var(--color-surface-hover);
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.searchable-select-no-results {
    padding: 12px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-base);
    font-style: italic;
}