.input {
    &-wrapper {
        @extend .flex-column;

        position: relative;
    }

    &__prefix {
        @extend .text-muted;

        font-size: var(--h5);
        line-height: 1;
        margin-bottom: 2px;
    }

    &__field-container {
        @extend .align-center;

        gap: 10px;
        position: relative;
        width: 100%;
        padding: 0.75em 1em 0.75em 1em;
        font-size: var(--p);
        border: 1px solid var(--transp-2);
        border-radius: var(--border05);
        color: var(--text);
        transition: border var(--transition), background-color var(--transition);

        &:focus-within:not(.input__field-container-readonly):not(.has-error) {
            border-color: var(--primary-300);
        }

        &.has-error {
            border-color: var(--error);
        }
    }

    &__field {
        font: inherit;
        outline: 0;
        border: 0;
        padding: 0;
        margin: 0;
        flex: 1;
        background-color: transparent;
        color: inherit;
        width: 100%;

        &[type="color"] {
            flex: auto;
        }

        &-withPassword {
            padding-right: 2em;
        }

        &-color {
            width: calc(100% - 32px);
        }

        &-icon {
            width: 100%;
        }
    }

    &__toggle-btn {
        @extend .icon-hover;

        position: absolute;
        right: 0.4em;
        top: .5em;
        width: 32px;
        height: 32px;
        font-size: var(--p-small);
        color: var(--text-500);
        @include transition(all);

        &:hover {
            color: var(--text);
        }

        .icon-eye,
        .icon-eye-slash {
            width: 1.5em;
            height: 1.5em;
            transition: opacity var(--transition) ease;
        }

        .icon-eye.visible,
        .icon-eye-slash.visible {
            display: inline;
        }
    }

    &__error {
        color: var(--error);
        font-size: var(--small);
        font-weight: 500;
        letter-spacing: 0.02em;
        margin-top: 0.2em;
        animation: fadeIn 0.3s ease-out;
    }

    &__postprefix {
        display: flex;
        align-items: center;
    }
}

.icon-input-container {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 10px;
}

.icon-input-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: var(--text-300);
    
    svg {
        width: 100%;
        height: 100%;
        fill: currentColor;
    }
}

.icon-picker {
    @extend .blur-bg;

    position: absolute;
    z-index: 9999;
    display: none;
    flex-direction: column;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    will-change: opacity, transform;
    contain: content;
    overflow: hidden;
    border-radius: 12px;
    width: 350px;
    height: 450px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    outline: none;
    color: var(--text);
    border: 1px solid var(--transp-1);
    background-color: var(--blurred-background);
    pointer-events: none;
    visibility: hidden;

    &.active {
        display: flex;
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
    }

    &__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px;
        border-bottom: 1px solid var(--transp-1);
    }

    &__search {
        flex: 1;
        margin-right: 8px;
        z-index: 10;

        &-input {
            width: 100%;
            background-color: var(--transp-05);
            border-radius: 8px;
            border: 1px solid var(--transp-1);
            padding: 10px 12px;
            color: var(--text);
            font-size: var(--p-small);
            outline: none;
            transition: all 0.2s ease;
            pointer-events: auto;

            &:focus {
                border-color: var(--primary-300);
                background-color: var(--transp-1);
            }
        }
    }

    &__close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        border-radius: 8px;
        cursor: pointer;
        color: var(--text-500);
        transition: all 0.2s ease;

        &:hover {
            color: var(--text);
            background-color: var(--transp-1);
        }

        svg {
            width: 16px;
            height: 16px;
        }
    }

    &__body {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    &__categories {
        display: flex;
        padding: 12px 12px 0;
        gap: 8px;
        overflow-x: auto;
        scrollbar-width: thin;

        &::-webkit-scrollbar {
            height: 3px;
        }
    }

    &__category {
        font-size: var(--p-small);
        font-weight: 500;
        padding: 8px 12px;
        border-radius: 8px;
        cursor: pointer;
        white-space: nowrap;
        transition: all 0.2s ease;

        &:hover {
            background-color: var(--transp-1);
        }

        &.active {
            background-color: var(--primary);
            color: var(--background);
        }
    }

    &__styles {
        display: flex;
        padding: 8px 12px;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: thin;

        .icon-picker__tab {
            display: none;
        }

        &::-webkit-scrollbar {
            height: 3px;
        }
    }

    &__style {
        padding: 6px 12px;
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.2s ease;
        white-space: nowrap;
        font-size: var(--p-small);
        font-weight: 500;
        display: flex !important;

        &:hover {
            background-color: var(--transp-1);
        }

        &.active {
            background-color: var(--primary);
            color: var(--background);
        }
    }

    &__styles {
        display: flex;
        padding: 8px 12px;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: thin;

        .icon-picker__tab {
            display: none !important;
        }

        &::-webkit-scrollbar {
            height: 3px;
        }
    }

    &__content {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 10px;
        overflow-y: auto;
        padding: 12px;
        flex: 1;
        min-height: 0;
    }

    &__icon {
        aspect-ratio: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.15s ease;
        color: var(--text-200);
        background-color: var(--transp-05);

        &:hover {
            color: var(--text);
            transform: scale(1.05);
            background-color: var(--transp-1);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        }

        &.active {
            background-color: var(--primary);
            color: var(--background);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        svg {
            fill: currentColor;
            width: 20px;
            height: 20px;
        }
    }

    &__pagination {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px;
        gap: 12px;
        border-top: 1px solid var(--transp-1);

        &-prev,
        &-next {
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            cursor: pointer;
            color: var(--text);
            background-color: var(--transp-05);
            transition: all 0.2s ease;

            &:hover:not(:disabled) {
                background-color: var(--transp-1);
                color: var(--primary);
            }

            &:disabled {
                opacity: 0.4;
                cursor: default;
            }
        }

        &-info {
            font-size: var(--p-small);
            color: var(--text-500);
        }
    }

    &__loading,
    &__error,
    &__empty {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px;
        color: var(--text-500);
        font-size: var(--p-small);
        text-align: center;
    }

    &__error {
        color: var(--error);
    }
    
    &__skeleton {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 10px;
        grid-column: 1 / -1;
        width: 100%;
    }
    
    &__skeleton-item {
        aspect-ratio: 1;
        border-radius: 8px;
        background-color: var(--transp-1);
        animation: pulse 1.5s ease-in-out infinite;
    }
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 0.3;
    }
    100% {
        opacity: 0.6;
    }
}

input:-webkit-autofill,
input:-webkit-autofill:focus {
    transition: background-color 600000s 0s, color 600000s 0s;
}

input[data-autocompleted] {
    background-color: var(--transp-1) !important;
}

input:disabled {
    opacity: 0.5 !important;
}

.filepond--panel-root {
    background-color: var(--background-800) !important;
    color: var(--text) !important;
    transition: background-color var(--transition);
}

.filepond--drop-label.filepond--drop-label label {
    color: var(--text-300) !important;
}

@media (prefers-reduced-motion: reduce) {
    .icon-picker,
    .icon-picker__icon {
        transition: none !important;
    }
}