/* Advanced CSS Animations and Effects */

/* === ADVANCED ANIMATIONS === */

/* Floating Animation with 3D Transform */
@keyframes float3D {
    0%, 100% {
        transform: translateY(0px) rotateX(0deg) rotateY(0deg);
    }
    25% {
        transform: translateY(-10px) rotateX(2deg) rotateY(1deg);
    }
    50% {
        transform: translateY(-5px) rotateX(-1deg) rotateY(-2deg);
    }
    75% {
        transform: translateY(-15px) rotateX(1deg) rotateY(1deg);
    }
}

/* Morphing Border Animation */
@keyframes morphBorder {
    0%, 100% {
        border-radius: 20px 20px 20px 20px;
    }
    25% {
        border-radius: 50px 20px 50px 20px;
    }
    50% {
        border-radius: 20px 50px 20px 50px;
    }
    75% {
        border-radius: 30px 30px 30px 30px;
    }
}

/* Advanced Glow Pulse */
@keyframes advancedGlow {
    0%, 100% {
        box-shadow: 
            0 0 20px rgba(102, 126, 234, 0.3),
            0 0 40px rgba(118, 75, 162, 0.2),
            0 0 60px rgba(240, 147, 251, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: 
            0 0 30px rgba(102, 126, 234, 0.6),
            0 0 60px rgba(118, 75, 162, 0.4),
            0 0 90px rgba(240, 147, 251, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.4);
    }
}

/* Text Shimmer Effect */
@keyframes textShimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

/* Particle Burst Animation */
@keyframes particleBurst {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(2) rotate(360deg);
        opacity: 0;
    }
}

/* Wave Animation */
@keyframes wave {
    0%, 100% {
        clip-path: polygon(0 45%, 15% 44%, 32% 50%, 54% 60%, 70% 61%, 84% 59%, 100% 52%, 100% 100%, 0% 100%);
    }
    50% {
        clip-path: polygon(0 60%, 16% 65%, 34% 66%, 51% 62%, 67% 50%, 84% 45%, 100% 46%, 100% 100%, 0% 100%);
    }
}

/* Matrix Effect */
@keyframes matrix {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 0% 100%;
    }
}

/* === ENHANCED CARD ANIMATIONS === */

/* Card Entrance Animation */
.auth-card {
    animation: 
        slideUp 0.8s cubic-bezier(0.4, 0, 0.2, 1),
        float3D 8s ease-in-out infinite 1s;
}

.auth-card:hover {
    animation: 
        float3D 8s ease-in-out infinite,
        advancedGlow 3s ease-in-out infinite,
        morphBorder 6s ease-in-out infinite;
}

/* === TEXT EFFECTS === */

.brand-title {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #f5576c 75%, #4facfe 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbowText 4s ease-in-out infinite;
    position: relative;
}

.brand-title::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: textShimmer 3s ease-in-out infinite;
}

/* === FORM FIELD ANIMATIONS === */

/* Enhanced Focus Animation */
.form-control-modern:focus {
    animation: fieldFocus 0.3s ease-out;
}

@keyframes fieldFocus {
    0% {
        transform: scale(1) translateY(0);
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
    50% {
        transform: scale(1.02) translateY(-2px);
        box-shadow: 0 0 0 5px rgba(102, 126, 234, 0.2);
    }
    100% {
        transform: scale(1) translateY(-2px);
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    }
}

/* Icon Bounce Animation */
.input-icon {
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.input-wrapper.focused .input-icon {
    animation: iconBounce 0.6s ease-out;
    color: #667eea;
}

@keyframes iconBounce {
    0% {
        transform: translateY(-50%) scale(1);
    }
    50% {
        transform: translateY(-50%) scale(1.3) rotate(10deg);
    }
    100% {
        transform: translateY(-50%) scale(1) rotate(0deg);
    }
}

/* === BUTTON EFFECTS === */

/* Advanced Button Hover */
.btn-primary-modern {
    position: relative;
    overflow: hidden;
}

.btn-primary-modern::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-primary-modern:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary-modern:active {
    animation: buttonPress 0.1s ease-out;
}

@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.98);
    }
    100% {
        transform: scale(1);
    }
}

/* === BACKGROUND EFFECTS === */

/* Enhanced Particle System */
.modern-auth-body {
    position: relative;
}

.modern-auth-body::before {
    animation: 
        floatingParticles 20s linear infinite,
        particleGlow 8s ease-in-out infinite alternate;
}

@keyframes particleGlow {
    0% {
        opacity: 0.3;
    }
    100% {
        opacity: 0.8;
    }
}

/* Flowing Waves Effect */
.auth-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(45deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    clip-path: polygon(0 45%, 15% 44%, 32% 50%, 54% 60%, 70% 61%, 84% 59%, 100% 52%, 100% 100%, 0% 100%);
    animation: wave 8s ease-in-out infinite;
    z-index: 1;
}

/* === LOADING ANIMATIONS === */

/* Advanced Loading Spinner */
.advanced-spinner {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
}

.advanced-spinner::before,
.advanced-spinner::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: currentColor;
}

.advanced-spinner::before {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

.advanced-spinner::after {
    width: 12px;
    height: 12px;
    top: 4px;
    left: 4px;
    border-top-color: rgba(255, 255, 255, 0.5);
    animation: spin 0.5s linear infinite reverse;
}

/* === ERROR ANIMATIONS === */

/* Shake Animation for Errors */
.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);
    }
}

/* Error Glow Effect */
.error-glow {
    animation: errorGlow 1s ease-in-out;
}

@keyframes errorGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(231, 76, 60, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(231, 76, 60, 0.8);
    }
}

/* === SUCCESS ANIMATIONS === */

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

@keyframes successBounce {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.1);
    }
    60% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

/* === MOBILE OPTIMIZATIONS === */

@media (max-width: 768px) {
    .auth-card {
        animation: slideUp 0.6s ease;
    }
    
    .auth-card:hover {
        animation: none;
    }
    
    .modern-auth-body::before {
        animation-duration: 30s;
    }
    
    .brand-title::after {
        animation: none;
    }
}

/* === ACCESSIBILITY === */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .auth-card:hover {
        transform: none !important;
    }
}

/* === PERFORMANCE OPTIMIZATIONS === */

.auth-card,
.form-control-modern,
.btn-modern,
.input-icon,
.brand-title {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* === INTERACTIVE ENHANCEMENTS === */

/* Hover Trail Effect */
.btn-modern {
    position: relative;
    overflow: hidden;
}

.btn-modern:hover::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: trailExpand 0.6s ease-out;
}

@keyframes trailExpand {
    to {
        width: 100px;
        height: 100px;
        opacity: 0;
    }
}

/* Focus Ring Animation */
.form-control-modern:focus {
    position: relative;
}

.form-control-modern:focus::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid rgba(102, 126, 234, 0.5);
    border-radius: 18px;
    animation: focusRing 2s ease-in-out infinite;
}

@keyframes focusRing {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.02);
    }
}

/* === THEME TRANSITIONS === */

.theme-transition * {
    transition: 
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease !important;
}