/* ========================================
   FUTURO - FORM SUBMISSION ANIMATION
   Form → Letter → Fly Off → Success Message
   ======================================== */

/* Form animation states */
.form-container {
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-container.submitting {
    opacity: 0.7;
    pointer-events: none;
}

.form-container.success {
    opacity: 0;
    transform: scale(0.8);
}

/* Submit button glow effect */
.submit-button {
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.submit-button.loading {
    background: linear-gradient(135deg, #a78bfa 0%, #ec4899 100%);
    box-shadow: 
        0 0 30px rgba(139, 92, 246, 0.8),
        0 0 60px rgba(236, 72, 153, 0.6),
        inset 0 0 20px rgba(255, 255, 255, 0.3);
    animation: buttonGlow 1.5s ease-in-out infinite;
}

@keyframes buttonGlow {
    0%, 100% {
        box-shadow: 
            0 0 30px rgba(139, 92, 246, 0.8),
            0 0 60px rgba(236, 72, 153, 0.6),
            inset 0 0 20px rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 
            0 0 50px rgba(139, 92, 246, 1),
            0 0 100px rgba(236, 72, 153, 0.9),
            inset 0 0 30px rgba(255, 255, 255, 0.5);
    }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Letter envelope animation container */
.letter-animation-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

.letter-animation-container.active {
    display: block;
}

/* Letter envelope */
.letter-envelope {
    position: absolute;
    width: 200px;
    height: 140px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: letterAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes letterAppear {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Envelope body */
.envelope {
    position: relative;
    width: 200px;
    height: 140px;
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    border-radius: 10px;
    box-shadow: 
        0 10px 40px rgba(139, 92, 246, 0.6),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

/* Envelope flap */
.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 100px solid transparent;
    border-right: 100px solid transparent;
    border-top: 70px solid #ec4899;
    transform-origin: top center;
    animation: flapClose 0.5s ease-in-out 0.3s forwards;
}

@keyframes flapClose {
    from {
        transform: rotateX(180deg);
    }
    to {
        transform: rotateX(0deg);
    }
}

/* Letter paper inside */
.letter-paper {
    position: absolute;
    width: 160px;
    height: 100px;
    background: white;
    top: 20px;
    left: 20px;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: paperSlide 0.4s ease-out forwards;
}

@keyframes paperSlide {
    from {
        transform: translateY(-60px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Letter lines decoration */
.letter-line {
    height: 3px;
    background: rgba(139, 92, 246, 0.3);
    margin: 10px 15px;
    border-radius: 2px;
}

.letter-line:nth-child(1) {
    width: 80%;
}

.letter-line:nth-child(2) {
    width: 90%;
}

.letter-line:nth-child(3) {
    width: 70%;
}

/* Fly away animation */
.letter-envelope.fly-away {
    animation: flyAway 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes flyAway {
    0% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translate(20%, -80%) scale(0.8) rotate(15deg);
        opacity: 0.8;
    }
    100% {
        transform: translate(120%, -150%) scale(0.3) rotate(45deg);
        opacity: 0;
    }
}

/* Success message */
.success-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 3rem 4rem;
    border-radius: 25px;
    text-align: center;
    z-index: 10000;
    box-shadow: 
        0 20px 60px rgba(16, 185, 129, 0.5),
        inset 0 2px 8px rgba(255, 255, 255, 0.3);
    max-width: 500px;
    width: 90%;
}

.success-message.show {
    animation: successAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes successAppear {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-10deg);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: checkPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.3s forwards;
    transform: scale(0);
}

@keyframes checkPop {
    0% {
        transform: scale(0) rotate(-180deg);
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

.success-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    font-family: 'Outfit', sans-serif;
}

.success-text {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Backdrop overlay */
.form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.form-overlay.show {
    opacity: 1;
    pointer-events: all;
}

/* Error message */
.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 2.5rem 3.5rem;
    border-radius: 20px;
    text-align: center;
    z-index: 10000;
    box-shadow: 
        0 20px 60px rgba(239, 68, 68, 0.5),
        inset 0 2px 8px rgba(255, 255, 255, 0.3);
    max-width: 450px;
    width: 90%;
}

.error-message.show {
    animation: errorShake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

@keyframes errorShake {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translate(-52%, -50%) scale(1);
    }
    20%, 40%, 60%, 80% {
        transform: translate(-48%, -50%) scale(1);
    }
}

.error-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    font-family: 'Outfit', sans-serif;
}

.error-text {
    font-size: 1rem;
    opacity: 0.95;
}

/* Confetti particles for success */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #8b5cf6;
    position: absolute;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .letter-envelope {
        width: 150px;
        height: 105px;
    }
    
    .envelope {
        width: 150px;
        height: 105px;
    }
    
    .envelope-flap {
        border-left: 75px solid transparent;
        border-right: 75px solid transparent;
        border-top: 52px solid #ec4899;
    }
    
    .letter-paper {
        width: 120px;
        height: 75px;
        top: 15px;
        left: 15px;
    }
    
    .success-message,
    .error-message {
        padding: 2rem 2.5rem;
    }
    
    .success-title,
    .error-title {
        font-size: 1.4rem;
    }
    
    .success-text,
    .error-text {
        font-size: 0.95rem;
    }
    
    .success-icon,
    .error-icon {
        font-size: 3rem;
    }
}
