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

@import '../../../utilities/sizeToken.module.scss';
@import '../../../utilities/transitions.module.scss';
@import '../../../utilities/mediaQuery.module.scss';

.content,
.subContent {
    display: block;
    border-radius: var(--radius);
    background-color: var(--base-color);
    border: var(--line-width) solid var(--line-color);
    box-shadow: var(--shadow-matrix);
    width: 250px;
    overflow: auto;
    max-height: var(--radix-dropdown-menu-content-available-height);

    &:focus-within {
        border-color: var(--line-color-x-strong);
    }

    &[data-padding='compact'] .item,
    &[data-padding='compact'] .subTrigger {
        padding: sizeToken(2) sizeToken(5);
    }

    &[data-padding='comfortable'] .item,
    &[data-padding='comfortable'] .subTrigger {
        padding: sizeToken(3) sizeToken(5);
    }

    @include sm {
        width: auto;
        min-width: 250px;
        max-width: 350px;
    }
}

.subContent {
    margin-left: sizeToken(2);
}

.item,
.subTrigger {
    @include transition-colors;
    display: flex;
    align-items: center;
    gap: sizeToken(1.5);
    margin: sizeToken(1);
    border-radius: sizeToken(1);
    cursor: pointer;
    text-align: start;
    font-size: var(--body-size-medium);
    line-height: var(--body-size-medium-line-height);
    color: var(--text-color-weak);
    outline-style: none;

    &[data-state='open'] {
        background-color: var(--box-neutral-color);
        color: var(--text-color);
    }

    &[data-emphasis='danger'] {
        color: var(--text-color-negative);
    }

    &[data-highlighted] {
        background-color: var(--box-neutral-color);
        color: var(--box-neutral-inverse-color-hover);
    }

    &[data-emphasis='danger'][data-highlighted] {
        background-color: var(--text-color-negative);
        color: var(--box-neutral-strong-inverse-color);
    }

    &[data-disabled] {
        cursor: not-allowed;
        color: var(--text-color-disabled);
    }

    span {
        width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .subMenuIndicator {
        order: 2;
        margin-left: auto;
    }
}

.group {
    .item ~ &,
    .group ~ & {
        border-top: var(--line-width) solid var(--line-color-strong);
    }
    &:has(+ .item) {
        border-bottom: var(--line-width) solid var(--line-color-strong);
    }
}

.slot {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: sizeToken(1.5);

    // Left slot
    &:not([data-name='right']) {
        order: -1;
    }

    // Right slot
    &[data-name='right'] {
        order: 1;
        margin-left: auto;

        & ~ .subMenuIndicator {
            margin-left: sizeToken(1.5);
        }
    }

    // 2 slots without any name should be implicitly ordered
    &:not([data-name='right']) ~ .slot:not([data-name='left']) {
        order: 1;
        margin-left: auto;

        & ~ .subMenuIndicator {
            margin-left: 0;
        }
    }
}
