@import '../../containers/Application/colors.scss';

$headerTextDarkColor: $white;
$headerCellDarkBackgroundColor: $blueZodiac;
$headerButtonCellDarkBorderColor: rgba($silverChalice, .25);
$headerTextBrightColor: $black;
$headerCellBrightBackgroundColor: $alto;
$headerButtonCellBrightBorderColor: $silver;
$cellTextColor: $blueZodiac;
$cellTextColorActive: $white;
$cellBackgroundColor: $white;
$cellBorderColor: $cellBackgroundColor;
$cellBorderColorActive: $shakespeare;
$buttonCellBackgroundColor: $white;
$buttonCellBackgroundColorHover: $shakespeare;
$buttonCellBackgroundColorDisabled: $frenchGray;
$buttonCellBorderColor: $white;
$buttonCellColor: $buttonCellBackgroundColorHover;
$buttonCellColorDisabled: $buttonCellBackgroundColorDisabled;
$buttonCellColorHover: $buttonCellBackgroundColor;
$emptyMessageColor: $silver;
$rowHeight: 40px;
$paddingCell: 4px;
$borderWidth: 1px;
$borderRadius: 3px;

.table {
    border-collapse: separate;
    border-spacing: 0 5px;
    margin: -5px 0;
    overflow: hidden;
    min-width: 100%;
}

.header > tr {
    height: 60px;
}

.header-cell,
.cell,
.button-cell {
    &:first-child {
        border-top-left-radius: $borderRadius;
        border-bottom-left-radius: $borderRadius;
        border-left-width: $borderWidth;
    }

    &:last-child {
        border-top-right-radius: $borderRadius;
        border-bottom-right-radius: $borderRadius;
        border-right-width: $borderWidth;
    }
}

.header-cell {
    padding: 20px;
    font-size: 12px;
    font-weight: normal;

    > span {
        display: inline-flex;
        align-items: center;
    }

    &.clickable {
        padding: 0;

        button {
            height: 60px;
            padding: 5px 20px;
            color: inherit;
            border: none;
            background: none;
            display: inline-flex;
            align-items: center;

            &:not(:disabled) {
                cursor: pointer;
            }
        }
    }
}

.cell,
.header-cell {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 250px;
    text-align: left;
}

.cell-content {
    display: flex;
    align-items: center;
    height: 100%;
    min-height: calc($rowHeight - $paddingCell * 2 - $borderWidth * 2);
}

.toggle-icon {
    cursor: pointer;
    display: inline-block;
    width: 20px;
}

.cell-select {
    padding-right: 10px;
}

.header-cell-sort-icon {
    padding-left: 10px;
}

.header-button-cell {
    width: 1px;
    text-align: center;
    font-size: 16px;
}

.row {
    height: $rowHeight;

    &:hover {
        .cell {
            border-color: $cellBorderColorActive;
        }

        .button-cell {
            font-size: 16px;

            button {
                visibility: visible;
            }
        }
    }

    &.disabled {
        pointer-events: none;
        opacity: .5;

        .cell {
            border: $cellBorderColor;
        }

        .toggle-icon {
            pointer-events: auto;
        }
    }
}

.button-cell,
.header-button-cell {
    width: 56px;
}

.cell,
.button-cell {
    margin: 0;
    height: $rowHeight;
    padding: $paddingCell 20px;
    font-size: 12px;
    border-width: $borderWidth 0;
    border-style: solid;
    border-color: $cellBorderColor;
    color: $cellTextColor;
    background-color: $cellBackgroundColor;

    &.small {
        width: 1px;
    }
}

.button-cell {
    padding: 0;
    background-color: $cellBackgroundColor;
    color: $buttonCellColor;
    text-align: center;

    &:hover {
        button:not(:disabled) {
            visibility: visible;
            background-color: $buttonCellBackgroundColorHover;
            border-right: $borderWidth solid $buttonCellBorderColor;
            color: $buttonCellColorHover;
        }
    }

    button {
        visibility: hidden;
        width: 100%;
        height: 100%;
        border: none;
        color: $buttonCellColor;
        cursor: pointer;
        background-color: transparent;

        &:disabled {
            color: $buttonCellColorDisabled;
            cursor: default;
        }
    }
}

.table-placeholder-area {
    color: $emptyMessageColor;
    text-align: center;
    padding: 40px;
}

.table-placeholder-icon {
    font-size: 38px;
}

.table-placeholder-text {
    margin-top: 15px;
    font-size: 12px;
    font-weight: bold;
}

.dark {
    .header {
        color: $headerTextDarkColor;
    }

    .header-cell {
        background-color: $headerCellDarkBackgroundColor;
    }

    .header-button-cell {
        border-right: $borderWidth solid $headerButtonCellDarkBorderColor;
    }
}

.light {
    .header {
        color: $headerTextBrightColor;
    }

    .header-cell {
        background-color: $headerCellBrightBackgroundColor;
    }

    .header-button-cell {
        border-right: $borderWidth solid $headerButtonCellBrightBorderColor;
    }
}
