@import "./table-panel.less";
@import "./table-footer.less";

.Hylia-o-table-wrapper {
    width: 100%;
    border-radius: @radius;

    // Modifiers
    &--large {
        tbody tr {
            height: 8rem;
        }

        &.Hylia-o-table-wrapper--resizable  {
            .Hylia-o-table-header__resizer  {
                min-width: 8rem;
            }
        }

        .Hylia-o-table__body {
            tr {    
                // Stripe
                .Hylia-o-table-cell__content {
                    &:before {
                        background: linear-gradient(to bottom, transparent 0%, @stormtrooper 90%);
                    }
                }
                
                &:nth-child(even) {
                    .Hylia-o-table-cell__content {
                        &:before {
                            background: linear-gradient(to bottom, transparent 0%, @acolyte 100%); 
                        }
                    }
                }
                
                &.Hylia-o-table-row--selected {
                    .Hylia-o-table-cell__content {
                        &:before {
                            background: linear-gradient(to bottom, transparent 0%, lighten(@terran, 25%) 100%); 
                        }
                    }
                }

                &.Hylia-o-table-row--hover {
                    .Hylia-o-table-cell__content {
                        &:before {
                            background: linear-gradient(to bottom, transparent 0%, @adept 100%); 
                        }
                    }
                }
            }
        }

        .Hylia-o-table-cell {
            text-overflow: initial;
            white-space: normal;

            &__content {
                text-overflow: initial;
                white-space: normal;
                height: 5.3rem;
                overflow: hidden;
                margin: 1rem 0;
                display: flex;
                align-items: center;
    
                &:before {
                    content: "";
                    display: block;
                    height: 2rem;
                    width: 100%;
                    position: absolute;
                    bottom: 0;
                }
    
                & > * { 
                    margin: auto 0;
                }
            }
        }
    }
}

// Row
.Hylia-o-table-row {
    td {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .Hylia-a-inputCheckbox {
        opacity: 0;
        transition: opacity 0.3s;
    }

    &--hover {
        background-color: @adept !important;

        .Hylia-a-inputCheckbox {
            opacity: 1;
        }

        .Hylia-a-button-round {
            background-color: transparent !important;
        }

        .Hylia-a-button-ghost {
            background-color: @stormtrooper;
            
            &--positive {
                border: solid .1rem @namek;
            }

            &--negative {
                border: solid .1rem @ruban;
            }

            &--warning {
                border: solid .1rem @saien;
            }
        }
    }

    &--focused {
        td:first-child {
            position: relative;

            &:before {
                content: "";
                width: 0.4rem;
                height: 100%;
                top: 0;
                left: 0;
                display: block;
                position: absolute;
                background-color: @terran;
            }
        }
    }
}

// Table Thead
.Hylia-o-table-header {
    font-size: 1.4rem;
    color: @knight;

    &__resize {
        position: absolute;
        top: 0;
        right: -0.1rem;
        height: 100%;
        width: 0.4rem;
        z-index: 1;
        display: block;
        transition: background-color 0.3s;
        background-color: transparent;

        &--active {
            background-color: @terran !important;
            cursor: col-resize;

            &:before {
                content: "";
                height: 200vh;
                width: 0.1rem;
                background: @terran;
                position: absolute;
                right: .1rem;
                top: 0;
            }
        }

        &:hover {
            background-color: @terran !important;
            cursor: col-resize;

            &:before {
                content: "";
                height: 200vh;
                width: 0.1rem;
                background: @terran;
                position: absolute;
                right: .1rem;
                top: 0;
            }
        }
    }

    &__resizer {
        display: flex;
        align-items: center;
        width: 100%;
    }

    &__title {
        font-family: @regular_bold;
        user-select: none;
        text-overflow: ellipsis;
        padding-right: 1rem;
        overflow: hidden;
        display: inline-block;
        white-space: nowrap;
        cursor: pointer;
        min-width: 4rem;
        max-width: 30rem;

        &--sorted {
            color: @vader;
        }
    }

    &__info {
        margin-left: 0.5rem;
        color: @knight;
        cursor: pointer;
        transition: color 0.3s;

        &:hover {
            color: @vader;
        }
    }

    &__filter {
        position: absolute;
        top: 0;
        right: .5rem;
        width: 4rem;
        height: 100%;
        flex-grow: 0;
        flex-shrink: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        
        i {
            color: transparent;
            transition: color .3s;
        }

        &--active {
            i {
                color: @terran;
            }
        }
    }

    &__sort {
        position: relative;
        margin-right: 0.3rem;
        cursor: pointer;

        &--asc {
            color: @terran;
        }

        &--desc {
            color: @terran;
        }
    }

    &__cell {
        position: relative;
        white-space: nowrap;
        background-color: @adept;
        z-index: 1;
        padding: 1rem;
        box-sizing: initial;
        border-left: 0.1rem solid @apprentice;

        &:hover {
            .Hylia-o-table-header__filter i {
                color: @apprentice;
            }

            .Hylia-o-table-header__resize {
                background-color: @knight;
            }
        }

        &--filter {
           padding-right: 4rem; 
        }
    }

    &--options {
        tr th {
            border: none;
        }
    }
}

.Hylia-o-table {
    &__body {
        tr {
            // Stripe
            &:nth-child(even) {
                background-color: @acolyte;
            }

            &.Hylia-o-table-row--selected {
                background-color: lighten(@terran, 25%);
        
                .Hylia-a-inputCheckbox {
                    opacity: 1;
                }
            }
        }

        td {
            border-bottom: .1px solid @stormtrooper;
            
            button.Hylia-a-button:not(:last-child) {
                margin-right: 1rem;
            }
        }
    }

    // Align content
    &--align {
        &--center {
            .Hylia-o-table-cell__content {
                text-align: center;
            }
        }

        &--left {
            .Hylia-o-table-cell__content {
                text-align: left;
            }
        }

        &--right {
            .Hylia-o-table-cell__content {
                text-align: right;
            }
        }
    }
}

//***
// Container Table
//***
.Hylia-o-table-container {
    display: flex;
    background-color: @stormtrooper;
    border-collapse: collapse;
    border: 0.1rem solid @minion;
    position: relative;

    tr {
        height: 4rem;
    }

    td {
        padding: 0 1rem;
        font-family: @condensed_regular;
    }

    &__loader {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: ~"calc(100% - 4rem)";
        z-index: 3;
        background-color: fade(@stormtrooper, 90%);
    }

    &__empty {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 3;
        background-color: fade(@stormtrooper, 60%);
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;

        &__desc {
            background-color: @minion;
            padding: 1rem;
            border-radius: @radius;
        }
    }
}

//***
// Table Main
//***
.Hylia-o-table-main {
    flex: 1;
    position: relative;
    overflow: hidden;

    &:before {
        content: "";
        background: linear-gradient(-90deg, rgba(170, 170, 170, 0) 0%, @apprentice 100%);
        display: block;
        position: absolute;
        width: 0.6rem;
        height: 100%;
        top: 0;
        left: 0;
        opacity: 0;
        z-index: 2;
        transition: opacity 0.3s;
    }

    &:after {
        content: "";
        background: linear-gradient(90deg, rgba(170, 170, 170, 0) 0%, @apprentice 100%);
        display: block;
        position: absolute;
        width: 0.6rem;
        height: 100%;
        top: 0;
        right: 0;
        z-index: 2;
    }

    &__header {
        th:last-child {
            .Hylia-o-table-header__resize {
                display: none;
            }
        }
    }

    &__content {
        &--resizable {
            td {
                max-width: 0;
            }
        }
    }

    &--onScroll {
        &:before {
            opacity: 1;
        }
    }
    
    .Hylia-o-table {
        min-width: 100%;
    }
}

//***
// Table Options
//***
.Hylia-o-table-options {
    overflow: hidden;

    &__select {
        box-sizing: border-box;
        width: 4rem;
        
        .Hylia-a-inputCheckbox {
            justify-content: center;
        }

        .Hylia-a-inputCheckbox__apparence {
            // Remove margin input
            margin: 0;
        }
    }

    &__state {
        box-sizing: border-box;
        width: 4rem;
        vertical-align: middle;
    }

    &__status {
        width: 0.5rem;
        height: 0.5rem;
        margin: auto;
        display: block;
        border-radius: 50%;
        background-color: @apprentice;
        border: 0.5rem solid lighten(@apprentice, 25%);
        box-sizing: content-box;

        &--positive {
            background-color: @namek;
            border: 0.5rem solid lighten(@namek, 25%);
        }

        &--warning {
            background-color: @saien;
            border: 0.5rem solid lighten(@saien, 25%);
        }

        &--negative {
            background-color: @ruban;
            border: 0.5rem solid lighten(@ruban, 25%);
        }
    }
}

//***
// Table Actions
//***
.Hylia-o-table-actions {
    overflow-x: hidden;
    overflow-y: auto;

    &__more {
        i {
            color: @apprentice;
        }
    }

    &__btn {
        width: 20rem;
        overflow: inherit;

        &__container {
            display: flex;
            justify-content: center;
        }

        .Hylia-a-button {
            margin: 0;
            width: 100%;
            padding:0 1rem;

            &:hover {
                color: @stormtrooper;
            }
        }

        .Hylia-a-button-ghost {
            &--positive {
                &:hover {
                    background-color: @namek;
                }
            }

            &--negative {
                &:hover {
                    background-color: @ruban;
                }
            }

            &--warning {
                &:hover {
                    background-color: @saien;
                }
            }
        }
    }
}

//***
// Cell
//***
.Hylia-o-table-cell {
    &__content {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        vertical-align: middle;
        display: inline-block;
        width: 100%;
        position: relative;
    }
    
    &--left {
        text-align: left;
    }

    &--right {
        text-align: right;
    }

    &--center {
        text-align: center;
    }

    &--sorted {
        color: @smart;
    }
}

//***
// Button Menu
//***
.Hylia-o-table-button-menu {
    .panel-menu {
        bottom: -.7rem;
    }
    
    .Hylia-a-button {
        margin: 0;

        i {
            transition: color .3s;
            font-size: 1.3rem;
        }
        
        &:hover {
            background-color: transparent;
            box-shadow: none;

            i {
                color: @knight;
            }
        }

        &:focus {
            animation: none;
        }
    }
}

.Hylia-o-table-menu-filter {
    min-width: 14rem;

    border-radius: @radius;
    background-color: @stormtrooper;
    box-shadow: 0 0 .4rem 0 rgba(0, 0, 0, 0.29);

    &:before {
        position: absolute;
        z-index: 0;
        top: -0.8rem;
        right: 2.5rem;

        display: block;

        width: 1.5rem;
        height: 1.5rem;

        content: "";
        transform: rotate(45deg);
        background-color: @stormtrooper;
        box-shadow: -2px -2px 2px 0 rgba(0, 0, 0, 0.1);
    }

    &__content {
        position: relative;
        padding: 1rem;
    }
}
