/*     FORMS      */

/* Input Fields */
$inputBorder: darken(#fff, 20%) !default;
$inputFocusBgColor: darken(#fff, 2%) !default;
$inputFocusBorderColor: darken(#fff, 26%) !default;

form {
    margin-bottom: 1em;

    fieldset {
        border: none;
        padding: 0;
    }

    label {
        display: block;
    }

    .label--inline {
        display: inline-block;
        padding: 10px 0 0;
        font-weight: 600;
    }
}

.form-control--select {
    select {
        position: relative;
        height: 30px;
        padding-right: 30px;
        font-size: 0.9rem;
        -webkit-appearance: none;
        -moz-appearance: none;

        &::after {
            content: '\f0dc';
            font-family: FontAwesome;
            padding: 8px;
            position: absolute;
            right: 10px;
            top: 5px;
            z-index: 1;
            width: 10px;
            line-height: 50%;
            font-size: 0.86rem;
            color: #428bca;
            pointer-events: none;
        }
    }
}

input[type="text"], input[type="password"], input[type="date"], input[type="datetime"], input[type="email"], input[type="number"], input[type="search"], input[type="tel"], input[type="time"], input[type="url"], textarea, select {
    padding: 5px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: normal;
    border: 1px solid $inputBorder;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0, 0, 0, 0.1);
    // resets bootrap form-control changes-effect on input
    &:focus {
        background: $inputFocusBgColor;
        border-color: $inputFocusBorderColor;
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    }
    &[disabled] { background-color: #ddd; }

    @media (min-width: $screen-sm-min) {
        font-size: inherit;
    }
}

input[type="search"] {
    -webkit-appearance: textfield;
    outline-offset: -2px;
}

input::-webkit-search-decoration,
input::-webkit-search-cancel-button {
    display: none;
}

.form-inline,
.navbar-form {
    .form-control {
        display: inline-block;
    }
}

.search-wrapper {
    position: 0;
    background-color: white;
    border-radius: 20px;
    padding: 2px;

    &::after {
        font-family: "FontAwesome";
        position: relative;
        top: 0;
        left: -24px;
        color: gray;

        @media (min-width: $screen-sm-min) {
            top: 2px;
        }
    }
}

.navbar-search-form {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
}

// large text inputBorder
.input-lg {
    font-size: 1.42;
    font-weight: normal;
    height: 36px !important;
    line-height: 30px !important;
    padding: 4px 6px !important;
}

// Clear Table Filter button/icon
.filter {
    padding-right: 30px !important;
}

.clear-input-icon {
    position: absolute;
    right: 10px;
    top: 11px;
    z-index: 100;
    line-height: 100%;
    height: 100%;
    color: rgb(223, 223, 223);
    font-size: 1.1rem;
    cursor: pointer;
}

.clear-input-icon:active {
    color: rgb(203, 203, 203);
}

.red {
    border-color: red !important;
    color: red;
}

.dropzone {
    height: auto;
    text-align: center;

    .drop {
        min-height: 50px;
    }

    input[type="file"] {
        display: inline;
    }

    &.disabled {
        cursor: not-allowed;
        background-color: #fff;
    }
}

.item-picker {
    display: flex;
    height: auto;
    padding: 4px 6px;
    background-color: #fff;
    border: 1px solid #ccc;

    &__preview {
        flex: 1 1 auto;
        overflow: hidden;

        .result-table {
            background-color: #fff;

            > li {
                margin: 4px 6px;
                border: none;
            }
        }
    }

    > .btn {
        margin-left: 1em;
    }

    &.disabled {
        cursor: not-allowed;
        background-color: #fff;
    }

    &__browse {
        flex: 0 1 auto;
    }
}

.collapsible {
    padding-left: 20px;
    position: relative;

    .collapsible-trigger {
        position: absolute;
        top: 12px;
        left: 0;
        cursor: pointer;
        border: 0;
        background: none;
    }
}

// 'x' button to clear form entries.
.clear-button {
    display: inline-block;
    padding: 0 3px 0 5px;
    border: none;
    background: transparent;
    color: #428bca;
}

// Labels on form elements with invalid values.
.non-valid-label {
    font-size: 0.8rem;
    font-weight: bold;
    color: #e00;
    text-transform: uppercase;
}

.form-element-with-valid-message {
    display: block;
    position: relative;

    @at-root #{&}--inline {
        display: inline-block;
    }

    .non-valid-label {
        position: absolute;
        top: 100%;
        left: 0;
    }
}

.form-edit {
    @at-root #{&}__save-controls {
        display: flex;
        justify-content: flex-end;
        margin-top: 10px;
        text-align: right;

        button, a {
            flex: 0 1 auto;
            margin-left: 5px;
        }
    }
}

/* stylelint-disable-next-line selector-class-pattern */
.rf-RepeatingFieldset__item {
    display: flex;
    background: #fbfbfb;
    position: relative;
    border: 1px solid #ccc;
    border-radius: $border-radius-base;
    padding: 5px 30px 5px 10px;
    margin-bottom: 10px;

    /* stylelint-disable-next-line selector-class-pattern */
    > .rf-Field {
        width: 100%;
    }

    /* stylelint-disable-next-line selector-class-pattern */
    > .rf-Fieldset {
        flex: 1 1 auto;
        padding: 0;
        border: none;
        border-radius: none;
        margin-bottom: 0;
    }

    /* stylelint-disable-next-line selector-class-pattern */
    > .rf-RepeatingFieldset__remove {
        flex: 0 0 16px;
        padding: 0;
        height: 34px;
        border: none;
        background: transparent;
        font-size: 1.3rem;
    }
}

/* stylelint-disable-next-line selector-class-pattern */
.rf-Fieldset {
    border: 1px solid #ccc;
    border-radius: $border-radius-base;
    padding: 5px 10px;
    margin-bottom: 10px;

    @at-root #{&}__label {
        /* stylelint-disable-next-line selector-class-pattern */
        &.rf-Label {
            /* stylelint-disable-next-line selector-class-pattern */
            > .rf-Label__label {
                font-size: 1.5rem;
            }
        }
    }
}

/* stylelint-disable-next-line selector-class-pattern */
.rf-Label {
    display: inline-block;
    padding-right: 10px;
    margin-bottom: 5px;
    font-weight: 700;
}

// Mark required fields.
/* stylelint-disable-next-line selector-class-pattern */
.required .rf-Label__label::after {
    content: " *";
    color: #f00;
}

/* stylelint-disable-next-line selector-class-pattern */
.rf-Field {
    margin-bottom: 10px;

    label {
        margin-bottom: 5px;
        font-weight: 700;
    }

    textarea {
        width: 100%;
        padding: 4px 6px;
    }

    select {
        width: 100%;
        height: 34px;
    }

    input[type="text"],
    input[type="number"] {
        width: 100%;
        height: 34px;
        padding: 4px 6px;
    }
}

/* stylelint-disable-next-line selector-class-pattern */
.rf-RepeatingFieldset {
    margin-bottom: 15px;

    label {
        margin-bottom: 5px;
        font-weight: 700;
    }

    /* stylelint-disable-next-line selector-class-pattern */
    .rf-RepeatingFieldset__add {
        @extend .btn;
        @extend .btn-success;
        @extend .btn-sm;
    }
}

/* stylelint-disable-next-line selector-class-pattern */
.rf-Hint {
    font-size: 70%;
    font-weight: 400;
    display: block;
}

/* stylelint-disable-next-line selector-class-pattern */
.rf-Message {
    display: block;
    color: #f00;
}

/* stylelint-disable-next-line selector-class-pattern */
.rf-Field--invalid {
    border-color: $brand-danger;

    textarea,
    input[type="text"],
    input[type="password"],
    input[type="datetime"],
    input[type="datetime-local"],
    input[type="date"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    input[type="tel"],
    input[type="color"],
    .item-picker {
        border-color: $brand-danger;

        &:focus {
            border-color: darken($brand-danger, 10%);
            $shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px lighten($brand-danger, 20%);
        }
    }

    /* stylelint-disable-next-line selector-class-pattern */
    .rf-Label {
        color: darken($brand-danger, 10%);
    }
}
