// (C) 2020-2026 GoodData Corporation
@use "sass:color";
@use "mixins";
@use "variables";

.gd-input-syntax-highlighting-input {
    .cm-editor {
        .cm-matchingBracket {
            font-weight: bold;
            color: variables.$gd-color-dark;
            background-color: variables.$gd-palette-warning-dimmed;
        }

        .cm-nonmatchingBracket {
            color: variables.$gd-palette-error-base;
        }

        .cm-content {
            caret-color: transparent;
        }

        .cm-cursor,
        .cm-dropCursor {
            border-left-color: variables.$gd-medium-gray;
        }

        .cm-selectionBackground,
        &.cm-focused .cm-selectionBackground {
            background: variables.$gd-palette-primary-dimmed;
        }

        .cm-placeholder {
            color: variables.$gd-color-link;
            opacity: 0.75;
        }
    }

    &--default-chrome .cm-editor {
        // start of gd-input-base mixin body
        box-sizing: border-box;
        height: 100px;
        margin: 0;
        padding: 0;
        border: 1px solid variables.$gd-input-text-border;
        line-height: normal;
        vertical-align: middle;
        color: variables.$gd-medium-gray;
        background: variables.$gd-color-white;
        font-size: 14px;
        font-family: monospace;
        font-weight: 200;

        // Deviates from the mixin, which transitions `all`: `.cm-editor` is a sized, flex-grown box,
        // so `all` animates its height whenever a stylesheet or a container hands it a new one —
        // and CodeMirror re-measures partway through, re-laying out the text in steps.
        transition:
            border-color 0.25s ease-in-out,
            box-shadow 0.25s ease-in-out;
        // end of gd-input-base mixin body

        @include mixins.border-radius(3px);
        @include mixins.box-shadow(
            inset 0 1px 1px 0 color.adjust(variables.$gd-input-text-box-shadow-color, $alpha: -0.85)
        );

        @include mixins.placeholder {
            color: variables.$gd-color-link;
            opacity: 0.75;

            @include mixins.transition(color, 0.25s, ease-in-out);
        }

        &:hover {
            border-color: variables.$gd-input-text-hover-border;

            @include mixins.placeholder {
                color: variables.$gd-color-link;
            }
        }

        &.cm-focused {
            border-color: variables.$gd-palette-primary-base;
            outline: none;
            @include mixins.box-shadow(
                inset 0 1px 1px 0 color.adjust(variables.$gd-input-text-box-shadow-color, $alpha: -0.85)
            );
        }
    }
}
