/**
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions copyright [year] [name of copyright owner]".
 *
 * Portions copyright 2014-2016 ForgeRock AS.
 */

@or-color: #337ab7;
@and-color: @base-theme-color;
@not-color: #f0ad4e;

.webkit-text-rendering-bugfix {
    -webkit-transform: translateZ(0px);
    -webkit-backface-visibility: hidden;
}

.focus-state {
    outline: none;
    border-color: rgba(102, 175, 233, 0.4);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, 0.6);
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, 0.6);
}

.list-table {
    .list-group-header {
        text-transform: uppercase;
        font-weight: 600;
        letter-spacing: 1px;
        font-size: 12px;
        display: block;
        padding: 10px 15px 7px 0;
        border-bottom: 2px solid #ddd;
        margin-bottom: -1px;
        margin-top: 0;
    }

    &:not(.created-items) {
        .list-group-item:hover, .list-group-item:focus {
            cursor: pointer;
        }

        .list-group {
            border-bottom: 1px solid #eee;
        }
    }

    .list-group {
        box-shadow: none;
        -webkit-box-shadow: none;

        .list-group-item {
            border-right: 0;
            border-left: 0;
            border-radius: 0;

            &:first-child {
                border-top-width: 2px;
            }

            .list-item-text {
                float: left;
                overflow-x: hidden;
                text-overflow: ellipsis;
                width: 90%;
            }

            &.list-no-items {
                border: 0;
            }

            .fa-container {
                width: 5%;
            }

            .fa {
                opacity: 0;
                transition: all 300ms ease-in-out;
                color: #777;
                cursor: pointer;
                margin-top: 4px;

                &.fa-chevron-right {
                    padding-right: 10px;
                }

                &:focus {
                    outline: none;
                }
            }

            &:hover, &:focus {
                .fa-chevron-right {
                    opacity: 1;
                    color: #31708f;
                    padding-right: 0;
                }
            }

            &:focus {
                .focus-state;
                background-color: rgba(217, 237, 247, 0.5) !important;
            }

            &:not(.editing) {
                .radio-inline {
                    padding-top: 0;
                }
            }

            .radio-group {
                margin-right: 10px;
            }

            &.text-danger {
                background: #f2dede;
                transition: background 0.2s linear;

                .form-control {
                    color: @failure-color;
                }
            }

            &.text-success {
                background-color: #dff0d8;
                transition: background 0.2s linear;
            }

            &.text-info {
                background-color: #d9edf7;
            }
        }
    }

    &.created-items {
        .list-group {
            .list-group-item {
                .fa {
                    opacity: 1;

                    &:focus, &:hover {
                        opacity: 1;
                    }
                }

                .fa-close {
                    &:focus, &:hover {
                        color: @base-theme-color;
                    }
                }

                &.editing {
                    border-top-width: 2px;
                    background-color: @background-color;

                    .form-control {
                        display: inline-block;
                        width: 40%;
                        margin: 0 5px 4px;
                    }

                    .radio-group {
                        margin-top: 7px;
                    }
                }
            }
        }
    }
}

#selectedResTypes {
    margin-top: 34px;
}

.edit-policy-dialog {
    .modal-body {
        padding: 0;
    }
}

.item-button-panel {
    > span {
        opacity: 0.7;
        transition: opacity 200ms linear;

        &:hover, &:focus {
            opacity: 1;
        }
    }

    &.edit-state .fa {
        display: none;
    }
}

body.dragging,
body.dragging * {
    cursor: move !important;
}

body.editing {

    #condition-management #dropOffArea {
        li.editing-disabled {

            &:focus {
                cursor: default;
            }

            > .item-button-panel {
                .fa {
                    display: none;
                }
            }

            > .item-button-panel, > .form-control, > .item-data {
                color: #ccc;
            }
        }
    }

    #condition-management ol.condition-management-group {
        li.rule.editing {
            &:focus {
                cursor: default;
            }

            & + li.rule {
                display: none;
            }

            .item-button-panel {
                .fa {
                    display: none;
                }

                &.edit-state .fa {
                    display: inline-block;
                }
            }
        }
    }
}

.condition-management-group {
    padding: 0;
    margin-bottom: 20px;
}

#environmentContainer {
    position: relative;
}

#condition-management {

    .fa:hover {
        cursor: pointer;
    }

    .form-control {
        height: 30px;
        text-overflow: ellipsis;
    }

    .popover {
        min-width: 250px;
        color: #2a2f32;
    }

    .selectize-control.multi, .selectize-control.single {
        .selectize-input {
            margin-top: 16px;
            padding: 4px 15px;
            border-radius: 4px;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
            border-color: #ccc;
            min-height: inherit;
        }
    }

    .selectize-control.multi .selectize-input.has-items {
        padding: 2px 8px 0;
    }

    .selectize-control.single .selectize-input:after {
        right: 6px;
        margin-top: -3px;
    }

    .boolean-condition {
        padding-left: 0;
        display: inline;
        position: absolute;
        top: 15px;
        left: 0;

        .btn {
            padding: 4px 10px;
        }
    }

    label {
        display: block;
        float: left;
        padding: 0 5px 0 0;
        text-align: left;
        white-space: nowrap;
    }

    ol ol {
        padding: 0;
    }

    ol#dropOffArea li.invalid-rule {
        select {
            border-color: @failure-color;
        }
    }

    span.item-button-panel {
        float: right;

        > span {
            padding-left: 5px;

            &.tooltips {
                &:hover span, &:focus span {
                    margin-left: -54px;
                    width: 100px;
                }

                &.tooltips-wide {
                    &:hover span, &:focus span {
                        margin-left: -105px;
                        width: 200px;
                    }
                }
            }
        }
    }

    li.operator > span.item-button-panel {
        padding-top: 0;
    }

    li.editing span.item-button-panel {
        margin-top: 5px;
    }

    li.dragged {
        position: absolute;
        top: 0;
        opacity: 0.6;
        z-index: 200;

        .info-button {
            display: none;
        }
    }

    li.dragged.dropped {
        opacity: 1;
    }

    ol.dropbox {

        li.dragged {
            cursor: move;

            .info-button {
                display: none;
            }
        }
    }

    ol.condition-management-group {
        .rule, .operator, .placeholder {
            border-radius: 4px;
            border: 1px solid #ddd;
            display: block;
            margin: 15px 0 0;
            padding: 15px;
        }

        li.operator {
            display: block;
            margin: 15px 0 0;
            padding: 15px;

            &.or, &.and, &.not {
                cursor: default;

                > .form-control {
                    width: 145px;
                }

                &:focus {
                    outline: none;
                }

                &:not(:first-child):not(.editing-disabled):focus,
                &:not(:first-child):not(.editing-disabled):hover {
                    border-top-color: #777;
                    border-right-color: #777;
                    border-bottom-color: #777;
                    cursor: move;
                }
            }

            &.or {
                border-left: 4px solid @or-color;

                &.editing-disabled {
                    border-left-color: lighten(@or-color, 25%);
                }
            }

            &.and {
                border-left: 4px solid @and-color;

                &.editing-disabled {
                    border-left-color: lighten(@and-color, 25%);
                }
            }

            &.not {
                border-left: 4px solid @not-color;

                &.editing-disabled {
                    border-left-color: lighten(@not-color, 10%);
                }
            }
        }

        li.rule {
            cursor: default;

            &:focus {
                outline: none;
            }

            &:not(.editing-disabled):not(.editing):focus,
            &:not(.editing-disabled):not(.editing):hover {
                border-color: #777;
                cursor: move;
            }

            &.legacy-condition {
                color: #777;
            }
        }

        li.placeholder {
            position: relative;
            margin: 5px;
            padding: 0;
            height: 10px;
            background-color: #eee;
        }
    }

    .item-data {

        > div {
            font-size: 11px;
            line-height: 11px;
            border-right: 1px solid #ddd;
            padding-right: 8px;
            margin-right: 8px;
            float: left;

            &:last-of-type {
                border-right: none;
            }

            > h3 {
                color: inherit;
                font-weight: bold;
                font-size: 11px;
                line-height: 11px;
                padding-bottom: 5px;
                margin: 0;
            }

            > span {
                min-height: 11px;
                display: block;
                padding-bottom: 5px;
                .ellipsis;
                max-width: 500px;

            }

            &.no-float {
                float: none;
                margin-right: 30px;
            }
        }

        div.field-float-selectize {
            position: relative;
            float: left;
            height: 46px;
            min-width: 145px;
            max-width: 588px;
            margin: 0 5px 5px;
        }
    }

    li:not(.dragged) .info-button {
        float: right;
        margin: -3px 0 0;
        padding: 0;
    }

    .field-float-pattern, .field-float-select, .field-float-selectize {
        label {
            font-size: 11px;
            transition: all 0.1s linear;
            font-weight: bold;
            padding: 0;
            line-height: 11px;
            margin: 0;
        }
    }

    .field-float-pattern {
        min-height: 46px;
    }

    .field-float-select {
        min-height: 41px;
    }

    .field-float-pattern, .field-float-select {
        position: relative;
        margin: 0 5px 5px;
        float: left;
        min-width: 145px;

        &.button-field {
            min-width: 120px;
        }

        label {
            opacity: 0;
            &.showLabel {
                opacity: 1;
            }
        }

        input {
            position: absolute;
            left: 0;
            margin-top: 16px;
            width: 133px;

            /* Stop chromes autofill adding yellow backgrounds to datalists */
            &:-webkit-autofill {
                -webkit-box-shadow: 1px 1px 1px 0 rgba(0, 0, 0, 0.1) inset, 0 0 0 50px white inset;
                &:focus {
                    -webkit-box-shadow: 0 0 1px 1px #4481c4, 0 0 0 50px white inset;
                }
            }
        }

        &.type-selector-panel {
            label {
                top: 0;
                opacity: 1;
            }

            select {
                margin-top: 6px;
            }
        }

        select {
            margin-top: 16px;
            clear: left;
            float: left;

            &.placeholderText {
                color: #ddd;
                background-color: transparent;
                border-color: transparent;
                box-shadow: none;
            }
        }
    }

    .field-float-select:not(.type-selector-panel), .field-float-selectize {
        label {
            top: 10px;
            position: absolute;
            &.showLabel {
                top: 0;
            }
        }
    }

    .field-float-pattern {
        label {
            margin-top: 10px;
            &.showLabel {
                margin-top: 0;
            }
        }
    }

    .item-data {
        .fa-clock-o {
            position: absolute;
            right: 6px;
            bottom: 8px;
            color: #ccc;
            font-size: 14px;

            &:hover {
                cursor: text;
            }
        }

        .day-field, .time-field, .date-field {
            select, input {
                font-size: 12px
            }
        }

        .time-field {
            min-width: 75px;
            .form-control {
                padding-left: 10px;
                width: 75px;
            }
        }

        .day-field {
            min-width: 80px;
            .form-control {
                width: 80px;
            }
        }

        .date-field {
            min-width: 100px;
            .form-control {
                padding-left: 10px;
                width: 100px;
            }
        }
    }

    #conditionAttrTimeDate {
        border-right: none;
        margin-right: 0;

        div.pull-left {
            border-right: 1px solid #ddd;

            &:last-of-type {
                border-right: none;
            }
        }

        .selectize-input {
            height: 30px;

            .time-zone-selected {
                max-width: 120px;
                text-overflow: ellipsis;
                overflow-x: hidden;
            }
        }
    }

    .one-child-only {
        margin: 20px 0 0;
    }
}

.input-helper-text {
    color: #777;
    display: inline-block;
    margin-top: 5px;
}

.bootstrap-datetimepicker-widget table {
    td.active,
    td.active:hover,
    td span.active {
        background-color: @base-theme-color;
    }
}

#populateResource {
    #resourceBuilder {
        margin-top: 10px;
        float: left;
    }

    .btn {
        margin-top: 10px;
    }
}

.add-item-inline {
    padding: 0;
    margin-bottom: 15px;
}
