/*  -----------------------------------------------------------
    CF7 Custom Success Transitions
    ----------------------------------------------------------- */

/* CSS Custom Properties for easy customization */
:root {
    --cf7-transition-duration: 0.5s;
    --cf7-icon-size: 80px;
    --cf7-icon-size-mobile: 60px;
    --cf7-success-bg: rgba(31, 142, 250, 0.1);
    --cf7-success-color: #1F8EFA;
    --cf7-reset-btn-bg: #1F8EFA;
    --cf7-reset-btn-hover: #0d7ae0;
}

/* Container for forms with custom success enabled */
.cf7-custom-success {
    position: relative;
    min-height: 200px; /* Prevent layout shift */
    transition: all var(--cf7-transition-duration) ease-in-out;
}

/* Form state transitions */
.cf7-custom-success .wpcf7 {
    transition: opacity var(--cf7-transition-duration) ease-in-out,
                transform var(--cf7-transition-duration) ease-in-out;
    transform: translateY(0);
    opacity: 1;
}

/* Hide form when success is active */
.cf7-custom-success.cf7-success-active .wpcf7 {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

/* Hide default CF7 response output when custom success is active */
.cf7-custom-success.cf7-success-active .wpcf7-response-output {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    overflow: hidden !important;
}

/* Also target when the form has the sent class - override existing theme styling */
.cf7-custom-success .wpcf7.sent .wpcf7-response-output,
.cf7-custom-success .wpcf7 form.sent .wpcf7-response-output {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}

/* Success state container */
.cf7-success-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    opacity: 0;
    transition: opacity var(--cf7-transition-duration) ease-in-out 0.2s,
                transform var(--cf7-transition-duration) ease-in-out 0.2s;
    pointer-events: none;
    width: 100%;
    padding: 2rem;
    background: var(--cf7-success-bg);
    border-radius: 8px;
    border: 1px solid rgba(31, 142, 250, 0.2);
}

/* Show success message when active */
.cf7-custom-success.cf7-success-active .cf7-success-message {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

/* Success icon styling */
.cf7-success-icon {
    width: var(--cf7-icon-size);
    height: var(--cf7-icon-size);
    margin: 0 auto 1rem;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: cf7IconBounce 0.6s ease-out 0.3s both;
}

/* Success text */
.cf7-success-text {
    color: var(--cf7-success-color);
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    animation: cf7TextFade 0.5s ease-out 0.5s both;
}

/* Reset button */
.cf7-reset-btn {
    background: var(--cf7-reset-btn-bg);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.3s ease;
    animation: cf7ButtonSlide 0.5s ease-out 0.7s both;
}

.cf7-reset-btn:hover {
    background: var(--cf7-reset-btn-hover);
}

/* Auto-reset countdown */
.cf7-auto-reset-countdown {
    font-size: 0.8rem;
    color: #5E91A8;
    margin-top: 1rem;
    animation: cf7TextFade 0.5s ease-out 0.9s both;
}

/* Keyframe animations */
@keyframes cf7IconBounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes cf7TextFade {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cf7ButtonSlide {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsiveness */
@media (max-width: 767px) {
    .cf7-success-icon {
        width: var(--cf7-icon-size-mobile);
        height: var(--cf7-icon-size-mobile);
    }
    
    .cf7-success-text {
        font-size: 1rem;
    }
    
    .cf7-success-message {
        padding: 1.5rem;
    }
    
    .cf7-reset-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cf7-success-message {
        background: rgba(31, 142, 250, 0.2);
        border-color: var(--cf7-success-color);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .cf7-custom-success,
    .cf7-custom-success .wpcf7,
    .cf7-success-message,
    .cf7-success-icon {
        transition: none;
        animation: none;
    }
    
    .cf7-success-icon,
    .cf7-success-text,
    .cf7-reset-btn,
    .cf7-auto-reset-countdown {
        animation: none;
        opacity: 1;
        transform: none;
    }
}