// (C) 2007-2026 GoodData Corporation
@use "EditableLabel/_mixins" as form-mixins;
@use "mixins";

$editable-label-border: #b1c1d1;

%textarea-base {
    overflow: hidden;
    width: inherit;
    border: none;
    vertical-align: inherit;
    background: transparent;
    resize: none;

    &::placeholder {
        color: var(--gd-palette-complementary-6, #94a1ad);
    }
}

.editable-label {
    position: relative;

    .label-box {
        width: 400px;
        font-size: 15px;
    }

    .editable-label {
        cursor: text;
    }

    input {
        padding: 0;
        border: 0;
    }
}

.gd-editable-label-textarea-wrapper {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.gd-editable-label {
    display: inline-block;
    width: 100%;
    height: 100%;
    padding: 0 1px;
    border: 1px solid transparent;
    line-height: inherit;
    vertical-align: inherit;
    min-width: 5em;
    user-select: none;

    @include mixins.active-states {
        cursor: text;
        border-color: $editable-label-border;
    }

    &.is-editing {
        border-color: $editable-label-border;

        &::after {
            display: none;
        }
    }

    textarea {
        @extend %textarea-base;

        /** 
        * If a browser needs to programmatically scroll horizontally (such as for example when the text is long and overflows), make sure
        * it's on textarea itself (i.e. make sure the textarea is not bigger than the container element `.gd-editable-label-inner`), and
        * not on the nearest container (`.gd-editable-label-inner`), which can have unintended consequences if the `.scrollLeft` DOM property
        * is leftover and still has an effect even after leaving editing mode (such as in the case of invisible span inside of this container
        * that keeps overflowing even in non editing mode). See LX-2691 for more details.
        */
        max-width: 100%;
        min-width: inherit;

        display: block;
        padding: 0;
        line-height: inherit;
        font-size: inherit;
        text-align: inherit;
        outline: none;
    }
}

.gd-editable-label-inner {
    width: 100%;
    height: 100%;
    line-height: inherit;
    vertical-align: inherit;
    min-width: 5em;
}

.gd-editable-label-measure {
    position: absolute;
    visibility: hidden;
    white-space: pre;
    font: inherit;
    pointer-events: none;
}

.gd-editable-label-overlay {
    textarea {
        @extend %textarea-base;

        padding: 0 1px; /* needed for IE */
        text-align: center;
    }
}
