@import 'commons';

$m-file-upload-max-height: 120px;
$m-file-upload-max-height--s: 72px;

.m-file-upload {
    @include m-box-padding();

    &__error-message {
        margin-bottom: $m-space-md;

        &__title {
            font-weight: $m-font-weight-semi-bold;
        }

        &__list {
            margin-top: $m-space-xs;
            margin-bottom: 0;

            li {
                margin-top: $m-space-sm;

                &:first-child {
                    margin-top: 0;
                }
            }
        }

        &__file-name {
            margin-top: 0;
            word-break: break-all;
        }

        &__error {
            margin-top: 0;
            color: $m-color-error;

            @include m-font-size('xs');
        }
    }

    &__wrap {
        &.m--no-padding {
            padding-left: 0;
            padding-right: 0;
        }

        @media (min-width: $m-mq-min-sm) {
            padding: $m-space-lg $m-space-lg;
        }

        @media (max-width: $m-mq-max-sm) {
            padding: $m-space $m-space;
        }
    }

    &.m--is-drag-over {
        .m-file-upload__drop-zone {
            border-style: solid;
            border-color: $m-color-interactive;
            background: $m-color-information;
        }
    }

    &__drop-zone,
    &__no-drop-zone {
        border: $m-color-success $m-border-width dashed;
        padding: $m-space-lg $m-space;
        text-align: center;
        transition: background $m-transition-duration ease;

        &__title {
            margin-top: 0;
        }

        &__instructions {
            display: inline-flex;
            align-items: center;
            justify-content: center;

            .m-icon {
                color: $m-color-success;
                margin-right: $m-space-xs;
                margin-left: -5px; // magic number for alignment purpose
            }

            .m-file-select {
                margin-top: 0;
                margin-left: $m-space-xs;
            }

            &__title {
                font-weight: $m-font-weight-semi-bold;
                display: flex;
                align-items: center;
                margin-top: 0;
            }

            &__button {
                margin-top: $m-space-sm;
            }
        }

        &__format {
            margin-top: $m-space-xs;
            font-weight: $m-font-weight-semi-bold;
        }
    }

    &__title {
        margin-top: $m-space-md;
        padding-bottom: 8px;
        border-bottom: $m-border-width-sm solid $m-color-grey-light;
    }

    &__import-list {
        margin-top: $m-space-md;

        &__wrap {
            margin: 0;
            max-height: initial;

            li {
                max-height: $m-file-upload-max-height;
                display: flex;

                &:last-child {
                    .m-file-upload__import-list__content {
                        margin-bottom: 0;
                    }
                }

                &.m--is-leave-active {
                    transition: opacity $m-transition-duration, max-height $m-transition-duration-lg;
                }

                &.m--is-leave-to {
                    opacity: 0;
                    max-height: 0;
                }
            }
        }

        &__content {
            display: flex;
            flex: 1 1 auto;
            align-items: center;
            margin-bottom: $m-space-sm;
        }

        &__file-icon {
            display: flex;
            align-items: center;
        }

        &__progress-wrap {
            flex: 1 1 auto;
            padding: 0 $m-space;
            display: flex;
            flex-direction: column;
        }

        &__infos {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: $m-space-2xs;
        }

        &__name,
        &__size {
            margin-top: 0;
        }

        &__name {
            font-weight: $m-font-weight-semi-bold;
            word-break: break-all;
            flex: 1 0 0;
            padding-right: $m-space-2xs;
        }

        &__error-message {
            color: $m-color-error;
            @include m-font-size('sx');
            margin-top: 0;
        }

        &__size {
            color: $m-color-grey-dark;
            @include m-font-size('xs');
        }

        &__button:active::before {
            width: 32px !important;
            height: 32px !important;
        }
    }

    &__completed-list {
        padding-top: $m-space-md;

        &.m--is-leave-active {
            transition: opacity $m-transition-duration, max-height $m-transition-duration-lg;
        }

        &.m--is-leave-to {
            opacity: 0;
            max-height: 0;
        }

        &__wrap {
            margin: 0;
            max-height: initial;

            li {
                max-height: $m-file-upload-max-height--s;
                display: flex;

                &:last-child {
                    .m-file-upload__completed-list__content {
                        margin-bottom: 0;
                    }
                }

                &.m--is-leave-active {
                    transition: opacity $m-transition-duration, max-height $m-transition-duration-lg;
                }

                &.m--is-leave-to {
                    opacity: 0;
                    max-height: 0;
                }
            }
        }

        &.m--has-border {
            border-top: $m-border-width-sm solid $m-color-grey-light;
            margin-top: $m-space-md;
        }

        &__content {
            display: flex;
            flex: 1 1 auto;
            align-items: center;
            margin-bottom: $m-space-sm;
        }

        &__file-icon {
            display: flex;
            align-items: center;
        }

        &__infos {
            flex: 1 1 auto;
            padding: 0 16px;
        }

        &__infos-label,
        &__infos-size {
            margin-top: 0;
            line-height: 1;
        }

        &__infos-label {
            font-weight: $m-font-weight-semi-bold;
            padding-bottom: $m-space-2xs;
            word-break: break-all;
        }

        &__infos-size {
            color: $m-color-grey-dark;
            @include m-font-size('xs');
        }

        &__button:active::before {
            width: 32px !important;
            height: 32px !important;
        }
    }

    &__footer-cancel {
        margin-left: $m-space-sm;
    }
}
