/**
 * Authentication Performance CSS
 * Smooth loading transitions and animations for auth forms
 */

/* Loading button states */
.loading {
    position: relative;
    pointer-events: none;
}

.loading:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

/* Smooth transitions for form elements */
.auth-form {
    transition: all 0.2s ease-in-out;
}

.auth-form input {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.auth-form button {
    transition: all 0.15s ease-in-out;
}

/* Loading spinner animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Pulse animation for extended loading */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Fade in animation for loading messages */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.2s ease-out;
}

/* Loading state transitions */
.loading-enter {
    opacity: 0;
    transform: scale(0.95);
}

.loading-enter-active {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

/* Error state animations */
.error-shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Success state animation */
.success-bounce {
    animation: bounce 0.6s ease-in-out;
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

/* Progress indicator styles */
.progress-indicator {
    position: relative;
    overflow: hidden;
}

.progress-indicator::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.8), transparent);
    animation: progress 1.5s infinite;
}

@keyframes progress {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Responsive loading states */
@media (max-width: 640px) {
    .loading .flex {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .loading svg {
        margin: 0;
        width: 1rem;
        height: 1rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .loading {
        border: 2px solid currentColor;
    }
    
    .animate-spin {
        border: 2px solid currentColor;
        border-top-color: transparent;
        border-radius: 50%;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .animate-spin {
        animation: none;
    }
    
    .animate-pulse {
        animation: none;
    }
    
    .auth-form,
    .auth-form input,
    .auth-form button {
        transition: none;
    }
    
    .loading-enter-active {
        transition: none;
    }
}

/* Focus management during loading */
.loading:focus {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

/* Loading overlay for forms */
.form-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

.form-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}