/* Animation Keyframes */
:root {
    --error-message-color: #ff0000; /* Default error color */
    --success-message-title-color: rgb(204, 204, 204); /* Default success title color */
    --success-message-description-color: #ffffff; /* Default success description color */
}

@keyframes button-loading-spinner {
    to { transform: rotate(360deg); }
}


@keyframes giftBounce {
    0%, 100% {
        transform: scale(1.2) translateY(0) !important;
    }
    50% {
        transform: scale(1.2) translateY(-3px) !important;
    }
}

/* Rotate animation class */
.popup2-form-container {
    transform-origin: center center;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.popup2-modal-overlay[style*="display: flex"] .popup2-form-container {
    opacity: 1;
}

.popup2-modal-overlay.rotate-fade .popup2-form-container {
    animation: rotateFade 0.6s ease-out forwards;
}

.popup2-modal-overlay.rotate-fade-out .popup2-form-container {
    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 */
#popup2.show-variation-profile-a .ab-variation[data-variation-profile="profile-a"],
#popup2.show-variation-profile-b .ab-variation[data-variation-profile="profile-b"] {
    display: block;
}

/* --- 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 */
.popup2-form-container.animate-in,
.popup2-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 */
}
.popup2-form-container.animate-out {
     opacity: 1; /* Start opaque for animate-out */
}


.popup2-form-container.animate-in.fade-in {
    animation-name: fadeIn;
}
.popup2-form-container.animate-out.fade-out {
    animation-name: fadeOut;
}
.popup2-form-container.animate-in.slide-up-in {
    animation-name: slideUpIn;
}
.popup2-form-container.animate-out.slide-up-out {
    animation-name: slideUpOut;
}
/* --- End Added Animation Keyframes & Classes --- */


/* Rest of the existing CSS remains unchanged */
.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 */
.popup2-form-input.error:not(:focus) ~ .popup2-form-error {
    display: block;
}

/* Hide error message when input is focused */
.popup2-form-input:focus ~ .popup2-form-error {
    display: none;
}

/* Show valid icon when input is valid and not empty */
.popup2-form-input.valid:not(:placeholder-shown) ~ .valid-icon {
    display: block;
}

/* Show invalid icon when input has content but is not valid */
.popup2-form-input:not(.valid):not(:placeholder-shown) ~ .invalid-icon {
    display: block;
}

/* Sticky Bar */
.popup2-bar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    cursor: pointer !important;
    font-weight: normal !important;
    z-index: 99999 !important; /* Zwiększono z-index, aby był na wierzchu */
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-family: "Source Sans Pro", sans-serif !important;
    gap: 8px !important;
    padding: 0 15px !important;
    text-align: center !important;
}

.popup2-bar .gift-icon {
    width: 16px !important;
    height: 16px !important;
    display: inline-block !important;
    vertical-align: middle !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    position: static !important;
    transform: none !important;
    transition: transform 0.3s ease !important;
}

.popup2-bar:hover .gift-icon {
    transform: scale(1.2) !important;
}

/* Remove height change on mobile */
@media (max-width: 767px) {
    .popup2-bar:hover {
        height: 36px !important;
    }
}

/* Modal Overlay */
.popup2-modal-overlay {
    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;
}

.popup2-modal-overlay.popup2-initialized {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.popup2-modal-overlay.popup2-initialized[style*="display: flex"],
.popup2-modal-overlay[style*="display: flex"] {
    opacity: 1;
}

/* Form Container */
.popup2-form-container {
    margin: 120px 0 30px;
    border-radius: 12px;
    width: 730px;
    height: 428.5px;
    position: relative;
    overflow: visible;
    box-sizing: content-box !important;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.26);
    display: flex;
    transform-origin: center center;
}

/* Rest of the CSS remains unchanged */
/* Close Button */
.popup2-close-button {
    position: absolute;
    top: 8px;
    right: 8px;
    min-height: 0.5em !important;
    margin: 0px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.623) 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(73, 73, 73, 0.52);
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.popup2-close-button:hover {
    background-color: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

/* Layout Columns */
.popup2-image-column {
    width: 320px;
    height: 429px;
    overflow: hidden;
    position: relative;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    border-radius: 12px 0px 0px 12px;
}

.popup2-form-column {
    flex: 1;
    padding: 20px 20px 0px 20px;
}

/* Form Content */
.popup2-form-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Form Elements */
.popup2-form-group {
    position: relative;
    margin-bottom: 10px;
    width: 100%;
}

.popup2-form-error {
    position: absolute;
    bottom: -12px;
    left: 0;
    font-size: 14px;
    color: var(--error-message-color);
    display: none;
    margin: 0;
    padding: 0;
    font-family: "Source Sans Pro", sans-serif;
}

.popup2-form-input {
    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;
}

.popup2-form-input::placeholder {
    color: #5e5e5e !important;
    opacity: 1;
}

.popup2-form-input:focus {
    border: 2px solid #ffffff !important;
    box-shadow: inset 0 0 0 2px #000000 !important;
}

/* Form Header */
.popup2-form-header {
    text-align: center;
    margin-bottom: 20px;
}

.popup2-form-title {
    font-family: "Source Sans Pro", sans-serif;
    font-weight: 700;
    margin-bottom: 15px;
}

.popup2-form-description {
    font-family: "Source Sans Pro", sans-serif;
    line-height: 1.5;
    margin-bottom: 30px;
}

/* Submit Button */
.popup2-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: 3px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    margin: 0 auto;
    display: block;
}

.popup2-submit-button:hover {
    background-color: #333333;
}

.popup2-submit-button:disabled {
    background-color: #666666;
    cursor: not-allowed;
}

.popup2-submit-button.loading {
    color: transparent;
}

.popup2-submit-button.loading::after {
    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 */
.popup2-success-message {
    text-align: center;
    padding: 40px 20px;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    margin: 20px auto;
    max-width: 500px;
}

.popup2-success-message h3 {
    font-family: "Source Sans Pro", sans-serif;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--success-message-title-color);
}

.popup2-success-message p {
    font-family: "Source Sans Pro", sans-serif;
    font-size: 18px;
    color: var(--success-message-description-color);
    line-height: 1.5;
    margin: 0;
}


/* Responsive Styles */
@media (max-width: 767px) {
    .popup2-modal-overlay {
        padding: 0px 20px 0px 20px;
        align-items: flex-end;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        touch-action: none;
        -webkit-overflow-scrolling: none;
    }

    .popup2-form-container {
        flex-direction: column;
        height: auto;
        width: 100%;
        max-width: 400px;
        margin: 40px 0;
        background-color: #fff;
    }

    .popup2-image-column {
        width: 100%;
        height: 180px;
        order: -1; /* This ensures image is always at the top */
        display: block;
    }

    .popup2-mobile-image {
        display: none; /* Hide duplicate mobile image */
    }

    .popup2-form-title {
        font-size: 24px;
        margin: 0 0 10px;
    }

    .popup2-form-description {
        font-size: 16px;
        margin: 0px 10px 0px 10px;
        line-height: 1.4;
    }

    .popup2-form-group {
        margin: 0 0 12px;
    }

    .popup2-form-group:last-of-type {
        margin-bottom: 15px;
    }

    .popup2-submit-button {
        width: 260px !important;
        height: 36px !important;
        line-height: 36px !important;
        font-size: 16px;
        margin: 10px auto 10px;
    }


    .popup2-bar {
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        padding: 0 15px !important;
    }

    .popup2-bar .sticky-text {
        font-size: 18px !important;
        line-height: 18px !important;
    }

    .popup2-bar .gift-icon {
        width: 18px !important;
        height: 18px !important;
    }

    .popup2-bar:hover {
        height: 36px !important;
    }
}

/* Extra Small Devices */
@media (max-width: 360px) {
    .popup2-form-container {
        width: 100%;
        max-width: 340px;
    }


    .popup2-form-group {
        margin: 0 0 12px;
        padding: 0 20px;
    }

    .popup2-form-column {
        flex: 1;
        padding: 20px 0px 0px 0px;
    }

    .popup2-mobile-image {
        width: 100%;
        height: 120px;
    }
    .popup2-form-error {
        bottom: -12px;
    }
    .validation-icon {
        right: 22px;
    }
}
