:root {
    --error-message-color: #ff0000; /* Default error color */
    --success-message-title-color: rgb(104, 139, 107); /* Default success title color */
    --success-message-description-color: #333; /* Default success description color */
}

/* Initial State */
.popup1-modal-overlay.popup1-initialized { /* Added - */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.popup1-modal-overlay.popup1-initialized[style*="display: flex"] { /* Added - */
    opacity: 1;
}

/* Reset and Base Styles */
.popup1-modal-overlay, /* Added - */
.popup1-modal-overlay *, /* Added - */
.popup1-form-container, /* Added - */
.popup1-form-container * { /* Added - */
    box-sizing: border-box;
}

/* Rotate animation class */
.popup1-form-container { /* Added - */
    transform-origin: center center;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.popup1-modal-overlay[style*="display: flex"] .popup1-form-container { /* Added - */
    opacity: 1;
}

.popup1-modal-overlay.rotate-fade .popup1-form-container { /* Added - */
    animation: rotateFade 0.6s ease-out forwards;
}

.popup1-modal-overlay.rotate-fade-out .popup1-form-container { /* Added - */
    animation: rotateFadeOut 0.6s ease-in forwards;
}

/* Keyframes definition */
@keyframes rotateFade {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.3);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

@keyframes rotateFadeOut {
    from {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
    to {
        opacity: 0;
        transform: rotate(180deg) scale(0.3);
    }
}

/* A/B Testing Styles */
.ab-variation {
    display: none; /* Hide all variations by default */
}

/* The specific variation will be shown via JavaScript adding a class */
#popup1.show-variation-profile-a .ab-variation[data-variation-profile="profile-a"],
#popup1.show-variation-profile-b .ab-variation[data-variation-profile="profile-b"] {
    display: block;
}

@keyframes button-loading-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* --- Added Animation Keyframes & Classes --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slideUpIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUpOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-30px); }
}

/* Apply animations based on classes added by JS */
.popup1-form-container.animate-in,
.popup1-form-container.animate-out {
    /* Define common animation properties */
    animation-duration: 0.4s; /* Adjust duration as needed */
    animation-fill-mode: forwards;
    animation-timing-function: ease-in-out;
    /* Ensure opacity starts correctly for fade-in */
    opacity: 0; /* Start transparent for animate-in */
}
.popup1-form-container.animate-out {
     opacity: 1; /* Start opaque for animate-out */
}


.popup1-form-container.animate-in.fade-in {
    animation-name: fadeIn;
}
.popup1-form-container.animate-out.fade-out {
    animation-name: fadeOut;
}
.popup1-form-container.animate-in.slide-up-in {
    animation-name: slideUpIn;
}
.popup1-form-container.animate-out.slide-up-out {
    animation-name: slideUpOut;
}
/* --- End Added Animation Keyframes & Classes --- */


/* Modal Overlay */
.popup1-modal-overlay { /* Added - */
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20000001;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.popup1-modal-overlay[style*="display: flex"] { /* Added - */
    opacity: 1;
}

/* Form Container */
.popup1-form-container { /* Added - */
    margin: 120px 0 30px;
    border-radius: 0;
    box-shadow: 0 0 0 1px #fff;
    width: 730px;
    height: 428.5px;
    position: relative;
    overflow: visible;
    box-sizing: content-box !important;
    display: flex;
    transform-origin: center center;
}

/* Close Button */
.popup1-close-button { /* Added - */
    position: absolute;
    top: 8px;
    right: 8px;
    min-height: 0.5em !important;
    width: 24px;
    margin: 0px;
    height: 24px;
    background: rgba(0, 0, 0, 0.425) url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJ3aGl0ZSI+PHBhdGggZD0iTTE5IDYuNDFMMTcuNTkgNSAxMiAxMC41OSA2LjQxIDUgNSA2LjQxIDEwLjU5IDEyIDUgMTcuNTkgNi40MSAxOSAxMiAxMy40MSAxNy41OSAxOSAxOSAxNy41OSAxMy40MSAxMnoiLz48L3N2Zz4=') center/16px no-repeat;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 99999999;
    padding: 0;
    box-shadow: 0 0 0 2px rgba(237, 93, 77, 0.062);
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.popup1-close-button:hover { /* Added - */
    background-color: rgba(255, 254, 254, 0.4);
    box-shadow: 0 0 0 2px rgb(237 94 77 / 1%);
}

/* Layout Columns */
.popup1-image-column { /* Added - */
    width: 320px;
    height: 428px;
    overflow: hidden;
    position: relative;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

.popup1-form-column { /* Added - */
    flex: 1;
    padding: 20px 20px 0px 20px;
    width: 100%;
    max-width: 410px;
}

/* Form Header */
.popup1-form-header { /* Added - */
    text-align: left;
    margin-bottom: 30px;
}

.popup1-form-title { /* Added - */
    font-family: "Montserrat", sans-serif;
    font-weight: bold;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
    line-height: normal;
}

.popup1-form-subtitle { /* Added - */
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    font-family: "Montserrat", sans-serif;
    font-weight: 600;
    letter-spacing: 0.5px;
    justify-content: flex-start;
}

.popup1-form-description { /* Added - */
    font-family: "Open Sans", sans-serif;
    text-align: left;
    margin-bottom: 30px;
    line-height: normal;
}

/* Form Elements */
.popup1-form-group { /* Added - */
    position: relative;
    min-height: 50px;
    width: 100%;
    margin-bottom: 10px;
}

/* Re-adding subtitle rule with preview suffix */
.popup1-form-subtitle { /* Added - */
    display: flex;
    align-items: baseline;
    margin-bottom: 15px;
    font-family: "Montserrat", sans-serif;
    font-weight: 600;
    letter-spacing: 0.5px;
    justify-content: flex-start;
}

.popup1-form-error { /* Added - */
    position: absolute;
    bottom: -3px !important;
    font-size: 13px;
    color: var(--error-message-color);
    display: none;
    margin: 0;
    padding: 0;
}
/* Assuming this class might be used dynamically, add preview */
.popup1-form-error-message { /* Added - */
    color: var(--error-message-color);
}

.popup1-form-input { /* Added - */
    width: 100%;
    height: 38px !important;
    padding: 0px 10px;
    margin-bottom: 10px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    color: #333;
    background: #ffffff;
    font-family: "Open Sans", Helvetica, Arial, sans-serif;
}

.popup1-form-input::placeholder { /* Added - */
    color: #5e5e5e !important;
    opacity: 1;
}

.popup1-form-input:focus { /* Added - */
    border: 2px solid #ffffff !important;
    box-shadow: inset 0 0 0 2px #000000 !important;
    color: #333;
    opacity: 1;
    outline: 0;
}

.popup1-form-input:hover { /* Added - */
    box-shadow: 0px 0px 5px rgba(98, 139, 189, 0.5);
}

/* Validation States */
.validation-icon {
    display: none;
    position: absolute;
    right: 15px; /* Increased to move icon further left */
    top: 9px;  /* Adjusted for vertical centering (38px input height - 20px icon height) / 2 */
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.valid-icon {
    color: #4CAF50;
}

.invalid-icon {
    color: #ff4949;
}

/* Show error message when input is invalid and not focused */
.popup1-form-input.error:not(:focus) ~ .popup1-form-error { /* Added - */
    display: block;
}

.popup1-form-input:focus ~ .popup1-form-error { /* Added - */
    display: none;
}

.popup1-form-input.valid ~ .valid-icon { /* Added - */
    display: block;
}

.popup1-form-input:not(.valid):not(:placeholder-shown) ~ .invalid-icon { /* Added - */
    display: block;
}

.popup1-form-content {
    display: flex;
    flex-direction: column;
}

.popup1-submit-button {
    width: 250px !important;
    padding: 0px !important;
    line-height: 23px !important;
    min-height: 2.5em !important;
    font-weight: 400;
    font-family: "Source Sans Pro", sans-serif;
    border: none;
    border-radius: 4px;
    background-color: #000;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin: 15px auto 0;
    display: block;
}

.popup1-submit-button:hover { /* Added - */
    background-color: #333;
}

.popup1-submit-button:hover:after { /* Added - */
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.14);
    transition: all 0.2s ease;
    border-radius: 3px;
}

.popup1-submit-button:active:after { /* Added - */
    background: rgba(0,0,0,0.05) !important;
}

.popup1-submit-button.loading::after { /* Added - */
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: button-loading-spinner 0.8s linear infinite;
}

/* Success Message */
.popup1-success-message { /* Added - */
    text-align: center;
    padding: 40px 20px;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    margin: 20px auto;
    max-width: 500px;
}

.popup1-success-message h3 { /* Added - */
    font-family: "Montserrat", sans-serif;
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--success-message-title-color);
}

.popup1-success-message p { /* Added - */
    font-family: "Open Sans", sans-serif;
    font-size: 18px;
    color: var(--success-message-description-color);
    line-height: 1.5;
}

/* Responsive Styles */
@media (max-width: 767px) {
    .popup1-form-container { /* Added - */
        margin-top: 22%;
        margin-bottom: 10px;
        flex-direction: column;
        width: 361px;
        min-width: 361px;
        max-width: 361px;
        height: auto;
        transform-origin: center center;
    }

    .popup1-submit-button { /* Added - */
        font-size: 16px;
    }

    .popup1-image-column { /* Added - */
        width: 100%;
        height: 180px;
    }

    .popup1-form-column { /* Added - */
        padding: 10px 15px 0px 15px;
    }

    .popup1-form-title { /* Added - */
        font-size: 22px;
    }

    .popup1-form-subtitle, /* Added - */
    .popup1-form-description { /* Added - */
        font-size: 14px;
    }

    .popup1-success-message h3 { /* Added - */
        font-size: 28px;
    }

    .popup1-success-message p { /* Added - */
        font-size: 16px;
    }
}

/* Extra Small Devices */
@media (max-width: 360px) {
    .popup1-form-container { /* Added - */
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }

    .popup1-image-column { /* Added - */
        width: 100%;
        height: 120px;
    }
    .popup1-form-title { /* Added - */
        font-size: 22px;
    }

    .popup1-form-subtitle, /* Added - */
    .popup1-form-description { /* Added - */
        font-size: 14px;
    }

    .popup1-form-error { /* Added - */
        bottom: -3px !important;
        font-size: 10px !important;
    }
}
