/**
 * Trumbowyg v2.31.0 - A lightweight WYSIWYG editor
 * Default stylesheet for Trumbowyg editor
 * ------------------------
 * @link https://alex-d.github.io/Trumbowyg/
 * @license MIT
 * @author Alexandre Demode (Alex-D)
 *         Twitter : @AlexandreDemode
 *         Website : alex-d.fr
 */

@use "sass:color";

$button-size: 35px;
$icon-size: 17px;
$pane-spacing: 5px;

$light-color: #ecf0f1;
$light-background-color-pane: color.adjust($light-color, $lightness: -3%, $space: hsl);
$light-background-color-button: #ecf0f1;
$light-background-color-button-active: #fff;
$light-background-color-editor: #fff;
$light-background-color-dropdown: #fff;
$light-background-color-dropdown-button: #fff;
$light-background-color-modal: #fff;
$light-border-color: #d7e0e2;
$light-text-color: #222;
$light-text-color-dropdown-button: #222;

$dark-color: #222;
$dark-background-color-editor: #222;
$dark-background-color-pane: $dark-color;
$dark-background-color-button: $dark-color;
$dark-background-color-dropdown: $dark-background-color-pane;
$dark-background-color-dropdown-button: $dark-background-color-pane;
$dark-background-color-modal: #333;
$dark-background-color-modal-button: #333;
$dark-border-color: #343434;
$dark-text-color: #fff;
$dark-text-color-dropdown-button: #fff;

$modal-submit-color: #2ecc71 !default;
$modal-reset-color: #eee !default;

$transition-duration: 150ms !default;
$slow-transition-duration: 300ms !default;

$modal-label-width: 150px;

#trumbowyg-icons,
.trumbowyg-icons {
    overflow: hidden;
    visibility: hidden;
    height: 0;
    width: 0;
}

.trumbowyg-box,
.trumbowyg-modal {
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    svg {
        width: $icon-size;
        height: 100%;
        color: $light-text-color;
        fill: $light-text-color;
    }
}

.trumbowyg-box {
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.trumbowyg-editor-box {
    display: block;
    flex: 1;
}

.trumbowyg-box,
.trumbowyg-editor-box {
    position: relative;
    width: 100%;
    border: 1px solid $light-border-color;
}

.trumbowyg-box .trumbowyg-editor {
    min-height: 100%;
    margin: 0 auto;
}

.trumbowyg-box.trumbowyg-fullscreen {
    background: #fefefe;
    border: none !important;
}

.trumbowyg-editor-box,
.trumbowyg-textarea {
    position: relative;
    box-sizing: border-box;
    padding: 20px;
    width: 100%;
    border-style: none;
    resize: none;
    outline: none;
    overflow: auto;
    user-select: text; // Avoid issues on iOS

    &.trumbowyg-autogrow-on-enter {
        transition: height $slow-transition-duration ease-out;
    }
}

.trumbowyg-editor-box {
    padding: 0;
}


.trumbowyg-editor {
    outline: none;
    padding: 20px;
}

.trumbowyg-box-blur .trumbowyg-editor {
    *,
    &::before {
        color: transparent !important;
        text-shadow: 0 0 7px #333;
    }

    img,
    hr {
        opacity: 0.2;
    }
}

.trumbowyg-textarea {
    position: relative;
    display: block;
    overflow: auto;
    border: none;
    font-size: 14px;
    font-family: "Consolas", "Courier", "Courier New", monospace;
    line-height: 18px;
}

.trumbowyg-box.trumbowyg-editor-visible {
    .trumbowyg-textarea {
        height: 1px !important;
        width: 25%;
        min-height: 0 !important;
        padding: 0 !important;
        background: none;
        opacity: 0 !important;
    }
}

.trumbowyg-box.trumbowyg-editor-hidden {
    .trumbowyg-textarea {
        display: block;
        flex: 1;
        margin-bottom: 1px;
    }

    .trumbowyg-editor-box {
        display: none;
    }
}

.trumbowyg-box.trumbowyg-disabled {
    .trumbowyg-textarea {
        opacity: 0.8;
        background: none;
    }
}

.trumbowyg-editor-box[contenteditable=true]:empty:not(:focus)::before {
    content: attr(placeholder);
    color: #999;
    pointer-events: none;
    white-space: break-spaces;
}

.trumbowyg-button-pane {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    min-height: $button-size + 1;
    background: $light-color;
    border-bottom: 1px solid $light-border-color;
    margin: 0;
    padding: 0 $pane-spacing;
    position: relative;
    list-style-type: none;
    line-height: 10px;
    backface-visibility: hidden;
    overflow: hidden;
    z-index: 11;

    &::before,
    &::after {
        content: " ";
        display: block;
        position: absolute;
        top: $button-size;
        left: 0;
        right: 0;
        width: 100%;
        height: 1px;
        background: color.adjust($light-color, $lightness: -7%, $space: hsl);
    }

    &::after {
        top: $button-size * 2 + 1;
    }

    .trumbowyg-button-group {
        display: flex;
        flex-wrap: wrap;

        .trumbowyg-fullscreen-button svg {
            color: transparent;
        }

        &::after {
            content: " ";
            display: block;
            width: 1px;
            background: color.adjust($light-color, $lightness: -7%, $space: hsl);
            margin: 0 $pane-spacing;
            height: $button-size;
            vertical-align: top;
        }

        &:last-child::after {
            content: none;
        }
    }

    button {
        display: block;
        position: relative;
        width: $button-size;
        height: $button-size;
        padding: 1px 6px !important;
        margin-bottom: 1px;
        overflow: hidden;
        border: none;
        cursor: pointer;
        background: none;
        vertical-align: middle;
        transition: background-color $transition-duration, opacity $transition-duration;

        &.trumbowyg-textual-button {
            width: auto;
            line-height: $button-size;
            user-select: none;
        }
    }

    &.trumbowyg-disable button:not(.trumbowyg-not-disable):not(.trumbowyg-active),
    button.trumbowyg-disable,
    .trumbowyg-disabled & button:not(.trumbowyg-not-disable):not(.trumbowyg-viewHTML-button) {
        opacity: 0.2;
        cursor: default;
        pointer-events: none;
    }

    &.trumbowyg-disable,
    .trumbowyg-disabled & {
        .trumbowyg-button-group::before {
            background: color.adjust($light-background-color-button, $lightness: -3%, $space: hsl);
        }
    }

    button:not(.trumbowyg-disable):hover,
    button:not(.trumbowyg-disable):focus,
    button.trumbowyg-active {
        background-color: $light-background-color-button-active;
        outline: none;
    }

    .trumbowyg-open-dropdown {
        &::after {
            display: block;
            content: " ";
            position: absolute;
            top: 27px;
            right: 3px;
            height: 0;
            width: 0;
            border: 3px solid transparent;
            border-top-color: #555;
        }

        &.trumbowyg-textual-button {
            padding-left: 10px !important;
            padding-right: 18px !important;

            &::after {
                top: $icon-size;
                right: 7px;
            }
        }
    }

    .trumbowyg-right {
        margin-left: auto;
    }
}

.trumbowyg-dropdown {
    max-width: 300px;
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: nowrap;
    border: 1px solid $light-border-color;
    padding: $pane-spacing 0;
    border-top: none;
    background: $light-background-color-dropdown;
    color: $light-text-color;
    margin-left: -1px;
    box-shadow: rgba(0, 0, 0, .1) 0 2px 3px;
    z-index: 12;

    button {
        display: block;
        width: 100%;
        height: $button-size;
        line-height: $button-size;
        text-decoration: none;
        background: $light-background-color-dropdown-button;
        padding: 0 20px 0 10px;
        color: $light-text-color-dropdown-button;
        border: none;
        cursor: pointer;
        text-align: left;
        font-size: 15px;
        transition: all $transition-duration;

        &:hover,
        &:focus {
            background: $light-color;
        }

        svg {
            float: left;
            margin-right: 14px;
        }
    }
}

/* Modal box */
.trumbowyg-modal {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 520px;
    width: 100%;
    height: 350px;
    z-index: 12;
    overflow: hidden;
    backface-visibility: hidden;
}

.trumbowyg-modal-box {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 500px;
    width: calc(100% - 20px);
    padding-bottom: 45px;
    z-index: 1;
    background-color: $light-background-color-modal;
    text-align: center;
    font-size: 14px;
    font-family: "Trebuchet MS", Helvetica, Verdana, sans-serif;
    box-shadow: rgba(0, 0, 0, .2) 0 2px 3px;
    backface-visibility: hidden;

    .trumbowyg-modal-title {
        font-size: 24px;
        font-weight: bold;
        margin: 0 0 20px;
        padding: 15px 0 13px;
        display: block;
        border-bottom: 1px solid $light-border-color;
    }

    .trumbowyg-progress {
        width: 100%;
        height: 3px;
        position: absolute;
        top: 58px;

        .trumbowyg-progress-bar {
            background: #2BC06A;
            width: 0;
            height: 100%;
            transition: width $transition-duration linear;
        }
    }

    .trumbowyg-input {
        &-row {
            position: relative;
            margin: 15px 12px;
            border: 1px solid #dedede;
            overflow: hidden;
        }

        &-infos {
            text-align: left;
            transition: all 150ms;
            width: $modal-label-width;
            border-right: 1px solid #dedede;
            padding: 0 7px;
            background-color: color.adjust($light-color, $lightness: 5%, $space: hsl);
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;

            label {
                color: color.adjust($light-color, $lightness: -45%, $space: hsl);
                overflow: hidden;
                height: 27px;
                line-height: 27px;

                &, span {
                    display: block;
                    height: 27px;
                    line-height: 27px;
                    transition: all $transition-duration;
                }
            }

            .trumbowyg-msg-error {
                color: #e74c3c;
            }
        }

        &-html {
            padding: 1px 1px 1px $modal-label-width + 2px;

            &, input, textarea, select {
                font-size: 14px;
            }

            input, textarea, select {
                transition: all $transition-duration;
                height: 27px;
                line-height: 27px;
                border: 0;
                width: 100%;
                padding: 0 7px;

                &:hover,
                &:focus {
                    outline: 1px solid #95a5a6;
                }

                &:focus {
                    background: color.adjust($light-color, $lightness: 5%, $space: hsl);
                }
            }

            input[type="checkbox"] {
                width: 16px;
                height: 16px;
                padding: 0;
            }

            &-with-checkbox {
                text-align: left;
                padding: 3px 1px 1px 3px;
            }
        }

        &-error {
            input, select, textarea {
                outline: 1px solid #e74c3c;
            }

            .trumbowyg-input-infos label span:first-child {
                margin-top: -27px;
            }
        }
    }

    .error {
        margin-top: 25px;
        display: block;
        color: red;
    }

    .trumbowyg-modal-button {
        position: absolute;
        bottom: 10px;
        right: 0;
        text-decoration: none;
        color: #fff;
        display: block;
        width: 100px;
        height: $button-size;
        line-height: 33px;
        margin: 0 10px;
        background-color: #333;
        border: none;
        cursor: pointer;
        font-family: "Trebuchet MS", Helvetica, Verdana, sans-serif;
        font-size: 16px;
        transition: all $transition-duration;

        &.trumbowyg-modal-submit {
            right: 110px;
            background: color.adjust($modal-submit-color, $lightness: -3%, $space: hsl);

            &:hover,
            &:focus {
                background: color.adjust($modal-submit-color, $lightness: 5%, $space: hsl);
                outline: none;
            }

            &:active {
                background: color.adjust($modal-submit-color, $lightness: -10%, $space: hsl);
            }
        }

        &.trumbowyg-modal-reset {
            color: #555;
            background: color.adjust($modal-reset-color, $lightness: -3%, $space: hsl);

            &:hover,
            &:focus {
                background: color.adjust($modal-reset-color, $lightness: 5%, $space: hsl);
                outline: none;
            }

            &:active {
                background: color.adjust($modal-reset-color, $lightness: -10%, $space: hsl);
            }
        }
    }
}

.trumbowyg-overlay {
    position: absolute;
    background-color: hsla(0, 0%, 100%, 0.5);
    height: 100%;
    width: 100%;
    left: 0;
    display: none;
    top: 0;
    z-index: 10;
}

/**
 * Fullscreen
 */
body.trumbowyg-body-fullscreen {
    overflow: hidden;
}

.trumbowyg-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    z-index: 99999;

    &.trumbowyg-box,
    .trumbowyg-editor-box {
        border: none;
    }

    .trumbowyg-editor-box,
    .trumbowyg-textarea {
        height: auto !important;
        overflow: auto;
    }

    .trumbowyg-overlay {
        height: 100% !important;
    }

    .trumbowyg-button-group .trumbowyg-fullscreen-button svg {
        color: $dark-color;
        fill: transparent;
    }
}

.trumbowyg-editor {
    object,
    embed,
    video,
    img {
        max-width: 100%;
    }

    video,
    img {
        height: auto;
    }

    img {
        cursor: move;
    }

    canvas:focus {
        outline: none;
    }

    /*
     * For resetCss option
     */
    &.trumbowyg-reset-css {
        background: #fefefe !important;
        font-family: "Trebuchet MS", Helvetica, Verdana, sans-serif !important;
        font-size: 14px !important;
        line-height: 1.45em !important;
        color: #333 !important;
        font-weight: normal !important;

        a {
            color: #15c !important;
            text-decoration: underline !important;
        }

        div,
        p,
        ul,
        ol,
        blockquote {
            box-shadow: none !important;
            background: none !important;
            margin: 0 !important;
            margin-bottom: 15px !important;
            line-height: 1.4em !important;
            font-family: "Trebuchet MS", Helvetica, Verdana, sans-serif !important;
            font-size: 14px !important;
            border: none !important;
        }

        iframe,
        object,
        hr {
            margin-bottom: 15px !important;
        }

        blockquote {
            margin-left: 32px !important;
            font-style: italic !important;
            color: #555 !important;
        }

        ul {
            list-style: disc !important;
        }

        ol {
            list-style: decimal !important;
        }

        ul,
        ol {
            padding-left: 20px !important;
        }

        ul ul,
        ol ol,
        ul ol,
        ol ul {
            border: none !important;
            margin: 2px !important;
            padding: 0 !important;
            padding-left: 24px !important;
        }

        hr {
            display: block !important;
            height: 1px !important;
            border: none !important;
            border-top: 1px solid #CCC !important;
        }

        h1,
        h2,
        h3,
        h4 {
            color: #111 !important;
            background: none !important;
            margin: 0 !important;
            padding: 0 !important;
            font-weight: bold !important;
        }

        h1 {
            font-size: 32px !important;
            line-height: 38px !important;
            margin-bottom: 20px !important;
        }

        h2 {
            font-size: 26px !important;
            line-height: 34px !important;
            margin-bottom: 15px !important;
        }

        h3 {
            font-size: 22px !important;
            line-height: 28px !important;
            margin-bottom: 7px !important;
        }

        h4 {
            font-size: 16px !important;
            line-height: 22px !important;
            margin-bottom: 7px !important;
        }
    }
}

/*
 * Dark theme
 */
.trumbowyg-dark {
    .trumbowyg-textarea {
        background: $dark-background-color-editor;
        color: $dark-text-color;
        border-color: $dark-border-color;
    }

    .trumbowyg-box {
        border: 1px solid color.adjust($dark-color, $lightness: 7%, $space: hsl);

        &.trumbowyg-fullscreen {
            background: #111;
        }

        &.trumbowyg-box-blur .trumbowyg-editor {
            *,
            &::before {
                text-shadow: 0 0 7px #ccc;
            }
        }

        svg {
            fill: $dark-text-color;
            color: $dark-text-color;
        }
    }

    .trumbowyg-button-pane {
        background-color: $dark-background-color-pane;
        border-bottom-color: $dark-border-color;

        &::before,
        &::after {
            background: color.adjust($dark-color, $lightness: 7%, $space: hsl);
        }

        .trumbowyg-button-group:not(:empty) {
            &::after {
                background-color: color.adjust($dark-color, $lightness: 7%, $space: hsl);
            }

            .trumbowyg-fullscreen-button svg {
                color: transparent;
            }
        }

        &.trumbowyg-disable {
            .trumbowyg-button-group::after {
                background-color: color.adjust($dark-color, $lightness: 3%, $space: hsl);
            }
        }

        button:not(.trumbowyg-disable):hover,
        button:not(.trumbowyg-disable):focus,
        button.trumbowyg-active {
            background-color: #333;
        }

        .trumbowyg-open-dropdown::after {
            border-top-color: #fff;
        }
    }

    .trumbowyg-fullscreen {
        .trumbowyg-button-pane .trumbowyg-button-group:not(:empty) .trumbowyg-fullscreen-button svg {
            color: $light-color;
            fill: transparent;
        }
    }

    .trumbowyg-dropdown {
        border-color: $dark-border-color;
        background: $dark-background-color-modal;
        box-shadow: rgba(0, 0, 0, .3) 0 2px 3px;

        button {
            background: $dark-background-color-modal-button;
            color: $dark-text-color;

            &:hover,
            &:focus {
                background: $dark-color;
            }
        }
    }

    // Modal box
    .trumbowyg-modal-box {
        background-color: $dark-background-color-modal;
        color: $dark-text-color;

        .trumbowyg-modal-title {
            border-bottom: 1px solid #555;
            color: $dark-text-color;
            background: color.adjust($dark-color, $lightness: 10%, $space: hsl);
        }

        .trumbowyg-input-row {
            border-color: $dark-background-color-button;
        }

        .trumbowyg-input-infos {
            color: #eee;
            background-color: color.adjust($dark-color, $lightness: 5%, $space: hsl);
            border-right-color: $dark-background-color-button;

            span {
                color: #eee;
                background-color: color.adjust($dark-color, $lightness: 5%, $space: hsl);
                border-color: $dark-border-color;
            }

            span.trumbowyg-msg-error {
                color: #e74c3c;
            }
        }

        .trumbowyg-input-row.trumbowyg-input-error {
            input,
            select,
            textarea {
                border-color: #e74c3c;
            }
        }

        input,
        select,
        textarea {
            border-color: $dark-border-color;
            color: $dark-text-color;
            background: $dark-background-color-editor;

            &:hover,
            &:focus {
                border-color: color.adjust($dark-color, $lightness: 25%, $space: hsl);
            }

            &:focus {
                background-color: color.adjust($dark-color, $lightness: 5%, $space: hsl);
            }
        }

        .trumbowyg-modal-button {
            &.trumbowyg-modal-submit {
                background: color.adjust($modal-submit-color, $lightness: -20%, $space: hsl);

                &:hover,
                &:focus {
                    background: color.adjust($modal-submit-color, $lightness: -10%, $space: hsl);
                }

                &:active {
                    background: color.adjust($modal-submit-color, $lightness: -25%, $space: hsl);
                }
            }

            &.trumbowyg-modal-reset {
                background: #333;
                color: #ccc;

                &:hover,
                &:focus {
                    background: #444;
                }

                &:active {
                    background: #111;
                }
            }
        }
    }

    .trumbowyg-overlay {
        background-color: rgba(15, 15, 15, 0.6);
    }
}
