//
// Dependencies
// --------------------------------------------------

@import "global.less";
@import "icon.less";

//
// Forms
// --------------------------------------------------

@import "form.base.less";
@import "form.groups.less";

// Load order
@import "select.less";
@import "checkbox.less";

//
// Form containers
//

.form-preview {
    padding: @padding-standard;
    margin-bottom: 20px;
    background: white;
    border: 1px solid #eee;

    >.form-group:last-child {
        padding-bottom: 0;

        .radio, .checkbox {
            margin-bottom: 0;
        }
    }

    // Form to sit flush to the element above
    &.form-flush {
        border-top: none;
    }

    // Style primary tabs
    .control-tabs.primary-tabs {
        > ul.nav-tabs, > div > ul.nav-tabs, > div > div > ul.nav-tabs {
            > li a > span.title {
                &:before, &:after {
                    background: white;
                }
            }
            > li.active a {
                &:before {
                    background-color: white;
                }
            }
        }
    }
}

//
// Nice forms
//

.form-elements, .form-tabless-fields {
    .clearfix();
}

.form-control {
    position: relative;
    -webkit-appearance: none;
    border: 1px solid @input-border;
    .box-shadow(@input-box-shadow);

    &:focus {
        border: 1px solid @color-form-field-border-focus;
    }

    &.icon {
        background-repeat: no-repeat;
        background-position: right -2px;
        padding-right: 30px !important;
        background-image: url('@{image-path}/bitmap-icons.png');

        &.plus { background-position: right -124px; }
        &.search { background-position: right -83px; }
        &.user { background-position: right -41px; }
        &.lock { background-position: right 0; }
    }

    &.growable {
        width: 110px;
        //.transition(width 0.2s);
        &:focus, &:active {
            width: 200px !important;
        }
    }
}

.form-group {
    position: relative;

    &:empty {
        display: none;
    }

    &, &.layout-item {
        padding-bottom: @padding-standard;
        margin-bottom: 0;
    }

    .box-sizing(border-box);

    &.is-required {
        > label:after {
            background-color: @color-form-required-asterisk;
            width: 5px;
            height: 5px;
            margin-left: 3px;
            vertical-align: super;
            font-size: 60%;
            content: "";
            display: inline-block;
            .border-radius(8px);
        }
    }

    &.span-full {
        width: 100%;
        float: left;
    }

    &.span-left {
        float: left;
        width: 48.5%;
        clear: left;
    }

    &.span-right {
        float: right;
        width: 48.5%;
        clear: right;
    }

    &.layout-relative {
        padding-bottom: 0;
    }

    &.checkbox-field {
        padding-bottom: 5px;
    }

    &.number-field {
        > .form-control { text-align: right; }
    }

    &.checkbox-align {
        padding-left: 28px;
        margin-top: -5px;
    }

    &.field-align-above {
        margin-top: -5px;
    }

    &.field-slim {
        &.span-left, &.span-right {
            width: 50%;
        }
    }

    &.field-indent {
        padding-left: 23px;
    }

    &.input-sidebar-control {
        padding-right: 35px;

        .sidebar-control {
            position: absolute;
            right: 8px;
            top: 34px;
            font-size: 16px;
            color: @color-input-sidebar-control;
            &:hover, &:focus {
                text-decoration: none;
                color: @link-color;
                outline: none;
            }
        }
    }
}

.form-group-preview {

    .form-control {
        background-color: @color-form-field-preview-bg;
        color: @color-form-field-preview-text;
        height: auto;
        min-height: 38px;
        border-color: #eee;
        .box-shadow(none);
    }

    .custom-checkbox,
    .custom-radio {
        label { cursor: default; }
    }
}

.help-block {
    font-size: @font-size-base - 1;
    margin-bottom: 0;
    &.before-field {
        margin-top: 0;
        margin-bottom: 17px;
    }
}

.input-with-icon {
    position: relative;

    > .icon {
        position: absolute;
        z-index: @zindex-form;
        padding: 13px;
        pointer-events: none;
        color: @color-form-field-icon;
        font-size: 15px;
        margin-top: -1px;
    }

    &.right-align {
        > .icon { right: 0; }
        input { padding-right: 32px !important; }
    }

    &.left-align {
        > .icon { left: 0; }
        input { padding-left: 32px !important; }
    }
}

.field-section {
    border-bottom: 1px solid @color-form-field-border;
    padding-top: 3px;
    padding-bottom: 7px;

    > h4 {
        color: rgba(0,0,0,.6);
    }

    > p:first-child,
    > h4:first-child {
        margin: 0;
    }

    &.is-collapsible {
        cursor: pointer;

        > h4:before {
            // Icon
            display: inline-block;
            .icon-FontAutumn();
            vertical-align: baseline;
            content: @chevron-up;

            font-size: 12px;
            margin: 2px 8px 0;
            float: right;
            color: rgba(0,0,0,.4);
            .transition(all 0.3s);
            .scaleAxes(1, 1);
        }

        &:hover {
            border-bottom: 1px solid darken(@color-form-field-border, 10%);
            > h4:before {
                color: inherit;
            }
        }
    }
}

.form-group.section-field.collapsed {
    .field-section.is-collapsible > h4:before {
        .scaleAxes(1, -1);
    }
}

.field-textarea {
    resize: vertical;
    &.size-tiny { min-height: @size-tiny; }
    &.size-small { min-height: @size-small; }
    &.size-large { min-height: @size-large; }
    &.size-huge { min-height: @size-huge; }
    &.size-giant { min-height: @size-giant; }
}

.field-checkboxlist:not(.is-scrollable) {
    padding: 20px 20px 2px 20px;
    .border-radius(@border-radius-base);
    background: @color-form-checkboxlist-background;
    border: 1px solid @color-form-checkboxlist-border;

    //.checkbox:last-of-type {
    //    margin-bottom: 0;
    //}
}

.field-checkboxlist.is-scrollable {
    small {
        color: @text-muted;
    }
}

.field-checkboxlist-scrollable {
    background: @color-form-checkboxlist-background;
    border: 1px solid @color-form-checkboxlist-border;
    padding-left: 15px;
    height: @size-large + 100;

    // First checkbox
    .checkbox {
        margin-top: 15px;
        margin-bottom: 5px;
    }

    // All others
    .checkbox ~ .checkbox { margin-top: 0; }
}

.field-recordfinder {
    background-color: @color-form-field-bg;
    border: 1px solid @color-form-field-border;
    overflow: hidden;
    position: relative;
    .box-shadow(@input-box-shadow);
    .border-radius(@input-border-radius);

    .form-control {
        background: transparent;
        border-color: transparent;
        height: auto;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        padding: 7px 30px 7px 11px;
        .box-shadow(none);
    }
    .btn {
        background: transparent;
        position: absolute;
        right: -2px;
        top: 50%;
        margin-top: -43px;
        height: 88px;
        color: lighten(@color-form-field-recordfinder-btn, 15%);
        text-shadow: none;
        padding-left: 15px;
        padding-right: 15px;

        i {
            font-size: 14px;
        }

        &:hover {
            color: @color-form-field-recordfinder-btn;
        }
    }
    .text-muted i {
        font-size: 14px;
        position: relative;
        top: 1px;
        display: inline-block;
        margin: 0 2px;
    }
    .primary {
        font-weight: 600;
    }
}

.recordfinder-search {
    background-position: right -81px !important;
    border-top: none  !important;
    border-left: none  !important;
    border-right: none  !important;
    border-radius: 0;
}

.form-buttons {
    .clearfix();
    padding-bottom: @padding-standard;
    font-size: 0;

    .btn {
        margin-right: 15px;

        &.no-margin-right {
            margin-right: 0;
        }
    }

    .btn-group {
        margin-right: 10px;

        .btn {
            margin-right: 0;
        }
    }

    .pull-right {
        margin-right: 0;
        margin-left: 10px;
    }

    &.buttons-offset {
        padding-left: 20px;
    }
}

body.slim-container {
    .form-buttons {
        padding: 0 20px 20px;
    }
}

@media (max-width: @form-breakpoint-max) {
    .form-group {
        &.span-left, &.span-right {
            width: 100%;
            clear: none;
        }
    }
}

//
// Select2
//

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border: none;
}

.select2-dropdown {
    z-index: @zindex-select;
}

//
// Controls inside toolbar
//

[data-control=toolbar] {
    .form-control {
        display: inline-block;
        margin-right: 15px;
    }

    input[type=text].form-control, label {
        position: relative;
        top: 5px;
    }

    label {
        margin-right: 7px;

        &.standalone {
            margin-right: 15px;
        }
    }

    .select2-container {
        display: inline-block;
        width: auto;
        height: 36px;
        margin-right: 15px;

        .select2-selection__rendered {
            line-height: 17px;
        }

        .select2-selection--single {
            height: 36px;
        }
    }

    select.form-control.custom-select {
        display: none;
    }
}
