/* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
 * ┃ ██████ ██████ ██████       █      █      █      █      █ █▄  ▀███ █       ┃
 * ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█  ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄  ▀█ █ ▀▀▀▀▀ ┃
 * ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄   █ ▄▄▄▄▄ ┃
 * ┃ █      ██████ █  ▀█▄       █ ██████      █      ███▌▐███ ███████▄ █       ┃
 * ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
 * ┃ Copyright (c) 2017, the Perspective Authors.                              ┃
 * ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
 * ┃ This file is part of the Perspective library, distributed under the terms ┃
 * ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
 * ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
 */

:host {
    #add-expression-button:before {
        content: var(--psp-label--add-expression-button--content, "New Column");
        text-transform: uppercase;
        font-size: 0.8333333em;
    }

    .column-selector-column-title {
        display: flex;
        width: 100%;
        flex-direction: row !important;
        align-items: center;
    }

    .column_name {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 0 1 auto;
        padding-left: 6px;
        display: inline-block;
        align-items: center;
        line-height: normal;

        &:only-child {
            padding-right: 12px;
        }
        &.none:only-child {
            padding-left: 12px;
        }
    }

    .column-selector--spacer {
        width: 67px;
        flex: 0 100000000 67px;
    }

    /* Inactive columns need to account for expression buttons, which won't be */
    /* the last child if it has a button */
    #sub-columns .column-selector--spacer:last-child {
        width: 93px;
        flex: 0 100000000 93px;
    }

    .show-aggregate .column-selector--spacer {
        width: 0px;
    }

    .show-aggregate {
        .column_name:only-child {
            padding-right: 12px;
        }
    }

    #sub-columns .column_name:only-child {
        padding-right: 12px;
    }
}

:host {
    #add-expression {
        border: var(--column-add--border, 1px solid transparent);
        min-height: 24px;
        flex-direction: row;
        background-color: var(--psp-placeholder--background);
        border-radius: 2px;
        display: flex;
        align-items: center;
        margin-right: 7px;
        cursor: pointer;
        margin-bottom: 4px;

        /* Button icon */
        & > .icon {
            background-repeat: no-repeat;
            background-color: var(--psp--color);
            display: inline-flex;
            -webkit-mask-size: cover;
            mask-size: cover;
            margin-left: 9px;
            -webkit-mask-image: var(--psp-icon--add-expression--mask-image);
            mask-image: var(--psp-icon--add-expression--mask-image);
            &:before {
                line-height: 0;
                content: var(--psp-icon--add-expression--mask-image);
                visibility: hidden;
            }
        }

        /* Text label of the button e.g. "New Column" */
        & > span {
            align-self: center;
            margin-left: 7.5px;
            text-overflow: ellipsis;
            white-space: nowrap;
            pointer-events: none;
        }

        &.modal-target,
        &.dragdrop-hover {
            color: var(--psp--background-color);
            background-color: var(--psp--color);
            & > .icon {
                background-color: var(--psp--background-color);
            }
        }
    }

    .dragdrop-highlight {
        .pivot-column-border,
        .column-selector-column-border {
            border: 1px solid var(--psp--color);
        }
    }

    .column-selector-column-border,
    .pivot-column-border {
        &.snap-drag-image {
            background-color: var(--psp--background-color) !important;
            border: 1px solid var(--psp--color) !important;
            position: absolute !important;
            pointer-events: none;
            left: 0;
            z-index: -100000;
            width: 100%;
            height: 24px;

            .sort-icon,
            label,
            .dropdown-width-container {
                display: none;
            }

            .aggregate-selector-wrapper {
                min-width: 0px;
                max-width: 0px;
            }
        }
    }

    .column-selector-column-border {
        flex: 1 1 auto;
        overflow: hidden;
        position: relative;
        display: inline-flex;
        border: 1px solid transparent;
        border-radius: 2px;
    }

    .column-selector-border.snap-drag-image {
        & > *:not(.column_name) {
            display: none;
        }

        .column_name {
            padding-left: 6px !important;
        }
    }

    .dragdrop-highlight .column-selector-column .column-selector-border,
    .dragdrop-highlight
        .column-selector-column
        .column-selector-draggable.empty-named,
    .dragdrop-highlight
        #top_panel
        .pivot-column.column-empty
        .pivot-column-draggable {
        border-color: var(--psp--color);
    }

    .column-selector-column {
        display: flex;
        flex-direction: row-reverse;
        align-items: center;

        /* Expression column toolbar buttons */
        span.expression-edit-button,
        span.expression-delete-button {
            padding-top: 1px;
            font-family: var(--psp-button--font-family, inherit);
            cursor: pointer;
            padding: 2px 4px 0 4px;
            margin-right: 4px;
            margin-left: auto;
            border-radius: 3px;
            &:hover,
            &.is-editing {
                background-color: var(--psp--color);
                .icon {
                    background-color: var(--psp--background-color);
                }
            }
        }

        span.expression-edit-button.disabled {
            opacity: 0;
            pointer-events: none;
        }

        span.expression-delete-button {
            padding-left: 5px;
            margin-right: 8px;
            margin-left: auto;

            &:before {
                content: var(--column-close--content, "close");
            }
        }

        span.expression-delete-button + span.expression-edit-button {
            margin-left: 0px;
        }

        span.expression-edit-button .icon {
            background-repeat: no-repeat;
            background-color: var(--psp--color);
            display: inline-block;
            -webkit-mask-size: cover;
            mask-size: cover;
            -webkit-mask-image: var(--psp-icon--column-settings--mask-image);
            mask-image: var(--psp-icon--column-settings--mask-image);

            &:before {
                content: var(--psp-icon--column-settings--mask-image);
                visibility: hidden;
            }
        }

        .column-selector-draggable {
            cursor: move;
            display: flex;
            align-items: start;
            flex-grow: 1;
            color: inherit;
            box-sizing: border-box;
            flex-direction: row;
            align-items: stretch;
            position: relative;
            min-height: 28px;
            padding-bottom: 4px;

            &.show-aggregate {
                .column_name {
                    padding-left: 5px;
                }
            }

            &.empty-named {
                cursor: auto;
                padding-bottom: 0px;
                margin-bottom: 4px;
                min-height: 24px;
            }

            &:not(.empty-named) .column-selector-column-border > .drag-handle {
                margin: 0px 0 0 6px;
                flex: 0 0 auto;
                background-repeat: no-repeat;
                background-color: var(--psp--color);
                display: inline-block;
                -webkit-mask-size: cover;
                mask-size: cover;
                -webkit-mask-image: var(
                    --psp-icon--psp-icon--column-drag-handle--mask-image
                );
                mask-image: var(
                    --psp-icon--psp-icon--column-drag-handle--mask-image
                );

                &:before {
                    content: var(
                        --psp-icon--psp-icon--column-drag-handle--mask-image
                    );
                    visibility: hidden;
                }
            }
        }
    }

    .is_column_active.inactive {
        min-width: 0px;
        margin: 0 6px 0 0;
    }

    .is_column_active {
        display: inline-flex;
        overflow: hidden;
        margin-bottom: 4px;
        flex: 0 0 auto;
        cursor: pointer;
        font-size: var(--psp-column-selector--font-size, 14px);
        font-family: var(
            --column-selector--font-family,
            var(--psp-button--font-family, inherit)
        ) !important;

        &,
        &.select-mode,
        &.toggle-mode {
            margin: 0 6.5px 4px 6.5px;
        }
    }

    #selected-columns {
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #active-columns,
    #sub-columns {
        display: flex;
        flex: 0 1 auto;
        overflow-x: hidden !important;
        overflow-y: scroll;
        min-height: 20%;
    }

    #sub-columns .scroll-panel-container:before {
        font-size: var(--label--font-size, 0.75em);
        padding: var(--column_type--padding, 0px 0px 0px 0px);
        position: absolute;
        height: 28px;
        top: -30px;
        display: inline-flex;
        align-items: flex-end;
        content: var(--psp-label--all-columns--content, "All Columns");
    }

    #sub-columns .scroll-panel-container {
        margin-top: 30px;
        margin-bottom: 4px;
    }

    /* #sub-acolumns .scroll-panel-container #add-expression {
        padding-top: 28px;
        margin-top: 0;
    }   */

    #sub-columns .column-selector-column.column-selector-column-hidden {
        overflow: hidden;
        height: 0;
        margin-bottom: 0px;
    }

    #sub-columns {
        position: relative;
        flex: 0 10000000 auto;
    }

    #active-columns {
        display: flex;
        padding-bottom: 8px;
        padding-top: 6px;
    }

    #active-columns,
    #column_settings_sidebar,
    #sub-columns {
        .is_column_active {
            background-repeat: no-repeat;
            background-color: var(--psp--color);
            -webkit-mask-size: cover;
            mask-size: cover;
        }
    }

    #active-columns,
    #column_settings_sidebar {
        width: 100%;

        .is_column_active.select-mode {
            -webkit-mask-image: var(--psp-icon--radio-on--mask-image);
            mask-image: var(--psp-icon--radio-on--mask-image);

            &:before {
                line-height: 0;
                content: var(--psp-icon--radio-on--mask-image);
                visibility: hidden;
            }

            &:not(.required):hover {
                -webkit-mask-image: var(--psp-icon--radio-hover--mask-image);
                mask-image: var(--psp-icon--radio-hover--mask-image);
            }
        }

        .is_column_active.toggle-mode {
            -webkit-mask-image: var(--psp-icon--checkbox-on--mask-image);
            mask-image: var(--psp-icon--checkbox-on--mask-image);

            &:before {
                line-height: 0;
                content: var(--psp-icon--checkbox-on--mask-image);
                visibility: hidden;
            }

            &:not(.required):hover {
                -webkit-mask-image: var(--psp-icon--checkbox-hover--mask-image);
                mask-image: var(--psp-icon--checkbox-hover--mask-image);
            }
        }

        .is_column_active {
            &.required {
                opacity: 0.3;
                cursor: initial;
            }

            &.inactive {
                background: none;
            }
        }

        .column-selector-column {
            position: relative;

            .column-selector-draggable {
                width: calc(100% - 27px);
            }

            .column-selector-column-border {
                border-color: var(--psp-inactive--color);
                background-color: var(--psp--background-color);
            }

            &:before {
                font-size: var(--label--font-size, 0.75em);
                left: 0px;
                padding: var(--column_type--padding, 0px 0px 0px 0px);
                position: absolute;
                margin-top: -43px;
                content: var(--default-column-title, attr(data-label));
            }

            &[data-label] {
                margin-top: 22px;
            }
        }
    }

    .dragover,
    .column-selector-column .column-selector-draggable.empty-named {
        background-color: var(--psp-placeholder--background);
        border-color: transparent;
        border-radius: 2px;
    }

    .dragover-container .is_column_active {
        opacity: 0;
        margin: 0 6px 0 0;
        min-width: 0px;
        width: 0px;
    }

    .column-selector-column .column-selector-draggable.dragover {
        border: 1px solid var(--psp--color);
        position: relative;
        &:before {
            content: " ";
            position: absolute;
            z-index: -1;
            top: 5px;
            left: 5px;
            right: 5px;
            bottom: 5px;
            border-radius: 2px;
            background-color: var(--psp--color);
            opacity: 0.3;
        }

        & > * {
            opacity: 0;
        }
    }

    .column-selector-column {
        .column-selector-column-border {
            background-color: var(--psp-placeholder--background);
            border: 1px solid transparent;
            align-items: center;
        }
    }

    #active-columns .column-selector-column.dragdrop-hover,
    #active-columns.dragdrop-highlight .column-selector-column,
    .column-selector-column.dragdrop-hover {
        .column-selector-column-border {
            border-color: var(--psp--color);
        }
    }

    /* Inactive Columns are the columns in the column selector not currently */
    /* selected for the `columns` field of the `ViewConfig`. */
    #sub-columns {
        padding-bottom: 8px;

        &:empty {
            display: none;
            margin: 0px;
        }

        .is_column_active.select-mode {
            -webkit-mask-image: var(--psp-icon--radio-off--mask-image);
            mask-image: var(--psp-icon--radio-off--mask-image);

            &:before {
                line-height: 0;
                content: var(--psp-icon--radio-off--mask-image);
                visibility: hidden;
            }

            &:hover {
                -webkit-mask-image: var(--psp-icon--radio-hover--mask-image);
                mask-image: var(--psp-icon--radio-hover--mask-image);
            }
        }

        .is_column_active.toggle-mode {
            -webkit-mask-image: var(--psp-icon--checkbox-off--mask-image);
            mask-image: var(--psp-icon--checkbox-off--mask-image);

            &:before {
                line-height: 0;
                content: var(--psp-icon--checkbox-off--mask-image);
                visibility: hidden;
            }

            &:hover {
                -webkit-mask-image: var(--psp-icon--checkbox-hover--mask-image);
                mask-image: var(--psp-icon--checkbox-hover--mask-image);
            }
        }

        .column-selector-column {
            .column-selector-draggable {
                width: calc(100% - 27px);
            }
        }
    }
}
