/**
 * FingradeSelect - Universal Select & Multiselect Styles
 */

.fg-select {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
}

.fg-select-hidden-native {
    display: none !important;
}

/* Hide extra arrows in existing parent containers */
.filter-field--select:has(.fg-select) > .field-icon--right,
.fg-select + .field-icon--right,
.fg-select ~ .field-icon--right {
    display: none !important;
}

/* --- Trigger & Input Box --- */
.fg-select__trigger {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 40px;
    padding: 0;
    gap: 8px;
    background-color: var(--black-50);
    border: 1px solid var(--black-100);
    border-radius: 8px;
    box-sizing: border-box;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Small mode support */
.fg-select--small .fg-select__trigger {
    height: 32px;
}

/* Hover State */
.fg-select:hover:not(.is-disabled) .fg-select__trigger {

}

/* In Focus / Open State: Green 400 */
.fg-select.is-open .fg-select__trigger,
.fg-select.is-focused .fg-select__trigger {
    border-color: var(--green-400);
    background-color: var(--black-50);
    outline: none;
}

/* Error State */
.fg-select.is-error .fg-select__trigger {
    background-color: var(--red-50);
    border-color: var(--red-500);
}

.fg-select__input {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-width: 0;
    margin: 0 !important;
    padding: 8px 36px 8px 12px !important;
    border: none !important;
    outline: none !important;
    background-color: transparent !important;
    font-family: inherit;
    font-size: 14px;
    line-height: 18px;
    font-weight: 400;
    color: var(--black-800);
    box-sizing: border-box;
    cursor: pointer;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.fg-select--small .fg-select__input {
    font-size: 12px;
    line-height: 16px;
    padding: 6px 32px 6px 10px !important;
}

.fg-select.is-open .fg-select__input,
.fg-select.is-focused .fg-select__input {
    cursor: text;
}

.fg-select__input::placeholder {
    color: var(--black-500);
    opacity: 1;
}

/* --- Arrow Icon Button --- */
.fg-select__arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    margin: 0;
    background-color: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    color: var(--black-900);
    transition: transform 0.2s ease, color 0.2s ease;
    pointer-events: none;
}

.fg-select.is-open .fg-select__arrow {
    transform: translateY(-50%) rotate(180deg);
    color: var(--black-900);
}

/* --- Dropdown Menu Popup --- */
.fg-select__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    width: max-content;
    max-width: 380px;
    max-height: 180px;
    background-color: var(--white);
    border: 1px solid var(--black-100);
    border-radius: 8px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 0px 4px rgba(0, 0, 0, 0.06);
    z-index: 1050;
    display: none;
    box-sizing: border-box;
    overflow: hidden;
    animation: fgSelectDropdownFade 0.15s ease-out;
}

@keyframes fgSelectDropdownFade {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fg-select.is-open .fg-select__dropdown {
    display: block;
}

/* Dropdown list container */
.fg-select__list {
    max-height: 180px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    list-style: none;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--black-500) transparent;
}

.fg-select__list::-webkit-scrollbar {
    width: 4px;
}

.fg-select__list::-webkit-scrollbar-track {
    background-color: transparent;
}

.fg-select__list::-webkit-scrollbar-thumb {
    background-color: var(--black-500);
    border-radius: 2px;
}

/* --- Dropdown Items (List Item, height: 32px) --- */
.fg-select__item {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 32px;
    padding: 4px 12px;
    gap: 12px;
    font-size: 14px;
    line-height: 20px;
    color: var(--black-900);
    background-color: var(--white);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.12s ease, color 0.12s ease;
    box-sizing: border-box;
}

.fg-select__item:hover,
.fg-select__item.is-highlighted {
    background-color: var(--black-50);
}

/* Single select: selected item with background and checkmark on the right */
.fg-select:not(.fg-select--multiple) .fg-select__item.is-selected {
    background-color: var(--black-50);
}

.fg-select__item-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Right checkmark in Single Select */
.fg-select__checkmark {
    margin-left: auto;
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--green-600);
    flex-shrink: 0;
}

.fg-select:not(.fg-select--multiple) .fg-select__item.is-selected .fg-select__checkmark {
    display: flex;
}

.fg-select__item.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.fg-select__item.is-hidden {
    display: none !important;
}

/* --- Multiselect Checkbox (20x20px, radius 6px) --- */
.fg-select__checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    flex-shrink: 0;
    border-radius: 6px;
    border: 1px solid var(--black-100);
    background-color: var(--black-50);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    box-sizing: border-box;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.fg-select__checkbox svg {
    width: 12px;
    height: 12px;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.fg-select__item:hover .fg-select__checkbox:not(.is-checked) {
    border-color: var(--black-300);
}

.fg-select__item.is-selected .fg-select__checkbox {
    background-color: var(--green-600);
    border-color: var(--green-600);
}

.fg-select__item.is-selected .fg-select__checkbox svg {
    opacity: 1;
    transform: scale(1);
}

/* --- Empty state & Disabled State --- */
.fg-select__empty {
    padding: 16px 12px;
    font-size: 13px;
    color: var(--black-500);
    text-align: center;
}

.fg-select.is-disabled {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}
