/* Overlay */
.cpm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    opacity: 0;
    -webkit-transition: opacity 0.3s ease-in-out;
    transition: opacity 0.3s ease-in-out;
}

.cpm-overlay.active {
    opacity: 1;
}

/* Popup Container */
.cpm-popup-container {
    position: fixed;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
    z-index: 9999;
    opacity: 0;
    -webkit-transition: opacity 0.3s ease-in-out;
    transition: opacity 0.3s ease-in-out;
    max-height: 90vh;
    overflow-y: auto;
    width: 50%;
}

.cpm-popup-container.active {
    opacity: 1;
}

/* Popup Content */
.cpm-popup-content {
    background: #ffffff;
    border-radius: 8px;
    -webkit-box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
    padding: 30px;
    max-width: 100%;
}

/* Close Button */
.cpm-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    -webkit-transition: color 0.2s ease;
    transition: color 0.2s ease;
    z-index: 10;
}

.cpm-close-btn:hover {
    color: #333;
}

.cpm-close-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Inner Content */
.cpm-popup-inner {
    position: relative;
}

/* Prevent body scroll when popup is open */
body.cpm-popup-open {
    overflow: hidden;
}

/* Responsive adjustments for popup content */
.cpm-popup-inner > * {
    max-width: 100%;
}

/* Gravity Forms specific adjustments */
.cpm-popup-inner .gform_wrapper {
    max-width: 100%;
}

.cpm-popup-inner .gform_wrapper form {
    margin: 0;
}

.cpm-popup-inner .gform_body {
    width: 100%;
}

.cpm-popup-inner .gform_footer {
    padding-top: 20px;
}

/* Ensure form fields are properly sized */
.cpm-popup-inner input[type="text"],
.cpm-popup-inner input[type="email"],
.cpm-popup-inner input[type="tel"],
.cpm-popup-inner input[type="url"],
.cpm-popup-inner input[type="number"],
.cpm-popup-inner select,
.cpm-popup-inner textarea {
    max-width: 100%;
    -webkit-box-sizing: border-box;
            box-sizing: border-box;
}

/* Contact Form 7 specific adjustments */
.cpm-popup-inner .wpcf7 {
    max-width: 100%;
}

.cpm-popup-inner .wpcf7 form {
    margin: 0;
}

.cpm-popup-inner .wpcf7 .wpcf7-response-output {
    margin: 1em 0;
}

.cpm-popup-inner .wpcf7 .wpcf7-not-valid-tip {
    display: block;
    margin-top: 5px;
}

.cpm-popup-inner .wpcf7 .wpcf7-spinner {
    /*visibility: visible;*/
}

.cpm-popup-inner .wpcf7 input[type="text"],
.cpm-popup-inner .wpcf7 input[type="email"],
.cpm-popup-inner .wpcf7 input[type="tel"],
.cpm-popup-inner .wpcf7 input[type="url"],
.cpm-popup-inner .wpcf7 input[type="number"],
.cpm-popup-inner .wpcf7 input[type="date"],
.cpm-popup-inner .wpcf7 select,
.cpm-popup-inner .wpcf7 textarea {
    width: 100%;
    max-width: 100%;
    -webkit-box-sizing: border-box;
            box-sizing: border-box;
}

/* CF7 validation messages */
.cpm-popup-inner .wpcf7-validation-errors,
.cpm-popup-inner .wpcf7-mail-sent-ok,
.cpm-popup-inner .wpcf7-mail-sent-ng,
.cpm-popup-inner .wpcf7-spam-blocked {
    border: 2px solid;
    padding: 10px 15px;
    margin: 1em 0;
}

.cpm-popup-inner .wpcf7-validation-errors {
    border-color: #f00;
    background-color: #ffeded;
}

.cpm-popup-inner .wpcf7-mail-sent-ok {
    border-color: #398f14;
    background-color: #e7f7e1;
}

.cpm-popup-inner .wpcf7-mail-sent-ng,
.cpm-popup-inner .wpcf7-spam-blocked {
    border-color: #ff0000;
    background-color: #ffeded;
}

/* Fix CF7 spinner - hide by default, show only when submitting */
.cpm-popup-inner .wpcf7 .ajax-loader {
    visibility: hidden !important;
}

.cpm-popup-inner .wpcf7.submitting .ajax-loader {
    visibility: visible !important;
}

/* Tablet styles */
@media screen and (max-width: 1024px) {
    .cpm-popup-container {
        width: 90%;
    }
    
    .cpm-popup-content {
        padding: 25px;
    }
}

/* Mobile styles */
@media screen and (max-width: 768px) {
    .cpm-popup-container {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .cpm-popup-content {
        border-radius: 0;
        padding: 20px;
        min-height: 100vh;
    }
    
    .cpm-close-btn {
        top: 10px;
        right: 10px;
    }
}

/* Scrollbar styling for popup */
.cpm-popup-container::-webkit-scrollbar {
    width: 8px;
}

.cpm-popup-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.cpm-popup-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.cpm-popup-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Animation improvements */
@-webkit-keyframes cpmFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
@keyframes cpmFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@-webkit-keyframes cpmFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes cpmFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.cpm-overlay.cpm-fade-in {
    -webkit-animation: cpmFadeIn 0.3s ease-in-out forwards;
            animation: cpmFadeIn 0.3s ease-in-out forwards;
}

.cpm-overlay.cpm-fade-out {
    -webkit-animation: cpmFadeOut 0.3s ease-in-out forwards;
            animation: cpmFadeOut 0.3s ease-in-out forwards;
}

.cpm-popup-container.cpm-fade-in {
    -webkit-animation: cpmFadeIn 0.3s ease-in-out forwards;
            animation: cpmFadeIn 0.3s ease-in-out forwards;
}

.cpm-popup-container.cpm-fade-out {
    -webkit-animation: cpmFadeOut 0.3s ease-in-out forwards;
            animation: cpmFadeOut 0.3s ease-in-out forwards;
}

/* Accessibility improvements */
.cpm-popup-container:focus {
    outline: none;
}

/* Handle very long content */
.cpm-popup-inner {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Loading state */
.cpm-popup-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Error state */
.cpm-popup-error {
    text-align: center;
    padding: 40px;
    color: #d63638;
}