@use '../../styles/bootstrap/variables' as bootstrap-variables;
@use '../../styles/variables';
@use 'sass:math';

.thy-input {
    position: relative;
    width: 100%;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    .input-border {
        position: absolute;
        width: 100%;
        height: 100%;
        border: bootstrap-variables.$input-border-width solid variables.$input-border-color;
    }
    .form-control {
        flex: 1;
        border: 0;
    }
    .input-prepend {
        margin-left: variables.$input-padding-x-fixed;
        line-height: 1;
    }
    .input-append {
        margin-right: variables.$input-padding-x-fixed;
        line-height: 1;
    }
    .input-password-icon {
        color: variables.$gray-400;
        .thy-icon {
            font-size: 20px;
        }
    }
    .input-label {
        position: absolute;
        top: 1px;
        left: variables.$input-padding-x-fixed;
        background: variables.$bg-default;
        padding: 0 5px;
        font-size: variables.$font-size-sm;
        transition: all 0.3s ease-out 0.1s;
        color: variables.$primary;
        width: 1px;
        height: 1px;
        overflow: hidden;
        z-index: -1;
        &.active {
            width: auto;
            height: auto;
            z-index: 0;
            top: -10px;
        }
        &-sm,
        &-xs {
            &.active {
                top: -13px;
            }
        }
    }
    &[disabled]:not([disabled='false']) {
        background-color: variables.$input-disabled-bg;
        .input-append,
        .input-prepend {
            background-color: variables.$input-disabled-bg;
            pointer-events: none;
        }
    }

    & > .input-prepend + .form-control {
        padding-left: variables.$input-padding-x-fixed;
        padding-right: variables.$input-padding-x-fixed;
    }
}

.thy-input-search {
    .input-prepend,
    .input-append {
        position: absolute;
    }

    &.thy-input-search-before {
        .input-search-control {
            padding-left: variables.$input-padding-x-fixed + variables.$input-padding-x-fixed + 0.875rem;
        }

        &-with-clear {
            .input-search-control {
                padding-right: 2 * variables.$input-padding-x-fixed + 0.875rem;
            }
        }
    }

    &.thy-input-search-after {
        .input-search-control {
            padding-right: 3 * variables.$input-padding-x-fixed + 0.875rem;
        }
    }

    .input-prepend {
        margin-left: 0px;
        font-size: variables.$font-size-base;
        left: variables.$input-padding-x-fixed;
        top: calc((100% - 14px) / 2);
        color: variables.$input-icon-color;
    }

    .input-append {
        right: variables.$input-padding-x-fixed;
        font-size: variables.$font-size-base;
        top: calc((100% - 14px) / 2);
        margin-right: 0px;
        line-height: 1;

        .thy-icon,
        .close {
            font-size: variables.$font-size-base;
        }
        &.input-append-divider {
            &::after {
                width: 1px;
                height: 16px;
                content: ' ';
                position: absolute;
                // top: 50%;
                top: -1px;
                right: 22px;
                background: variables.$gray-200;
            }
        }
    }

    .input-search-control {
        padding-right: variables.$input-padding-x-fixed + variables.$input-padding-x-fixed + 0.875rem;
        transition: none;
    }

    &.thy-input-search-ellipse {
        border-radius: variables.$input-ellipse-radius;
        .input-search-control {
            border-radius: variables.$input-ellipse-radius;
            background: variables.$input-ellipse-background-color;
            &:not(:disabled) {
                &:hover {
                    background: variables.$input-ellipse-hover-focus-background-color;
                    border-color: variables.$input-ellipse-hover-border-color;
                }
                &:focus {
                    background: variables.$input-ellipse-hover-focus-background-color;
                    border-color: variables.$input-ellipse-focus-border-color;
                }
            }
        }
    }

    &.thy-input-search-transparent {
        border: 0px;
        background-color: transparent;
        .input-search-control {
            border: 0px;
            background-color: transparent;
        }
    }

    &[disabled]:not([disabled='false']) {
        &:hover {
            border-color: variables.$input-disabled-border-color;
        }
        &:focus {
            border-color: variables.$input-disabled-border-color;
        }
    }
}

.input-label-container {
    position: relative;
    display: block;
    width: 100%;
    .input-label {
        position: absolute;
        top: 1px;
        left: 10px;
        background: variables.$bg-default;
        padding: 0 5px;
        font-size: variables.$font-size-sm;
        transition: all 0.3s ease-out 0.1s;
        color: variables.$primary;
        width: 1px;
        height: 1px;
        overflow: hidden;
        z-index: -1;
        &.active {
            width: auto;
            height: auto;
            z-index: 0;
            top: -10px;
        }
        &-sm,
        &-xs {
            &.active {
                top: -13px;
            }
        }
    }
}

// Form control feedback states
//
// Apply contextual and semantic states to individual form controls.
.has-feedback {
    // Enable absolute positioning
    position: relative; // Ensure icons don't overlap text
    .form-control {
        padding-right: 2 * variables.$input-padding-x + 1rem;
    }
}

// Feedback icon (requires .glyphicon classes)
.form-control-feedback {
    position: absolute; // top: (2 * $input-padding-y + $input-line-height * $font-size-base - $input-line-height) / 2;
    top: 50%;
    // margin-top: -(($font-size-md * $input-line-height) / 2);
    transform: translateY(-50%);
    right: variables.$input-padding-x;
    z-index: 2; // Ensure icon is above input groups
    display: block; // width: $input-hei;
    // height: @input-height-base;
    // line-height: $input-line-height;
    text-align: center;
    pointer-events: none;
    font-size: variables.$font-size-md;
    -webkit-font-smoothing: subpixel-antialiased;
    color: variables.$input-icon-color;
}

.form-group {
    > .col,
    > [class*='col-'] {
        > .form-control-feedback {
            // 0.9375rem is ($grid-gutter-width / 2)
            right: 0.9375rem + variables.$input-padding-x;
        }
    }
}

textarea {
    overflow: auto;
    &::-webkit-scrollbar-corner,
    &::-webkit-scrollbar-track-piece,
    &::-webkit-scrollbar-track {
        border-bottom-right-radius: variables.$input-border-radius;
    }
}
