//
// Disable ms-clear pseudo-element globally to avoid confusion with the
// existing clearable integration in TYPO3
//
// https://msdn.microsoft.com/en-us/library/windows/apps/hh465740.aspx
//
*::-ms-clear {
    display: none;
}

//
// Form
//
#typo3-docbody form {
    margin-bottom: 1.25em;
}

//
// Go back A-tags
//
a.typo3-goBack {
    font-weight: bold;

    img {
        margin-right: 5px;
        vertical-align: middle;
    }
}

span.typo3-moduleHeader img {
    margin-right: 4px;
    vertical-align: middle;
}

//
// Form control state additions
//
.has-change {
    @include form-control-validation($state-info-text, $state-info-text, $state-info-bg);

    .thumbnail-status {
        border: 1px solid $state-info-text;
    }
    // A loading order issue prevents .has-change to be overridden with .has-error
    // this is a workaround needs to be cleaned up in a less file restructuring
    &.has-error {
        @extend .has-error;
    }
}

//
// Input group additions
//
.input-group-icon {
    width: 32px;
    vertical-align: middle;

    img {
        width: 100%;
        max-height: 18px;
    }
}

.input-group-addon {
    min-width: 2.5em;
}

//
// IE: ensure DatePicker is opened on button click
//
label {
    .icon {
        img {
            pointer-events: none;
        }
    }
}

//
// Form control additions
//
.form-control {
    min-width: 120px;
}

.form-control-adapt {
    width: auto;
    max-width: 100%;
}

.form-control-wrap {
    margin: 9px 0;
}

.form-control-holder {
    position: relative;
}

.row {
    > .form-group {
        > .form-control-wrap {
            margin-bottom: 0;
        }
    }
}

.form-group {
    .t3js-formengine-field-item {
        position: relative;

        > .t3js-charcounter {
            left: 0;
            position: absolute;
            top: 100%;
        }
    }
}

.form-control[disabled],
.form-control[readonly],
fieldset[disabled] .form-control {
    color: $input-color-disabled;
}

//
// Form control icon
//
.form-control-icon {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translate(0, -50%);
    z-index: 1;

    + .form-control,
    + .form-control-clearable .form-control {
        padding-left: 3.25em;
    }
}

//
// Form group validation states
//
.form-group.has-error {
    label:before {
        font-family: FontAwesome;
        font-size: 12px;
        text-align: center;
        content: $fa-var-exclamation-circle;
        color: $brand-danger;
        display: inline-block;
    }

    .btn-toolbar {
        label:before {
            font-family: inherit;
            font-size: inherit;
            margin-right: inherit;
            text-align: inherit;
            content: '';
            color: inherit;
            display: block;
        }
    }

    .input-group-btn {
        label {
            border-color: $brand-danger;

            .t3-icon {
                color: $brand-danger;
            }
        }

        label:before {
            font-family: inherit;
            font-size: inherit;
            margin-right: inherit;
            text-align: inherit;
            content: '';
            color: inherit;
            display: block;
        }
    }
}

//
// Select
//
select {
    &.form-control {
        &[multiple],
        &[size] {
            min-height: 156px;
            width: 100% !important;
        }

        &[size="1"] {
            height: $input-height-base;
            min-height: 0;
        }

        &[size="1"],
        &:not([size]) {
            appearance: none;

            &::-ms-expand {
                display: none;
            }

            &:not(.form-select-no-siblings) {
                background-image: url('#{$path-sysext}/core/Resources/Public/Icons/T3Icons/actions/actions-view-list-expand.svg');
                background-position: right 4px center;
                background-repeat: no-repeat;
                background-size: 16px 16px;
                padding-right: 24px;
            }

            &.input-sm,
            .form-group-sm & {
                line-height: 16px;
            }
        }

        > optgroup {
            margin-top: 9px;

            &:first-child {
                margin-top: 0;
            }
        }

        option {
            padding-top: 2px;
            padding-bottom: 2px;
        }
    }

    &.icon-select {
        option {
            padding-left: 22px;
        }
    }
}

//
// Styles for the "clearable" jquery plugin.
//
.form-control-clearable {
    position: relative;

    .form-control {
        padding-right: 2.3em;
    }

    .close {
        position: absolute;
        height: 16px;
        z-index: 3;
        top: 50%;
        right: 0.5em;
        transform: translate(0, -50%);

        .icon {
            vertical-align: 0;
        }
    }
}

.input-group {
    .form-control-clearable {
        display: table-cell;

        .form-control {
            display: block;
        }
    }
}

//
// Styles for the "capslock" jquery plugin.
//
.form-notice-capslock {
    position: absolute;
    right: 6px;
    top: 50%;
    margin-top: -10px;
    height: 20px;
    width: 20px;
    padding: 3px;
    z-index: 10;
    background-color: #fff;

    > img {
        display: block;
        opacity: 0.5;
    }
}

//
// Form Inline adjustments
//
.form-inline-spaced {
    margin: 0 -0.5em $line-height-computed;

    .form-group {
        margin: 0.5em 0.5em 0;

        label {
            margin-right: 0.5em;
        }
    }
}

//
// Form group additions
//
.form-group-dashed {
    & + .form-group-dashed {
        padding-top: 15px;
        border-top: 1px dashed #ccc;
    }
}

//
// Form Sections
//
.form-section {
    border: 1px solid #ccc;
    background-color: #fafafa;
    padding: 15px 12px 3px;

    & + .form-section {
        margin-top: -1px;
    }
}

.tab-pane {
    > .form-section:first-child {
        border-top: none;
    }
}

.form-section-headline {
    margin-top: 0;
    margin-bottom: 10px;
}

//
// Form Wizards
//
.form-wizards-wrap {
    display: table;
    width: 100%;

    > .form-wizards-element {
        display: table-cell;
        width: 100%;
    }

    > .form-wizards-items-top {
        display: table-row;
    }

    > .form-wizards-items-aside {
        display: table-cell;
        vertical-align: top;
        padding-left: 5px;
        white-space: nowrap;
    }

    > .form-wizards-items-bottom {
        display: table-row;
    }

    > .form-wizards-items-bottom:first-child {
        margin-top: 4px;
    }
}

//
// Form Irre
//
.form-irre-header {
    display: table;
    margin: -5px;

    @include user-select(none);
}

.form-irre-header-cell {
    display: table-cell;
    vertical-align: middle;
    white-space: nowrap;
    padding: 5px;
}

.form-irre-header-body {
    width: 100%;
    font-weight: normal;
    white-space: normal;

    dl {
        @extend .dl-horizontal;

        margin-bottom: 0;
    }
}

.form-irre-header-icon {
    padding-right: 0;
}

.form-irre-header-control {
    cursor: auto;

    .btn-group > .btn {
        float: none;
    }
}

//
// Form Multi Group
//
.form-multigroup-wrap {
    width: 100%;
    display: table;

    .form-multigroup-item {
        display: table-cell;
        width: 50%;
        vertical-align: top;

        + .form-multigroup-item {
            padding-left: 5px;
        }
    }

    .form-multigroup-item-wizard {
        margin-bottom: 5px;

        + select.form-control[multiple],
        + select.form-control[size] {
            min-height: 125px;
        }
    }

    .form-wizards-wrap {
        width: 100%;
    }
}

//
// Radio & Checkbox
//
.radio-row,
.checkbox-row {
    margin-top: 10px;
    margin-bottom: 5px;
}

.radio-column,
.checkbox-column {
    margin-bottom: 5px;

    > .radio,
    > .checkbox {
        margin: 0;
    }
}

.radio-inline,
.checkbox-inline {
    &.radio,
    &.checkbox {
        display: block;
        margin-left: 0;
        margin-right: 10px;
        margin-bottom: 10px;
        padding: 0;

        @media (max-width: $screen-xs-max) {
            & + .radio,
            & + .checkbox {
                margin-top: -5px;
            }
        }

        @media (min-width: $screen-sm-min) {
            display: inline-block;
            margin-top: 10px;

            label {
                white-space: nowrap;
            }
        }
    }
}

//
// Autoresize for Textareas
//
// no manual resizing for textareas (works on non-IE browser only anyways)
// as it is handled by JS: "autosize"
//
textarea {
    &.formengine-textarea {
        resize: none;
    }
}
