/* ============================================================
   Searchable dropdown widget (forms-dropdown.js)
   Enhances <select class="select2"> in Umbraco Forms.
   No jQuery / no external libraries.
   ============================================================ */

:root {
    --ss-border: #cfd4d9;
    --ss-border-focus: #337ab7;
    --ss-accent: #0a7a4b;
    --ss-accent-soft: rgba(51, 122, 183, .25);
    --ss-radius: 6px;
    --ss-text: #2c3e50;
    --ss-muted: #6c757d;
}

/* Hide the native select but keep it available for form submission/validation. */
select.ss-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.ss-wrapper {
    position: relative;
    width: 100%;
    font-size: 1rem;
    color: var(--ss-text);
}

/* The clickable control */
.ss-control {
    display: flex;
    align-items: center;
    gap: .35rem;
    min-height: 2.5rem;
    padding: .35rem 2rem .35rem .75rem;
    border: 1px solid var(--ss-border);
    border-radius: var(--ss-radius);
    background: #fff;
    cursor: pointer;
    position: relative;
    flex-wrap: wrap;
}

.ss-control:focus {
    outline: 0;
    border-color: var(--ss-border-focus);
    box-shadow: 0 0 0 3px var(--ss-accent-soft);
}

.ss-wrapper.ss-open .ss-control {
    border-color: var(--ss-border-focus);
    box-shadow: 0 0 0 3px var(--ss-accent-soft);
}

.ss-values {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    flex: 1 1 auto;
    min-width: 0;
}

.ss-placeholder {
    color: var(--ss-muted);
}

.ss-single {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Multi-select tags */
.ss-tag {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .1rem .3rem .1rem .5rem;
    background: var(--ss-accent-soft);
    color: var(--ss-accent);
    border-radius: 4px;
    font-size: .85rem;
    line-height: 1.4;
}

.ss-tag-remove {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 .15rem;
}

.ss-tag-remove:hover {
    color: #c0392b;
}

/* Caret (chevron down arrow) */
.ss-caret {
    position: absolute;
    right: .9rem;
    top: 50%;
    width: 9px;
    height: 9px;
    margin-top: -6px; /* shift up so the rotated square centers vertically */
    border-right: 2px solid var(--ss-muted);
    border-bottom: 2px solid var(--ss-muted);
    transform: rotate(45deg);
    transform-origin: center;
    transition: transform .15s ease;
    pointer-events: none;
}

.ss-wrapper.ss-open .ss-caret {
    margin-top: -2px;
    transform: rotate(-135deg);
}

/* Dropdown panel */
.ss-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--ss-border);
    border-radius: var(--ss-radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
    overflow: hidden;
}

.ss-wrapper.ss-open .ss-panel {
    display: block;
}

.ss-search {
    width: 100%;
    box-sizing: border-box;
    padding: .5rem .75rem;
    border: 0;
    border-bottom: 1px solid var(--ss-border);
    font-size: 1rem;
    outline: 0;
}

.ss-list {
    list-style: none;
    margin: 0;
    padding: .25rem 0;
    max-height: 240px;
    overflow-y: auto;
}

.ss-option {
    padding: .5rem .75rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Remove any inherited decorative bullet/dot (e.g. a teal li::before marker,
   a list-style marker, or a background bullet from the global site styles)
   on dropdown options. High specificity + !important so it always wins over
   the global content-area list styling. */
.ss-wrapper .ss-panel ul.ss-list,
.ss-wrapper .ss-panel ul.ss-list li.ss-option {
    list-style: none !important;
    list-style-type: none !important;
    list-style-image: none !important;
}

.ss-wrapper .ss-panel ul.ss-list li.ss-option {
    background-image: none !important;
    text-indent: 0 !important;
}

.ss-wrapper .ss-panel ul.ss-list li.ss-option::before {
    content: none !important;
    display: none !important;
    background: none !important;
}

.ss-wrapper .ss-panel ul.ss-list li.ss-option::marker {
    content: "" !important;
    color: transparent !important;
    font-size: 0 !important;
}

.ss-option.ss-active {
    background: #337ab7;
    color: #fff;
}

.ss-wrapper .ss-panel ul.ss-list li.ss-option:hover {
    background: #337ab7;
    color: #fff;
}

.ss-option.ss-selected {
    font-weight: 600;
    color: var(--ss-accent);
}

.ss-option.ss-selected::after {
    content: "\2713";
    float: right;
    margin-left: .5rem;
}

.ss-option.ss-disabled {
    color: var(--ss-muted);
    cursor: not-allowed;
    opacity: .6;
}

.ss-empty {
    padding: .5rem .75rem;
    color: var(--ss-muted);
    font-style: italic;
}
