/* ==========================================================================
    Form Input
========================================================================== */

.c-formElement {
    @include default-styles();
    @include floating-label();

    &:not(
            .c-formElement--upload--boxed,
            .c-formElement--upload--bordered,
            .c-formElement--upload--line
        ) {
        @include input-placeholder(inherit, inherit, var(--gray-500));

        input {
            @include input-reset();
        }
    }

    /* Input
    ========================================================================== */

    &--boxed {
        background: var(--gray-200);

        /* Colored line on focus */
        input:focus ~ .c-formElement--focusLine {
            border-color: var(--form-element-color);
        }

        /* Floating label */
        input:focus ~ label,
        :not(:placeholder-shown) ~ label {
            @include font-size(10px);
            top: calc((var(--form-element-padding) + 5px) * -1);
            opacity: 0.8;
        }
    }

    &--bordered {
        @include bordered-styles();

        /* Colored line on focus */
        input:focus ~ .c-formElement--focusLine {
            border-color: var(--form-element-color);
        }

        /* Floating label */
        input:focus ~ label,
        :not(:placeholder-shown) ~ label {
            @include font-size(10px);
            top: calc((var(--form-element-padding) + 5px) * -1);
            opacity: 0.8;
        }
    }

    &--line {
        background: transparent;

        &.c-floatingLabel {
            label {
                left: 0;
            }
        }

        input {
            padding-left: 0;
        }

        hr {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            margin: 0;
            height: 1px;
            background: var(--gray-400);
        }

        .c-formElement--focusLine {
            top: calc(100% - 1px);
            right: auto;
            bottom: auto;
            left: 0;
            border: none;
            width: 0%;
            height: 1px;
            background: var(--form-element-color);
            transition: all 0.35s $ease-in;
        }

        /* Colored line on focus */
        input:focus ~ .c-formElement--focusLine {
            width: 100%;
        }

        /* Floating label */
        input:focus ~ label,
        :not(:placeholder-shown) ~ label {
            @include font-size(10px);
            top: calc((var(--form-element-padding) + 5px) * -1);
            opacity: 0.8;
        }
    }

    /* File Upload
    ========================================================================== */

    &--upload {
        input {
            @include visually-hidden();
        }

        label {
            background: none;
            border: none;
            margin: 0 !important;
            padding: var(--form-element-padding);
            width: 100%;
        }

        &--boxed {
            background: var(--gray-200);

            svg {
                position: absolute;
                top: 50%;
                right: var(--form-element-padding);
                transform: translate3d(0, -50%, 0);
                width: 24px;
                fill: var(--body-text-color);
                pointer-events: none;
            }

            input {
                @include visually-hidden();
            }

            label {
                background: none;
                border: none;
                margin: 0 !important;
                padding: var(--form-element-padding)
                    calc(var(--form-element-padding) + 2em)
                    var(--form-element-padding) var(--form-element-padding);
                width: 100%;
                min-height: 51px;
            }

            /* Colored line on focus */
            input:focus ~ .c-formElement--focusLine {
                border-color: var(--form-element-color);
            }
        }

        &--bordered {
            @include bordered-styles();

            svg {
                position: absolute;
                top: 50%;
                right: var(--form-element-padding);
                transform: translate3d(0, -50%, 0);
                width: 24px;
                fill: var(--body-text-color);
                pointer-events: none;
            }

            input {
                @include visually-hidden();
            }

            label {
                background: none;
                border: none;
                margin: 0 !important;
                padding: var(--form-element-padding)
                    calc(var(--form-element-padding) + 2em)
                    var(--form-element-padding) var(--form-element-padding);
                width: 100%;
                min-height: 51px;
            }

            /* Colored line on focus */
            input:focus ~ .c-formElement--focusLine {
                border-color: var(--form-element-color);
            }
        }

        &--line {
            background: transparent;

            svg {
                position: absolute;
                top: 50%;
                right: var(--form-element-padding);
                transform: translate3d(0, -50%, 0);
                width: 24px;
                fill: var(--body-text-color);
                pointer-events: none;
            }

            input {
                @include visually-hidden();
            }

            label {
                background: none;
                border: none;
                margin: 0 !important;
                padding: var(--form-element-padding)
                    calc(var(--form-element-padding) + 2em)
                    var(--form-element-padding) 0;
                width: 100%;
                min-height: 51px;
            }

            hr {
                position: absolute;
                bottom: 0;
                left: 0;
                width: 100%;
                margin: 0;
                height: 1px;
                background: var(--gray-700);
            }

            .c-formElement--focusLine {
                top: calc(100% - 1px);
                right: auto;
                bottom: auto;
                left: 0;
                border: none;
                width: 0%;
                height: 1px;
                background: var(--form-element-color);
                transition: all 0.35s $ease-in;
            }

            /* Colored line on focus */
            input:focus ~ .c-formElement--focusLine {
                width: 100%;
            }
        }
    }
}
