/*
 * SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
 *
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

@import (reference) "../../customize/src/less2/include/browser.less";
@import (reference) "../../customize/src/less2/include/markdown.less";
@import (reference) "../../customize/src/less2/include/framework.less";

&.cp-app-code {
    .framework_main(
        @bg-color: @colortheme_apps[code],
    );

    display: flex;
    flex-flow: column;
    max-height: 100%;
    min-height: auto;
    background-color: @cp_preview-bg;

    #cp-app-code-container {
        display: inline-flex;
        flex-flow: column;
        height: 100%;
        min-height: 100%;
        min-width: 20%;
        max-width: 80%;
        resize: horizontal;
        overflow: hidden;
        width: 50%;
        &.cp-app-code-fullpage {
            max-width: 100%;
            resize: none;
            flex: 1;
        }
    }
    .CodeMirror {
        flex: 1;
        font-size: initial;
        width: 100%;
    }
    .CodeMirror-focused .cm-matchhighlight {
        background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
        background-position: bottom;
        background-repeat: repeat-x;
    }
    #cp-app-code-editor {
        flex: 1;
        display: flex;
        flex-flow: row;
        height: 100%;
        overflow: hidden;
        &.cp-app-code-present {
            #cp-app-code-container { display: none; }
            #cp-app-code-preview { border: 0; }
        }
        &.cp-chat-visible {
            #cp-app-code-container {
                width: 35%;
            }
        }
    }
    #cp-app-code-preview {
        padding: 5px 10px;
        overflow: auto;
        display: inline-block;
        height: 100%;
        border-left: 1px solid black;
        box-sizing: border-box;
        //font-family: Calibri,Ubuntu,sans-serif;
        font: @colortheme_app-font;
        position: relative;
        flex: 1;

        .markdown_main();
        .markdown_cryptpad();
        .todo-list-item {
            .fa {
                &.fa-check-square {
                    font-size: 15px;
                    margin-top: 5px;
                }
            }
        }

        .cp-app-code-preview-empty {
            display: none;
        }
        &.cp-app-code-preview-isempty {
            display: flex;
            align-items: center;
            justify-content: center;
            #cp-app-code-preview-content {
                display: none;
            }
            .cp-app-code-preview-empty {
                //flex: 1 1 auto;
                max-height: 100%;
                max-width: 100%;
                display: block;
                opacity: 0.2;
            }
        }
    }

    #cp-app-code-preview-content {
        background-color: @cp_preview-bg;
        color: @cp_preview-fg;
        max-width: 70ch;
        margin: 1em auto;

        .markdown_preformatted-code;
        .markdown_gfm-table();
        table {
            margin-bottom: 1rem;
        }
        media-tag > * {
            margin-bottom: 1rem;
        }
        a {
            color: @cp_preview-link;
            text-decoration: underline;
        }
    }

    .cp-splitter {
        position: absolute;
        height: 100%;
        width: 8px;
        top: 0;
        left: 0;

        cursor: col-resize;
    }

    @media (max-width: @browser_media-medium-screen) {
        #cp-app-code-editor {
            &.cp-app-code-present {
                #cp-app-code-preview {
                    flex: 1;
                    max-width: 100%;
                    border: 0;
                    #cp-app-code-preview-content {
                        margin: 10px;
                    }
                }
            }
            &:not(.cp-app-code-present) {
                #cp-app-code-container {
                    flex: 1;
                    max-width: 100%;
                    resize: none;
                    .CodeMirror-sizer > div {
                        padding-bottom: 100px;
                    }
                }
            }
        }
    }
    #cp-app-code-print {
        position: relative;
        display: none;
        .markdown_preformatted-code;
        .markdown_gfm-table();
    }
}

