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

.dash-width-resizer-container {
    position: absolute;
    top: 0;
    right: 20px;
    bottom: 100%;
    height: 100%;
}

.dash-height-resizer-container {
    position: absolute;
    right: 10px;
    bottom: 20px;
    left: 10px;
    height: 0;
}

.dash-width-resizer-hotspot,
.resizer-drag-preview {
    display: flex;
    justify-content: center;
    width: 20px;
    cursor: col-resize;
}

.dash-height-resizer-hotspot,
.height-resizer-drag-preview {
    position: absolute;
    display: flex;
    align-items: center;
    overflow: hidden;
    height: 40px;
    cursor: row-resize;
}

.dash-height-resizer-hotspot {
    width: 100%;
}

.gd-fluidlayout-width-resizer {
    height: 100%;
    padding: 0 4px;

    &.active {
        background-color: variables.$gd-palette-primary-base-t85;
    }

    &.error {
        background-color: kit-variables.$gd-palette-error-dimmed;
    }

    .width-resizer-line {
        height: 100%;
        border-left: 2px dashed;

        &.default {
            border-color: kit-variables.$gd-color-disabled;
        }

        &.muted {
            border-color: kit-variables.$gd-color-text;
        }

        &.active {
            border-color: kit-variables.$gd-palette-primary-base;
        }

        &.error {
            border-color: kit-variables.$gd-palette-error-base;
        }
    }
}

.gd-fluidlayout-height-resizer {
    width: 100%;
    height: 10px;
    padding: 4px 0;

    &.active {
        background-color: variables.$gd-palette-primary-base-t85;
    }

    &.error {
        background-color: kit-variables.$gd-palette-error-dimmed;
    }

    .height-resizer-line {
        width: 100%;
        border-top: 2px dashed;
        border-color: kit-variables.$gd-palette-primary-base;

        &.default {
            border-color: kit-variables.$gd-color-disabled;
        }

        &.muted {
            border-color: kit-variables.$gd-color-text;
        }

        &.active {
            border-color: kit-variables.$gd-palette-primary-base;
        }

        &.error {
            border-color: kit-variables.$gd-palette-error-base;
        }
    }
}

.sdk-edit-mode-on {
    .resizer-drag-preview,
    .dash-height-resizer-hotspot,
    .dash-width-resizer-hotspot,
    .height-resizer-drag-preview {
        z-index: zIndexes.$resize-basic;
    }

    .dash-width-resizer-hotspot {
        position: absolute;
        left: 10px;
        overflow: hidden;
        height: 100%;
    }

    .gd-resize-overlay,
    .gd-resize-overlay-text {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        margin: 5px;
    }

    .gd-resize-overlay {
        z-index: zIndexes.$resize-basic-overlay;
        border-width: 0;
        border-radius: calc(#{variables.$gd-dashboards-content-widget-borderRadius} + 5px);
        background-color: var(--gd-palette-complementary-0-t50, rgba(255, 255, 255, 0.5));

        &.active {
            background-color: variables.$gd-palette-primary-base-mix15-white;
        }

        &.error {
            background: variables.$gd-palette-primary-base-mix15-white;
        }

        &.squared {
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: 0;
            border-radius: 0;
        }
    }

    .gd-resize-overlay-text {
        z-index: zIndexes.$resize-basic-overlay-text;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 5px;
        color: var(--gd-palette-complementary-6-from-theme, variables.$info-text-color);
        font-weight: bold;
        text-align: center;
    }
}

.gd-resize-bullet {
    width: 10px;
    height: 10px;
    padding-left: 2px;
    padding-right: 2px;
}

.gd-resize-bullet-icon {
    display: block;
    width: 6px;
    height: 6px;

    .active {
        fill: kit-variables.$gd-palette-primary-base;
    }

    .initial {
        fill: var(--gd-palette-complementary-9, #000);
    }

    .passive {
        fill: var(--gd-palette-complementary-6-from-theme, kit-variables.$default-gd-color-disabled);
    }
}

.gd-resize-bullets-bar {
    position: absolute;
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 10px 15px 8px;
    background: var(
        --gd-dashboards-content-backgroundColor-from-theme,
        var(--gd-palette-complementary-0-from-theme, rgba(255, 255, 255, 0.95))
    );
}

.gd-grid-layout-width-resizer-drag-preview {
    &.gd-first-container-row-widget {
        .gd-fluidlayout-width-resizer__container {
            padding-top: 0;
        }
    }
}

.gd-grid-layout-resizer-drag-preview,
.gd-grid-layout {
    .gd-fluidlayout-width-resizer__container {
        padding: 10px 0;
        border-radius: 4px;
    }

    .gd-fluidlayout-width-resizer {
        display: flex;
        flex-direction: column;
        border-radius: 4px;
        align-items: center;
        padding: 0;

        .width-resizer-line {
            flex: 1 0 auto;
            width: 0;
            height: unset;
        }
    }

    .dash-height-resizer-container {
        position: relative;
        right: unset;
        bottom: unset;
        left: unset;
        height: 0;
    }

    .width-resizer-drag-handler {
        $width-resizer-center-size: 10px;

        width: $width-resizer-center-size;
        height: $width-resizer-center-size;
        border: 2px solid;
        border-radius: 3px;
        flex: 0 0 $width-resizer-center-size;

        &.default {
            border-color: kit-variables.$gd-color-disabled;
        }

        &.muted {
            border-color: kit-variables.$gd-color-text;
        }

        &.active {
            border-color: kit-variables.$gd-palette-primary-base;
        }

        &.error {
            border-color: kit-variables.$gd-palette-error-base;
        }
    }

    .gd-fluidlayout-height-resizer {
        padding: 0;
        margin-top: 7px;
        display: flex;
        flex-direction: row;
        border-radius: 4px;

        .height-resizer-line {
            flex: 1 0 auto;
            margin-top: 4px;
            width: unset;
        }
    }
}

.gd-grid-layout-resizer-drag-preview.height-resizer-drag-preview {
    height: 20px;
}

.gd-grid-layout {
    .dash-width-resizer-container {
        position: absolute;
        right: -20px;
        width: 20px;
        display: flex;
        justify-content: center;

        &.gd-first-container-row-widget {
            .gd-fluidlayout-width-resizer__container {
                padding-top: 0;
            }
        }
    }

    .gd-fluidlayout-width-resizer__container {
        background: variables.$gd-dashboards-content-backgroundColor;
        width: 20px;
        display: flex;
        justify-content: center;
    }

    .dash-height-resizer-hotspot {
        position: absolute;
        bottom: -6px;
        display: flex;
        height: 20px;
    }

    .gd-hover-detector {
        width: 100%;
        height: 100%;
    }

    .gd-resize-overlay {
        top: 5px;
        bottom: 5px;
        left: -5px;
        right: -5px;
        border-radius: calc(#{variables.$gd-dashboards-content-widget-borderRadius});
    }

    .gd-resize-overlay.gd-first-container-row-widget {
        top: -5px;
    }
}

.sdk-edit-mode-on .gd-grid-layout {
    .dash-width-resizer-hotspot {
        position: static;
        width: 20px;
        display: flex;
        justify-content: center;
    }

    .gd-resize-overlay-text {
        right: -10px;
        left: -10px;
    }
}

.gd-grid-layout__ruler {
    // layout must not jump when ruler is displayed and must be visible at the top also when page is scrolled out
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding: 20px;

    .gd-grid-layout__item--span-1 {
        position: relative;
    }

    .gd-resize-bullet {
        position: relative;
        left: -13px;
        width: 6px;
        height: 6px;
        padding-left: 0;
        padding-right: 0;
    }

    .gd-resize-bullet--last {
        position: absolute;
        top: 0;
        right: -13px;
        left: unset;
    }
}

.gd-grid-layout-ruler {
    $root: &;

    --bullet-size: 6px;
    --bullet-size-active: 9px;
    --gap: 20px;

    padding: 20px 0 20px var(--gap);
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    pointer-events: none;

    &__grid {
        flex-grow: 1;
        flex-shrink: 0;
        display: grid;
        gap: var(--gap);
        grid-template-columns: repeat(var(--columns-num), 1fr);
        grid-template-rows: auto;
        justify-content: start;
        align-items: stretch;
    }

    &__bullet-container {
        width: var(--gap);
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
        left: calc(var(--gap) * -1);

        &--last {
            left: 0;
        }
    }

    &__bullet {
        width: var(--bullet-size);
        height: var(--bullet-size);
        border-radius: 100%;
        background-color: var(
            --gd-palette-complementary-6-from-theme,
            kit-variables.$default-gd-color-disabled
        );
        position: absolute;

        opacity: 0;
        transform: translateY(-20px);
        transition:
            transform 0.2s ease-out,
            opacity 0.1s ease-in,
            width 0.1s ease-out,
            height 0.1s ease-out;

        #{$root}--active & {
            opacity: 1;
            transform: translateY(0);
        }

        &--active {
            background-color: kit-variables.$gd-palette-primary-base;
            width: var(--bullet-size-active);
            height: var(--bullet-size-active);
        }

        &--initial {
            background-color: var(--gd-palette-complementary-9, #000);
        }
    }
}
