$quill-background-accent-lighter: #EBEBEB;
$quill-background-accent-darker: #DCDCDC;
$quill-background-fill-color: #FFFFFF;
$quill-controls-color: #424242;
$quill-controls-color-active: #0185D3;
$quill-link-color: #0185D3;
$quill-popup-border-color: #CCCCCC;


.quill-holder {
    background-color: $quill-background-fill-color;
    border: 1px solid #222222;
    border-radius: 3px;
    border-top-width: 4px;
    margin: 15px 0;
    width: 100%;

    a {
        color: $quill-link-color;
    }

    .ql-toolbar {
        box-shadow: 0 1px 3px rgba(0,0,0,0.12),0 1px 2px rgba(0,0,0,0.24);
        box-sizing: border-box;
        height: 36px;
        padding: 0 2px;

        -webkit-user-select: none;
           -moz-user-select: none;
            -ms-user-select: none;
                user-select: none;

        .ql-format-group {
            color: $quill-controls-color;
            display: block;
            float: left;
            margin: 0;
            position: relative;
            vertical-align: inherit;

            .ql-format-button {
                background-image: none !important;
                box-sizing: border-box;
                cursor: pointer;
                display: block;
                float: left;
                height: 36px;
                line-height: 36px;
                margin: 0 2px;
                position: relative;
                text-align: center;
                vertical-align: inherit;
                width: 36px;

                transition: background 0.2s ease 0s;

                .ql-button-explainer {
                    background: #616161;
                    border-radius: 2px;
                    color: #FFFFFF;
                    font-size: 12px;
                    font-weight: 500;
                    left: 50%;
                    line-height: 24px;
                    opacity: 0;
                    padding: 0 8px;
                    position: absolute;
                    top: calc(100% + 2px);
                    transform: scale(0, 0) translateX(-50%);
                    transform-origin: left center 0px;
                    white-space: nowrap;
                    width: auto;
                    z-index: 90;

                    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
                    transition-delay: 0s;
                }

                &:hover {
                    background-color: $quill-background-accent-lighter;

                    .ql-button-explainer {
                        opacity: 0.95;
                        transform: scale(1, 1) translateX(-50%);
                        visibility: visible;

                        transition-delay: 0.6s;
                    }
                }

                &.ql-active {
                    color: $quill-controls-color-active;
                }
            }

            .ql-format-separator {
                background-color: $quill-background-accent-darker;
                box-sizing: border-box;
                display: block;
                float: left;
                height: 32px;
                margin: 2px;
                vertical-align: inherit;
                width: 1px;
            }

            .ql-picker {
                box-sizing: border-box;
                color: $quill-controls-color;
                display: block;
                float: left;
                font-size: 14px;
                font-weight: 500;
                position: relative;

                .ql-picker-label {
                    background-color: $quill-background-fill-color;
                    background-image: none !important;
                    border: 0 none !important;
                    box-sizing: border-box;
                    cursor: pointer;
                    display: block;
                    float: left;
                    height: 36px;
                    line-height: 34px;
                    padding: 0;
                    position: relative;
                    padding-left: 10px;
                    padding-right: 20px;
                    vertical-align: inherit;
                    width: 100%;

                    &.ql-active {
                        color: $quill-controls-color;
                    }

                    &:hover {
                        background-color: $quill-background-accent-lighter;
                        color: $quill-controls-color;
                    }

                    &::after {
                        border-left: 4px solid transparent;
                        border-right: 4px solid transparent;
                        border-top: 4px solid $quill-controls-color;
                        content: "";
                        height: 0;
                        position: absolute;
                        right: 7px;
                        top: 15px;
                        width: 0;
                    }
                }

                .ql-picker-options {
                    background-color: $quill-background-fill-color;
                    border: 1px solid transparent;
                    box-sizing: border-box;
                    color: $quill-controls-color;
                    display: none;
                    max-height: 275px;
                    overflow: scroll;
                    padding: 4px 0;
                    top: 36px;
                    position: absolute;
                    width: 100%;

                    .ql-picker-item {
                        box-sizing: border-box;
                        cursor: pointer;
                        display: block;
                        font-size: 14px;
                        height: 35px;
                        line-height: 21px;
                        padding: 7px 10px;
                        vertical-align: inherit;

                        &.ql-selected {
                            background: $quill-background-accent-darker;
                            color: $quill-controls-color;
                        }

                        &:hover {
                            background: $quill-background-accent-lighter;
                            color: $quill-controls-color;
                        }
                    }
                }

                &.ql-expanded {
                    .ql-picker-label {
                        background-color: $quill-background-accent-darker !important;
                        color: $quill-controls-color;
                        z-index: 2;
                    }

                    .ql-picker-options {
                        border-color: $quill-popup-border-color;
                        box-shadow: rgba(0,0,0,0.2) 0 2px 8px;
                        display: block;
                        margin-top: -1px;
                        z-index: 1;
                    }
                }

                + select + .ql-button-explainer {
                    background: #616161;
                    border-radius: 2px;
                    color: #FFFFFF;
                    font-size: 12px;
                    font-weight: 500;
                    left: 50%;
                    line-height: 24px;
                    opacity: 0;
                    padding: 0 8px;
                    position: absolute;
                    top: calc(100% + 2px);
                    transform: scale(0, 0) translateX(-50%);
                    transform-origin: left center 0px;
                    white-space: nowrap;
                    width: auto;
                    z-index: 90;

                    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
                    transition-delay: 0s;
                }

                &:hover {
                    + select + .ql-button-explainer {
                        opacity: 0.95;
                        transform: scale(1, 1) translateX(-50%);
                        visibility: visible;

                        transition-delay: 0.6s;
                    }

                    &.ql-expanded {
                        + select + .ql-button-explainer {
                            display: none;
                            opacity: 0;
                            transform: scale(0, 0) translateX(-50%);
                        }
                    }
                }

                &.ql-size {
                    width: 65px;

                    + select + .ql-button-explainer {
                        left: calc(50% - 23px);
                    }
                }

                &.ql-align {
                    font-size: 16px;

                    .ql-picker-label {
                        &::before {
                            display: inline-block;
                            font: normal normal normal 14px / 1 FontAwesome;
                            font-size: inherit;
                            text-rendering: auto;

                            -webkit-font-smoothing: antialiased;
                            -moz-osx-font-smoothing: grayscale;
                        }

                        &[data-value="left"]::before {
                            content: "\f036";
                        }

                        &[data-value="center"]::before {
                            content: "\f037";
                        }

                        &[data-value="right"]::before {
                            content: "\f038";
                        }

                        &[data-value="justify"]::before {
                            content: "\f039";
                        }
                    }

                    .ql-picker-options {
                        .ql-picker-item {
                            background-image: none !important;
                            font-size: 16px;
                            text-align: center;
                            width: 100%;

                            &::before {
                                display: inline-block;
                                font: normal normal normal 14px / 1 FontAwesome;
                                font-size: inherit;
                                text-rendering: auto;

                                -webkit-font-smoothing: antialiased;
                                -moz-osx-font-smoothing: grayscale;
                            }

                            &[data-value="left"]::before {
                                content: "\f036";
                            }

                            &[data-value="center"]::before {
                                content: "\f037";
                            }

                            &[data-value="right"]::before {
                                content: "\f038";
                            }

                            &[data-value="justify"]::before {
                                content: "\f039";
                            }
                        }
                    }

                    + select + .ql-button-explainer {
                        left: calc(50% + 32.5px);
                    }
                }
            }

            &.dropdowns-group {
                width: 116px;
            }
        }
    }

    .ql-container {
        box-sizing: border-box;
        cursor: text;
        font-family: Helvetica,Arial,sans-serif;
        font-size: 13px;
        height: 100%;
        line-height: 1.42;
        margin: 0;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 12px 15px;
        position: relative;

        .ql-editor {
            box-sizing: border-box;
            min-height: 100%;
            outline: none;
            tab-size: 4;
            white-space: pre-wrap;

            div {
                margin: 0;
                padding: 0;
            }

            a {
                text-decoration: underline;
            }

            b {
                font-weight: 700;
            }

            i {
                font-style: italic;
            }

            s {
                text-decoration: line-through;
            }

            u {
                text-decoration: underline;
            }

            a,
            b,
            i,
            s,
            u,
            span {
                background-color: inherit;
            }

            img {
                max-width: 100%;
            }

            blockquote,
            ol,
            ul {
                margin: 0 0 0 2em;
                padding: 0;
            }

            ol {
                list-style-type: decimal;
            }

            ul {
                list-style-type: disc;
            }

            &.ql-ie-9 br,
            &.ql-ie-10 br {
                display: none;
            }
        }
    }
}

.ql-image-tooltip {
    padding: 10px;
    width: 300px;

    &::after {
        clear: both;
        content: "";
        display: table;
    }

    a {
        border: 1px solid $quill-link-color;
        box-sizing: border-box;
        display: inline-block;
        float: left;
        padding: 5px;
        text-align: center;
        width: 50%;

        &.insert {
            background-color: $quill-link-color;
            color: $quill-background-fill-color;
        }
    }

    img {
        bottom: 0;
        left: 0;
        margin: auto;
        max-height: 100%;
        max-width: 100%;
        position: absolute;
        right: 0;
        top: 0;
    }

    .input {
          box-sizing: border-box;
          width: 100%;
    }

    .preview {
        border: 1px dashed $quill-popup-border-color;
        color: $quill-popup-border-color;
        height: 200px;
        margin: 10px 0px;
        position: relative;

        span {
            display: inline-block;
            position: absolute;
            text-align: center;
            top: 40%;
            width: 100%;
        }
    }
}

.ql-link-tooltip {
    padding: 5px 10px;

    input.input {
        width: 170px;
    }

    input.input,
    a.done {
        display: none;
    }

    a.change {
        margin-right: 4px;
    }

    &.editing {
        input.input,
        a.done {
          display: inline-block;
        }

        a.url,
        a.change,
        a.remove {
          display: none;
        }
    }

    a,
    span {
        line-height: 25px;
    }
}


.ql-paste-manager {
    left: -100000px;
    position: absolute;
    top: 50%;
}

.ql-tooltip {
    background-color: $quill-background-fill-color;
    border: 1px solid $quill-popup-border-color !important;
    box-shadow: rgba(0,0,0,0.2) 0 2px 8px;
    box-sizing: border-box;
    color: $quill-controls-color;
    position: absolute;
    top: 0px;
    white-space: nowrap;
    z-index: 2000;

    a {
        color: $quill-link-color;
        cursor: pointer;
        text-decoration: none;
    }

    .input {
        border: 1px solid $quill-popup-border-color;
        margin: 0px;
        padding: 5px;
    }
}

@media (max-width: 479px) {
    .quill-holder {
        .ql-toolbar {
            padding: 0;

            .ql-format-group {
                .ql-format-button {
                    margin: 0;
                    width: 32px;
                }

                .ql-format-separator {
                    margin: 2px 0;
                }
            }
        }
    }
}

@media (max-width: 419px) {
    .quill-holder {
        .ql-toolbar {
            height: 73px;

            .ql-format-group {
                .ql-format-button {
                    font-size: 14px;
                }

                .ql-picker {
                    .ql-picker-label {
                        font-size: 14px;
                    }
                }

                .last-separator {
                    display: none;
                }

                &.last-format-group {
                    border-top: 1px solid $quill-background-accent-darker;
                    width: 100%;
                }
            }
        }
    }
}