@use '../variables';
@use '../mixins/border-radius' as br;
@use '../mixins/scrollbars';
@use '../buttons';

nw-angular-picker {
    @include scrollbars.scrollbars();

    .disabled {
        opacity: 0.5;
    }

    .nw-picker {
        position: relative;
    }
    .input-container {
        position: relative;
    }
    .input-placeholder {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        padding: 9px 12px;
        font-size: 14px;
        line-height: 1;
    }
    .search-input {
        cursor: pointer;

        &[aria-expanded='true'] {
            ~ .input-placeholder {
                display: none;
            }
        }
        &:not([aria-expanded='true']) {
            @extend .btn-secondary;

            &::placeholder {
                color: transparent;
            }
        }
        ~ .dropdown-icon,
        ~ .reset-icon {
            position: absolute;
            right: 10px;
            font-size: 18px;
            font-weight: 100;
            top: 50%;
            transform: translateY(-50%);
            cursor: pointer;
        }
        ~ .reset-icon {
            color: variables.get-color('gray');
            right: 5px;
        }
    }
    .scroll-container {
        overflow-y: auto;
        max-height: 400px;

        @media (max-width: variables.$screen-sm) {
            flex: 1;
            max-height: unset;
        }
    }
    .results-actions {
        display: flex;
        justify-content: space-between;
        padding: 0 8px;
        line-height: 32px;
        color: variables.get-color('gray');
        border-bottom: 1px solid variables.$divider-color-primary;
    }
    .search-results {
        position: absolute;
        width: 100%;
        margin-bottom: 24px;
        background-color: #fff;
        z-index: 10;

        .picker-options-list,
        .selected-items {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .no-results-text,
        .no-selections-text {
            padding: 8px;
            margin: 0;
            font-style: italic;
        }

        .search-result,
        .parent {
            position: relative;
            padding-left: 8px;
            font-size: 14px;
            color: variables.get-color('gray');
            cursor: pointer;

            &:hover,
            &.keyboard-focused {
                background: variables.get-color('coolgray', 5x-light);
            }

            &.keyboard-focused {
                outline: 2px solid variables.$primary-base;
                outline-offset: -2px;
            }
            .item-label {
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                flex: 1;
            }
            .btn-ghost:not(:hover) {
                color: variables.get-color('gray');
            }
            .result-item {
                display: flex;
                flex-direction: row;
                align-items: center;
                line-height: 32px;

                input[type='checkbox']:focus:not(:focus-visible) ~ label::before {
                    outline: none;
                    box-shadow: none;
                }

                .checkbox {
                    margin: 0;
                }
            }
            &.excluded {
                .item-label {
                    text-decoration: line-through;
                }
            }
            .drilldown {
                @include br.border-left-radius(0);
                &:focus-visible {
                    outline: 2px solid variables.$primary-base;
                    outline-offset: -2px;
                }
            }
        }
        .picker-action {
            color: variables.get-color('primary', base);
            font-size: 13px;
        }
        @media (max-width: variables.$screen-sm) {
            display: flex;
            flex-direction: column;
            position: fixed;
            top: 0;
            left: 0;
            height: 100%;
            padding: 0;
            max-height: initial;
            overflow-y: auto;
            z-index: 100;

            &.slide-up-in {
                animation: picker-slide-up-in 200ms linear forwards;
            }
            &.slide-down-out {
                animation: picker-slide-down-out 200ms linear forwards;
            }
        }
        .results-header {
            display: none;
            height: 50px;
            line-height: 45px;
            padding: 0 12px;
            width: 100%;
            font-size: 32px;
            border-bottom: 1px solid variables.$divider-color-primary;

            @media (max-width: variables.$screen-sm) {
                display: flex;
                justify-content: flex-end;
            }
        }
        .results-footer {
            padding: 8px;
            border-top: 1px solid variables.$divider-color-primary;
            button {
                &:focus-visible {
                    outline: none;
                    box-shadow:
                        0 0 0 2px white,
                        0 0 0 4px variables.$primary-base;
                }
            }
        }
    }

    @keyframes picker-slide-up-in {
        from {
            top: 100%;
            transform: scale(0);
        }
        to {
            top: 0;
            transform: scale(1);
        }
    }

    @keyframes picker-slide-down-out {
        from {
            top: 0;
            transform: scale(1);
        }
        to {
            top: 100%;
            transform: scale(0);
        }
    }
}
