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

@if not $prev-form {
    // Fix input lists (radio, checkboxes, dropdown) for Bootstrap 5
    // See https://github.com/yiisoft/yii2-bootstrap5/issues/99
    .is-invalid[aria-invalid="true"] .form-check-input {
        &, &:checked {
            border-color: var(--bs-form-invalid-border-color);
        }

        & ~ .form-check-label {
            color: var(--bs-form-invalid-color);
        }

        & ~ .invalid-feedback {
            display: block;
        }
    }


    label {
        font-weight: 700;

        &[required]:after {
            content: " *";
            color: var(--bs-accent);
        }
    }

    // Remove BS5 inner black color in radio
    .form-check-input:checked {
        background-color: transparent;
    }

    div.required > label:after {
        content: " *";
        color: var(--bs-accent);
    }

    .form-checkboxes-normal {
        .radio label,
        .checkbox label {
            font-weight: 500;
        }
    }

    %form-control-base {
        border: 2px solid var(--hh-background-color-page);
        box-shadow: none;
        min-height: 35px;
        background-color: var(--hh-background-color-main);
        font-size: 14px;

        &:focus {
            border: 2px solid var(--bs-accent);
            outline: 0;
            box-shadow: none;
            background-color: var(--hh-background-color-main);
        }

        &[readonly] {
            background-color: var(--bs-secondary-bg);
            opacity: 1;
        }

        &.form-search {
            border-radius: 30px;
            padding-left: 34px;
        }
    }

    .form-control {
        @extend %form-control-base;
    }

    .form-group-search {
        position: relative;

        &:before {
            font: 14px FontAwesome;
            content: "\f002";
            color: var(--hh-background-color-page);
            position: absolute;
            top: 10px;
            left: 13px;
        }

        .form-button-search {
            position: absolute;
            top: 4px;
            right: 4px;
            border-radius: 30px;
        }
    }

    select.form-control:not([multiple]) {
        appearance: none;
        background-image: url("../img/select_arrow.png") !important;
        background-repeat: no-repeat;
        background-position: right 16px;
        overflow: hidden;
    }

    div.PendingRegistrations {
        thead > tr > th > label, tbody > tr > td > label {
            margin-bottom: 0;
            height: 17px;
        }
    }

    // Placeholder text

    ::placeholder {
        color: var(--hh-text-color-soft3) !important;
    }

    /* hide native password reveal icons */
    input::-ms-clear, input::-ms-reveal {
        display: none;
    }

    // Placeholder text for empty content
    .placeholder {
        padding: 10px;
        color: var(--hh-text-color-secondary);
    }

    // HTML5 Placeholder jQuery Plugin
    input.placeholder,
    textarea.placeholder {
        padding: 0 0 0 10px;
        color: var(--hh-text-color-secondary);
    }

    .invalid-feedback {
        font-size: 12px;
    }

    .form-text, .text-body-secondary {
        color: var(--hh-text-color-soft);
        font-size: 13px;
    }

    .panel-body > .text-body-secondary {
        padding-right: 20px;
        margin-bottom: 20px;
    }

    .hint-block {
        color: var(--hh-text-color-soft2) !important;
        font-size: 12px;
    }

    .hint-block:hover {
        color: var(--hh-text-color-secondary) !important;
        font-size: 12px;
    }

    a.input-field-addon {
        font-size: 12px;
        float: right;
        margin-top: -10px;
    }

    a.input-field-addon-sm {
        font-size: 11px;
        float: right;
        margin-top: -10px;
    }

    .timeZoneInputContainer {
        padding-top: 10px;
    }

    .timeZoneInputContainer ~ .form-text {
        margin: 0;
    }

    // Flatelements
    .radio input[type=radio],
    .radio-inline input[type=radio],
    .checkbox input[type=checkbox],
    .checkbox-inline input[type=checkbox] {
        position: relative;
        margin-left: 0;
    }

    input[type=checkbox], input[type=radio] {
        -webkit-appearance: none;
        position: relative;
        display: inline-block;
        width: auto;
        height: auto;
        min-height: auto;
        padding: 7px;
        margin: 0 6px 0 0;
        vertical-align: middle;
        background: var(--hh-background-color-main);
        border: 2px solid var(--hh-background3);
        border-radius: 3px;
        cursor: pointer;

        &:disabled {
            background: var(--hh-background3) !important;
            border: 2px solid var(--hh-background3) !important;
            cursor: not-allowed;
        }
    }

    input[type=checkbox] {
        &:focus {
            border: 2px solid var(--hh-text-color-highlight) !important;
            outline: none;
        }

        &:checked {
            border: 2px solid var(--bs-accent);
            background: var(--bs-accent);
            color: var(--hh-accent-contrast);

            &::after {
                content: '\f00c'; /* FontAwesome checkmark */
                font-family: 'FontAwesome'; /* FontAwesome Font */
                font-size: 12px;
                position: absolute;
                top: -1px;
                left: 1px;
                color: var(--hh-accent-contrast);
            }
        }
    }

    input[type=radio] {
        border-radius: 50%;

        &:checked {
            border: 2px solid var(--hh-background3);
            color: #99a1a7;

            &::after {
                content: ' ';
                width: 8px;
                height: 8px;
                border-radius: 50%;
                position: absolute;
                top: 3px;
                background: var(--bs-accent);
                text-shadow: none;
                left: 3px;
                font-size: 32px;
            }
        }
    }

    .form-check-label {
        cursor: pointer;
    }

    div.mb-3 {
        div.checkbox {
            .form-text {
                margin-left: 23px;
            }

            // avoid spacing between checkbox and hint
            .invalid-feedback:empty {
                display: none;
            }
        }
    }

    // Radio pills
    .radio-pills {
        display: flex;
        flex-wrap: wrap;
        border: 1px solid var(--bs-light);
        border-radius: 4px;
        width: fit-content;

        div.radio {
            flex: 1;
            text-align: center;
            font-size: 12px;
            border-radius: 3px;
            background: var(--hh-background-color-main);
            box-shadow: none;
            margin: 0 !important;
            white-space: nowrap;

            &:hover, &.active {
                background: var(--bs-light);
            }

            .fa {
                margin-right: 5px;

                &.radio-pill-active-icon {
                    display: none;
                }
            }

            &.active .fa.radio-pill-active-icon {
                display: inline;
            }

            label {
                font-weight: 600;
                padding: 2px 12px;
                line-height: 21px;
            }

            &::after {
                content: ' ';
                border-right: 1px solid var(--bs-light);
                position: absolute;
                top: 20%;
                height: 60%;
                left: 0;
                z-index: 1;
            }

            &:first-child, &:hover + div.radio, &.active, &.active + div.radio {
                &::after {
                    display: none;
                }
            }
        }

        input[type=radio] {
            display: none;
        }
    }

    .radio-pills-wide {
        width: auto;
    }

    altcha-widget.form-control {
        width: fit-content;
        padding: 0;

        .altcha {
            border: none !important;
        }
    }

    //
    // Errror handling
    //
    .errorMessage {
        color: var(--bs-danger);
        padding: 10px 0;
    }

    // Errror handling
    .error {
        border-color: var(--bs-danger) !important;
    }

    .bootstrap-timepicker-widget .form-control {
        padding: 0;
    }

    .form-collapsible-fields {
        margin-bottom: 12px;
        border-left: 3px solid var(--bs-primary);
        background-color: var(--hh-background-color-secondary);
    }

    .form-collapsible-fields-label {
        margin-bottom: 0;
        padding: 12px;
        cursor: pointer;

        label {
            margin-bottom: 0;
            cursor: pointer;
        }
    }

    .form-collapsible-fields fieldset {
        padding-top: 15px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .form-collapsible-fields-label {
        .fa-plus {
            display: none;
        }
        &.collapsed {
            .fa-minus {
                display: none;
            }
            .fa-plus {
                display: initial;
            }
        }
    }

    // editor
    .content_create,
    .content_edit {
        .richtext-create-input-group {
            display: flex;
            align-items: flex-end;
            flex-direction: column;

            > .mb-3 {
                flex-grow: 1;
                width: 100%;
                margin-bottom: 0 !important;

                [data-ui-markdown] {
                    word-break: break-word !important;

                    pre code {
                        display: block;
                        width: 0;
                    }
                }
            }

            .mb-3, .form-text {
                margin: 0;
            }
        }

        // fileupload button
        .richtext-create-buttons {
            white-space: nowrap;
            padding-top: 6px;

            .btn:not(.dropdown-toggle) {
                margin-left: 6px;
            }

            .btn.fileinput-button, .fileinput-button + .dropdown-toggle {
                background: var(--hh-background-color-page);
                color: var(--hh-text-color-default) !important;
                border-color: var(--hh-background-color-page);

                &:hover, &:focus {
                    background: var(--hh-background3) !important;
                    border-color: var(--hh-background3);
                }

                &:active, &.active {
                    background: var(--hh-background4) !important;
                    border-color: var(--hh-background4);
                }
            }

            .btn.dropdown-toggle {
                margin-left: 0;
            }
        }

        .fileinput-button:active {
            box-shadow: none !important;
        }
    }

    #choose-language-form {
        min-width: 150px;
    }
}
