@import "../../../../assets/less/core/boot.less";

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

//
// Form containers
//

.form-preview {
    padding: @padding-standard;
    margin-bottom: 20px;
    background: @primary-bg;
    border: 1px solid @primary-border;

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

        .form-check {
            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: @primary-bg;
                }
            }
            > li.active a {
                &:before {
                    background-color: @primary-bg;
                }
            }
        }
    }
}

//
// Nice forms
//

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

.form-control {
    position: relative;
    -webkit-appearance: none;
    // border: 1px solid @input-border;

    &:focus {
        border: 1px solid @input-border-focus; // gray-800
        box-shadow: none;
    }

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

        @media (max-width: @screen-xs) {
            width: 40px;
            text-indent: -999px;

            &:focus,
            &:active {
                text-indent: 0;
                width: 100px !important;
            }

            &.icon {
                padding-right: 0 !important;
            }
        }
    }

    &.is-searchable {
        border-radius: 100px;
    }
}

.search-input-container {
    position: relative;

    &:before {
        position: absolute;
        width: 16px;
        height: 16px;
        background-position: 0 -38px;
        z-index: 1;
        right: 8px;
        top: 11px;
    }
}

.form-group {
    position: relative;
    box-sizing: border-box;

    &:empty {
        display: none;
    }

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

    &.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;
        }
    }

    .form-translatable {
        display: inline-block;
        position: relative;
        height: 20px;
        width: 25px;
        border-radius: 5px;
        background-color: @input-translatable-bg;
        color: @input-translatable-color;

        // Alignment
        margin-bottom: -5px;
        margin-left: 2px;

        i {
            font-size: 16px;
            position: absolute;
            top: 2px;
            left: 4px;
        }

        &.no-label {
            position: absolute;
            top: 1px;
            right: 0;
            left: auto;
            z-index: 2;
        }
    }

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

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

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

    &.clear-full {
        clear: both;
    }

    &.clear-left {
        clear: left;
    }

    &.clear-right {
        clear: right;
    }

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

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

        > .form-check {
            margin-bottom: 10px;
        }
    }

    &.radio-field {
        > .form-check {
            margin-bottom: 10px;
        }
    }

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

    &.radio-align {
        padding-left: 23px;
        margin-top: -20px;
    }

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

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

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

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

    // @deprecated (used by sitemap and pages)
    &.input-sidebar-control {
        padding-right: 35px;

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

.form-horizontal {
    .col-horizontal {
        width: 155px;
    }

    .form-group {
        &.checkbox-field {
            padding-bottom: 20px;
        }
    }
}

.form-group-preview {
    .form-control {
        background-color: @input-disabled-bg;
        height: auto;
        min-height: 38px;
        word-break: break-word;
        box-shadow: none;
    }

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

.col-form-label,
.form-label {
    font-weight: 600;
}

.form-text {
    margin-bottom: 0;

    &.before-field {
        margin-top: -.135rem;
        margin-bottom: .385rem;
    }
}

.control-disabled {
    .form-text {
        opacity: .5;
    }
}

.input-with-icon {
    position: relative;

    > .icon {
        position: absolute;
        z-index: @zindex-form;
        padding: 10px;
        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;
        }
    }

    &.size-sm {
        > .icon {
            margin-top: 0;
            padding: 5px 8px;
        }
    }
}

.input-no-spinner {
    -moz-appearance: textfield;

    &::-webkit-inner-spin-button,
    &::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
}

.field-section {
    border-bottom: 1px solid var(--bs-border-color);
    padding-top: 3px;
    padding-bottom: 7px;

    > h4 {
        font-weight: 400;
        font-size: 1.3rem;
    }

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

    &.is-collapsible {
        cursor: pointer;

        > h4:before {
            // Icon
            display: inline-block;
            vertical-align: baseline;
            .icon(@icon-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 @input-border-fade;
            > h4:before {
                color: inherit;
            }
        }
    }
}

.field-action {
    border-bottom: 1px solid @input-border;
    padding: 10px 0 5px;
    margin-top: -20px;

    h5 {
        margin-bottom: .35rem;
        margin-top: .75rem;
        font-weight: 400;
        font-size: 1rem;
    }

    p {
        color: @secondary-color;
        margin-bottom: 0;
        font-size: .9rem;
    }

    .field-action-button {
        margin-top: 15px;
        margin-bottom: 10px;

        @media (min-width: 992px) {
            text-align: right;
        }
    }
}

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

.field-horizontalrule hr {
    height: 1px;
    background: #000;
    margin: 0;
    opacity: .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 {
    .field-checkboxlist-inner {
        border-radius: @border-radius-base;
        background: @input-bg;
        border: 1px solid @input-border;
    }

    &:not(.is-scrollable) {
        .field-checkboxlist-inner {
            padding: 15px 15px 2px 15px;
        }
    }

    .checkboxlist-controls {
        padding: 3px;
        font-size: 0;
        white-space: nowrap;
        background: @input-bg;
        border-top: 1px solid @input-border;
        border-left: 1px solid @input-border;
        border-right: 1px solid @input-border;
        border-top-left-radius: @border-radius-base;
        border-top-right-radius: @border-radius-base;

        + .field-checkboxlist-inner {
            border-top-left-radius: 0;
            border-top-right-radius: 0;
            border-top-color: @toolbar-border;
        }
    }

    .form-check {
        margin-bottom: 10px;
    }

    .checkboxlist-group {
        margin: 0;
        padding-left: 1.1rem;
        list-style: none;
    }

    .checkboxlist-group, .checkboxlist-group-item {
        /* alternative to :empty */
        &:not(:has(*)) {
            display: none;
        }
    }
}

.field-checkboxlist-scrollable {
    height: @size-large + 100;

    // First checkbox
    .form-check {
        margin-left: 15px;
        margin-top: 15px;
        margin-bottom: 10px;
    }

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

.form-group.inline-options {
    .field-checkboxlist:not(.is-scrollable) {
        .field-checkboxlist-inner {
            padding: 15px 15px 5px 15px;
        }
    }

    .form-check {
        display: inline-block;
        margin-right: 15px;
    }
}

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

    &.is-horizontal {
        padding-left: 155px;
    }

    .btn {
        margin-right: 7px;

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

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

        .btn {
            margin-right: 0;
        }
    }

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

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

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

body .modal-footer {
    .form-buttons {
        padding: 0;
    }
}

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

body.compact-container .form-fatal-error {
    padding: 1rem @padding-standard 0 @padding-standard;
}

//
// 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;
    }
}
