// (C) 2024-2025 GoodData Corporation

@use "sass:color";
@use "variables";
@use "@gooddata/sdk-ui-kit/styles/scss/Button/variables" as button-variables;
@use "@gooddata/sdk-ui-kit/styles/scss/variables" as kit-variables;

.gd-sidebar-container {
    position: sticky;
    top: 0;
    width: 230px;
    height: 100vh;
    border-right: variables.$nav-border;

    &--resizable {
        min-width: 230px;
        width: 100%;
    }
}

.gd-resizable-sidebar {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;

    // Lift the wrapper above sibling main-content during drag so the indicator
    // rail isn't covered by widgets/charts with their own stacking context.
    &--dragging,
    &:has(.gd-resizable-sidebar__handle:focus) {
        z-index: 9999;
    }

    &__handle {
        opacity: 0;
        position: absolute;
        top: 0;
        bottom: 0;
        transform: translateX(calc(var(--drag-x, 0) - 50%));
        z-index: 2;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 6px;
        background: transparent;
        border: 0;
        cursor: col-resize;
        // Prevent the browser from claiming the first touchmove for panning
        // before pointer capture engages on pointerdown.
        touch-action: none;

        &:focus {
            outline: none;
        }

        &:disabled {
            cursor: initial;
        }

        &--dragging {
            opacity: 1;
        }

        .gd-resizable-sidebar--resizable:hover &,
        .gd-resizable-sidebar--resizable:focus-within & {
            opacity: 1;
        }
    }

    &__handle-grip {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        height: 25px;
        padding: 5px 3px;
        background: var(--gd-palette-complementary-0);
        border: 1px solid var(--gd-palette-complementary-5);
        border-radius: 2px;

        .gd-resizable-sidebar--dragging &,
        .gd-resizable-sidebar__handle:focus & {
            border: 2px solid kit-variables.$gd-color-highlight;
            border-radius: 3px;
        }

        .gd-resizable-sidebar--dragging &::after,
        .gd-resizable-sidebar__handle:focus &::after {
            content: "";
            position: absolute;
            top: 0;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            z-index: -1;
            width: 2px;
            background: kit-variables.$gd-color-highlight;
            box-shadow: 0 0 0 4px variables.$gd-palette-primary-base-t85;
        }
    }
}

.add-item-panel {
    padding: 0 7px;
}

.add-item-placeholder {
    position: relative;
    display: flex;
    align-items: center;
    height: 47px;
    padding: 0 10px 0 50px;
    border: 1px solid color.adjust(variables.$dialog-border, $alpha: -1);
    border-radius: 2px;
    font-size: 12px;
    line-height: 14px;
    color: kit-variables.$gd-color-text;
    cursor: pointer;

    &.disabled {
        color: kit-variables.$gd-color-disabled;
        cursor: default;
        user-select: none;
    }

    &:hover:not(.disabled) {
        border-color: var(
            --gd-palette-complementary-5-from-theme,
            color.adjust(variables.$dialog-border, $alpha: -0.5)
        );
        box-shadow:
            0 1px 3px 0 button-variables.$button-shadow-lighter,
            0 2px 9px 0 button-variables.$button-shadow-darker;
        background: var(
            --gd-palette-complementary-0-t10,
            color.adjust(kit-variables.$default-gd-color-white, $alpha: -0.05)
        );
    }

    &::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        display: block;
        flex: 0 0 auto;
        width: 50px;
        background-repeat: no-repeat;
        background-position: center;
    }

    &.add-panel-item {
        padding: 0 10px 0 0;

        .add-panel-item__text {
            flex-grow: 1;
            display: flex;
            align-items: center;
            gap: 10px;
            justify-content: space-between;
        }

        svg {
            margin: 0 14px;
        }

        &::before {
            content: none;
        }

        &:hover {
            .gd-add-item-placeholder-help-trigger {
                display: block;
                cursor: help;
            }
        }

        .gd-add-item-placeholder-help-trigger {
            display: none;
            flex: 0 0 auto;
            margin-left: auto;
            margin-right: 5px;
            font-weight: normal;
        }

        span {
            flex: 0 0 auto;
        }
    }

    span {
        flex: 1 1 auto;
    }
}

.gd-visualizations-related-header {
    display: flex;
    gap: 5px;
    justify-content: flex-start;
    align-items: flex-end;
    height: 100%;
    padding: 5px 0 5px 10px;
    font-size: 12px;
    line-height: 12px;
    color: kit-variables.$gd-color-state-blank;
}

.gd-container-tooltip {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    max-width: 260px;

    &__image {
        background-image: url("@gooddata/sdk-ui-dashboard/esm/assets/flexible-layouts-tooltip.gif");
        background-repeat: no-repeat;
        background-position: left top;
        background-size: contain;
        aspect-ratio: 44/27; // This needs to be updated if the image is ever changed
    }

    &__actions {
        padding-top: 10px;
        display: flex;
        gap: 10px;
        justify-content: flex-end;
        align-items: baseline;
    }
}
