/*
 * Forms.
 */

.data-form {
    flex: 1 0 auto; // to fill page if needed
    display: flex;
    flex-direction: column;
    justify-content: stretch;
}

.data-form-flush {
    > .form-primary-section {
        padding: $modal-inner-padding;

        + .form-primary-section {
            border-top: 1px solid $accordion-border-width solid $accordion-border-color;;
        }

        + .form-sections {
            border-top: 1px solid $accordion-border-width solid $accordion-border-color;;
        }
    }
}

.form-mode {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    .btn-link {
        font-weight: bold;
    }
}


// -
// Errors & messages
// ---

@each $state, $data in $form-validation-states {
    @include custom-form-validation-state($state, $data...);
}

.valid-feedback,
.invalid-feedback,
.incomplete-feedback {
    // because bootstrap only display it if it's placed just after a .form-control.is-invalid
    // which is not always possible with our advanced form types
    display: block;
    // this cannot be customized in pure bootstrap and it may blend the messages with .form-text.
    font-weight: $form-feedback-font-weight;
}

// @deprecated
.help-block {
    text-align: justify;

    padding-left: $padding-base-horizontal + 1px; // keep alignment with error blocks
    margin-bottom: 0; // top margin is sufficient to stack and bottom margin add spacing in some cases

    // Just expose some vars as bootstrap doesn't do it
    color: $help-block-color;
    font-size: $help-block-font-size;

    .help-icon {
        width: 20px - $icon-text-spacer; // small cheat to have the same spacing than checkbox (currently 20px)
        text-align: center;
        margin-right: $icon-text-spacer;
    }
}


// -
// Multi steps Forms.
// ---

.form-stepper {
    .progress + .h-title {
        margin-top: calc($line-height-computed - 4px); // 4px is to absorb progress bar height
    }
}

.form-stepper-footer {
    text-align: right;

    .btn + .btn {
        margin-left: 5px;
    }

    .btn-next {
        min-width: 240px;
    }
}


// -
// Fieldset
// ---

.sub-fields {
    padding-left: calc(map-get($spacers, 3) - 2px);
    border-left: 2px solid $input-border-color;

    @include border-bottom-start-radius($input-border-radius);
}


// -
// Inputs
// ---

// force buttons to have the same rounding than form-control
.input-group > .btn,
.input-group .dropdown > .btn {
    @include border-radius($input-border-radius);
}

// restrictive selector to override bootstrap
// bottom margin is to add space for vertical display, but is not removed in inline mode,
// and it can create inconsistent margin.
.form-check.form-check-inline {
    margin-bottom: 0;
}


// -
// Buttons
// ---

.form-toolbar {
    bottom: map-get($spacers, 3);
    z-index: $zindex-dropdown - 1;

    .btn {
        width: 5rem;
        height: 5rem;
        display: inline-flex;
        justify-content: center;
        align-items: center;
        font-size: $h2-font-size;

        @include box-shadow($box-shadow);
    }
}

.form-btn-cancel {
    // outline buttons have transparent background
    // this will avoid seeing trough the button when it overlaps the content
    background-color: $body-bg;
}

.validation-status {
    background-color: $body-bg;
    border-radius: 50rem;
    @include box-shadow($box-shadow-sm);
    cursor: help;
    /*cursor: help;
    margin: 0 $padding-base-horizontal;*/
}

// -
// Utilities
// ---

// Utility class to avoid extra space after a form.
// meant to be used on a `.form-group`
// @deprecated
.form-last {
    margin-bottom: 0 !important;
}

// @deprecated
.input-placeholder {
    color: $input-placeholder-color;
}
