/*
 * 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/tokenfield.less';
@import (reference) '../../customize/src/less2/include/framework.less';
@import (reference) '../../customize/src/less2/include/markdown.less';

&.cp-app-file {

    .framework_min_main(
        @bg-color: @colortheme_apps[file],
    );
    .tokenfield_main();

    @button-border: 2px;

    // body
    display: flex;
    flex-flow: column;
    background-color: @cp_app-bg;

    #cp-app-file-content {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-flow: column;
        min-height: 0;
    }

    #cp-app-file-content.ready {
        //background: url('/customize/bg3.jpg') no-repeat center center;
        background-size: cover;
        background-position: center;
    }

    #cp-app-file-upfile, #cp-app-file-dlfile {
        display: block;
        height: 100%;
        width: 100%;
        border: @button-border solid black;
    }

    .cp-app-file-input {
        width: 0.1px;
        height: 0.1px;
        opacity: 0;
        overflow: hidden;
        position: absolute;
        z-index: -1;
    }

    .mediatag_cryptpad();
    media-tag {
        img {
            max-width: 100%;
            max-height: ~"calc(100vh - 96px)";
        }
        .plain-text-reader {
            align-self: flex-start;
            width: 90vw;
            height: 100%;
            padding: 2em;
            background-color: @cp_markdown-block-bg;
            color: @cp_markdown-block-fg;
            overflow-y: auto;
            word-wrap: break-word;
            white-space: pre-wrap;
        }
    }

    #cp-app-file-download-form {
        padding: 0px;
        margin: 0px;

        position: relative;
        display: block;
        max-width: 90vw;
        height: 150px;
        width: ~"min(90vw, 600px)";
        .cp-app-file-progress-container {
            margin-top: 5px;
            height: 40px;
            font-size: 20px;
            border: 1px solid @cp_file-progress-bg;
            background: white;
            color: @cp_file-progress-fg;
            display: flex;
            justify-content: space-between;
            position: relative;
            .cp-app-file-progress-dl {
                border-right: 1px solid @cp_file-progress-fg;
            }
            .cp-app-file-progress-dl, .cp-app-file-progress-dc {
                width: 50%;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                z-index: 2;
            }
            .cp-app-file-progress {
                z-index: 1;
                position: absolute;
                top: 0;
                left: 0;
                bottom: 0;
                background: @cp_file-progress-bg;
            }
        }
        .cp-app-file-progress-txt {
            margin-left: 30px;
        }
    }
    #cp-app-file-upload-form {
        padding: 0px;
        margin: 0px;

        position: relative;
        width: 50vh;
        height: 50vh;
        display: block;
        margin: 50px auto;
        max-width: 80vw;
        button {
            width: 100%;
            line-height: ~"calc(50vh - 20px)";
            text-align: center;
            position: relative;
            padding: 10px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            height: 50vh;
            box-sizing: border-box;
        }
    }
    #cp-app-file-download-form {
        label {
            display: flex;
            justify-content: center;
            align-items: center;
            white-space: normal;
            word-wrap: break-word;
            span {
                width: 50vh;
                max-width: 80vw;
                text-align: center;
                line-height: 1.5em;
            }
        }
    }
    .cp-app-file-block {
        display: block;
    }
    .cp-app-file-hidden {
        display: none;
    }
    .cp-app-file-input + label {
        display: block;
    }


    #cp-app-file-download-view {
        flex: 1;
        display: flex;
        min-height: 0;
        align-items: center;
        justify-content: center;
        flex-flow: column;
        media-tag {
            flex: 1;
            min-height: 0;
            max-width: 100vw;
            display: flex;
            align-items: center;
            justify-content: center;
            &> * {
                max-height: 100%;
                max-width: 100%;
            }
            &:empty {
                display: none !important;
            }
        }

    }
}
