.buttonWrap {
    width: fit-content;
}

.droppable {
    display: grid;
    grid-template-columns: minmax(0, 1fr);

    &:not(:empty) {
        padding-top: var(--space-s);
    }

    &.droppable-picture-card {
        padding-top: initial;
    }

    &__item {
        margin: 0 0 8px;

        &--dragged {
            filter: brightness(90%);
        }

        &--picture_card {
            margin: 0 8px 0 0;
        }

        &--text_type {
            margin: 0 0 2px;
        }
    }
}

.droppable-picture-card {
    display: flex;
    flex-wrap: wrap;
}

$item-border-width: 1px;
$item-padding: calc(var(--control-space-m) / 2);
$item-height: calc(var(--control-height-m) + #{$item-padding}* 2);

.item {
    height: var(--upload-picture-item-height, $item-height);
    padding: var(--upload-picture-item-padding, $item-padding);
    font-size: var(--upload-picture-item-fz, var(--control-text-size-m));
    line-height: 1.2;
    border: $item-border-width solid
        var(--upload-picture-item-bcolor, var(--color-control-bg-border-default));
    border-radius: var(--upload-picture-item-bradius, var(--control-radius));
    background: var(--upload-picture-item-bg, var(--color-control-bg-default));
    color: var(--upload-color, var(--color-control-typo-default));
    transition: border-color 0.2s ease;

    &__PictureCard {
        position: relative;
        height: 100%;
        min-height: 108px;

        &::before {
            content: '';
            position: absolute;
            z-index: 2;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            border: 1px solid
                var(--upload-picture-item-bcolor, var(--color-control-bg-border-default));
            border-radius: var(--upload-picture-item-bradius, var(--control-radius));
            background-color: var(--color-bg-tone);
            opacity: 0;
            transition: all 0.3s;
        }

        &:hover {
            border-color: var(
                --upload-picture-item-bcolor-hover,
                var(--color-control-bg-border-default-hover)
            );

            &::before {
                opacity: 0.8;
            }

            .item_Actions {
                opacity: 1;
            }
        }
    }

    &__TextType {
        --upload-text-type-item-bcolor-hover: var(--color-control-bg-clear-hover);
        padding: unset;
        padding-right: $item-padding;
        border: none;
        height: 100%;
        transition: background-color 0.2s;

        &:hover {
            background-color: var(--upload-text-type-item-bcolor-hover);

            .item_Actions__TextType {
                opacity: 1;
            }
        }
    }

    &__Error {
        --upload-picture-item-bcolor: var(--color-bg-alert);
        --upload-picture-item-bcolor-hover: var(--color-bg-alert);
        --upload-color: var(--color-typo-alert);
    }

    &:global(.upload) {
        display: block;
        height: 100%;
        border: none;
    }
}

.item_Content {
    display: flex;
    gap: var(--upload-picture-item-padding, $item-padding);
    align-items: center;
    height: 100%;

    &__PictureCard {
        position: relative;
    }
}

.item_Name {
    display: inline-block;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item_Actions {
    display: flex;
    flex-shrink: 0;
    gap: var(--space-3xs);

    &__PictureCard {
        opacity: 0;
        position: absolute;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 2;
    }

    &__TextType {
        transition: opacity 0.2s;
        opacity: 0;
    }
}

.item_Thumb {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    width: calc(#{$item-height} - #{$item-padding}* 2 - #{$item-border-width}* 2);
    border-radius: var(--upload-picture-item-bradius, var(--control-radius));
    overflow: hidden;
    background-color: var(--color-control-bg-clear-hover);

    &::after {
        content: '';
        display: block;
        padding-top: 100%;
    }

    svg {
        position: absolute;
        width: 16px;
        height: auto;
    }

    &__TextType {
        background-color: initial;
    }

    &__PictureCard {
        width: 86px;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;

        svg {
            font-size: 50px;
        }
    }

    &__DefaultPictureCardUpload {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 86px;
        height: 100%;
        min-height: 86px;
    }
}

.item_Image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    object-fit: cover;
}

.item_ActionButton {
    --button-bg-focus: transparent;
}

.item_Preview {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-control-bg-clear-hover);
    &__Image {
        width: 100%;
    }
    &Error {
        min-height: 290px;
    }
}

:global {
    .upload {
        &-drag {
            text-align: center;
            background: var(--color-control-bg-clear);
            border: 1px dashed var(--color-control-bg-border-default);
            border-radius: var(--control-radius);
            transition: border-color 0.2s ease, background-color 0.2s ease;
            cursor: pointer;

            &-hover,
            &:hover {
                background-color: var(--color-control-bg-clear-hover);
                border-color: var(--color-control-bg-border-default-hover);
            }

            &-container {
                height: 100%;
            }
        }

        &-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: var(--space-l);
        }

        &-disabled {
            background-color: var(--color-control-bg-disable);
            border-color: transparent;
            cursor: not-allowed;

            &.upload-btn {
                background-color: transparent;
            }

            &:hover,
            &:global(.upload-drag-hover) {
                background-color: var(--color-control-bg-disable);
                border-color: transparent;

                &.upload-btn {
                    background-color: transparent;
                }
            }
        }
    }
}

.uploadStyleExample_Img {
    margin-bottom: var(--space-2xs);
    color: var(--color-control-typo-secondary);

    svg {
        width: 50px;
        height: auto;
    }
}

.uploadStyleExample_Text {
    margin-bottom: var(--space-2xs);
    color: var(--color-typo-secondary);
}
