// (C) 2024-2025 GoodData Corporation

@use "Dialog/variables" as dialog-variables;
@use "mixins" as mx;
@use "variables";

.gd-rich-text-content {
    width: 100%;
    height: 100%;
    min-height: 19px; // We need to cover at least one line, otherwise scrollbar will show.
    color: var(--gd-palette-complementary-7);

    textarea {
        width: 100%;
        height: 100%;
        background-color: variables.$gd-color-white;
        line-height: 19px;
        font-size: 14px;
        font-weight: 400;
        font-family: variables.$measure_sequence_number_font;
        color: var(--gd-palette-complementary-7);
        border: none;
        resize: none;
        box-sizing: border-box;

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

    .gd-rich-text-metric-empty {
        color: variables.$gd-color-text;
    }

    .gd-rich-text-metric-error,
    .gd-rich-text-metric-multiple,
    .gd-rich-text-parameter-error {
        color: variables.$gd-palette-error-base;
    }

    .gd-rich-text-metric-restricted {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        color: var(--gd-palette-complementary-6);
        font-weight: 400;
    }
}

.gd-rich-text-content-view {
    // styles for markdown elements
    * {
        margin-top: 0;
        color: var(--gd-palette-complementary-7);
    }

    a,
    a * {
        cursor: pointer;
        color: variables.$gd-palette-primary-base;
        text-decoration: underline;

        @include mx.active-states {
            color: variables.$gd-color-text;
            text-decoration: underline;
        }
    }

    a:hover,
    a:hover * {
        color: variables.$gd-color-text;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        color: variables.$gd-color-text;
        font-weight: 700;
        text-align: left;
        letter-spacing: 0;
    }

    h1 {
        font-size: 17px;
        line-height: 23px;
        margin-bottom: 10px;
    }

    h2 {
        font-size: 15px;
        line-height: 20px;
        margin-bottom: 10px;
    }

    h3,
    h4,
    h5,
    h6 {
        font-size: 14px;
        line-height: 19px;
        margin-bottom: 5px;
    }

    p,
    ul,
    ol,
    .gd-rich-text-blank-line {
        font-size: 14px;
        font-weight: 400;
        line-height: 19px;
        letter-spacing: 0;
        text-align: left;
        margin-bottom: 0;
    }

    p + p {
        margin-top: 0.625rem;
    }

    .gd-rich-text-blank-line {
        height: 1lh;
    }

    // A paragraph after blank lines keeps the gap it has after a block, the lines adding to it. Above the
    // first block there is no block to keep a gap from. `:where` keeps that guard out of the specificity,
    // so the rule weighs no more than it did without it and a host's own block spacing still wins.
    :where(:not(.gd-rich-text-blank-line)) ~ .gd-rich-text-blank-line + p {
        margin-top: 0.625rem;
    }

    hr {
        border-top: 0;
        border-bottom: 1px solid variables.$gd-border-color;
    }
}

// known overrides inside other wrappers
.bubble .bubble-content .content .gd-rich-text-content {
    a {
        color: variables.$gd-palette-primary-base;
        font-size: 14px;
        line-height: 19px;

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

    > p {
        font-size: 14px;
        line-height: 19px;
    }
}
