// Harmonize focus style between browsers
$autofillFocusBorderColor: $colorWheel-01;
$autofillBgColor: rgb(250, 255, 189); // = Chrome default setting

@mixin focus-style {
    border: 1px solid $info !important;
    &:-webkit-autofill {
        border-color: $autofillFocusBorderColor !important;
    }
}
input,
select,
textarea {
    &:focus {
        outline: none;
    }
    &:not(.error):not(.select2-input):focus {
        @include focus-style;
    }
}

label, .form_desc {
    display: inline-block;
    cursor: pointer;
    margin-bottom: 5px;
    padding-right: 10px;

    abbr {
        color: $info;
        border-bottom: none;
        cursor: inherit;
        text-decoration: none;
        padding-left: 2px;
    }
}

#loginForm {
    label {
        abbr {
            display:none;
        }
    }
}

.uploader .file-upload.grid-row {
    max-width: none;
}

.file-upload {
    display: inline-block;
    position: relative;
    overflow:hidden;
    max-width: 300px;
    .file-name {
        padding:  2px 5px;
        background: white;
        &.placeholder {
            font-style: italic;
            color: whiten($textColor, .8);
        }
        @include simple-border();
        &.active {
            font-style: normal;
            color: $textColor;
        }
    }
    input[type="file"] {
        font-size: 80px !important;
        position: absolute;
        left: auto;
        right: 0;
        top: 0;
        opacity: 0;
        cursor: pointer;
    }

    &:hover {
        .btn-info {
            opacity: .85;
        }
    }
}

.uri-container {
    position: relative;
    display: inline-block;
    width: 65%;
    overflow:hidden;
    input {
        &.final {
            width: calc(100% - 30px) !important;
            position: absolute;
            left: 0;
            top: 0;
            border-color: #bbb;
            height: 100%;
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
            border-right: none;
        }
    }
    .clipboard-command {
        position: absolute;
        top: 0;
        right: 0;
        background: whiten($uiHeaderBg, .3);
        cursor: pointer;
        color: $textColor;
        display: block;
        width: 30px;
        height: 100%;
        text-align:center;
        line-height: 23px;
        text-shadow: none;
        border: 1px #ccc solid;
        border-top-right-radius: 2px;
        border-bottom-right-radius: 2px;
        &:hover {
            background: whiten($uiHeaderBg, .45);
        }
    }
}

.file-drop {
    height: 150px;
    overflow-y: auto;
    border: solid 1px $uiGeneralContentBorder;
    position: relative;
    .dragholder{
        padding-top: 20px;
        text-align: center;
        color: $uiGeneralContentBorder;
        @include font-size(20);
    }
    &.drag-hover {
        border-color: $uiClickableHoverBg;
        color: $uiClickableHoverBg;
        &:after {
            content: attr(data-drop-msg);
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            width: 75%;
            height: 30px;
            padding: 5px;
            background-color: $info;
            color: white();
            text-align: center;
            margin: auto;
        }
    }
    ul {
        list-style-type: none;
        position: relative;
        margin: 0;
        padding: 0;
        & > li{
            position: relative;
            padding: 6px 60px 6px 6px;
            @include simple-border;
            @extend .truncate;
            &:before {
                @include tao-icon-setup;
                @include icon-document;
                @include font-size(14);
                line-height: 14px;
                margin-right: 5px;
                color: $info;
            }
            .size {
                color: $info;
                margin-left: 5px;
                font-style: italic;
            }
            .status {
                position: absolute;
                right: 30px;
                top: 6px;
                &.sending:before {
                    @include tao-icon-setup;
                    @include icon-download;
                    @include fade(2s);
                    @include repeat;
                }
                &.success:before{
                    @include tao-icon-setup;
                    @include icon-success;
                    color: $success;
                }
                &.error:before{
                    @include tao-icon-setup;
                    @include icon-error;
                    color: $error;
                }
            }
            .icon-close {
                position: absolute;
                right: 6px;
                top: 6px;
            }
        }
    }
}


.pseudo-label-box {
    position: relative;
    cursor: pointer;
    & > label {
        width: 20px;
        position: absolute;
        top: 0;
        margin: 0;
        left: 0;

        & + div {
            cursor: pointer;
            margin-left: 24px;
        }
    }
    abbr {
        border: none;
        color: $info;
    }
}

ol, ul {
    &.horizontal {
        .pseudo-label-box {
            & > label {
                & + div {
                    display: table;
                }
            }
        }
    }
}

input[type="color"],
input[type="date"],
input[type="datetime"],
input[type="datetime-local"],
input[type="email"],
input[type="month"],
input[type="number"],
input[type="range"],
input[type="search"],
input[type="tel"],
input[type="time"],
input[type="text"],
input[type="password"],
input[type="url"],
input[type="week"],
textarea,
select {
    @include simple-border();
    @include border-radius(2);
    font-family: $regularFont;
    padding: 4px;
    min-inline-size: 150px;
    background-color: white;
    color: $textColor;
    max-inline-size: 300px;

    &.disabled, &[disabled], &[readonly] {
        color: $textColor;
        opacity: .55 !important;
        cursor: default;
    }
    &.disabled, &[disabled] {
        cursor: not-allowed !important;
    }

    & ~ .validate-error {
        color: $error;
    }
    &.error {
        border-color: $error;
        color: $error;
        & + .form-error{
            color: $error;
            text-align: right;
        }
    }
}

input[type="text"].viewable-hiddenbox-input,
input[type="password"].viewable-hiddenbox-input {
    @include border-radius-right(0);
    border-right-width: 0;
    -webkit-tap-highlight-color: rgba(0,0,0,0); // remove the gray overlay when input field is tapped on iPad
    &:focus {
        border-right-width: 0 !important;
    }
    &::-ms-reveal {
        display: none; // remove microsoft password toggler
    }
}

.viewable-hiddenbox-toggle {
    @include simple-border();
    @include border-radius-right(2);
    @include border-radius-left(0);
    border-left-width: 0;
    padding: 2px 4px 0;
    background-color: white;
    color: whiten($textColor, .3);
    cursor: pointer;

    &:hover {
        color: $textColor;
    }
}

.viewable-hiddenbox-input.error + .viewable-hiddenbox-toggle {
    border-color: $error;
}

.viewable-hiddenbox-input:focus:not(.error) + .viewable-hiddenbox-toggle {
    @include focus-style();
    border-left:0 !important;
}

.viewable-hiddenbox-input:-webkit-autofill + .viewable-hiddenbox-toggle {
    background-color: $autofillBgColor;
}

.viewable-hiddenbox-input:-webkit-autofill:focus:not(.error) + .viewable-hiddenbox-toggle {
    border-color: $autofillFocusBorderColor !important;
}

.form_radlst {

    input[type="radio"],
    input[type="checkbox"] {
        &.error {

            + label {
                border-color: $error;
                color: $error;
            }
        }
    }

    &.error {
        .select2-container {
            > :first-child {
                border-color: $error;
            }
        }
    }

    + .form-error {
        color: $error;
        text-align: right;
    }

}

option {
    background: white;
    color: $textColor;
}



label {
    position: relative;
    [class^="icon-checkbox"],
    [class*=" icon-checkbox"] {
        &:after {
            @include icon-checkbox-bg;
            color:white !important;
        }
    }
    [class^="icon-radio"],
    [class*=" icon-radio"] {
        padding: 0 2px 0 3px;
        &:after {
            @include icon-radio-bg;
            color:white !important;
        }
    }
    .icon-checkbox,
    .icon-checkbox-crossed {
        padding: 0 3px 0 3px;
    }
    .icon-checkbox-checked {
        padding: 0 0 0 3px;
    }
    [class^="icon-"],
    [class*=" icon-"] {
        @include font-size(16);
        position: relative;
        top: 2px;
        color: #555;
        display: inline-block;
        width: 20px;
        &:before, &:after {
            position: relative;
        }
        &:before {
            z-index: 3;
        }
        &:after {
            position: relative;
            z-index: 2;
            left: -1em;
        }
    }

    input[type="radio"],
    input[type="checkbox"] {
        @include visuallyHidden;

        &:focus ~ [class^="icon-"],
        &:focus ~ [class*=" icon-"],
        &:active ~ [class^="icon-"],
        &:active ~ [class*=" icon-"] {
            color: #222;
        }
        &:checked ~ .icon-checkbox:before {
            @extend %icon-checkbox-checked-before;
        }
        &:indeterminate ~ .icon-checkbox:before {
            @extend %icon-checkbox-indeterminate-before;
        }
        &:checked ~ .icon-radio:before {
            @extend %icon-radio-checked-before;
        }
        &:checked ~ .icon-checkbox.cross:before {
            @extend %icon-checkbox-crossed-before;
        }
        &:indeterminate ~ .icon-checkbox:before {
            @extend %icon-checkbox-indeterminate-before;
        }
        &.disabled, &[disabled], &[readonly] {
            & ~[class^="icon-"],
            & ~[class*=" icon-"],
            & ~label {
                cursor: not-allowed !important;
                opacity: .4 !important;
                color: #555;
            }
        }
    }
}

// Edge styles go here, they cannot be include in the rule set below :-(
@supports (-ms-ime-align:auto) {
    label {
        [class^="icon-radio"],
        [class*=" icon-radio"],
        [class^="icon-checkbox"],
        [class*=" icon-checkbox"] {
            &:after {
                left:auto !important;
                top: 0 !important;
                z-index: 2;
                position: absolute;
            }
        }
    }
}

// IE10+ CSS styles go here
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    label {
        [class^="icon-radio"],
        [class*=" icon-radio"],
        [class^="icon-checkbox"],
        [class*=" icon-checkbox"] {
            &:after {
                color:white !important;
                left:2px;
                position: absolute;
                z-index: 2;
            }
        }
    }
}

.search-form, .filter-form {
    display:none;

    @include font-size(13);
    .xhtml_form {

        .form_desc {
            display:block;
            width: auto;
            margin-top: 5px;
            margin-bottom: 1px;
        }
        .form-toolbar {
            margin: 0 !important;
        }
        input {
            &[type="text"], &[type="password"] {
                width: 100%;
                max-width: none;
            }
        }
        select, textarea, .form_radlst {
            width: 100%;
            max-width: none;
        }

        .form-group {
            margin-bottom: 0;
            & > div > div {
                margin-bottom: 10px;
            }
        }
        label {
            margin: 0;
        }

        .form_radlst {
            padding-left: 2px
        }
    }

    .ui-widget-header, .search-title {
        @include font-size(16);
        border: none;
        margin: 8px 0;
    }

    & > div {
        background: transparent;
    }
}

.xhtml_form {
    form, .form {
        > div {
            margin-bottom: 10px;

            &.property-container {
                border-top: 1px solid $uiGeneralContentBorder;
                .tree {
                    ul {
                        background: transparent !important;
                    }
                }
            }

        }
        h3 {
            margin: 0 0 12px;
        }
    }



    // these buttons are originally green which turned out to be avery poor choice
    [class^="btn-"], [class*=" btn-"],
    button, input[type="submit"], input[type="reset"] {
        &.btn-success {
            @include generic-btn-primary(white(), $info);
            &.btn-secondary {
                @include generic-btn-secondary($info, $uiGeneralContentBg);
            }
        }
    }

    .form-toolbar {
        text-align: right;
        margin: 30px 0 0 0;
        @extend %clearfix;

        [dir="rtl"] & {
            text-align: left;
        }
    }

    .property-title {
        margin-bottom: 10px;
    }

    .property-heading-icon {
        margin-left: 5px;
        &:hover {
            color: $info;
        }
    }

    .property-heading-label {
        padding-left: 5px;
        &:before {
            font-size: 12px;
            content: '\2022 ';
            line-height: 2px;
            opacity: .8;
        }
    }

    .property-edit-container {
        display:none;
        width: 100%;
    }


    .property-heading-toolbar {
        float: right;
        .property-parent-label {
            display:inline-block;
            padding: 0 5px;
        }
        [class^="icon-"], [class*=" icon-"] {
            background: white(.5);
            @include simple-border();
            margin-left: 1px;
            padding: 3px;
            cursor: pointer;
            min-width: 24px;
            display: inline-block;
            text-align: center;
            &:hover {
                background: white(.7);
                color: $info;
            }
        }
    }

    .property-block {
        overflow: hidden;
        padding: 6px 0;
        border-bottom: 1px white solid;
        &.property-block-first {
            border-top: 1px white solid;
        }
        &.readonly-property div {
            display: inline;
            div {
                float: right;
                padding-left: 5px;
                color: whiten($textColor, .4);
                cursor: default;
            }
        }
        &.parent-property div {
            display: inline;
            div {
                float: right;
                padding-left: 5px;
                color: whiten($textColor, .2);
            }
        }
        &.regular-property {
            & > div {
                @include simple-border();
                padding: 15px;
                background: white(.5);
                margin: 5px 0;
                position: relative;
                top: 6px;
                div {
                    padding: 2px 0
                }
            }
        }
    }

    ul.json-object-list {
        @include simple-border();
        display: inline-block;
        padding: 15px;
        width: 65%;
        margin: 5px 0;
        position: relative;
        background: white(.5);
        list-style-type: none;

        li {
            margin-bottom: 10px;

            input[type="text"] {
                width: 100%;
            }
        }
    }

    .bool-list {
        overflow: hidden;
        .form_desc {
            float:left;
        }
    }

    .form_disabled_message {
        width: 65%;
        margin-left: auto;
        font-size: 12px;
    }

    .form_desc {
        width: 35%;
        display:inline-block;
        padding: 0 10px 0 0;
        vertical-align: bottom;

        &.hidden-input-label {
            width: auto;
        }

        & ~ .form-elt-container {
            display: inline-block;
            width: 65%;
            .tree {
                max-width: none;
                @include simple-border();
            }
        }
        & ~.form-error{
            color: $error;
            text-align: right;
        }

        [dir="rtl"] & {
            padding: 0 0 0 10px;
        }
    }
    input {
        &[type="text"], &[type="password"] {
            width: 65%;
            max-width: none;
        }
    }
    select, textarea, .form_radlst {
        width: 65%;
        max-width: none;
    }

    .viewable-hiddenbox {
        display: flex;
        label {
            flex: 0 0 auto;
        }
        input {
            flex: 1 1 auto;
            height: 100%; // Safari fix
        }
        .viewable-hiddenbox-toggle {
            flex: 0 0 24px;
        }
    }

    .form_radlst {
        display:inline-block;
    }

    .datepicker-input {
        /*
        z-index value of datepicker will be inherited from input z-index value+1
        z-index of datepiker should be higher than z-index of main menu (see https://oat-sa.atlassian.net/browse/TAO-936)
        */
        position: relative;
        z-index: 8100;
    }

    .form-group {
        & > div > div {
            position: relative;
            margin-bottom: 12px;
            .has-unit {
                padding-right: 45px
            }
            .unit {
                position: absolute;
                top: 1px;
                right: 1px;
                background: $canvas;
                width: auto;
                display: block;
                padding: 3px 10px;
                @include border-radius-right();
                opacity: .8;
                cursor: default;
            }
        }
    }

    .btn-info {
        float:left;
    }

    .btn-success {
        float: right;
    }

    .form_checklst{
        .grid-row {
            [class*=" col-"], [class^="col-"] {
                margin: 0;
                .elt_desc {
                    padding: 0 10px;
                }
                .tooltip-trigger{
                    position: relative;
                    top: 2px;
                    color: $danger;
                }
            }
            &.readonly{
                .elt_desc, input[type="checkbox"]{
                    cursor: not-allowed;
                }
                .elt_desc{
                    opacity : 0.45;
                }
            }
        }
    }
}


input {
    &[type="checkbox"], &[type="radio"] {
        position: relative;
        margin-right: 4px;
    }
}

#cspHeader {
    .form_radlst {
        width: 85%
    }
}
