@use "sass:math";

.label-item {
    display: flex;
    align-items: center;
    gap: var(--c--globals--spacings--2xs);
    padding-block: var(--c--globals--spacings--3xs);
    padding-inline: var(--c--globals--spacings--3xs);
    color: inherit;
    font-weight: 500;
    text-decoration: none;
    border-radius: 4px;
    justify-content: space-between;
    position: relative;
    width: 100%;
    --label-toggle-size: 1.5rem;
}

.label-item__column {
    display: flex;
    gap: var(--c--globals--spacings--base);
    position: relative;
    align-items: center;
    min-width: 0;
}

.label-item__column:first-child {
    flex: 1;
    min-width: 0;
    /* Reserve space for toggle (RTL-safe) */
    padding-inline-start: var(--label-toggle-size);
}

.label-item__toggle {
    /* Position the toggle button absolutely to not affect text alignment */
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    width: var(--label-toggle-size);
    height: var(--label-toggle-size);
}

.label-item__column:last-child {
    justify-content: flex-end;
    flex-shrink: 0;
}

.label-item--drag-over,
.label-item:not(.label-item--active):hover,
.label-item:not(.label-item--active):focus-within,
.label-item:not(.label-item--active)[data-focus-within="true"]  {
    background-color: var(--c--contextuals--background--semantic--contextual--primary);
}

.label-item--active {
    background-color: var(--c--contextuals--background--semantic--contextual--primary);
    font-weight: 600;
}

.label-item__toggle:disabled {
    visibility: hidden;
}

.label-item__name {
    display: flex;
    align-items: center;
    gap: var(--c--globals--spacings--xs);
    cursor: pointer;
    border-radius: 4px;
    flex: 1;
    min-width: 0;

    .label-item__icon {
        border: 1px solid var(--c--contextuals--border--semantic--contextual--primary);
        width: 0.75rem;
        height: 0.75rem;
        border-radius: 4px;
        box-sizing: border-box;
        padding: 0;
        margin: 0;
        flex-shrink: 0;
    }

    .label-name {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
}

.label-item:hover .label-item__dropdown-actions,
.label-item[data-focus-within="true"] .label-item__dropdown-actions {
    visibility: visible;
    opacity: 1;
}

.label-item__dropdown-actions {
    visibility: hidden;
    opacity: 0;

    & .c__button__icon > span {
        font-size: var(--c--globals--font--sizes--h3);
    }
}
