/*************************************************
* ---- Grid ----
*/

.w2ui-grid {
    position: relative;
    border: @grid-border;
    border-radius: 2px;
    overflow: hidden !important;

    > div {
        position: absolute;
        overflow: hidden;
    }

    // ===== Grid Header =====

    .w2ui-grid-header {
        position: absolute;
        border-bottom: @grid-header-border-bottom !important;
        height: 28px;
        overflow: hidden;
        color: @grid-header-color;
        font-size: 13px;
        text-align: center;
        padding: 7px;
        .linear-gradient-vertical(@grid-header-linear-gradient-start, @grid-header-linear-gradient-end);
        border-top-left-radius: 2px;
        border-top-right-radius: 2px;
    }

    // ===== Grid Toolbar =====

    .w2ui-grid-toolbar {
        position: absolute;
        border-bottom: @grid-toolbar-border;
        background-color: @grid-toolbar-background-color;
        height: 38px;
        padding: 6px 1px 4px 1px;
        margin: 0px;
        box-shadow: @grid-toolbar-shadow;
    }

    // ===== Grid Search =====

    .w2ui-toolbar-search {
        position: relative;
        width: 160px;
        margin-right: 3px;

        .w2ui-search-all {
            outline: none !important;
            width: 160px !important;
            border-radius: 3px !important;
            line-height: normal !important;
            height: 23px !important;
            border: @grid-search-all-border !important;
            color: @grid-search-all-color !important;
            background-color: @grid-search-all-background-color !important;
            padding: 3px 18px 3px 21px !important;
            margin: 0px !important;
            margin-top: 1px !important;
        }

        .w2ui-search-down {
            position: absolute;
            margin-top: -7px;
            margin-left: 4px;
        }

        .w2ui-search-clear {
            position: absolute;
            width: 16px;
            height: 16px;
            margin-top: -8px;
            margin-left: -20px;
            border-radius: 15px;
            cursor: default;
            &:hover {
                background-color: #D77F7F;
                color: white;
            }
            &:before {
                position: relative;
                top: 2px;
                left: 5px;
                opacity: 0.6;
                color: inherit;
                text-shadow: inherit;
                content: 'x';
                cursor: default;
            }
        }
    }

    // ===== Grid Body =====

    .w2ui-grid-body {
        position: absolute;
        overflow: hidden;
        padding: 0px;
        background-color: @grid-background-color;
        .user-select;

        input, select, textarea {
            .user-select(text);
        }

        div.w2ui-input {
            .user-select(tex);
            pointer-events: auto;
            background-color: white;
            padding: 4px 2px;
            border: 1px solid transparent;
            width: 100%;
            height: 100%;
            pointer-events: auto;
            outline: none;
            white-space: pre;
            overflow: hidden;
        }

        .w2ui-grid-columns, .w2ui-grid-fcolumns {
            overflow: hidden;
            position: absolute;
            left: 0px;
            top: 0px;
            right: 0px;
            box-shadow: @grid-headers-shadow;
            height: auto;

            table {
                height: auto;
            }

            .w2ui-resizer {
                position: absolute;
                z-index: 1000;
                display: block;
                background-image: none;
                background-color: rgba(0,0,0,0); /* needed for IE */
                padding: 0px;
                margin: 0px;
                width: 6px;
                height: 12px;
                cursor: col-resize;
            }
        }

        .w2ui-grid-records, .w2ui-grid-frecords {
            position: absolute;
            left: 0px;
            right: 0px;
            top: 0px;
            bottom: 0px;

            table {
                tr {
                    &.w2ui-odd {
                        color: @grid-row-color;
                        background-color: @grid-row-odd-background-color;
                        &:hover, &.w2ui-record-hover {
                            color: @grid-row-hover-color;
                            background-color: @grid-row-hover-background-color;
                        }
                        &.w2ui-empty-record:hover {
                            background-color: @grid-row-odd-background-color;
                        }
                    }
                    &.w2ui-even {
                        color: @grid-row-color;
                        background-color: @grid-row-even-background-color;
                        &:hover, &.w2ui-record-hover {
                            color: @grid-row-hover-color;
                            background-color: @grid-row-hover-background-color;
                        }
                        &.w2ui-empty-record:hover {
                            background-color: @grid-row-even-background-color;
                        }
                    }
                    &.w2ui-selected, td.w2ui-selected {
                        color: @grid-row-selected-color !important;
                        background-color: @grid-row-selected-background-color !important;
                    }
                    &.w2ui-inactive, td.w2ui-inactive {
                        background-color: @grid-row-inactive-background-color !important;
                    }
                }
            }

            .w2ui-expanded {
            }

            .w2ui-expanded1 {
                height: 0px;
                border-bottom: 1px solid rgb(178, 186, 192);
                & > div {
                    height: 0px;
                    border: 0px;
                    transition: height .3s, opacity .3s;
                }
            }

            .w2ui-expanded2 {
                height: 0px;
                border-radius: 0px;
                border-bottom: 1px solid rgb(178, 186, 192);
                & > div {
                    height: 0px;
                    border: 0px;
                    transition: height .3s, opacity .3s;
                }
            }

            .w2ui-load-more {
                border-top: @grid-row-border-right;
                cursor: pointer;
                > div {
                    text-align: center;
                    color: @grid-row-number-color;
                    background-color: @grid-row-number-background-color;
                    padding: 10px 0px 15px 0px;
                    border-top: 1px solid @grid-background-color;
                    &:hover {
                        color: @grid-row-hover-color;
                        background-color: @grid-row-hover-background-color;
                    }
                }
            }
        }

        // this table CSS for both columns and records
        table {
            border-spacing: 0px;
            border-collapse: collapse;
            table-layout: fixed;
            width: 1px; // otherwise auto and does not work

            .w2ui-head {
                margin: 0px;
                padding: 0px;
                border-right: @grid-headers-border;
                border-bottom: @grid-headers-border;
                color: @grid-headers-color;
                .linear-gradient-vertical(@grid-headers-linear-gradient-start, @grid-headers-linear-gradient-end);

                > div {
                    padding: 7px 3px;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                    overflow: hidden;
                    position: relative;
                }

                &.w2ui-col-intersection {
                    border-right-color: @input-focus-outline-color;
                }

                &.w2ui-reorder-cols-head {
                    &:hover {
                        cursor: move;
                    }
                }

                .col-intersection-marker {
                    padding: 0;
                    position: absolute;
                    height: 100%;
                    top: 0;

                    &.left {
                        left: 0;
                        margin-left: -5px;
                    }

                    &.right {
                        right: 0;
                        margin-right: -5px;
                    }

                    .top-marker {
                        position: absolute;
                        top: 0;
                        height: 0;
                        width: 0;
                        border-top: 5px solid @input-focus-outline-color;
                        border-left: 5px solid transparent;
                        border-right: 5px solid transparent;
                    }

                    .bottom-marker {
                        position: absolute;
                        bottom: 0;
                        height: 0;
                        width: 0;
                        border-bottom: 5px solid @input-focus-outline-color;
                        border-left: 5px solid transparent;
                        border-right: 5px solid transparent;
                    }
                }
            }

            td {
                border-right: @grid-row-border-right;
                border-bottom: @grid-row-border-bottom;
                cursor: default;
                overflow: hidden;

                &.w2ui-soft-span, &.w2ui-soft-hidden {
                    border-right-color: transparent;
                }

                &.w2ui-grid-data {
                    margin: 0px;
                    padding: 0px;

                    .w2ui-info {
                        position: relative;
                        top: 1px;
                        font-size: 14px;
                        color: #8D99A7;
                        cursor: pointer;
                        width: 16px;
                        display: inline-block;
                        margin-right: 2px;
                        text-align: center;
                    }

                    & > div {
                        padding: 3px 3px 3px 3px;
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                    }

                    & > div.flexible-record {
                        height: auto;
                        overflow: visible;
                        white-space: normal;
                    }

                    .w2ui-show-children {
                        width: 16px;
                        height: 10px;
                        display: inline-block;
                        position: relative;
                        top: -1px;
                        cursor: pointer;
                    }
                }
                &:last-child {
                    border-right: 0px;
                }
            }

            .w2ui-col-number {
                width: 34px;
                color: @grid-row-number-color;
                background-color: @grid-row-number-background-color;
                div {
                    padding: 0px 7px 0px 3px;
                    text-align: right;
                }
                &.w2ui-head {
                    cursor: pointer;
                }
            }

            .w2ui-col-select {
                width: 26px;
                div {
                    padding: 0px 0px;
                    text-align: center;
                    overflow: hidden;
                    input[type=checkbox] {
                        //margin: 3px 1px; //* needed for Opera on Mac */
                        margin-top: 0px;
                        margin-bottom: 0px;
                        position: relative;
                    }
                }
            }

            .w2ui-col-expand {
                width: 26px;
                div {
                    padding: 0px 0px;
                    text-align: center;
                    font-weight: bold;
                }
            }

            .w2ui-col-selected {
                background-color: #d1d1d1 !important;
            }

            .w2ui-row-selected {
                background-color: #d1d1d1 !important;
            }
        }

        div.w2ui-col-header { // div needed
            height: auto !important;
            width: 100%;
            overflow: hidden;
            padding-right: 10px !important;
        }
        div.w2ui-col-header > div.w2ui-sort-up {
            border: 4px solid transparent;
            border-bottom: 5px solid #8D99A7;
            margin-top: -2px;
            margin-right: -7px;
            float: right;
        }

        div.w2ui-col-header > div.w2ui-sort-down {
            border: 4px solid transparent;
            border-top: 5px solid #8D99A7;
            margin-top: 2px;
            margin-right: -7px;
            float: right;
        }

        & .w2ui-col-group {
            text-align: center;
        }

        .w2ui-grid-scroll1 {
            position: absolute;
            left: 0px;
            bottom: 0px;
            border-top: 1px solid #ddd;
            border-right: 1px solid #ddd;
            background-color: #FAFAFA;
        }
    }

    .w2ui-grid-empty-msg {
        position: absolute;
        top: 27px;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(255, 255, 255, 0.65);
        > div {
            position: absolute;
            left: 0;
            right: 0;
            top: 45%;
            transform: translateY(-45%);
            text-align: center;
            font-size: 13px;
            color: #666;
        }
    }

    .w2ui-changed {
        .background-image(@image-changed, no-repeat, top, right);
    }

    .w2ui-edit-box {
        position: absolute;
        z-index: 1001;
        border: 2px solid #6299DA;
        pointer-events: auto;
    }

    .w2ui-editable {
        overflow: hidden;
        height: 100% !important;
        margin: 0px !important;
        padding: 0px !important;

        input {
            border: 0px;
            border-radius: 0px;
            margin: 0px;
            padding: 4px 3px;
            width: 100%;
            height: 100%;
        }
        input.w2ui-select {
            outline: none !important;
            background: #fff;
        }
    }

    .w2ui-grid-summary {
        position: absolute;
        box-shadow: @grid-summary-shadow;

        table {
            color: @grid-summary-color;
            .w2ui-odd {
                background-color: @grid-summary-odd-background-color;
            }
            .w2ui-even {
                background-color: @grid-summary-even-background-color;
            }
        }
    }

    // ===== Grid Footer =====

    .w2ui-grid-footer {
        position: absolute;
        margin: 0px;
        padding: 0px;
        text-align: center;
        height: 24px;
        overflow: hidden;
        .user-select(text);
        box-shadow: @grid-footer-shadow;
        color: @grid-footer-color;
        background-color: @grid-footer-background-color;
        border-top: @grid-footer-border-top;
        border-bottom-left-radius: 2px;
        border-bottom-right-radius: 2px;

        .w2ui-footer-left {
            float: left;
            padding-top: 5px;
            padding-left: 5px;
        }

        .w2ui-footer-right {
            float: right;
            padding-top: 5px;
            padding-right: 5px;
        }

        .w2ui-footer-center {
            padding: 2px;
            text-align: center;

            .w2ui-footer-nav {
                width: 110px;
                margin: 0 auto;
                padding: 0px;
                text-align: center;

                input[type=text] {
                    padding: 1px 2px 2px 2px;
                    border-radius: 3px;
                    width: 40px;
                    text-align: center;
                }

                a.w2ui-footer-btn {
                    display: inline-block;
                    border-radius: 3px;
                    cursor: pointer;
                    font-size: 11px;
                    line-height: 16px;
                    padding: 1px 5px;
                    width: 30px;
                    height: 18px;
                    margin-top: -1px;
                    color: @grid-footer-btn-color;
                    background-color: @grid-footer-btn-background-color;

                    &:hover {
                        color: @grid-footer-btn-hover-color;
                        background-color: @grid-footer-btn-hover-background-color;
                    }
                }
            }
        }
    }

    .w2ui-grid-focus-input {
        position: absolute;
        top: 0;
        right: 0;
        z-index: -1;
        opacity: 0;
        overflow: hidden; // needed for Safari 10
        // needed for IE11
        padding: 0px;
        margin: 0px;
        width: 1px;
        height: 1px;
        resize: none;
        border: 0px;
        // --
    }
}

/* SpeadSheet */

.w2ui-ss .w2ui-grid-body {

    .w2ui-grid-records {
        table tr td.w2ui-selected {
            background-color: #EEF4FE !important;
        }
        table tr td.w2ui-inactive {
            background-color: #F4F6F9 !important;
        }
        // line border
        table td {
            border-right-width: 1px;
            border-bottom: 1px solid #efefef;
        }
        // no alternating rows
        table tr.w2ui-odd,
        table tr.w2ui-even,
        table tr.w2ui-odd:hover,
        table tr.w2ui-even:hover {
            background-color: inherit;
        }
        table tr:first-child td {
            border-top: 0px;
            border-bottom: 0px;
        }
    }

    .w2ui-grid-frecords {
        table tr td.w2ui-selected {
            background-color: #EEF4FE !important;
        }
        table tr td.w2ui-inactive {
            background-color: #F4F6F9 !important;
        }
        // line border
        table td {
            border-right-width: 1px;
            border-bottom: 1px solid #efefef;
        }
        // no alternating rows
        table tr.w2ui-odd,
        table tr.w2ui-even,
        table tr.w2ui-odd:hover,
        table tr.w2ui-even:hover {
            background-color: inherit;
        }
        table tr:first-child td {
            border-bottom: 0px;
        }
    }

    .w2ui-selection {
        position: absolute;
        z-index: 1000;
        border: 2px solid #6299DA; /* #457FC2; */
        pointer-events: none;

        .w2ui-selection-resizer {
            cursor: crosshair;
            position: absolute;
            bottom: 0px;
            right: 0px;
            width: 6px;
            height: 6px;
            margin-right: -3px;
            margin-bottom: -3px;
            background-color: #457FC2;
            border: 0.5px solid #fff;
            outline: 1px solid white;
            pointer-events: auto;
        }

        &.w2ui-inactive {
            border: 2px solid #C0C2C5;
            .w2ui-selection-resizer {
                 background-color: #B0B0B0;
            }
        }
    }

    .w2ui-soft-range  {
        position: absolute;
        pointer-events: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .w2ui-changed {
        background: inherit; /* do not show changed for spreadsheet */
    }
}

// === Info bubble in the grid

.w2ui-info-bubble {
    table {
        font-size: 11px;
        font-family: @main-font-family;
        color: white;
        text-shadow: 1px 1px solid #999;

        tr td:first-child {
            white-space: nowrap;
            padding: 2px;
            padding-right: 10px;
            color: #ddd;
            vertical-align: top;
        }

        tr td:last-child {
            white-space: pre;
            padding: 2px;
        }
    }
}

// === Global Search slide down

.w2ui-overlay .w2ui-select-field {
    padding: 4px 0px;
    cursor: default;
    table {
        font-size: 11px;
        font-family: @main-font-family;
        border-spacing: 0px;
        border-collapse: border-collapse;
        tr {
            height: 27px;
            &:hover {
                background-color: @grid-row-selected-background-color;
            }
            td:nth-child(1) {
                width: 26px;
                padding-right: 6px;
                text-align: right;
                color: #888;
            }
            td:nth-child(2) {
                padding: 3px 20px 3px 0px;
            }
        }
    }
}

.w2ui-overlay .w2ui-col-on-off {
    padding: 4px 0px;
    table {
        border-spacing: 0px;
        border-collapse: border-collapse;
        tr:hover {
            background-color: @grid-row-selected-background-color;
        }
        td {
            input[type=checkbox] {
                margin: 3px 2px 2px 2px;
            }
            label {
                display: block;
                padding: 3px 0px;
                padding-right: 10px;
            }
        }
        td:first-child {
            padding: 4px 0px 4px 6px;
        }
        td:last-child {
            padding: 4px 6px 4px 0px;
        }
    }
}

.w2ui-overlay .w2ui-grid-searches {
    text-align: left;
    padding: 0px;
    border-top: 0px;
    background-color: @grid-searches-background-color;
    table {
        padding: 4px;
        padding-top: 12px;
        border-collapse: border-collapse;
        td {
            padding: 4px;
            &.close-btn {
                width: 20px;
                padding-right: 20px;
                button {
                    min-width: 24px;
                    height: 24px;
                    padding-top: 5px !important;
                }
            }
            &.caption {
                text-align: right;
                padding-right: 5px;
                border-right: @grid-searches-inner-border;
            }
            &.operator {
                text-align: left;
                padding: 0px 10px;
                padding-right: 5px;
                border-right: @grid-searches-inner-border;
                height: 31px;
            }
            &.operator select {
                width: 100%;
                color: black;
            }
            /* for IE */
            &.operator select::-ms-expand {
                display: none;
            }
            &.value {
                padding-right: 5px;
                padding-left: 5px;
                input[type=text] {
                    border-radius: 3px;
                    padding: 3px;
                    margin-right: 3px;
                    height: 23px;
                }
                select {
                    padding: 3px;
                    margin-right: 3px;
                    height: 23px;
                }
            }
            &.actions {
                border-right: 0px;
                > div {
                    margin: -7px;
                    margin-top: 15px;
                    padding: 13px 0px;
                    text-align: center;
                    background-color: @grid-searches-buttons-background-color;
                    border-top: @grid-searches-inner-border;
                }
            }
        }
    }
}
