@layer components {

    .btn:has(> .loader) {
        position: relative;
    }

    .loader {
        display: none; 
        &.active {
            position: absolute;
            cursor: default;
            display: flex;
            justify-content: center;
            align-items: center;
            top: 0;
            right: 0;
            left: 0;
            bottom: 0;

            /* For preventing double click and visual feedback,
                setting 'disabled' attribute on btn works well for turbo-submit event
                but in a regular full page submit, it blocks form submission. :/
                So instead, we use the loader div to block access to the button 
                and give it a background opacity for visual feedbback */
            background-color: #fff5;
        }
    }

    .spinner {
        width: 20px;
        height: 20px;
        border: 3px solid transparent;
        border-radius: 50%;
        border-top-color: white;
        border-right-color: white;
        animation: spin 0.8s linear infinite;
    }

    @keyframes spin {
        0% {
            transform: rotate(0deg);
        }

        100% {
            transform: rotate(360deg);
        }
    }
}