// (C) 2024-2025 GoodData Corporation
@use "sass:color";
@use "variables";
@use "zIndexes";
@use "@gooddata/sdk-ui-kit/styles/scss/variables" as kit-variables;

.gd-dashboard-nested-layout-widget {
    .gd-dashboard-nested-layout-content.dash-item-content {
        border-radius: 0;
        padding: 19px 10px 15px 10px;
    }

    & .is-selectable {
        &.gd-dashboard-nested-layout-content.dash-item-content:not(.is-selected):hover,
        &.gd-dashboard-nested-layout-content.dash-item-content.is-dragging-widget {
            border-style: solid;
        }

        &.dash-item-content:not(.is-selected):hover
            > .gd-dashboard-nested-layout-widget-visualization-content:first-child
            > .gd-dashboard-nested-layout-tab:not(.is-selected),
        &.dash-item-content.is-dragging-widget .gd-dashboard-nested-layout-tab {
            display: flex;
            color: kit-variables.$gd-color-link;
            background-color: kit-variables.$is-focused-background;

            .gd-dashboard-nested-layout-tab__text {
                background-color: kit-variables.$is-focused-background;
            }
        }
    }

    & .gd-dashboard-nested-layout-tab.is-selected {
        display: flex;
        color: kit-variables.$gd-color-text-light;
        background-color: kit-variables.$gd-palette-primary-base;

        .gd-dashboard-nested-layout-tab__text {
            background-color: kit-variables.$gd-palette-primary-base;
        }

        path {
            fill: kit-variables.$gd-color-text-light;
        }
    }

    .drop-target-inner {
        align-content: center;
        height: 100%;

        p {
            font-size: 18px;
        }
    }
}

.gd-dashboard-nested-layout-tab {
    display: none;
    width: auto;
    padding: 2px 5px;
    font-size: 11px;
    position: absolute;
    left: calc(0px - #{variables.$gd-dashboards-content-widget-borderWidth});
    top: calc(0px - #{variables.$gd-dashboards-content-widget-borderWidth});
    z-index: zIndexes.$drag-and-drop-container-draggable-tab;

    & > .gd-dashboard-nested-layout-tab__icon {
        display: block;
        position: absolute;
        width: 6px;
        height: 10px;
        margin-top: 2px;
        margin-right: 5px;
    }

    & > .gd-dashboard-nested-layout-tab__text {
        z-index: 1;
        margin-left: 11px;
    }
}

.gd-dashboard-nested-layout-widget-visualization-content {
    width: 100%;
    height: 100%;

    .drag-info-placeholder-inner {
        padding: 0;
    }

    .drag-info-placeholder-box,
    .drag-info-placeholder-drop-target {
        width: 100%;
        height: 100%;
        margin: 0;
        align-content: center;
    }

    .drag-info-placeholder {
        padding: 0 0 0 10px;
    }

    .drag-info-empty-nested-layout {
        align-items: center;
        display: flex;
        flex-direction: column;
        gap: 8px;
        height: 100%;
        justify-content: center;
    }
}

.gd-grid-layout {
    .gd-fluidlayout-column-dropzone {
        height: 100%;
    }

    .gd-empty-dashboard-dropzone {
        .drag-info-placeholder-inner,
        .drag-info-placeholder-drop-target {
            height: 100%;
        }

        .drop-target-inner {
            align-content: center;
            height: 100%;
        }

        .drag-info-placeholder {
            min-height: 300px;
        }
    }
}

// Definition of horizontal and vertical hot and drop zones.
.gd-grid-layout-dropzone {
    $dropzoneRoot: &;
    z-index: zIndexes.$drag-and-drop-drop-zone;

    &--type-prev,
    &--type-next {
        position: absolute;
    }

    &--type-prev {
        .drop-hint {
            float: left;
            margin-left: -3px;
        }
    }

    &--type-next {
        .drop-hint {
            float: right;
            margin-left: 3px;
        }
    }

    &--hidden {
        display: none;
    }

    // definition of horizontal drop zones
    &--direction-row {
        &#{$dropzoneRoot}--type-prev,
        &#{$dropzoneRoot}--type-next {
            top: 0;
            bottom: 0;
            width: 50%;

            &#{$dropzoneRoot}--full {
                width: 100%;
            }
        }

        &#{$dropzoneRoot}--type-prev {
            left: 0;

            &#{$dropzoneRoot}--active {
                #{$dropzoneRoot}__drop-target--direction-row {
                    left: -15px;
                }
            }
        }

        &#{$dropzoneRoot}--type-next {
            right: 0;

            &#{$dropzoneRoot}--active {
                #{$dropzoneRoot}__drop-target--direction-row {
                    right: -15px;
                }
            }
        }

        &#{$dropzoneRoot}--extended {
            width: 100%;
        }

        &#{$dropzoneRoot}--isOverNestedLayout {
            &#{$dropzoneRoot}--type-prev,
            &#{$dropzoneRoot}--type-next {
                // nested container has has narrower hotspot so it is possible to drop widget into it, while
                // the non-container widgets inside of it are split half and half (50%)
                width: 50px;
            }
        }
    }

    // definition of vertical drop zones
    &--direction-column {
        &#{$dropzoneRoot}--type-prev,
        &#{$dropzoneRoot}--type-next {
            right: 0;
            left: 0;
            height: 50%;

            &#{$dropzoneRoot}--full {
                width: 100%;
                height: 100%;
            }
        }

        &#{$dropzoneRoot}--type-prev {
            top: 0;

            &#{$dropzoneRoot}--active {
                #{$dropzoneRoot}__drop-target--direction-column {
                    top: -5px; // shift above the widget, in the middle of space between two widgets
                }
            }
        }

        &#{$dropzoneRoot}--type-next {
            bottom: 0;

            &#{$dropzoneRoot}--active {
                #{$dropzoneRoot}__drop-target--direction-column {
                    bottom: -5px; // shift below the widget, in the middle of space between two widgets
                }
            }
        }

        &#{$dropzoneRoot}--isOverNestedLayout {
            &#{$dropzoneRoot}--type-prev,
            &#{$dropzoneRoot}--type-next {
                // nested container has has narrower hotspot so it is possible to drop widget into it, while
                // the non-container widgets inside of it are split half and half (50%)
                height: 50px;
            }
        }

        &#{$dropzoneRoot}--isInFirstRow {
            &#{$dropzoneRoot}--type-prev {
                &#{$dropzoneRoot}--active {
                    // stylelint-disable-next-line max-nesting-depth
                    #{$dropzoneRoot}__drop-target--direction-column {
                        top: -15px; // the first widget does not have same padding as the subsequent ones
                    }
                }
            }
        }
    }

    // drop target inside of the drop zone
    &__drop-target {
        display: none;
        position: absolute;

        &--direction-row {
            padding: 10px 0;
            width: 10px;
            height: 100%;

            #{$dropzoneRoot}__drop-target-inner {
                width: 4px;
            }
        }

        &--direction-column {
            padding: 0;
            width: 100%;
            height: 10px;

            #{$dropzoneRoot}__drop-target-inner {
                width: 100%;
            }
        }

        &#{$dropzoneRoot}--isInFirstRow {
            padding-top: 0;
        }
    }

    &--active {
        #{$dropzoneRoot}__drop-target {
            display: block;
        }
    }

    &__drop-target-border {
        width: 100%;
        height: 100%;
        padding: 2px;
        border: 1px dashed kit-variables.$gd-palette-primary-base;
        border-radius: 15px;
        background-color: kit-variables.$gd-palette-primary-dimmed;
    }

    &__drop-target-inner {
        height: 100%;
        padding: 0;
        border-radius: 2px;
        background-color: kit-variables.$gd-palette-primary-base;
    }
}
