@import "../../../../assets/less/core/boot.less";

@fileupload-progress-bar-height: 5px;
@fileupload-inactive-icon: #808b93;

.field-fileupload {

    .attachment-input {
        position: absolute;
        visibility: hidden;
        width: 10px;
        opacity: 0;
    }

    .attachment-item {
        position: relative;
    }

    .image-multi, .file-multi {
        ul {
            padding: 0; margin: 0;
            .clearfix;

            li {
                list-style: none;
                float: left;
                margin-right: 35px;
                margin-bottom: 15px;
            }
        }
    }

    .file-multi .attachment-item, .file-single.attachment-item {
        width: 100px;
        height: 100px;
    }

    .active-image, .active-file {
        display: block;
        height: 100%;
        width: 100%;
        border: 1px solid #e0e0e0;
        background: white;
        position: relative;
        outline: none;
        overflow: hidden;
        padding: 5px;

        .caption {
            position: absolute;
            bottom: 0;
            font-size: 11px;
            background: rgba(0,0,0,.05);
            color: #999;
            padding: 2px 5px;
            width: 100%;
            .text-overflow();
        }
    }

    .active-image {
        img { width: 100%; height: 100%; }
    }

    .active-file {
        padding: 0;
        .file-icon {
            position: absolute;
            top: 7px;
            left: 0;
            width: 100%;
            text-align: center;
            i {
                font-size: 64px;
                color: #444;
            }
            b {
                position: absolute;
                left: 0;
                bottom: 10px;
                color: #FFF;
                display: block;
                width: 100%;
                font-size: 12px;
                font-weight: normal;
                letter-spacing: 1px;
                text-transform: uppercase;
                text-align: center;
                text-indent: 12px;
            }
        }

    }

    .uploader-toolbar {
        .transition(opacity .2s);
        height: 100%;
        background: #e0e0e0;
        position: absolute;
        top: 0;
        right: -20px;
        width: 20px;

        h3, p {
            display: none;
        }

        a {
            text-decoration: none;
            display: block;
            padding: 3px 0 0 7px;
            color: #999;
            font-size: 15px;
            margin-left: -4px;
            text-align: center;
            &:hover { color: #666; }

            &.uploader-file-link {
                display: none;
            }
        }
    }

    .no-attachment {
        display: block;
        height: 100%;
        width: 100%;
        border: 2px dotted #e0e0e0;
        position: relative;
        outline: none;
        table {
            position: absolute;
            height: 100%;
            width: 100%;
        }

        table td {
            line-height: 16px;
            font-size: 11px;
            vertical-align: middle;
            height: 100%;

            &:before {
                text-align: center;
                width: 100%;
                display: block;
                font-size: 22px;
                color: rgba(0,0,0,.1);
                vertical-align: middle;
            }

            span {
                display: block;
                padding: 10px;
                text-align: center;
            }
        }

        &:hover {
            /*background: #ffffdd;*/
            border: 2px dotted rgba(0,0,0,.1);
        }

        &:focus {
            border: 2px solid #ccc;
            background: transparent;
        }
    }

    .uploader-progress {
        position: relative;
        top: -(@fileupload-progress-bar-height + 2);
    }

    //
    // Loading
    //

    .uploader-progress {
        margin: 0 2px;
        visibility: hidden;
        overflow: hidden;
        height: @fileupload-progress-bar-height;
        margin-bottom: @line-height-computed;
        background-color: @progress-bg;
        border-radius: @border-radius-base;
        .box-shadow(inset 0 1px 2px rgba(0,0,0,.1));
        .progress-bar {
            line-height: @fileupload-progress-bar-height;
            color: @progress-bar-color;
            background-color: #ccc;
            .box-shadow(none);
        }
    }

    .loading {
        img, .file-icon {
            .opacity(.5);
        }
        .uploader-loading {
            background-image: url(../../../../assets/images/loading-indicator-transparent.svg);
            position: absolute;
            content: ' ';
            width: 40px;
            height: 40px;
            left: 50%;
            top: 50%;
            margin-top: -(20px + @fileupload-progress-bar-height / 2);
            margin-left: -20px;
            display: block;
            background-size: 40px 40px;
            background-position: 50% 50%;
            .animation(spin 1s linear infinite);
        }
        .no-attachment {
            cursor: default;
            border: 2px solid #ccc;
            table td:before { display: none; }
        }
        .uploader-progress {
            visibility: visible;
        }
    }

    //
    // Sortable
    //

    &.is-sortable {

        li.placeholder {
            position: relative;
            border: 2px dotted #e0e0e0;
        }

        li.dragged {
            position: absolute;
            .opacity(.5);
            z-index: 2000;
            .uploader-toolbar {
                display: none;
            }
        }
    }

    .no-data {
        background: #f6f6f6;
        border: 1px solid #e0e0e0;
        color: #555555;
        font-size: 13px;
        .box-sizing(border-box);
        padding: 10px;
    }
}

.form-sidebar {
    .field-fileupload {
        .image-multi {
            margin-right: -5px;
            ul li {
                margin-right: 5px;
                margin-bottom: 5px;
            }
        }
    }
}

//
// Desktop Friendly
//

html:not(.touch) {

    .image-multi, .file-multi {
        ul li { margin-right: 15px; }
    }

    .field-fileupload {
        .attachment-item {
            .uploader-toolbar {
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: white;
                .opacity(0);
                .transition(all .3s ease);

                a {
                    display: inline-block;
                    text-align: left;
                    padding: 0 0 5px 6px;
                    font-size: 16px;
                    color: @fileupload-inactive-icon;
                    margin-left: 5px;

                    &:before {
                        margin-right: 0;
                    }

                    &:hover {
                        color: #0181b9;
                    }

                    &.uploader-remove {
                        position: absolute;
                        right: 5px;
                        top: 1px;
                        font-size: 13px;

                        &:hover {
                            color: #c73f26;
                        }
                    }

                    &.uploader-config,
                    &.uploader-file-link {
                        display: inline-block;
                    }
                }

                div.controls {
                    position: absolute;
                    bottom: 0;
                    left: 0;
                }

                h3, p {
                    display: block;
                    padding: 15px 13px 0;
                    color: #7e8c8d;
                    margin-top: 0;
                    line-height: 140%;
                }

                h3 {
                    word-wrap: break-word;
                    font-weight: 700;
                    font-size: 12px;
                    .text-overflow();
                }

                p {
                    font-size: 11px;
                    padding-top: 0;
                    white-space: normal;
                    position: absolute;
                    top: 35px;
                    bottom: 20px;
                    width: 100%;
                    .opacity(0.8);

                    abbr {
                        border-bottom: none;
                    }
                }
            }

            &:hover {
                .uploader-toolbar {
                    .opacity(1);
                }
            }
        }
    }

}