@import url("https://esm.sh/tom-select@2.4.3/dist/css/tom-select.min.css");

.ts-control {
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    color: #000000;
    display: inline-flex;
    font-size: 14px;
    line-height: 1.5;
    min-height: 40px;
    padding: 8px 12px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

.ts-control:hover {
    border-color: #a3a3a3;
}

.ts-control.focus {
    outline: none;
    border-color: #000000;
    border-width: 2px;
    padding: 7px 11px;
}

.ts-control > input {
    color: inherit;
    font-size: inherit;
}

.ts-dropdown {
    background-color: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -4px rgba(0, 0, 0, 0.1);
    color: #000000;
    font-size: 14px;
    line-height: 1.5;
    margin-top: 4px;
    z-index: 1000;

    /* Setup transition */
    transition-behavior: allow-discrete;
    transition-duration: 150ms;
    transition-property: display, opacity, transform;

    /* Exit stage to */
    opacity: 0;
    transform: scale(0.95);

    /* On stage */
    .dropdown-active & {
        opacity: 1;
        transform: scale(1);
    }

    /* Enter stage from */
    @starting-style {
        .dropdown-active & {
            opacity: 0;
            transform: scale(0.95);
        }
    }
}

.ts-dropdown-content:not(:has(.optgroup)) {
    padding: 4px;
}

.optgroup:not(:first-child) {
    border-top: 1px solid #e5e5e5;
}

.optgroup {
    padding: 4px;
}

.optgroup-header {
    background-color: inherit;
    color: #71717a;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.create {
    padding: 6px 8px;
    color: #4f46e5;
    font-weight: 500;
}

.option {
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.option:hover {
    background-color: #f5f5f5;
}

.active {
    background-color: #f4f4f5 !important;
    color: #000000 !important;
}

.active:hover {
    background-color: #e4e4e7 !important;
}

.highlight {
    background-color: transparent !important;
}

.spinner {
    margin: 6px 0 0;
}

.spinner::after {
    border-color: #a3a3a3;
}

/* Single select with chevron */
.ts-wrapper.single .ts-control {
    background-color: #ffffff !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%23a3a3a3' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E") !important;
    background-position: center right 8px !important;
    background-repeat: no-repeat !important;
    background-size: 20px auto !important;
    padding-right: 36px !important;
}

/* Multi select items/tags */
.ts-wrapper.multi .ts-control {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px;
}

.ts-wrapper.multi .ts-control > .item {
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    border-radius: 6px;
    color: #000000;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    padding: 4px 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ts-wrapper.multi .ts-control > .item .remove {
    color: #71717a;
    font-size: 16px;
    margin-left: 2px;
    transition: color 0.15s ease;
}

.ts-wrapper.multi .ts-control > .item .remove:hover {
    color: #ef4444;
}

/* Disabled state */
.disabled .ts-control {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #fafafa;
}

.disabled .ts-control * {
    cursor: not-allowed !important;
}

/* Invalid state */
.invalid .ts-control {
    border-color: #ef4444;
}

.invalid .ts-control:focus {
    border-color: #dc2626;
}

/* Hide the original select element but keep it accessible */
select[data-controller~="combobox"] {
    clip: rect(0 0 0 0);
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
