@keyframes badgeModalBackdropIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes badgeModalBackdropOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes badgeModalDialogIn {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes badgeModalDialogOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-40px);
    }
}

.BadgeModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;

    &__backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        animation: badgeModalBackdropIn 0.2s ease-out;
    }

    &__dialog {
        position: relative;
        z-index: 1;
        background: var(--center-channel-bg, #fff);
        color: var(--center-channel-color, #3d3c40);
        border-radius: 8px;
        box-shadow: 0 20px 32px rgba(0, 0, 0, 0.12);
        width: 480px;
        max-width: 90vw;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        animation: badgeModalDialogIn 0.2s ease-out;
    }

    &--closing {
        .BadgeModal__backdrop {
            animation: badgeModalBackdropOut 0.15s ease-in forwards;
        }

        .BadgeModal__dialog {
            animation: badgeModalDialogOut 0.15s ease-in forwards;
        }
    }

    &--compact {
        .BadgeModal__body {
            overflow: visible;
        }

        .BadgeModal__dialog {
            overflow: visible;
        }
    }

    &__header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px 24px 0;

        h4 {
            margin: 0;
            font-size: 18px;
            font-weight: 600;
        }

        .close-btn {
            background: none;
            border: none;
            font-size: 24px;
            cursor: pointer;
            color: var(--center-channel-color, #3d3c40);
            opacity: 0.56;
            padding: 0;
            line-height: 1;

            &:hover {
                opacity: 1;
            }
        }
    }

    &__body {
        padding: 20px 24px;
        overflow-y: auto;
        flex: 1;
    }

    .grant-intro {
        font-size: 14px;
        margin: 0 0 16px;
        opacity: 0.72;
    }

    &__footer {
        display: flex;
        justify-content: flex-end;
        gap: 8px;
        padding: 16px 24px;
        border-top: 1px solid rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.08);
    }

    .form-group {
        margin-bottom: 16px;

        label {
            display: block;
            font-size: 12px;
            font-weight: 600;
            margin-bottom: 4px;
            text-transform: uppercase;
            opacity: 0.64;

            .required {
                color: var(--error-text, #d24b4e);
                margin-left: 2px;
            }
        }

        > input[type='text'],
        > select,
        > textarea {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.16);
            border-radius: 4px;
            font-size: 14px;
            background: var(--center-channel-bg, #fff);
            color: var(--center-channel-color, #3d3c40);

            &:focus {
                border-color: var(--button-bg, #166de0);
                outline: none;
            }
        }

        > textarea {
            resize: vertical;
            min-height: 60px;
        }

        .emoji-input {
            display: flex;
            align-items: center;
            border: 1px solid rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.16);
            border-radius: 4px;
            background: var(--center-channel-bg, #fff);

            &:focus-within {
                border-color: var(--button-bg, #166de0);
            }

            &__icon {
                display: flex;
                align-items: center;
                justify-content: center;
                flex-shrink: 0;
                width: 36px;
                height: 36px;
                padding: 0;
                border: none;
                background: none;
                color: rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.56);
                cursor: pointer;

                &:hover {
                    color: var(--center-channel-color, #3d3c40);
                }

                .emoticon {
                    display: block;
                }
            }

            .emojisprite,
            .emoticon {
                margin-right: 4px;
            }

            input[type='text'] {
                flex: 1;
                border: none;
                background: transparent;
                padding: 8px 12px 8px 0;

                &:focus {
                    outline: none;
                    border-color: transparent;
                    box-shadow: none;
                }
            }
        }
    }

    .checkbox-group {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;

        label {
            font-size: 14px;
            font-weight: normal;
            margin: 0;
            text-transform: none;
            opacity: 1;
            cursor: pointer;
        }
    }

    .inline-type-section {
        padding: 12px;
        margin-top: 8px;
        border: 1px dashed rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.24);
        border-radius: 4px;
        background: rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.04);
    }

    .btn {
        padding: 8px 20px;
        border-radius: 4px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        border: none;

        &--primary {
            background: var(--button-bg, #166de0);
            color: var(--button-color, #fff);

            &:hover {
                opacity: 0.88;
            }

            &:disabled {
                opacity: 0.5;
                cursor: not-allowed;
            }
        }

        &--cancel {
            background: transparent;
            color: var(--center-channel-color, #3d3c40);
            border: 1px solid rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.16);

            &:hover {
                background: rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.08);
            }
        }

        &--danger {
            background: var(--error-text, #d24b4e);
            color: #fff;

            &:hover {
                opacity: 0.88;
            }
        }
    }

    .error-message {
        color: var(--error-text, #d24b4e);
        font-size: 13px;
        margin-top: 8px;
    }

    .delete-section {
        margin-top: 16px;
        padding-top: 16px;
        border-top: 1px solid rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.08);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .confirm-delete {
        display: flex;
        align-items: center;
        gap: 8px;

        span {
            font-size: 13px;
            color: var(--error-text, #d24b4e);
        }
    }

    .type-select {
        position: relative;

        &__trigger {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.16);
            border-radius: 4px;
            font-size: 14px;
            background: var(--center-channel-bg, #fff);
            color: var(--center-channel-color, #3d3c40);
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
            text-align: left;

            &:hover {
                border-color: rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.32);
            }
        }

        &__value {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        &__arrow {
            font-size: 12px;
            opacity: 0.56;
            margin-left: 8px;
            flex-shrink: 0;
        }

        &__dropdown {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            margin-top: 4px;
            background: var(--center-channel-bg, #fff);
            border: 1px solid rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.16);
            border-radius: 4px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
            z-index: 10;
            max-height: 160px;
            overflow-y: auto;
        }

        &__option {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 8px 12px;
            cursor: pointer;
            font-size: 14px;

            &:hover {
                background: rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.08);
            }

            &--selected {
                background: rgba(var(--button-bg-rgb, 22, 109, 224), 0.08);
                font-weight: 600;
            }

            &--create {
                border-top: 1px solid rgba(var(--center-channel-color-rgb, 61, 60, 64), 0.08);
                color: var(--button-bg, #166de0);
                font-weight: 600;
            }
        }

        &__option-name {
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        &__delete-btn {
            background: none;
            border: none;
            color: var(--center-channel-color, #3d3c40);
            opacity: 0.4;
            cursor: pointer;
            padding: 0 4px;
            font-size: 12px;
            line-height: 1;
            flex-shrink: 0;

            &:hover {
                opacity: 1;
                color: var(--error-text, #d24b4e);
            }
        }

    }
}
