/**
 * Custom select — обёртка над native <select>.
 * Использование: <select data-custom-select>...</select>
 * или window.initCustomSelects(container) после динамической вставки.
 */

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

.custom-select__native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.custom-select__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.custom-select__trigger:hover:not(:disabled) {
    border-color: var(--border-light);
    background: rgba(255, 255, 255, 0.07);
}

.custom-select--open .custom-select__trigger,
.custom-select__trigger:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 72, 249, 0.15);
    outline: none;
}

.custom-select__value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select__value--placeholder {
    color: var(--text-muted);
}

.custom-select__chevron {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.custom-select--open .custom-select__chevron {
    transform: rotate(180deg);
}

.custom-select__list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: min(280px, 50vh);
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: rgba(15, 15, 30, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.custom-select__list--portal {
    position: fixed;
    z-index: 1300;
    right: auto;
}

.custom-select__list[hidden] {
    display: none;
}

.custom-select__option {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.custom-select__option:hover,
.custom-select__option--focused {
    background: rgba(94, 72, 249, 0.12);
    color: var(--text-primary);
}

.custom-select__option--selected {
    color: var(--accent-light);
    background: rgba(94, 72, 249, 0.16);
}

.custom-select__option--disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.custom-select--disabled .custom-select__trigger {
    opacity: 0.55;
    cursor: not-allowed;
}

.custom-select__native:invalid {
    box-shadow: none;
}

.custom-select--invalid .custom-select__trigger {
    border-color: rgba(255, 100, 100, 0.55);
    box-shadow: 0 0 0 3px rgba(255, 100, 100, 0.12);
}

@media (max-width: 640px) {
    .custom-select__trigger {
        min-height: 48px;
    }
}
