@import "../../../../../backend/assets/less/core/boot.less";

/*
 * General control styling
 */

@table-active-border: #e0e0e0;
@table-inactive-border: #e0e0e0;

.control-table {
    .table-container {
        border: 1px solid @table-inactive-border;
        .border-radius(4px);
        overflow: hidden;
        margin-bottom: 15px;

        &:last-child {
            margin-bottom: 0;
        }
    }

    &.active .table-container {
        border-color: @table-active-border;
    }

    table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;

        td, th {
            padding: 0;
            font-size: 13px;
            color: #555555;
        }

        [data-view-container] {
            padding: 5px 10px;
            width: 100%;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            min-height: 28px;
        }
    }

    table.headers {
        &:after {
            content: ' ';
            display: block;
            position: absolute;
            left: 1px;
            right: 1px;
            margin-top: -1px;
            border-bottom: 1px solid @table-inactive-border;
        }

        th {
            padding: 7px 10px;
            font-weight: normal;
            text-transform: uppercase;
            font-size: @font-size-base - 3;
            color: #333333;
            background: white;
            border-right: 1px solid #ecf0f1;
            [data-view-container] {
                padding-bottom: 6px;
            }

            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;

            &:last-child {
                border-right: none;
            }
        }
    }

    &.active table.headers:after {
        border-bottom-color: @table-active-border;
    }

    table.data {
        td {
            border: 1px solid #ecf0f1;

            .content-container {
                position: relative;
                padding: 1px;
            }

            &.active {
                border-color: @color-focus!important;

                .content-container {
                    padding: 0;
                    border: 1px solid @color-focus;

                    &:before, &:after {
                        content: ' ';
                        background: @color-focus;
                        position: absolute;
                        left: -2px;
                        top: -2px;
                    }

                    &:before {
                        width: 1px;
                        bottom: -2px;
                    }

                    &:after {
                        right: -2px;
                        height: 1px;
                    }
                }
            }
        }

        tr {
            background-color: white;

            &.error {
                background-color: #fbecec!important;

                td.active.error {
                    border-color: #ec0000!important;

                    .content-container {
                        border-color: #ec0000!important;
                        &:before, &:after {
                            background-color: #ec0000!important;
                        }
                    }
                }
            }
        }

        tr:nth-child(2n) {
            background-color: #fbfbfb;
        }
    }

    table.data {
        tr:first-child td {
            border-top: none;
        }

        tr:last-child td {
            border-bottom: none;
        }

        td:first-child {
            border-left: none;
        }

        td:last-child {
            border-right: none;
        }
    }

    .control-scrollbar {
        > div {
            .border-bottom-radius(4px);
            overflow: hidden;
        }

        table.data {
            tr:last-child td {
                border-bottom: 1px solid #ecf0f1;
            }
        }
    }

    .toolbar {
        background: white;
        border-bottom: 1px solid @table-inactive-border;

        a.btn {
            color: #323e50;
            padding: 8px 10px;
            .opacity(0.5);
            .box-shadow(none) !important;
            text-shadow: none;

            &:hover {
                .opacity(1);
            }
        }

        .table-search {
            float: right;
            margin: 3px 3px 0 0;

            .table-search-input {
                height: auto;
                padding: 5px 13px 5px;
            }
        }

        a.table-icon {
            &:before {
                display: inline-block;
                content: ' ';
                width: 16px;
                height: 16px;
                margin-right: 8px;
                position: relative;
                top: 3px;
                background: transparent url(../images/table-icons.gif) no-repeat 0 0;
                background-size: 32px auto;
            }

            &.add-table-row-above:before {
                background-position: 0 -56px;
            }

            &.delete-table-row:before {
                background-position: 0 -113px;
            }
        }
    }

    &.active .toolbar {
        border-bottom-color: @table-active-border;
    }

    .pagination {
        ul {
            padding: 0;
            margin-bottom: 15px;

            li {
                list-style: none;
                padding: 4px 6px;
                .border-radius(2px);
                display: inline-block;
                margin-right: 5px;
                font-size: 12px;
                background: #ecf0f1;
                line-height: 100%;

                a {
                    text-decoration: none;
                    color: #95a5a6;
                }

                &.active {
                    background: @brand-accent;

                    a {color: #ffffff;}
                }
            }
        }
    }
}

@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-devicepixel-ratio: 1.5), only screen and (min-resolution: 1.5dppx) {
    .control-table .toolbar {
        a {
            &:before {
                background-position: 0px -9px;
                background-size: 16px auto;
            }

            &.add-table-row-above:before {
                background-position: 0 -39px;
            }

            &.delete-table-row:before {
                background-position: 0 -66px;
            }
        }
    }
}

/*
 * String and autocomplete editors
 */

.control-table {
    td[data-column-type=string],
    td[data-column-type=autocomplete] {
        input[type=text] {
            width: 100%;
            height: 100%;
            display: block;
            outline: none;
            border: none;
            padding: 6px 10px 7px;
        }
    }
}

html.chrome {
    .control-table {
        td[data-column-type=string],
        td[data-column-type=autocomplete] {
            input[type=text] {
                padding: 6px 10px 7px!important;
            }
        }
    }
}

html.safari, html.gecko {
    .control-table {
        td[data-column-type=string],
        td[data-column-type=autocomplete] {
            input[type=text] {
                padding: 5px 10px 5px;
            }
        }
    }
}

ul.table-widget-autocomplete {
    background: white;
    font-size: 13px;
    margin-top: 0;
    border: 1px solid #808c8d;
    border-top: 1px solid #ecf0f1;
    .border-bottom-radius(4px);

    li a {
        padding: 5px 10px;
    }
}

/*
 * Checkbox editor
 */

.control-table {
    td[data-column-type=checkbox] {
        div[data-checkbox-element] {
            width: 16px;
            height: 16px;
            border-radius: @border-radius-base;
            background-color: #FFFFFF;
            border: 1px solid @color-custom-input-border;
            margin: 5px 5px 5px 10px;
            cursor: pointer;

            .user-select(none);

            &:hover {
                border-color: darken(@color-custom-input-border, 10%);
                color: darken(@color-custom-input-icon, 10%);
            }

            &.checked {
                border-width: 2px;

                &:before {
                    .icon(@check);
                    font-size: 10px;
                    position: relative;
                    left: 1px;
                    top: -4px;
                }
            }

            &:focus {
                border-color: @color-focus;
                outline: none;
            }
        }
    }
}

/*
 * Dropdown editor
 */

.control-table {
    td[data-column-type=dropdown] {
        .user-select(none);

        .dropdown-arrow() {
            .icon(@angle-down);
            font-size: 13px;
            line-height: 100%;
            color: #95a5a6;
            position: absolute;
            top: 8px;
            right: 10px;
        }

        [data-view-container] {
            padding-right: 20px;
            position: relative;
            cursor: pointer;

            &:after {
                .dropdown-arrow();
            }

            &:hover:after {
                color: @link-color;
            }
        }

        [data-dropdown-open=true] {
            background: white;
            [data-view-container]:after {
                .icon(@angle-up);
            }
        }

        .content-container {
            outline: none;
        }
    }
}

/* Frameless control styles start */

.widget-field.frameless .control-table {
    .table-container {
        border-top: none;
        border-left: none;
        border-right: none;
        .border-radius(0);
    }

    .toolbar {
        background: transparent;
    }
}

/* Frameless control styles end */

html.cssanimations {
    .control-table td[data-column-type=dropdown] {
        [data-view-container].loading:after {
            background: url('../../../../../../modules/system/assets/ui/images/loader-transparent.svg') 50% 50%;
            background-size: 15px 15px;
            position: absolute;
            width: 15px;
            height: 15px;
            top: 6px;
            right: 5px;
            content: ' ';
            .animation(spin 1s linear infinite);
        }
    }
}

.table-control-dropdown-list {
    .user-select(none);
    position: absolute;
    background: white;
    border: 1px solid @table-active-border;
    border-top: none;
    padding-top: 1px;
    overflow: hidden;
    z-index: 1000;
    .box-sizing(border-box);
    .border-bottom-radius(4px);

    ul {
        border-top: 1px solid #ecf0f1;
        padding: 0;
        margin: 0;
        max-height: 200px;
        overflow: auto;
    }

    li {
        list-style: none;
        font-size: 13px;
        color: #555555;
        padding: 5px 10px;
        cursor: pointer;
        outline: none;

        &:focus {
            background: @color-focus;
            color: white;
        }
    }
}
