@use "../globals/" as *;
@use "../util/" as *;



.tabs {
    display: flex;
    flex-direction: column;

    &.tabs-reverse {
        flex-direction: column-reverse;
    }

    &.tabs-vertical {
        flex-direction: row;
    }

    &.tabs-vertical-reverse {
        flex-direction: row-reverse;
    }

    &.tabs-rounded {
        border-radius: $base-border-radius;

        .tabs-toolbar {
            border-radius: $base-border-radius;
        }

        .tabs-panels {
            border-radius: $base-border-radius;
        }
    }
}

.tabs-toolbar {    
    position: relative;
    background-color: var(--bg-core-primary-light);

    &.tabs-border-left {
        border-top-right-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-right: 1px solid $element-fg-core;
    }

    &.tabs-border-right {
        border-top-left-radius: 0 !important;
        border-bottom-left-radius: 0 !important;
        border-left: 1px solid $element-fg-core;
    }

    &.tabs-border-top {
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-bottom: 1px solid $element-fg-core;
    }

    &.tabs-border-bottom {
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
        border-top: 1px solid $element-fg-core;
    }

    &.tabs-rounded {
        border-radius: $base-border-radius;
    }

    &.tabs-vertical {
        .tabs-toolbar-inner {
            flex-direction: column;

            .tabs-scroll-button {
                .button-root {
                    width: 100%;
                    border-radius: 0px;
                    height: 32px;

                    .icon-button-label {
                        .icon-root{
                            transform:rotate(90deg);
                        }
                    }
                }
            }
        }
    }

    & .tabs-toolbar-inner {
        display: flex;
        min-height: 48px;
        align-items: center;
    }
}


.tabs-toolbar-content {
    width: 100%;
    flex: 1 1 auto;
    display: inline-block;
    position: relative;
    white-space: nowrap;
    overflow: hidden;

    & .tabs-toolbar-wrapper {
        width: max-content;
        position: inherit;
        display: flex;
        transition: .3s cubic-bezier(.25,.8,.5,1);

        &.tabs-centered {
            margin: auto;
        }

        &.tabs-vertical {
            flex-direction: column;
        }
    }
}

.tabs-panels {
    position: relative;
    transition: .3s cubic-bezier(.25,.8,.5,1);

    &.tabs-vertical {
        display: flex;
        flex-grow: 1;
    }
}

.tab {
    width:100%;
    min-width: 160px;
    display: inline-flex;
    padding: 6px 12px;
    min-height: 48px;
    flex-shrink: 0;
    flex-shrink: 1;
    font-weight: 500;
    line-height: 1.75;
    user-select: none;
    white-space: normal;
    letter-spacing: 0.02857em;
    text-transform: uppercase;
    text-align: center;
    align-items: center;
    justify-content: center;
    transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;

    &:hover {
        cursor: pointer;
        background-color: var(--bg-core-primary-lighten);
    }

    &.tab-active {
        color: var(--bg-core-primary-darken);

        &:hover {
            background-color: var(--bg-core-primary-darken);
            color: var(--bg-core-primary-light);
        }
    }

    &.disabled {
        cursor: default;
        pointer-events: none;
        color: #ccc;
    }

    & .tab-icon-text {
        margin-right: 8px;
        margin-inline-end: 8px;
        margin-inline-start: unset;
    }
}

.tab-slider {
    position: absolute;
    background: var(--bg-core-primary-darken);

    &.tab-slider-horizontal {
        height: 2px;
        left: 0;
        bottom: 0;
        transition: left .3s cubic-bezier(.64,.09,.08,1);
        will-change: left;

        &.tab-slider-horizontal-reverse {
            top: 0px;
        }
    }

    &.tab-slider-vertical {
        width: 2px;
        right: 0;
        transition: top .3s cubic-bezier(.64,.09,.08,1);
        will-change: top;

        &.tab-slider-vertical-reverse {
            left: 0;
            right: unset;
        }
    }
}

.tab-badge{
    margin-left:8px;
    margin-inline-start: 8px;
    margin-inline-end: unset;
}

@each $key, $val in $theme-colors {
    .tabs-toolbar-#{$key} {
        background-color: $val;
        color: set-color($val);

        .tab-slider {
            background: lighten($val, 10);
        }

        .tab {
            &.tab-active {
                color: darken($val, 10);

                &:hover {
                    background-color: darken($val, 20);
                }
            }
        }
    }
}



.tab-transition {
    &-enter {
        transform: translate(100%, 0);
    }

    &-leave, &-leave-active {
        position: absolute;
        top: 0;
    }

    &-leave-to {
        position: absolute;
        transform: translate(-100%, 0);
    }
}

.tab-reverse-transition {
    &-enter {
        transform: translate(-100%, 0);
    }

    &-leave, &-leave-to {
        top: 0;
        position: absolute;
        transform: translate(100%, 0);
    }
}

.dynamic-tabs {
    .tabs-toolbar {
        .tab {
            padding: 6px 14px;

            .icon-button {
                padding: 4px;
                margin-right: -4px;
                margin-inline-end: -4px;
                margin-inline-start: unset;
            }

            .tabs-panel-header-before {
                padding-right: 8px;
                padding-inline-end: 8px;
                padding-inline-start: unset;
            }

            .tabs-panel-header-after {
                padding-left: 8px;
                padding-inline-start: 8px;
                padding-inline-end: unset;
            }
        }
    }
}

.tabs-header {
    &.tabs-header-before {
        display: inherit;
    }

    &.tabs-header-after {
        display: inherit;
    }
}

.tabs-panel-header {
    display: flex;
    flex: 1 1 auto;

    &.tabs-panel-header-before {
        justify-content: flex-start;
    }

    &.tabs-panel-header-after {
        justify-content: flex-end;
    }
}

