/* datatable and treetable */

body .ui-datatable, body .ui-treetable {

    background-color: #fff;

    .ui-treetable-header, ui-treetable-footer {
        border-color: @datatable-border-color;
        padding: 10px 5px;
    }

    th {
        font-weight: 600;
    }

    th.ui-state-default {
        border-color: @datatable-border-color;
    }

    th.ui-state-hover {
        background: #d3d5d8;
        border-color: @datatable-border-color;
    }

    th.ui-state-active {
        background: #E6E6E6;
        color: #444;
    }

    tbody {

      > tr.ui-widget-content {
        border-color: @datatable-border-color;
      }

      > tr > td > a {
        cursor: pointer;
        color: @light-blue;

        &:hover {
          text-decoration: underline;
          cursor: pointer;
        }
      }

      > tr {
        &.ui-widget-content {
          border-top-color: @datatable-row-border-color;
          border-bottom-color: @datatable-row-border-color;
          border-left: @datatable-border-color;
          border-right: @datatable-border-color;
        }

        &.ui-widget-content.ui-state-hover {
          border-color: @datatable-row-border-color !important;
        }

        &.ui-widget-header > td {
          border-color: @datatable-border-color !important;
          font-weight: 600;
        }
      }
    }

    tr.ui-state-hover:not(.ui-state-highlight), tr.ui-state-hover:not(.ui-state-highlight) td {
        background-color: @datatable-row-hover-color;
    }

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

      thead.ui-datatable-scrollable-theadclone {
        visibility: hidden;
      }
    }

    .ui-datatable-header, .ui-treetable-header, .ui-datatable-footer, .ui-treetable-footer {
        background: #fff;
        font-size: 18px;
        font-weight: 500;
        border-color: @datatable-border-color
    }

    th[role="columnheader"].ui-state-default {
        background: #fff none;
        border: 1px solid @datatable-border-color;
        box-shadow: none !important;
        outline: 0 !important;
        position: relative;
        font-weight: 600;
        border-radius: 0;
        &.ui-sortable-column.ui-state-active {
            background-image: -webkit-linear-gradient(top, #ffffff, darken(#ffffff,8%));
            background-image: linear-gradient(top, #ffffff, darken(#ffffff,8%));

        }
    }

    td[role="gridcell"] {
        position: relative;
        a {
            position: relative;
        }
    }

    .ui-widget-content .ui-state-highlight a {
        text-decoration: underline;
        &:hover {
            color: #222;
        }
    }

    .border-bottom-radius(0);
    .border-top-radius(3px);


    &.box-default {
        .datatableBoxColors(@gray-lte, @admin-text-color)
    }

    &.box-primary {
        .datatableBoxColors(@light-blue, #fff)
    }

    &.box-danger {
        .datatableBoxColors(@red, #fff)
    }

    &.box-fatal {
        .datatableBoxColors(@dark-red, #fff)
    }

    &.box-warning {
        .datatableBoxColors(@yellow, #fff)
    }

    &.box-success {
        .datatableBoxColors(@green, #fff)
    }

    &.box-info {
        .datatableBoxColors(@aqua, #fff)
    }

    &.box-teal {
        .datatableBoxColors(@admin-teal, #fff)
    }

    table tbody td, table thead th {
        padding: 10px 10px;
    }

    table thead th.ui-filter-column {
        padding: 5px 2px;
    }

    th .ui-column-customfilter {
        .ui-selectonemenu, .ui-selectcheckboxmenu {
            background-color: #fff;
        }

        input {
            width: 100%;
        }

        div.ui-selectcheckboxmenu {
            min-width: auto;
        }

        .ui-spinner-button span.ui-icon.icon-ripple:before {
            margin-left: -14px;
        }

        div.ui-selectonemenu div.ui-selectonemenu-trigger .icon-ripple.ui-icon-triangle-1-s {
            margin-left: 2px;
        }

        div.ui-selectcheckboxmenu .ui-selectcheckboxmenu-trigger .ui-icon.icon-ripple {
            left: 3px;
        }

    }

    span.ui-sortable-column-icon {

        &.ui-icon-carat-2-n-s {
            background-image: none;
            display: inline;

            &:before {
                font-family: 'Glyphicons Halflings';
                color: @admin-text-color;
                position: relative;
                font-size: @font-awesome-icon-size;
                padding: 0 7px;
                top: 1px;
                font-weight: 500;
                overflow: hidden;
                opacity: .35 ;
                content: "\e150";
            }
        }

        &.ui-icon-carat-2-n-s.ui-icon-triangle-1-s {
            background-image: none;
            display: inline;

            &:before {
                font-family: 'Glyphicons Halflings';
                color: @admin-text-color;
                position: relative;
                font-size: @font-awesome-icon-size;
                padding: 0 7px;
                top:-2px;
                font-weight: 500;
                overflow: hidden;
                opacity: .6;
                content: "\e156" !important;
            }
        }

        &.ui-icon-carat-2-n-s.ui-icon-triangle-1-n {
            background-image: none;
            display: inline;

            &:before {
                font-family: 'Glyphicons Halflings';
                color: @admin-text-color;
                position: relative;
                font-size: @font-awesome-icon-size;
                padding: 0 7px;
                font-weight: 500;
                top: 2px;
                overflow: hidden;
                opacity: .6;
                content: "\e155" !important;
            }
        }

    }

}

.ui-datatable-odd, ui-treetable-odd {
    background-color: #f9f9f9;
}

.ui-datatable-rowordering.ui-state-active {
    background: #14a4ff none repeat scroll 0 0;
}

body .ui-datatable, body .ui-treetable {

    .ui-selection-column {

        .ui-radiobutton .ui-radiobutton-box, .ui-chkbox .ui-chkbox-box, .ui-radiobutton .ui-radiobutton-box.ui-state-active, .ui-chkbox .ui-chkbox-box.ui-state-active {

            background-color: #fff;

            .ui-chkbox-icon:before {
                color: #fff;
            }

            .ui-chkbox-icon {
                &.ui-icon-check {
                    &:before {
                        color: #444;
                    }
                }

                &.ui-icon-blank {
                    &:before {
                        color: transparent;
                    }
                }
            }

            .ui-icon-bullet {
                width: 10px;
                height: 10px;
                margin-left: -5px;
                margin-top: 3px;
                color: #444 !important;
            }

            &.ui-state-focus {
                -moz-box-shadow: 0 0 5px @box-shadow-color;
                -webkit-box-shadow: 0 0 5px @box-shadow-color;
                box-shadow: 0 0 5px @box-shadow-color;
                border-color: lighten(@box-shadow-color, 30%);
                background-color: #fff;
            }

        }

        .ui-radiobutton {
            background-color: transparent;
        }

        .ui-radiobutton .ui-radiobutton-box.ui-state-active {
            border-color: #444;
            span.ui-radiobutton-icon {
                background-color: #444 !important;
            }
        }

    }

    th.ui-state-default[role="columnheader"] {
        background: transparent none;
        overflow: visible;

        .ui-chkbox-box.ui-state-active {
            border: 1px solid #d2d6de;
        }
    }

}

body .ui-datatable, body .ui-treetable {
    td.ui-selection-column, th.ui-selection-column {
        @media (max-width: @screen-sm-max) {
            width: 8% !important;
        }

        @media (max-width: @screen-xs-max) {
            width: 10% !important;

        }

    }

    tr {
      &.ui-widget-content.ui-state-hover {
        border-bottom: #f4f4f4 !important;
        border-top: #f4f4f4 !important;
      }

      &.ui-datatable-selectable.ui-state-highlight {

        div.ui-chkbox-box.ui-state-active {
          border-color: @brand-primary;
        }
        .ui-icon:before {
          color: #fff;
        }
      }

    }

}

body .ui-treetable .ui-treetable-data {

    span.ui-treetable-toggler {
        background-image: none !important;
        display: inline !important;

        &.ui-icon-triangle-1-e:before {
            font-family: 'Glyphicons Halflings';
            color: @admin-text-color;
            position: relative;
            font-size: @glyphicon-icon-size;
            font-weight: bold;
            top: -5px;
            padding: 0 4px;
            overflow: hidden;
            content: "\e258" !important;
        }

        &.ui-icon-triangle-1-s:before {
            font-family: 'Glyphicons Halflings';
            color: @admin-text-color;
            position: relative;
            font-size: @glyphicon-icon-size;
            font-weight: bold;
            padding: 0 4px;
            overflow: hidden;
            top: -5px;
            content: "\e259" !important;
        }
    }

    tr[aria-selected="true"]:not(.ui-treetable-partialselected) {

        .ui-icon-triangle-1-s, .ui-icon-triangle-1-e {
            &:before {
                color:#fff;
            }
        }

    }

}


body .ui-treetable .ui-treetable-selectable-node .ui-chkbox.ui-selection .ui-chkbox-icon.ui-icon-check:before {
    color: @admin-text-color;
    top:1px;
}

@-moz-document url-prefix() {
    @media (max-width: @screen-xm) {
        body .ui-treetable .ui-treetable-selectable-node .ui-chkbox.ui-selection .ui-chkbox-icon.ui-icon-check:before {
            top:0px; //checkbox is not centered on firefox on small screens
        }
    }
}

body .ui-treetable  {

    span.ui-treetable-toggler {
        margin-right: 5px;
    }

    div.ui-chkbox-box {
        margin-top: 3px;
        margin-right: 2px;
    }
}

/* datatable paginator */
body div.ui-datatable, body div.ui-treetable {
    div.ui-paginator {
        border: 1px solid #f4f4f4;
        span.ui-paginator-pages {
            overflow: hidden;
            padding: 6px 12px;
            display: inline;
            line-height: 1.42857143;
        }
    }

    div.ui-paginator-bottom {
        border-top-color: transparent;
    }

    div.ui-paginator-top {
        border-bottom-color: transparent;
    }

    td.ui-datatable-subtable-header {
        border-color: @datatable-border-color;
        border-bottom-color: @datatable-row-border-color;
    }

}

body .ui-paginator {
    .ui-paginator-page, .ui-paginator-pages, .ui-paginator-current, select, .ui-paginator-first, .ui-paginator-prev, .ui-paginator-last, .ui-paginator-next {
        background: #fff;
        position: relative;
        font-weight: 400;
        display: inline-block;
        zoom: 1;
        margin: 0 0 0 -1px;
        line-height: 1.42857143;
        cursor: pointer;
        text-decoration: none;
        border-radius: 0;
        outline: 0;
        .box-shadow(none);
        a.ui-state-hover {
            background: #e6e6e6;
        }
    }
    .ui-paginator-page, .ui-paginator-pages, .ui-paginator-current {
        padding: 6px 12px;
    }

    .ui-paginator-first, .ui-paginator-prev, .ui-paginator-last, .ui-paginator-next, select {
        padding: 6px 8px;
    }

    .ui-paginator-prev {
        margin-right: 1px;
    }

    select.ui-paginator-rpp-options {
        padding: 6px 8px;
        -moz-appearance: none;
    }

    a.ui-paginator-last span.ui-icon-seek-end {
        background-image: none !important;
        display: inline !important;
        font-size: 0;
        &:before {
            font-family: FontAwesome;
            color: @admin-text-color;
            position: relative;
            font-size:  (@font-awesome-icon-size - 1) ;
            top: 0;
            padding: 0 4px;
            content: "\f051" !important;
        }
    }

    a.ui-paginator-first span.ui-icon-seek-first {
        background-image: none !important;
        display: inline !important;
        font-size: 0;
        &:before {
            font-family: FontAwesome;
            color: @admin-text-color;
            position: relative;
            font-size: (@font-awesome-icon-size - 1);
            top: 0;
            padding: 0 4px;
            overflow: hidden;
            content: "\f048" !important;
        }
    }

    a.ui-paginator-next span.ui-icon-seek-next {
        background-image: none !important;
        display: inline !important;
        font-size: 0;
        margin-left: -1px;
        margin-right: -4px;
        &:before {
            font-family: FontAwesome;
            color: @admin-text-color;
            position: relative;
            font-size: (@font-awesome-icon-size - 1);
            top: 0;
            padding: 0 4px;
            overflow: hidden;
            content: "\f054" !important;
        }
    }

    a.ui-paginator-prev span.ui-icon-seek-prev {
        background-image: none !important;
        display: inline !important;
        font-size: 0;
        margin-left: -4px;
        margin-right: -1px;
        &:before {
            font-family: FontAwesome;
            color: @admin-text-color;
            position: relative;
            font-size: (@font-awesome-icon-size - 1);
            top: 0;
            padding: 0 4px;
            overflow: hidden;
            content: "\f053" !important;
        }
    }

}

@media (max-width: @screen-xm) {
    body div.ui-treetable, body div.ui-datatable {
        div.ui-paginator span.ui-paginator-pages {
            display: none ;
        }
    }
}

@media (max-width: @screen-xm) {
    body .ui-paginator {

        .ui-paginator-prev {
            margin-right: 0px;
        }

        span.ui-icon:hover {
            opacity: 1;
        }
    }

}

body .ui-paginator .ui-paginator-pages a {
    color: #666 !important;
    -moz-transition: background-color 0.3s;
    -o-transition: background-color 0.3s;
    -webkit-transition: background-color 0.3s;
    transition: background-color 0.3s;
}

body .ui-paginator .ui-paginator-page.ui-state-active {
    background: @light-blue;
    color: #fff !important;
    border-color: @light-blue;
}

span.ui-paginator-current {
    font-weight: 600 !important;
}


.ui-datatable .ui-datatable-sticky {
    z-index: 999!important;
}

.datatableBoxColors(@color, @text-color) {
    .ui-datatable-header, .ui-treetable-header {
        border-top: 3px solid @color;
    }

    &.box-solid {
        .ui-datatable-header, .ui-treetable-header, .ui-datatable-footer, .ui-treetable-footer {
            background-color: @color;
            color: @text-color;
        }
        thead tr[role="row"] {
            background-color: @color;
        }

        th[role="columnheader"] {
            span.ui-column-title {
                color: @text-color
            }

            .ui-sortable-column-icon:before {
                color:@text-color;
            }

            &.ui-state-default.ui-sortable-column.ui-state-active {
                background-image: -webkit-linear-gradient(top, @color, darken(@color,20%));
                background-image: linear-gradient(top, @color, darken(@color,20%));

            }
        }

    }
}

body .ui-treetable .ui-selection .ui-chkbox-box {
    background-color: #ffffff;
}

/* Editable */

td.ui-editable-column .ui-cell-editor-input {
    background-color: #fff;

    .ui-inputfield {
        width: 100%;
    }

    &:hover, .ui-inputfield:hover {
        background-color: @datatable-row-hover-color;
    }
}

.ui-row-editor  {

    a {
        text-decoration: none!important;
    }

    span.ui-icon {
        background-image: none;
        display: inline;
    }
    span.ui-icon-pencil:before {
        font-family: FontAwesome;
        position: relative;
        font-size: @font-awesome-icon-size - 1;
        overflow: hidden;
        content: "\f040";
    }

    span.ui-icon-check:before {
        font-family: 'Glyphicons Halflings';
        position: relative;
        font-size: @font-awesome-icon-size - 1;
        overflow: hidden;
        content: "\e013";
    }

    span.ui-icon-close:before {
        font-family: 'Glyphicons Halflings';
        position: relative;
        font-size: @font-awesome-icon-size - 1;
        overflow: hidden;
        content: "\e014";
    }

}

//adjust hover on row selection pluseditable row
tr.ui-datatable-selectable.ui-row-editing {
    &.ui-state-highlight {
        .ui-cell-editor-input {
            &:hover, .ui-inputfield:hover {
                background-color: @datatable-row-hover-color;
            }
        }
    }
    div.ui-cell-editor-input {
        &:hover, .ui-inputfield:hover {
            background-color: #fff;
        }
    }
}

@media (max-width: @screen-xs) {

    .ui-row-editor  {
        span.ui-icon-pencil:before {
            font-size: @font-awesome-icon-size;
        }

        span.ui-icon-check:before {
            font-size: @font-awesome-icon-size;
        }

        span.ui-icon-close:before {
            font-size: @font-awesome-icon-size;
        }
    }

}

/* no-border */
body .ui-datatable.no-border, body .ui-treetable.no-border {

    th[role="columnheader"], tbody, .ui-datatable-header, .ui-datatable-subtable-header, .ui-datatable-footer, .ui-treetable-header, .ui-paginator, td {
        border:transparent!important;
        border-top: none!important;
        border-bottom: none!important;

        &.ui-editable-column {
            .ui-selectonemenu, .ui-inputfield, .ui-autocomplete {
                border-left: transparent!important;
                border-right: transparent!important;
                border-radius: 0!important;
                &.ui-state-hover {
                    border-top-color: transparent!important;
                    border-bottom-color: transparent!important;
                    border-radius: 0!important;
                }
            }
        }
    }
    tfoot td {
        border-left: transparent!important;
        border-right: transparent!important;
    }
    tr, tr.ui-widget-content {
        border-left: transparent!important;
        border-right: transparent!important;
        &.ui-state-hover {
            border-top: 1px solid @datatable-row-border-color!important;
            border-bottom: 1px solid @datatable-row-border-color!important;
        }
    }
    td[role="gridcell"] {
        text-align: center;
    }
}

//row grouping

a.ui-rowgroup-toggler {
    text-decoration: none!important;

    .ui-rowgroup-toggler-icon {

        &.ui-icon-circle-triangle-s {
            background-image: none;
            display: contents;
            &:before {
                font-family: 'Glyphicons Halflings';
                color: @admin-text-color;
                position: relative;
                top: -2px;
                font-size: @glyphicon-icon-size!important;
                overflow: hidden;
                content: "\e259" !important;
            }

            &.icon-ripple:before {
                left: -4px;
                margin-right: -8px;
            }
        }

        &.ui-icon-circle-triangle-e {
            display: contents;
            background-image: none;
            &:before {
                font-family: 'Glyphicons Halflings';
                color: @admin-text-color;
                position: relative;
                top: -2px;
                font-size: @glyphicon-icon-size!important;
                overflow: hidden;
                content: "\e258" !important;
            }

            &.icon-ripple:before {
                left: -4px;
                margin-right: -8px;
            }
        }
    }

}

@supports (-ms-ime-align: auto) {
    body a.ui-rowgroup-toggler .ui-rowgroup-toggler-icon {
        &.ui-icon-circle-triangle-s,  &.ui-icon-circle-triangle-e {
            display: ruby-base;
        }
    }
}

//row expansion
div.ui-row-toggler {
    background-image: none!important;
    display: inline;
    outline: none;

    &.ui-icon-circle-triangle-e {
        &:before {
            font-family: 'Glyphicons Halflings';
            color: @admin-text-color;
            position: relative;
            font-weight: bold;
            top: -2px;
            font-size: @glyphicon-icon-size!important;
            overflow: hidden;
            content: "\e258" !important;
        }

        &.icon-ripple:before {
            left: -4px;
        }

    }

    &.ui-icon-circle-triangle-s {
        &:before {
            font-family: 'Glyphicons Halflings';
            color: @admin-text-color;
            position: relative;
            font-weight: bold;
            top: -2px;
            font-size: @glyphicon-icon-size !important;
            overflow: hidden;
            content: "\e259" !important;
        }

        &.icon-ripple:before {
            left: -4px;
        }

    }

}

body.sidebar-collapse .ui-datatable.ui-datatable-sticky > .ui-datatable.ui-datatable-sticky {
  margin-left: -(@sidebar-width - 50px);
}

