
.mh-file-viewer {
    background: #353b48;
    bottom: 0;
    left: 0;
    overflow: hidden;
    position: absolute;
    right: 0;
    top: 0;

    &__filename {
        display: block;
        font-weight: bold;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    &__file-size {
        display: block;
    }

    &__buttons {
        display: flex;
        justify-content: space-between;
        position: absolute;
        width: 112px;
        z-index: 2;
    }

    .mh-file-field--file & {

        &__info {
            align-items: center;
            display: flex;
            justify-content: left;
        }

        &__filename {
            line-height: 48px;
            max-width: calc(100% - 240px);
            padding-left: 8px;
        }

        &__file-size {
            margin-left: 8px;
        }

        &__buttons {
            right: 8px;
            top: 8px;
        }
    }

    .mh-gallery-item & {

        &__info {
            display: flex;
            flex-direction: column;
            height: 100%;
            justify-content: center;
            padding: 8px;
            text-align: center;

            &::before {
                background:
                    transparent
                    url('#{$manhattan-manage-asset-root}/assets/file.svg')
                    center center
                    no-repeat;
                background-size: 32px;
                content: '';
                display: block;
                height: 32px;
                margin: 0 auto;
                width: 32px;
            }
        }

        &__filename {
            line-height: 24px;
            max-width: 100%;
            margin-top: 8px;
        }

        &__file-size {
            line-height: 24px;
        }

        &__handle {
            height: 100%;
            left: 0;
            position: absolute;
            top: 0;
            width: 100%;
            z-index: 1;
        }

        &__buttons {
            bottom: 8px;
            left: calc(50% - 56px);
        }
    }

    &__download {
        @extend %icon-btn;

        background-image: url('#{$manhattan-manage-asset-root}/assets/drop.svg');
    }

    &__metadata {
        @extend %icon-btn;

        background-image: url('#{$manhattan-manage-asset-root}/assets/metadata.svg');
    }

    &__remove {
        @extend %icon-btn;

        background-image: url('#{$manhattan-manage-asset-root}/assets/remove.svg');
    }
}

.mh-image-viewer {
    background:
        transparent
        url('#{$manhattan-manage-asset-root}/assets/checkers.svg')
        top left
        repeat;
    bottom: 0;
    left: 0;
    overflow: hidden;
    position: absolute;
    right: 0;
    top: 0;

    &__buttons {
        bottom: 8px;
        display: flex;
        justify-content: space-between;
        left: calc(50% - 76px);
        position: absolute;
        width: 152px;
        z-index: 2;
    }

    &__image {
        background-position: center center;
        background-repeat: no-repeat;
        background-size: contain;
        bottom: 0;
        left: 0;
        overflow: hidden;
        position: absolute;
        right: 0;
        top: 0;
    }

    &__handle {
        height: 100%;
        left: 0;
        position: absolute;
        top: 0;
        width: 100%;
        z-index: 1;
    }

    &__download {
        @extend %icon-btn;

        background-image: url('#{$manhattan-manage-asset-root}/assets/drop.svg');
    }

    &__edit {
        @extend %icon-btn;

        background-image: url('#{$manhattan-manage-asset-root}/assets/edit.svg');
    }

    &__metadata {
        @extend %icon-btn;

        background-image: url('#{$manhattan-manage-asset-root}/assets/metadata.svg');
    }

    &__remove {
        @extend %icon-btn;

        background-image: url('#{$manhattan-manage-asset-root}/assets/remove.svg');
    }
}


.mh-image-set-viewer {
    background:
        transparent
        url('#{$manhattan-manage-asset-root}/assets/checkers.svg')
        top left
        repeat;
    bottom: 0;
    left: 0;
    overflow: hidden;
    position: absolute;
    right: 0;
    top: 0;

    &__image {
        background-position: center center;
        background-repeat: no-repeat;
        background-size: contain;
        bottom: 0;
        left: 0;
        overflow: hidden;
        position: absolute;
        right: 0;
        top: 0;
    }

    &__versions {
        background-color: rgba(0, 0, 0, 0.5);
        border-radius: 2px;
        left: 8px;
        max-height: 32px;
        overflow: hidden;
        padding-top: 32px;
        position: absolute;
        top: 8px;
        width: 160px;

        &::after {
            content: '';
            display: block;
            pointer-events: none;
            margin-top: -2px;
            height: 0;
            width: 0;
            border-left: 4px solid transparent;
            border-right: 4px solid transparent;
            border-top: 4px solid #EFF2F4;
            position: absolute;
            top: 16px;
            right: 12px;
        }

        &--open {
            max-height: calc(100% - 16px);

            &::after {
                transform: scaleY(-1.0);
            }

            .mh-image-set-viewer {
                &__version {
                    position: static !important;
                }
            }
        }
    }

    &__version {
        cursor: pointer;
        font-size: 15px;
        height: 32px;
        line-height: 32px;
        overflow: hidden;
        padding: 0 32px 0 8px;
        text-overflow: ellipsis;
        white-space: nowrap;

        &:hover {
            background: rgba(0, 0, 0, 0.25);
        }

        &--selected {
            left: 0;
            position: absolute;
            width: 100%;
            top: 0;
        }
    }

    // Buttons

    &__version-buttons {
        bottom: 8px;
        display: flex;
        justify-content: center;
        height: 32px;
        left: 0;
        position: absolute;
        right: 0;
    }


    &__clear,
    &__edit,
    &__upload {
        @extend %icon-btn;
        margin: 0 8px;
    }

    &__alt,
    &__remove {
        @extend %icon-btn;
        position: absolute;
    }

    &__alt {
        background-image: url('#{$manhattan-manage-asset-root}/assets/tag.svg');
        right: 48px;
        top: 8px;
    }

    &__clear {
        background-image:
            url('#{$manhattan-manage-asset-root}/assets/clear.svg');
        display: none;
    }

    &__edit {
        background-image:
            url('#{$manhattan-manage-asset-root}/assets/edit.svg');
    }

    &__remove {
        background-image:
            url('#{$manhattan-manage-asset-root}/assets/remove.svg');
        right: 8px;
        top: 8px;
    }

    &__upload {
        background-image:
            url('#{$manhattan-manage-asset-root}/assets/upload.svg');
        position: relative;
    }

    // -- Viewer states --

    &--base {
        .mh-image-set-viewer {

            // Hide the clear and upload buttons when viewing the base version
            &__clear,
            &__upload {
                display: none;
            }
        }
    }

    &--own-image {
        .mh-image-set-viewer {

            // Show the clear button and hide the upload button when viewing a
            // version with it's own image.
            &__clear {
                display: block;
            }

            &__upload {
                display: none;
            }
        }
    }
}
