.tox {
    .tinymce-skin() !important;
}

.tinymce-skin {
    color: @color-text;
    font-size: 14px;

    &.tox-tinymce {
        &:not(.tox-tinymce-inline) {
            border: @color-border solid 1px;
            border-radius: @border-radius;
        }
    }

    &:not(.tox-tinymce-inline) {
        .tox-editor-header {
            box-shadow: none;
            border-bottom: @color-split solid 1px;
            padding: 0;
        }
    }

    &.tox-tinymce-inline {
        .tox-editor-header {
            border: @color-border solid 1px;
            border-radius: @border-radius;
        }
    }

    .tox-promotion {
        padding: 4px;
        display: flex;
        align-items: center;

        &-link {
            font-size: 14px;
            display: flex;
            align-items: center;
            color: @color-primary;
            height: 28px;
            padding: 0 8px;
            border-radius: @border-radius;
            line-height: 1;
        }
    }

    .tox-menubar {
        padding: 4px;
        background: none;
        align-items: center;
        gap: 4px;

        + .tox-toolbar-overlord {
            padding: 4px;
            margin: 0;
            border-top: @color-split solid 1px;
        }
    }

    .tox-mbtn {
        border-radius: @border-radius;
        transition: all 0.2s;
        margin: 0;
        color: @color-text;

        &:hover:not(:disabled):not(.tox-mbtn--active) {
            background: #f5f5f5;
        }

        &--active {
            background: color(~`colorPalette('@{color-primary}', 1) `);
        }
    }

    .tox-toolbar__primary {
        gap: 4px;
    }

    .tox-toolbar__group {
        padding: 0;
        gap: 4px;
    }

    &:not([dir='rtl']) {
        .tox-toolbar__group {
            &:not(:last-of-type) {
                border: none;
            }
        }
    }

    .tox-tbtn {
        margin: 0;
        padding: 0;
        transition: all 0.2s;
        border-radius: @border-radius;
        color: @color-text;

        &--select {
            padding: 0 4px;
        }

        &:hover {
            background: #f5f5f5;
        }

        &--enabled {
            &,
            &:hover {
                background: color(~`colorPalette('@{color-primary}', 1) `);
            }
        }
    }

    .tox-split-button {
        margin: 0;
        border-radius: @border-radius;
    }

    &.tox-tinymce-aux {
        .tox-toolbar__overflow {
            border: none;
            padding: 4px;
            border-radius: @border-radius;
            box-shadow: @box-shadow;
            background-image: none;
            gap: 4px;
        }
    }

    .tox-menu {
        border: none;
        border-radius: @border-radius;
        box-shadow: @box-shadow;
        padding: 4px;
    }

    .tox-collection--list {
        .tox-collection__group {
            border-color: @color-split;

            &:first-child {
                padding-top: 0;
            }

            &:last-child {
                padding-bottom: 0;
            }
        }

        .tox-collection__item {
            border-radius: @border-radius;

            &--active {
                background: #f5f5f5;
            }
        }
    }

    .tox-pop__dialog {
        border: none;
        box-shadow: @box-shadow;
        border-radius: @border-radius;

        .tox-toolbar {
            padding: 4px;
            gap: 4px;
        }
    }

    .tox-pop {
        &::before {
            border: none;
            width: 8px;
            height: 8px;
            background: #fff;
            margin: 0;
        }
        &::after {
            display: none;
        }
        &.tox-pop--top {
            &::before {
                box-shadow: -2px -2px 5px #0000000f;
                transform: rotate(45deg) translate(0, -6px);
            }
        }

        &.tox-pop--bottom {
            &::before {
                box-shadow: 3px 3px 7px #00000012;
                transform: rotate(45deg) translate(0, -6px);
            }
        }

        &.tox-pop--left {
            &::before {
                box-shadow: -3px 3px 7px #00000012;
                transform: rotate(45deg) translate(-6px, 0);
            }
        }
    }

    .tox-dialog {
        border-radius: @border-radius;
        border: none;
        box-shadow: @box-shadow;
    }

    .tox-dialog-wrap__backdrop {
        background: @color-bg-mask;
    }

    .tox-dialog__header {
        padding: 0;
        border-bottom: @color-split solid 1px;

        .tox-button {
            margin-right: 16px;
        }
    }

    .tox-dialog__title {
        font-size: 16px;
        font-weight: 500;
        padding: 16px;
        color: @color-text;
    }

    .tox-dialog__footer {
        padding: 10px 16px;
        border-top: @color-split solid 1px;
    }

    .tox-dialog__body {
        font-size: 14px;
        color: @color-text;

        &-nav {
            padding: 2px 0;
            height: 100%;
            border-right: @color-split solid 1px;

            &-item {
                margin: 2px 0;
                height: 40px;
                display: flex;
                align-items: center;
                padding: 0 16px;
                position: relative;
                border: none;
                width: 100%;
                box-sizing: border-box;

                &--active {
                    background: color(~`colorPalette('@{color-primary}', 1) `);
                    color: @color-primary;

                    &::after {
                        content: '';
                        position: absolute;
                        top: 0;
                        bottom: 0;
                        right: -1px;
                        width: 3px;
                        background: @color-primary;
                    }
                }
            }
        }
    }

    .tox-button {
        border-radius: @border-radius;
        background: @color-primary;
        border-color: @color-primary;
        font-weight: normal;
        transition: all 0.2s;

        &:hover {
            background: color(~`colorPalette('@{color-primary}', 5) `);
            border-color: color(~`colorPalette('@{color-primary}', 5) `);
        }

        &--secondary {
            background: transparent;
            border-color: @color-border;
            color: @color-text;

            &:hover {
                color: @color-primary;
                border-color: @color-primary;
                background: transparent;
            }
        }

        &--naked {
            &,
            &:hover {
                background: transparent;
                border-color: transparent;
            }
        }
    }

    .tox-label {
        color: @color-text;
        line-height: 32px;
    }

    .tox-textfield,
    .tox-textarea-wrap,
    .tox-selectfield select,
    .tox-listboxfield .tox-listbox--select {
        border-radius: @border-radius;
        border-color: @color-border;
        padding: 3px 11px;
        min-height: 32px;
        color: @color-text;

        &:focus-within,
        &:focus {
            box-shadow: 0 0 0 2px color(~`colorPalette('@{color-primary}', 1) `);
            border-color: @color-primary;
        }
    }

    .tox-checkbox__icons {
        padding: 0;
        box-shadow: none;
    }

    .tox-checkbox__label {
        font-size: 14px;
    }

    .tox-listbox__select-label {
        font-size: 14px;
        padding: 0;
        margin: 0;
    }

    .tox-dialog__table tbody tr {
        border-bottom-color: @color-split;
    }
}

.x-editor {
    .mce-content-body {
        margin: 0;
        outline: none;
    }
}
