@import "~theme/globals";
:host {
    --placeholder-color: var(--gray-light);
    --toobar-background: var(--white);
    --button-color: var(--ion-text-color);
    --button-active-color: var(--gray);
    --background: var(--ion-item-background);
}

:host-context(body.dark) {
    --background: var(--gray-darker);
    --color: var(--white);
    --button-color: var(--gray-light);
    --button-active-color: var(--gray-dark);
    --placeholder-color: var(--gray);
    --toobar-background: var(--black);
}

:host {
    height: 40vh;
    overflow: hidden;
    min-height: 200px; /* Just in case vh is not supported */
    min-height: 40vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--background);

    .core-rte-editor-container {
        max-height: calc(100% - 46px);
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        &.toolbar-hidden {
            max-height: 100%;
        }

        .core-rte-info-message {
            padding: 5px;
            border-top: 1px solid var(--ion-color-secondary);
            background: var(--background);
            flex-shrink: 1;
            font-size: 1.1rem;

            .icon {
                color: var(--ion-color-secondary);
            }
        }
    }

    .core-rte-editor, .core-textarea {
        padding: 2px;
        margin: 2px;
        width: 100%;
        resize: none;
        background-color: var(--background);
        color: var(--color);
        flex-grow: 1;
    }

    .core-rte-editor {
        flex-grow: 1;
        flex-shrink: 1;
        -webkit-user-select: auto !important;
        user-select: auto !important;
        word-wrap: break-word;
        overflow-x: hidden;
        overflow-y: auto;
        cursor: text;
        img {
            @include padding(null, null, null, 2px);
            max-width: 95%;
            width: auto;
        }
        &:empty:before {
            content: attr(data-placeholder-text);
            display: block;
            color: var(--placeholder-color);
            font-weight: bold;
        }

        // Make empty elements selectable (to move the cursor).
        *:empty:after {
            content: '\200B';
        }
    }

    .core-textarea {
        flex-grow: 1;
        flex-shrink: 1;
        position: relative;

        ::ng-deep textarea {
            margin: 0 !important;
            padding: 0;
            resize: none;
            overflow-x: hidden;
            overflow-y: auto;
            position: absolute;
            top: 0;
            bottom: 0;
        }
    }

    div.core-rte-toolbar {
        display: flex;
        width: 100%;
        z-index: 1;
        flex-grow: 0;
        flex-shrink: 0;
        background-color: var(--toobar-background);
        padding-top: 5px;
        border-top: 1px solid var(--gray);

        ion-slides {
            width: 240px;
            flex-grow: 1;
            flex-shrink: 1;
        }

        button {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 36px;
            height: 36px;
            padding-right: 6px;
            padding-left: 6px;
            margin: 0 auto;
            font-size: 18px;
            background-color: var(--toobar-background);
            border-radius: 4px;
            @include core-transition(background-color, 200ms);
            color: var(--button-color);
            cursor: pointer;

            &.toolbar-button-enable {
                width: 100%;
            }

            &:active, &[aria-pressed="true"] {
                background-color: var(--button-active-color);
            }

            &.toolbar-arrow {
                width: 28px;
                flex-grow: 0;
                flex-shrink: 0;
                opacity: 1;
                @include core-transition(opacity, 200ms);

                &:active {
                    background-color: var(--toobar-background);
                }

                &.toolbar-arrow-hidden {
                    opacity: 0;
                }
            }
        }

        &.toolbar-hidden {
            visibility: none;
            height: 0;
            border: none;
        }
    }
}

:host-context(.keyboard-is-open) {
    min-height: 200px;
}
