/* ============================================================
   ROLE PICKER — Apple-style dropdown для ПК
   На мобилке полностью скрыт — там своя логика.
   ============================================================ */

body.mobile-device .role-picker {
    display: none !important;
}

body:not(.mobile-device) .profile-role-checkboxes.mobile-roles-only {
    display: none !important;
}

.role-picker {
    position: relative;
    display: block;
    width: 100%;
    font-family: inherit;
    user-select: none;
}

.role-picker-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 12px 18px;
    background: var(--card-bg);
    /* ← цвет как у остальных полей */
    border: 1.5px solid var(--border);
    border-radius: 14px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    transition:
        border-color .28s cubic-bezier(.16, 1, .3, 1),
        background-color .28s cubic-bezier(.16, 1, .3, 1),
        box-shadow .28s cubic-bezier(.16, 1, .3, 1),
        transform .25s cubic-bezier(.34, 1.56, .64, 1);
}

.role-picker-trigger:hover {
    background: var(--card-bg);
    border-color: rgba(0, 113, 227, .35);
    box-shadow: 0 4px 16px rgba(0, 113, 227, .08);
}

.role-picker-trigger:active {
    transform: scale(.985);
}

.role-picker.open .role-picker-trigger {
    background: var(--card-bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, .12), 0 4px 16px rgba(0, 113, 227, .08);
}

.role-picker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: var(--primary);
    flex-shrink: 0;
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
}

.role-picker.open .role-picker-icon {
    transform: scale(1.08);
}

.role-picker-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    color: var(--text-muted);
    transition: color .25s;
}

.role-picker.has-value .role-picker-label {
    color: var(--text-main);
    font-weight: 600;
}

.role-picker-badge {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 8px;
    border-radius: 11px;
    background: var(--primary);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: .3px;
}

.role-picker.has-value .role-picker-badge {
    display: inline-flex;
    animation: roleBadgePop .35s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes roleBadgePop {
    0% {
        transform: scale(.4);
        opacity: 0;
    }

    60% {
        transform: scale(1.15);
        opacity: 1;
    }

    100% {
        transform: scale(1);
    }
}

.role-picker-chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), color .25s;
}

.role-picker.open .role-picker-chevron {
    transform: rotate(180deg);
    color: var(--primary);
}

/* ---------- Панель ---------- */
.role-picker-panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    z-index: 800;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .14), 0 8px 20px rgba(0, 0, 0, .08);
    padding: 8px;
    opacity: 0;
    transform: translateY(-8px) scale(.96);
    transform-origin: top center;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
    transition: opacity .22s cubic-bezier(.16, 1, .3, 1),
        transform .38s cubic-bezier(.34, 1.56, .64, 1),
        max-height .38s cubic-bezier(.16, 1, .3, 1);
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
}

.role-picker.open .role-picker-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
    max-height: 520px;
}

body.dark-theme .role-picker-panel {
    background: rgba(28, 28, 30, .96);
    border-color: rgba(255, 255, 255, .08);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .7), 0 8px 20px rgba(0, 0, 0, .5);
}

/* Поиск */
.role-picker-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    padding: 4px 6px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--hairline);
}

.role-picker-search-wrap>span {
    position: absolute;
    left: 20px;
    top: 22px;
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    width: 16px;
    height: 16px;
}

.role-picker-search {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 42px;
    background: var(--bg-color);
    border: none;
    border-radius: 11px;
    font-family: inherit;
    font-size: 14.5px;
    color: var(--text-main);
    outline: none;
    transition: background .2s, box-shadow .2s;
}

.role-picker-search::placeholder {
    color: var(--text-muted);
}

.role-picker-search:focus {
    background: var(--card-bg);
    box-shadow: inset 0 0 0 1.5px var(--primary);
}

/* Список */
.role-picker-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 4px 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, .15) transparent;
}

.role-picker-list::-webkit-scrollbar {
    width: 6px;
}

.role-picker-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .12);
    border-radius: 3px;
}

body.dark-theme .role-picker-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .15);
}

/* Заголовок группы */
.role-group-title {
    position: sticky;
    top: 0;
    z-index: 2;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-muted);
    padding: 12px 14px 6px;
    background: var(--card-bg);
    margin-top: 6px;
    border-top: 1px solid var(--hairline);
}

body.dark-theme .role-group-title {
    background: rgba(28, 28, 30, .98);
}

.role-group-title:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 6px;
}

/* Строка роли */
.role-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    border-radius: 11px;
    cursor: pointer;
    user-select: none;
    font-size: 14.5px;
    color: var(--text-main);
    transition: background-color .18s cubic-bezier(.16, 1, .3, 1),
        color .18s,
        transform .18s cubic-bezier(.16, 1, .3, 1);
}

.role-option:hover {
    background: var(--bg-color);
    transform: translateX(2px);
}

body.dark-theme .role-option:hover {
    background: rgba(255, 255, 255, .05);
}

.role-option:active {
    transform: translateX(2px) scale(.985);
}

.role-option-label {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-option-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    transition: background .28s cubic-bezier(.34, 1.56, .64, 1),
        border-color .28s,
        transform .28s cubic-bezier(.34, 1.56, .64, 1);
}

.role-option-check svg {
    width: 12px;
    height: 12px;
    opacity: 0;
    transform: scale(.4);
    transition: opacity .2s, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.role-option.selected .role-option-check {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.06);
}

.role-option.selected .role-option-check svg {
    opacity: 1;
    transform: scale(1);
}

.role-option.selected {
    background: rgba(0, 113, 227, .06);
    color: var(--primary);
    font-weight: 600;
}

body.dark-theme .role-option.selected {
    background: rgba(0, 113, 227, .15);
}

.role-picker-empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}