@import '~@gravity-ui/uikit/styles/mixins';

.dl-field-editor {
    $class: &;
    $docPaddingSide: 24px;
    $controlsPaddingSide: 32px;

    width: 80vw;
    min-width: 800px;
    max-width: 1200px;
    display: flex;
    flex-direction: column;

    .g-dialog-header__caption {
        max-width: 80%;
    }

    &_additional-panel-open {
        max-width: min(calc(100vw - 530px), 1200px);
    }

    &__dialog_additional-panel-open {
        padding-right: 330px;

        /** hotfix clip-path for additional panel */
        & .g-modal__content {
            clip-path: none;
        }
    }

    &__settings {
        display: flex;
        align-items: center;
        padding: 0 $controlsPaddingSide 20px;
        border-bottom: 1px solid var(--g-color-line-generic);
    }

    &__settings-field-name {
        max-width: 100%;
    }

    &__settings-name {
        height: 36px;
        width: 100%;
    }

    #{$class}__settings-field-name-input {
        @include text-subheader-3();
        padding-right: 0;

        &_fake {
            position: absolute;
            visibility: hidden;
            white-space: pre;
        }
    }

    &__settings-field-name-icon {
        color: var(--g-color-text-secondary);
        margin-left: 6px;
    }

    &__settings-buttons-container {
        margin-left: auto;
    }

    &__hide-in-wizard-button {
        margin-right: 8px;

        &_last {
            margin-right: 0;
        }
    }

    &__content {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        height: calc(80vh - 100px);
    }

    &__content-panels {
        position: relative;
        height: 100%;
    }

    &__source-section {
        padding: 20px $controlsPaddingSide 0;
        overflow-y: auto;
    }

    &__source-section-control {
        flex-grow: 1;
        max-width: 580px;
        // while we can not control error div container we still can apply break-word
        word-break: break-word;
        width: 100%;

        &_short {
            max-width: 200px;
        }
    }

    &__source-section-hint {
        top: 1px;
        left: 5px;
    }

    &__row {
        display: flex;
        margin-bottom: 20px;
        line-height: 28px;
    }

    &__label {
        flex: 0 0 150px;
    }

    &__hide-in-wizard-checkbox {
        margin-left: 20px;
        flex: 0 0 180px;
    }

    &__icon-add-btn {
        position: relative;
        left: 8px;
        height: 100%;
    }

    &__hide-description-btn {
        margin-left: 68px;
    }

    &__formula-fields {
        height: 100%;
    }

    &__formula-editor-wrap {
        height: 100%;
    }

    &__formula-editor {
        height: calc(100% - 92px);
        min-height: 100px;
        border: none;
    }

    &__formula-editor-glyph {
        background-size: contain;
        background-repeat: no-repeat;
        background-image: url('../../assets/icons/alert.svg');
        // https://stackoverflow.com/a/43960991/604861
        filter: invert(19%) sepia(98%) saturate(5910%) hue-rotate(359deg) brightness(94%)
            contrast(118%);
        cursor: pointer;
    }

    &__cast-option {
        display: flex;
        align-items: center;
    }

    &__field-type-select-icon {
        opacity: 0.5;
        margin-right: 8px;
    }

    &__doc {
        display: flex;
        width: 100%;
        height: 100%;
    }

    &__doc-list {
        display: flex;
        height: 100%;
    }

    &__doc-list-item {
        display: flex;
        align-items: center;
        flex-grow: 1;
        height: 100%;
        padding-left: 32px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        cursor: pointer;

        &_group {
            font-weight: 500;
        }

        &_function {
            padding-left: 50px;
        }

        &_selected {
            background-color: var(--g-color-base-selection);
        }
    }

    &__doc-item-wrap {
        height: 100%;
    }

    &__doc-item-title {
        margin: 16px $docPaddingSide 0;
        font-size: var(--g-text-header-1-font-size);
        line-height: var(--g-text-header-1-line-height);
    }

    &__doc-item {
        display: flex;
        flex-direction: column;
        padding: 5px 16px 16px;

        & > * {
            margin: 6px 0;
        }

        & > h2 ~ p em {
            color: var(--g-color-text-info);
        }

        & a {
            text-decoration: none;
            color: var(--g-color-text-link);
        }

        & ul > li {
            margin: 4px 0;
        }

        & code {
            font-size: 14px;
            line-height: 16px;
            padding: 1px 4px;
            color: var(--g-color-text-misc);
            background-color: var(--g-color-base-misc-light);
            border-radius: 4px;
            white-space: nowrap;
        }

        &.yfm {
            padding: 5px $docPaddingSide 16px;

            .yfm-anchor {
                display: none;
            }
        }
    }

    &__doc-loader,
    &__empty-state {
        height: 100%;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    &__empty-state {
        padding-top: 0;
        padding-bottom: 0;
        overflow: clip;
    }

    /* TODO: remove styles, when it is possible to customize styles on List.Input [DATAUI-360] */
    & .g-list__filter {
        margin: 16px 16px 10px 32px;
        z-index: 0;
    }
}
