/* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
 * ┃ ██████ ██████ ██████       █      █      █      █      █ █▄  ▀███ █       ┃
 * ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█  ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄  ▀█ █ ▀▀▀▀▀ ┃
 * ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄   █ ▄▄▄▄▄ ┃
 * ┃ █      ██████ █  ▀█▄       █ ██████      █      ███▌▐███ ███████▄ █       ┃
 * ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
 * ┃ 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 {
    --settings-panel-z-index: 10;
    --psp--color: #ff0000;
}

/* Shift-key affordance: while the user holds Shift, any mask-image icon
 * tagged `.shift-alt-icon` recolors to advertise that a Shift-modified
 * action is available on the underlying control. `!important` is required
 * to beat per-icon ID-scoped `background-color` rules. */
:host(.shift-active) .shift-alt-icon {
    background-color: var(
        --shift-active--color,
        var(--psp-datagrid--pos-cell--color, #1078d1)
    ) !important;
}

:host(.shift-active) {
    #sub-columns {
        .is_column_active.toggle-mode {
            -webkit-mask-image: var(--psp-icon--radio-off--mask-image);
            mask-image: var(--psp-icon--radio-off--mask-image);

            &:before {
                content: var(--psp-icon--radio-off--mask-image);
            }

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

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

            &:before {
                content: var(--psp-icon--checkbox-off--mask-image);
            }

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

    #active-columns {
        .is_column_active.toggle-mode {
            -webkit-mask-image: var(--psp-icon--radio-on--mask-image);
            mask-image: var(--psp-icon--radio-on--mask-image);

            &:before {
                content: var(--psp-icon--radio-on--mask-image);
            }

            &: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.select-mode {
            -webkit-mask-image: var(--psp-icon--checkbox-on--mask-image);
            mask-image: var(--psp-icon--checkbox-on--mask-image);

            &:before {
                content: var(--psp-icon--checkbox-on--mask-image);
            }

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

::slotted(*) {
    pointer-events: var(--override-content-pointer-events);
}

:host input[type="number"]::-webkit-inner-spin-button {
    transform: scale(1.5) translateX(-5px); /* Makes the arrows 50% larger */
    filter: var(--psp-input--filter);
}

:host .sidebar_close_button {
    position: absolute;
    top: 0;
    padding-top: calc(
        (
                var(
                        --psp-plugin-selector--height,
                        var(--psp-status-bar--height, 48px)
                    ) -
                    20px
            ) /
            2
    );
    padding-bottom: calc(
        (
                var(
                        --psp-plugin-selector--height,
                        var(--psp-status-bar--height, 48px)
                    ) -
                    20px
            ) /
            2
    );
    z-index: 10000;
    height: var(
        --psp-plugin-selector--height,
        var(--psp-status-bar--height, 48px)
    );

    &:hover {
        cursor: pointer;
    }

    .sidebar_close_button_inner {
        border-radius: 5px 0 0 5px;
        height: 20px;
        background-color: var(--psp--background-color);
    }

    .sidebar_close_button_inner .icon {
        display: inline-block;
        mask-size: cover;
        -webkit-mask-size: cover;
        background-repeat: no-repeat;
        background-color: var(--psp--color);
        mask-image: var(--psp-icon--drawer-tab--mask-image);
        -webkit-mask-image: var(--psp-icon--drawer-tab--mask-image);

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

    &:hover .sidebar_close_button_inner .icon {
        mask-image: var(--psp-icon--drawer-tab-hover--mask-image);
        -webkit-mask-image: var(--psp-icon--drawer-tab-hover--mask-image);
    }
}

:host #settings_close_button,
:host #column_settings_close_button {
    left: -21px;
}

:host #debug_close_button.sidebar_close_button .sidebar_close_button_inner {
    background-attachment: fixed;
    background: var(--psp-sidebar--background);

    .icon {
        mask-image: var(--psp-icon--drawer-tab-hover--mask-image);
        -webkit-mask-image: var(--psp-icon--drawer-tab-hover--mask-image);
    }
}

:host
    #debug_close_button.sidebar_close_button:hover
    .sidebar_close_button_inner
    .icon {
    mask-image: var(--psp-icon--drawer-tab--mask-image);
    -webkit-mask-image: var(--psp-icon--drawer-tab--mask-image);
}

:host #debug_open_button.sidebar_close_button {
    right: 0px;
    cursor: pointer;

    .sidebar_close_button_inner {
        background-color: transparent;
    }
}

:host #debug_open_button.sidebar_close_button .sidebar_close_button_inner {
    .icon {
        mask-image: var(--psp-icon--drawer-tab-inverted--mask-image);
        -webkit-mask-image: var(--psp-icon--drawer-tab-inverted--mask-image);
    }

    &:hover .icon {
        mask-image: var(--psp-icon--drawer-tab-inverted-hover--mask-image);
        -webkit-mask-image: var(
            --psp-icon--drawer-tab-inverted-hover--mask-image
        );
    }
}

:host #debug_close_button.sidebar_close_button {
    right: 0px;
}

:host(:hover) {
    #menu-bar {
        opacity: 1 !important;
    }

    #component_container #settings_button,
    #component_container #settings_button.titled {
        opacity: 1;
    }
}

:host {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    font-size: 0.75em;

    * {
        box-sizing: border-box;
        line-height: 1.25;
    }

    #component_container {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        flex-direction: column;
    }

    #app_panel {
        position: absolute;
        bottom: 0px;
        left: 0;
        right: 0;
        top: 0;
        height: auto;
        flex-direction: row-reverse;
        & > .split-panel-divider {
            border-left: 1px solid var(--psp-inactive--color, #6e6e6e);
            margin-right: -5px;
        }
    }

    #modal_panel {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
        pointer-events: none;
        & > * {
            pointer-events: all;
        }
    }

    #modal_panel > .split-panel-divider {
        border-left: 1px solid var(--psp-inactive--color, #6e6e6e);
        margin-right: -5px;
    }

    #status_bar {
        height: var(--psp-status-bar--height, 48px);
    }

    #main_column_container {
        position: relative;
        display: flex;
        flex: 1 1 auto;
        overflow: hidden;
    }

    #main_column {
        display: flex;
        flex: 1 1 auto;
        overflow: hidden;
        flex-direction: column;
        position: relative;
        margin: var(--psp-main-column--margin);
        border: var(--psp-main-column--border);
        border-width: var(--psp-main-column--border-width);
        border-radius: var(--psp-main-column--border-radius);
    }

    #main_panel_container {
        position: relative;
        height: 100%;
        box-shadow: var(--plugin--box-shadow, none);
        background: var(
            --psp-main-column--background,
            var(--psp--background-color, none)
        );
        overflow: hidden;
        border: var(--psp-plugin--border, none);
    }

    #settings_panel {
        position: relative;
        flex: 0 0 auto;
        padding: 0pc;
        padding-left: 8px;
        box-sizing: border-box;
        width: 100%;
        z-index: var(--settings-panel-z-index);

        & > .split-panel-child {
            overflow: hidden;
        }

        & > .split-panel-divider {
            border-top: 1px solid var(--psp-inactive--color, #6e6e6e);
            border-bottom: 2px solid var(--psp-inactive--color, #6e6e6e);
            margin-left: -9px;
            margin-right: 0px;
            flex: 0 0 4px;
        }
    }

    #column_settings_sidebar .split-panel-divider {
        border-top: 1px solid var(--psp-inactive--color, #6e6e6e);
        border-bottom: 2px solid var(--psp-inactive--color, #6e6e6e);
        margin-left: -9px;
        margin-right: -4px;
        flex: 0 0 4px;
    }

    .noselect {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    .sidebar_column {
        background: var(--psp-sidebar--background);
        background-attachment: fixed;

        display: flex;
        list-style: none;
        flex-direction: column;
        flex: 1;

        /* Needs 2 because it must take precedence over teh chart legend. */
        z-index: 2;
    }

    #plugin_selector {
        margin-top: 3px;
        border-bottom-width: 1px;
        border-style: solid;
        border-color: var(--psp-inactive--color, #c5c9d0);
        border-top-width: 0px;
        border-left-width: 0px;
        border-right-width: 0px;
    }

    #component_container > #settings_button {
        opacity: 0;
        position: absolute;
        top: 0;
        right: 0;
        margin: var(--settings-button--margin, 10px 36px 0 0);
        padding: 0;
    }

    #close_button {
        background-color: var(--psp--background-color);
        padding: 0px;
        overflow: hidden;
        display: var(--psp-close-button--display, none);
        align-items: center;
        justify-content: center;
        z-index: 10000;
        border: 1px solid var(--psp-inactive--color);
        border-radius: 5px;
        font-size: 10px;
        font-weight: normal;

        &:hover {
            color: var(--psp--background-color, inherit);
            background-color: var(--psp--color);
            cursor: pointer;
        }

        &:hover .icon {
            background-color: var(--psp--background-color);
        }

        .icon {
            display: inline-block;
            mask-size: cover;
            -webkit-mask-size: cover;
            background-repeat: no-repeat;
            background-color: var(--psp--color);
            mask-image: var(--psp-icon--close--mask-image);
            -webkit-mask-image: var(--psp-icon--close--mask-image);

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

    #settings_button {
        background-color: var(--psp--background-color);
        padding: 0;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 3;
        border: 1px solid var(--psp-inactive--color);
        border-radius: 5px;
        font-size: 10px;
        font-weight: normal;

        &:hover {
            color: var(--psp--background-color, inherit);
            background-color: var(--psp--color);
            cursor: pointer;
        }

        &:hover .icon {
            background-color: var(--psp--background-color);
        }

        .icon {
            display: inline-flex;
            mask-size: cover;
            -webkit-mask-size: cover;
            background-repeat: no-repeat;
            background-color: var(--psp--color);
            mask-image: var(--psp-icon--drawer-tab-inverted--mask-image);
            -webkit-mask-image: var(
                --psp-icon--drawer-tab-inverted--mask-image
            );

            &:before {
                line-height: 0;
                display: inline-flex;
                content: var(--psp-icon--drawer-tab-inverted--mask-image);
                visibility: hidden;
            }
        }
    }

    .settings_tab_bar_scroll_offset {
        margin-left: -8px;
    }

    #settings_tab_bar {
        display: flex;
        &:after {
            content: " ";
            border-bottom: 1px solid var(--psp-inactive--color);
            background-color: #00000020;
            flex: 1 0 auto;
        }

        .settings_tab {
            border-right: 1px solid var(--psp-inactive--color);
            cursor: pointer;
            padding: 6px 8px;
            font-size: var(--label--font-size, 0.75em);
            text-transform: uppercase;
            flex: 0 1 100px;
            background-color: #00000020;
            border-bottom: 1px solid var(--psp-inactive--color);
            color: var(--psp-inactive--color);
            margin-left: -1px;
            border-left: 1px solid var(--psp-inactive--color);
            &:hover {
                color: inherit;
            }
        }

        .selected_tab {
            color: inherit;
            background-color: transparent;
            border-bottom: 1px solid transparent;
            box-shadow: 0px 9px 0px -8px var(--psp-inactive--color);
            height: calc(100% - 1px);
        }
    }

    .split-panel.orient-reverse
        > .split-panel-child:not(:last-child):not(.is-width-override) {
        max-width: 300px;
    }

    .sidebar_header {
        min-height: calc(
            var(
                    --psp-plugin-selector--height,
                    var(--psp-status-bar--height, 48px)
                ) +
                1px
        );
        overflow: hidden;
        display: flex;
        flex-direction: column;
        justify-content: center;
        border-bottom: 1px solid var(--psp-inactive--color, #6e6e6e);
    }

    .sidebar_header_title {
        padding-left: 9px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        margin-right: 30px;
    }

    .sidebar_border {
        height: 2px;
        width: 100%;
        background-color: var(--psp-inactive--color, #6e6e6e);
        margin-top: 1px;
        flex-shrink: 0;
        flex-grow: 0;
    }

    #query_tabbar_tab:before {
        content: var(--psp-label--query-tab--content);
    }

    #plugin_tabbar_tab:before {
        content: var(--psp-label--plugin-tab--content);
    }

    #debug_tabbar_tab:before {
        content: var(--psp-label--debug-tab--content);
    }

    label#stack-label:before {
        content: var(--psp-label--stack--content, "Stack");
    }

    label#alt_axis-label:before {
        content: var(--psp-label--alt-axis--content, "Alt Axis");
    }
}
