////
/// @group themes
/// @access public
/// @author <a href="https://github.com/desig9stein" target="_blank">Marin Popov</a>
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
////

/// @param {Map} $palette [$default-palette] - The palette used as basis for styling the component.
/// @param {Map} $schema [$light-schema] - The schema used as basis for styling the component.
/// @param {Color} $search-separator-border-color [null] - The combo search box separator color.
/// @param {Color} $empty-list-placeholder-color [null] - The combo placeholder text color.
/// @param {Color} $empty-list-background [null] - The combo list background color.
///
/// @requires $default-palette
/// @requires $light-schema
/// @requires apply-palette
/// @requires extend
@function igx-combo-theme(
    $palette: $default-palette,
    $schema: $light-schema,
    $search-separator-border-color: null,
    $empty-list-placeholder-color: null,
    $empty-list-background: null
) {
    $name: 'igx-combo';
    $combo-schema: ();

    @if map-has-key($schema, $name) {
        $combo-schema: map-get($schema, $name);
    } @else {
        $combo-schema: $schema;
    }

    $theme: apply-palette($combo-schema, $palette);

    @return extend($theme, (
        name: $name,
        palette: $palette,
        search-separator-border-color: $search-separator-border-color,
        empty-list-placeholder-color: $empty-list-placeholder-color,
        empty-list-background: $empty-list-background
    ));
}

/// @param {Map} $theme - The theme used to style the component.
/// @requires {mixin} igx-root-css-vars
/// @requires rem
/// @requires --var
@mixin igx-combo($theme) {
    @include igx-root-css-vars($theme);

    $left: if-ltr(left, right);
    $right: if-ltr(right, left);

    %igx-combo {
        position: relative;
        display: block;

        %igx-button--icon {
            width: rem(24px);
            height: rem(24px);
        }
    }

    %igx-combo__checkbox {
        margin-#{$right}: rem(8);
    }

    %igx-combo__drop-down {
        position: absolute;
        width: 100%;

        .igx-drop-down {
            width: 100%;
        }
    }

    %igx-combo__search {
        padding: rem(8px) rem(16px);
        margin: 0 !important;
        z-index: 26;
        border-bottom: 1px dashed --var($theme, 'search-separator-border-color');
    }

    %igx-combo__content {
        position: relative;
        overflow: hidden;

        &:focus {
            outline: transparent;
        }
    }

    %igx-combo__add {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: relative;
        padding: rem(16px);
        background: --var($theme, 'empty-list-background');
    }

    %igx-combo__empty {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        color: --var($theme, 'empty-list-placeholder-color');
        padding: 0 rem(24px);
        font-size: rem(13px);
    }

    // TODO: make this part better
    %igx-combo__add-item {
        &%igx-drop-down__item {
            width: auto !important;
            padding: 0 !important;

            &:hover {
                background: transparent!important;
            }
        }

        &%igx-drop-down__item--focused {
            &:focus {
                background: transparent!important;
            }
        }
    }
}
