/* nested inside #workspace so my styles take priority without having to spam !important */
.editor {
    max-width: 100%;
}

:root {
    --checkedDecor: line-through;
}

#workspace {
    max-width: auto;
    min-width: 0;
    flex-basis: 100%;

    .ql-container, .ql-toolbar {
        border: 1px solid var(--border-sep);
        border-radius: var(--corners);
        width: 100%;
    }
    .ql-container {
        background: color-mix(in srgb, var(--bg) calc(var(--panel-opacity) * 1%), transparent);
        backdrop-filter: blur(var(--panel-blur));
    }
    .ql-toolbar {
        background: color-mix(in srgb, var(--bg-3) calc(var(--panel-opacity) * 1%), transparent);
        backdrop-filter: blur(var(--panel-blur));
        position: relative;
        z-index: 1;
        height: auto;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 0;
        max-width: 100%;

        .ql-formats {
            margin: 0;
            height: 2rem;
            display: flex;
            align-items: center;
            padding: 2px;

            &:not(:last-child) {
                margin-right: 0.5rem;
            }

            button {
                height: 100%;
                aspect-ratio: 1/1;

                &:hover {
                    background: var(--btn-highlight);
                    color: var(--accent);
                }

                &.ql-active {
                    color: var(--accent);
                }
            }
        }

        .ql-table-button-disabled {
            background-color: var(--bg-2) !important;
            opacity: 0.5;
        }

        .ql-picker {
            height: 100%;
            border-radius: var(--corners);

            .ql-picker-label {
                color: var(--textm);
                display: flex;
                transition: background 0.15s ease;

                &:hover {
                    background: var(--btn-highlight);
                }
            }

            .ql-picker-options {
                background: var(--bg-3);
                border: 1px solid var(--border-sep);
                border-radius: var(--corners);
                padding: 0;
                flex-direction: column;

                .ql-picker-item {
                    color: var(--textm);
                    display: flex;
                    aspect-ratio: 1/1;
                    width: 100%;

                    &:hover {
                        background: var(--btn-highlight);
                    }
                }
            }

            &.ql-expanded {
                .ql-picker-label {
                    background: var(--btn-highlight);
                    border: 1px solid var(--border-sep);
                }

                .ql-picker-options {
                    display: flex;
                }
            }
        }
    }

    .ql-blank:before {
        color: var(--textm);
    }

    /*****
    /* past here is probably just inline styles for formats
    ******/
    .ql-editor {
        overflow: scroll;
        max-width: 100%;
        z-index: -1;

        &.nowrap {
            white-space: pre;
        }

        .ql-ui {
            height: 100%;
        }

        li[data-list="unchecked"], li[data-list="checked"] {
            .ql-ui:before {
                content: "";
                display: block;
                border: 1px solid var(--border-sep);
                height: 0.8em;
                width: auto;
                aspect-ratio: 1/1;
                position: absolute;
                top: 50%;
                left: 0;
                transform: translateY(-50%);
            }
        }

        li[data-list="checked"] {
            text-decoration: var(--checkedDecor);

            .ql-ui:before {border-color: var(--textm);}
            .ql-ui:after {
                font-family: 'tabler-icons';
                content: "\ea5e";
                font-size: 1.2em;
                color: var(--textm);
                display: block;
                position: absolute;
                top: 50%;
                transform: translateY(-50%);
                margin-left: -1.3em;
                margin-right: 0.3em;
            }
        }

        li[data-list="bullet"] {
            .ql-ui:before {
                content: "";
                background: currentColor;
                height: 0.5em;
                width: auto;
                aspect-ratio: 1/1;
                position: absolute;
                top: 0.5em;
                border-radius: 50%;
                margin-left: -1.2em
            }
        }

        .smartTypographyFlash {
            position: absolute;
            background-color: var(--accentm);
            border-radius: var(--corners);
            pointer-events: none;
            transition: opacity 0.2s ease-out;
            z-index: 10;
        }
    }
    
    .ql-tooltip {
        border: 1px solid var(--border-sep);
        background: var(--bg-3);
        border-radius: 1px;
        box-shadow: none;
        color: var(--textb);

        input {
            color: var(--textb);
            background: none;
            border: 1px solid var(--border-m);
            border-radius: var(--corners);

            &:focus {
                outline: none;
                border-color: var(--accent);
            }
        }

        .ql-action {
            color: var(--accent);
        }
    }

    /*********
      TABLES
    *********/
    td, th {
        border: 1px solid var(--border-m);
    }

    th {
        background: var(--bg-3);
    }

    .ql-table-select-container {
        background: var(--bg-3);
        border-radius: var(--corners);
        border: 1px solid var(--border-m);
        
        .ql-table-select-list {
            span {
                border: 1px solid var(--border-m);

                &.ql-cell-selected {
                    border: 1px solid var(--accent);
                    background: var(--accentm);
                    &:after {display: none;}
                }
            }
        }

        .ql-table-select-label {
            color: var(--textm);
        }
    }

    .ql-table-menus-container {
        background: var(--bg-3);
        border-radius: var(--corners);
        border: 1px solid var(--border-m);

        &.ql-table-triangle-down {
            &:after {
                color: var(--bg-3);
                border-bottom-color: var(--bg-3) !important;
            }
        }

        &.ql-table-triangle-up {
            &:after {
                color: var(--bg-3);
                border-top-color: var(--bg-3) !important;
            }
        }
    }

    .ql-table-dropdown {
        svg path {
            stroke: var(--textm);
        }

        &:hover {
            background: var(--btn-highlight);
        }

        .ql-table-tooltip {
            background: var(--bg);
            border: 1px solid var(--border-sep);
            padding: 0.2rem 0.3rem !important;
            border-radius: var(--corners);
            font-size: 0.9em;

            &:before {display: none;}
        }
    }

    .ql-table-dropdown-list {
        background: var(--bg-3);
        border-radius: var(--corners);
        border: 1px solid var(--border-m);

        li:hover {
            background: var(--btn-highlight);
        }

        .ql-table-divider {
            background: var(--border-m);
        }

        .ql-table-switch {
            position: relative;
            display: inline-block;
            height: 1em;
            width: 2em;
            vertical-align: text-bottom;
        }

        .ql-table-switch .ql-table-switch-inner {
            position: absolute;
            inset: 0;
            cursor: pointer;
            background: transparent;
            outline: 1px solid var(--border-m);
            outline-offset: 0.125em;
            border-radius: 1em;
            transition: all 0.15s ease;
        }

        .ql-table-switch .ql-table-switch-inner:before {
            content: "";
            position: static;
            display: block;
            height: 1em;
            width: 1em;
            background: var(--border-sep);
            border-radius: 1em;
            transform: translateX(0);
            transition: all 0.15s ease;
        }

        .ql-table-switch:hover .ql-table-switch-inner {
            outline-color: var(--textm);
        }

        .ql-table-switch .ql-table-switch-inner[aria-checked="true"] {
            outline-color: var(--accent);
            background: var(--accentm);
        }

        .ql-table-switch .ql-table-switch-inner[aria-checked="true"]:before {
            transform: translateX(1em);
            background: var(--accent);
        }
    }

    .ql-cell-focused:after {
        background: none;
        border-color: var(--accent);
    }

    .ql-cell-selected:after {
        background: color-mix(in srgb, var(--accent) 45%, transparent);
        border: 1px solid var(--accentm);
    }

    .ql-operate-line {
        background: var(--accent);
    }

    .ql-operate-block {
        border: 1px solid var(--border-m);
    }

    .ql-operate-drag-table {
        border: 1px dashed var(--accent);
    }

}
