/**
 * Form Submission Animations
 * Performant CSS animations and JavaScript effects for form conversion
 * Uses CSS transforms and opacity for optimal performance
 * 
 * @package LeadForm
 * @version 1.0.0
 */

/* ============================================
   LOADING STATE ANIMATIONS
   ============================================ */

/* Button loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 113, 177, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(34, 113, 177, 0);
    }
}

/* Button loading state */
.btn-loading {
    position: relative !important;
    color: transparent !important;
    pointer-events: none !important;
    animation: pulse-glow 2s infinite !important;
}

/* Loading spinner inside button */
.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   SUCCESS NOTIFICATION
   ============================================ */

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(-100vh) rotateZ(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotateZ(720deg);
    }
}

.success-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #34c759 0%, #30b747 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(52, 199, 89, 0.3);
    animation: slideInUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 9999;
    max-width: 90%;
    word-wrap: break-word;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.success-notification::before {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    flex-shrink: 0;
    font-weight: bold;
}

.success-notification.hide {
    animation: slideInUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) reverse;
}

/* ============================================
   ERROR NOTIFICATION
   ============================================ */

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.error-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ff3b30 0%, #ff453a 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(255, 59, 48, 0.3);
    animation: slideInUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), shake 0.3s;
    z-index: 9999;
    max-width: 90%;
    word-wrap: break-word;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.error-notification::before {
    content: '✕';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    flex-shrink: 0;
    font-weight: bold;
}

/* ============================================
   FORM SUBMISSION FEEDBACK
   ============================================ */

/* Field focus animation */
#form-container input:focus,
#form-container select:focus,
#form-container textarea:focus {
    transform: scale(1.01);
    transition: all 0.2s ease;
}

/* Invalid field shake */
.invalid-input {
    animation: shake 0.3s !important;
}

/* Field error message */
.field-error {
    color: #ff3b30;
    font-size: 12px;
    margin-top: 4px;
    animation: slideInUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   CONFETTI EFFECT (Optional)
   ============================================ */

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #34c759;
    pointer-events: none;
    animation: confetti-fall 3s ease-in forwards;
}

/* ============================================
   SMOOTH TRANSITIONS FOR ALL INTERACTIVE ELEMENTS
   ============================================ */

#custom-order-form button,
#custom-order-form input,
#custom-order-form select {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Submit button hover effect */
#custom-order-form button[type="submit"]:not(.btn-loading):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15) !important;
}

/* Submit button active effect */
#custom-order-form button[type="submit"]:not(.btn-loading):active {
    transform: translateY(0);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .success-notification,
    .error-notification {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        max-width: calc(100% - 20px) !important;
    }
}
