/* (c) Copyright Frontify Ltd., all rights reserved. */

@import '../../../utilities/mediaQuery.module.scss';
@import '../../../utilities/sizeToken.module.scss';
@import '../../../utilities/shadow.module.scss';
@import '../../../utilities/focusStyle.module.scss';

.root {

    display: block;
    background-color: var(--base-color);
    border: var(--line-width) solid var(--line-color);
    width: 100%;
    overflow: auto;
    max-height: var(--radix-popover-content-available-height);

    &[data-rounded='medium'] {
        border-radius: var(--radius);
    }

    &[data-rounded='large'] {
        border-radius: var(--radius-large);
    }

    &[data-shadow='medium'] {
        @include shadow-md;
    }

    &[data-shadow='large'] {
        @include shadow-lg;
    }

    @include sm {
        width: var(--flyout-width);
        max-width: var(--flyout-max-width);
        margin-top: 0;
        background-color: var(--base-color);
    }

    // Mobile view flyout -> dialog responsiveness
    body > [data-radix-popper-content-wrapper]:has(&) {
        @include max-sm {
            &:has([data-side='top']),
            &:has([data-side='bottom']) {
                // Radix always leaves an 8px gap on the left side via its transform property
                width: calc(100dvw - 16px);
            }
            // This prevents overflowing of content since radix applies a min-width of max-content
            min-width: 0 !important;
        }
    }

    @include focus-outline;
}

// Responsive dialog background element
.overlay {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100dvw;
    height: 100dvh;
    background-color: var(--box-positive-strong-inverse-color);
    opacity: 0.3;
    pointer-events: none;

    @include sm {
        display: none;
    }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    border-bottom: var(--line-width) solid var(--line-color);

    .root[data-flyout-spacing='tight'] & {
        padding: sizeToken(2);
    }

    .root[data-flyout-spacing='compact'] & {
        padding: sizeToken(4);
    }

    .root[data-flyout-spacing='comfortable'] & {
        padding: sizeToken(6);
    }

    .root[data-flyout-spacing='spacious'] & {
        padding: sizeToken(10);
    }
}

.body {
    display: flex;
    flex-direction: column;
    gap: sizeToken(4);

    .root[data-flyout-spacing='tight'] & {
        padding: sizeToken(2);
    }

    .root[data-flyout-spacing='compact'] & {
        padding: sizeToken(2) sizeToken(4);
    }

    .root[data-flyout-spacing='comfortable'] & {
        padding: sizeToken(4) sizeToken(6);
    }

    .root[data-flyout-spacing='spacious'] & {
        padding: sizeToken(6) sizeToken(10);
    }
}

.footer {
    display: flex;
    justify-content: flex-end;
    gap: sizeToken(2);
    font-weight: 400;
    border-top: var(--line-width) solid var(--line-color);

    .root[data-flyout-spacing='tight'] & {
        padding: sizeToken(2);
    }

    .root[data-flyout-spacing='compact'] & {
        padding: sizeToken(4);
    }

    .root[data-flyout-spacing='comfortable'] & {
        padding: sizeToken(6);
    }

    .root[data-flyout-spacing='spacious'] & {
        padding: sizeToken(10);
    }
}

.close {
    @include focus-outline;
    cursor: pointer;
}
