@use '../variables'as *;
@use '../mixins'as *;

$tab-color-indicator      : $component-color-muted;
$tab-color-indicator-dark : $component-color-muted-dark;

$tab-color     : $component-color-default;
$tab-color-dark: $component-color-default-dark;

$tab-color-accent    : $component-background-accent;
$tab-color-secondary : $component-background-secondary;

$tab-color-accent-dark    : $component-background-accent-dark;
$tab-color-secondary-dark : $component-background-secondary-dark;

$tab-border-color      : $component-border-default;
$tab-border-color-dark : $component-border-default-dark;

$tab-border-bottom: 1px solid $tab-border-color;
$tab-border-aside : 1px solid $tab-border-color;

$tab-border-color-dark: $tab-border-color-dark;

$tab-transition-time   : $animation-duration-short;
$tab-font-weight-active: $text-weight-semi-bold;

$tab-item-hover-background     : $component-background-shade;
$tab-item-hover-background-dark: $component-background-shade-dark;

@mixin pointer {
    cursor     : pointer;
    user-select: none;
}

@mixin tab {
    ul.#{$prefix}-tab {
        list-style   : none;
        margin       : 0px;
        padding      : 0px;
        border-bottom: $tab-border-bottom;

        li {
            display   : inline-block;
            box-sizing: border-box;

            a {
                display: block;
                @include component-padding;
                @include link-decoration($tab-color);
                // @include list-element-interaction($tab-item-hover-background);

                appearance : none;
                user-select: none;

                &:hover {
                    @include text-shadow($tab-color);
                }

                &:active,
                &:focus {
                    box-shadow: none !important;
                }
            }

            &.#{$prefix}-active {
                a {
                    font-weight: $tab-font-weight-active;
                }
            }
        }
    }
}

@mixin tab-underline {
    ul.#{$prefix}-tab.#{$prefix}-underline {
        li {
            a {
                position: relative;

                &:before {
                    position        : absolute;
                    content         : "";
                    height          : 2px;
                    background-color: $tab-color-indicator;
                    width           : 100%;
                    left            : 50%;
                    transform       : translateX(-50%) scale(0, 1);
                    bottom          : -1px;
                    border-radius   : 4px;
                    transition      : transform $tab-transition-time ease-out;
                }

                &:hover {
                    &:before {
                        transform: translateX(-50%) scale(0.6, 1);
                    }

                }

                &:active,
                &:focus {

                    &:before {
                        transform: translateX(-50%) scale(0.8, 1);
                    }
                }
            }

            &.#{$prefix}-active {
                a {
                    &:before {
                        background-color: $tab-color;
                        transform       : translateX(-50%) scale(0.6, 1);
                    }

                    &:hover {
                        &:before {
                            transform: translateX(-50%) scale(0.8, 1);
                        }
                    }

                    &:focus,
                    &:active {
                        &:before {
                            transform: translateX(-50%) scale(1, 1);
                        }

                    }
                }
            }
        }
    }
}

@mixin tab-side {
    ul.#{$prefix}-tab {
        &.#{$prefix}-tab-side {
            border-right : $tab-border-aside;
            border-bottom: none;

            li {
                display: list-item;

                a {
                    position: relative;
                    display : block;
                }
            }
        }

        &.#{$prefix}-tab-side-reverse {
            border-left  : $tab-border-aside;
            border-bottom: none;

            li {
                display: list-item;

                a {
                    position: relative;
                    display : block;
                }
            }
        }
    }
}


@mixin tab-underline-side {
    ul.#{$prefix}-tab.#{$prefix}-underline {
        &.#{$prefix}-tab-side {
            border-right : $tab-border-aside;
            border-bottom: none;

            li {
                display: list-item;

                a {
                    position: relative;
                    display : block;

                    &:before {
                        content      : "";
                        position     : absolute;
                        width        : 2px;
                        height       : 100%;
                        left         : calc(100% -1px);
                        top          : 50%;
                        border-radius: 4px;
                        transform    : translateY(-50%) scale(1, 0);
                        transition   : transform $tab-transition-time ease-out;
                    }

                    &:hover {
                        &:before {
                            transform: translateY(-50%) scale(1, 0.6);
                        }
                    }

                    &:active,
                    &:focus {
                        &:before {
                            transform: translateY(-50%) scale(0.8, 1);
                        }

                        box-shadow: none !important;
                    }
                }


                &.#{$prefix}-active {
                    a {
                        &:before {
                            transform: translateY(-50%) scale(1, 0.6);
                        }

                        &:hover {
                            &:before {
                                transform: translateY(-50%) scale(0.8, 1);
                            }
                        }

                        &:focus,
                        &:active {
                            &:before {
                                transform: translateY(-50%) scale(1, 1);
                            }
                        }
                    }

                }
            }
        }

        &.#{$prefix}-tab-side-reverse {
            border-left  : $tab-border-aside;
            border-bottom: none;

            li {
                display: list-item;

                a {
                    position: relative;
                    display : block;

                    &:before {
                        content      : "";
                        position     : absolute;
                        width        : 2px;
                        height       : 100%;
                        left         : -1px;
                        top          : 50%;
                        border-radius: 4px;
                        transform    : translateY(-50%) scale(1, 0);
                        transition   : transform $tab-transition-time ease-out;
                    }

                    &:hover {
                        &:before {
                            transform: translateY(-50%) scale(1, 0.6);
                        }
                    }

                    &:active,
                    &:focus {
                        &:before {
                            transform: translateY(-50%) scale(0.8, 1);
                        }

                        box-shadow: none !important;
                    }
                }


                &.#{$prefix}-active {
                    a {
                        &:before {
                            //      background-color: $tab-color-primary;
                            transform: translateY(-50%) scale(1, 0.6);
                        }

                        &:hover {
                            &:before {
                                transform: translateY(-50%) scale(0.8, 1);
                            }
                        }

                        &:focus,
                        &:active {
                            &:before {
                                transform: translateY(-50%) scale(1, 1);
                            }
                        }
                    }
                }
            }
        }
    }
}



@mixin tab-underline-accent {
    ul.#{$prefix}-tab.#{$prefix}-underline.#{$prefix}-accent {
        li.#{$prefix}-active {
            a {
                &:before {
                    background-color: $tab-color-accent !important;
                }
            }
        }
    }
}

@mixin tab-underline-accent-dark {
    @include mode-dark {
        ul.#{$prefix}-tab.#{$prefix}-underline.#{$prefix}-accent {
            li.#{$prefix}-active {
                a {
                    &:before {
                        background-color: $tab-color-accent-dark !important;
                    }
                }
            }
        }
    }
}

@mixin tab-underline-secondary {
    ul.#{$prefix}-tab.#{$prefix}-underline.#{$prefix}-secondary {
        li.#{$prefix}-active {
            a {
                &:before {
                    background-color: $tab-color-secondary !important;
                }
            }
        }
    }
}

@mixin tab-underline-secondary-dark {
    @include mode-dark {
        ul.#{$prefix}-tab.#{$prefix}-underline.#{$prefix}-secondary {
            li.#{$prefix}-active {
                a {
                    &:before {
                        background-color: $tab-color-secondary-dark !important;
                    }
                }
            }
        }
    }
}

@mixin tab-dark {
    @include mode-dark {
        ul.#{$prefix}-tab {
            li {
                a {
                    color: $tab-color-dark;
                    // @include list-element-interaction($tab-item-hover-background-dark);
                }
            }
        }
    }
}


@mixin tab-underline-dark {
    @include mode-dark {
        ul.#{$prefix}-tab {
            border-color: $tab-border-color-dark;

            li {
                a {

                    &:before {
                        background-color: $tab-color-indicator-dark;
                    }
                }

                &.#{$prefix}-active {
                    a {
                        &:before {
                            background-color: $tab-color-dark;
                        }
                    }
                }

            }
        }
    }
}

@mixin tab-side-dark {
    @include mode-dark {
        ul.#{$prefix}-tab {

            &.#{$prefix}-tab-side,
            &.#{$prefix}-tab-side-reverse {
                border-color: $tab-border-color-dark;
            }
        }
    }
}

@mixin tab-underline-side-dark {
    @include mode-dark {
        ul.#{$prefix}-tab {

            &.#{$prefix}-tab-side,
            &.#{$prefix}-tab-side-reverse {

                li {
                    &.#{$prefix}-active {
                        a {
                            &:before {
                                background-color: $tab-color-dark;
                            }
                        }

                    }
                }
            }
        }
    }
}

@mixin tab-side-print {
    @include mode-print {
        ul.#{$prefix}-tab {
            &.#{$prefix}-tab-side {
                border-color   : $component-print-border-color;
                //border-bottom: $component-print-border;

                li {
                    &.#{$prefix}-active {
                        a {
                            &:before {
                                background-color: $component-print-color;
                            }
                        }

                    }
                }
            }
        }
    }
}

@mixin tab-theme-print {
    @include mode-print {
        ul.#{$prefix}-tab {

            &.#{$prefix}-secondary,
            &.#{$prefix}-accent {
                li.#{$prefix}-active {
                    a {
                        &:before {
                            background-color: $component-print-color;
                        }
                    }
                }

            }
        }
    }
}

@mixin tab-print {
    @include mode-print {
        ul.#{$prefix}-tab {
            border-color: $component-print-border;

            li {
                a {
                    &:hover {
                        background-color: $component-print-background;
                    }

                    &:active {
                        background-color: $component-print-background;
                    }

                    &.#{$prefix}-active {
                        &:before {
                            background-color: $component-print-color;
                        }
                    }
                }
            }


        }
    }
}

@mixin definitions($options: ()) {
    @include tab();

    @if(not-option-disabled($options, 'dark')) {
        @include tab-dark();
    }

    @if(not-option-disabled($options, 'underline')) {
        @include tab-underline();

        @if(not-option-disabled($options, 'dark')) {
            @include tab-underline-dark();
        }

        @if(not-option-disabled($options, 'theme')) {
            @include tab-underline-accent();
            @include tab-underline-secondary();

            @if(not-option-disabled($options, 'print')) {
                @include tab-theme-print();
            }

            @if(not-option-disabled($options, 'dark')) {
                @include tab-underline-accent-dark();
                @include tab-underline-secondary-dark();
            }
        }
    }

    @if(not-option-disabled($options, 'print')) {
        @include tab-print();
    }

    @if(not-option-disabled($options, 'side')) {
        @include tab-side();

        @if(not-option-disabled($options, 'underline')) {
            @include tab-underline-side();

            @if(not-option-disabled($options, 'dark')) {
                @include tab-underline-side-dark();
            }
        }

        @if(not-option-disabled($options, 'print')) {
            @include tab-side-print();
        }

        @if(not-option-disabled($options, 'dark')) {
            @include tab-side-dark();
        }
    }


}