/* Frontend Modal Styles */

.custom-modal-wrapper {
    position: relative;
    display: inline-block;
}

.modal-trigger {
    background-color: #0073aa;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-trigger:hover {
    background-color: #005a87;
}

/* Image trigger styles */
.modal-trigger .modal-trigger-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    transition: transform 0.3s ease;
}

.modal-trigger:hover .modal-trigger-image {
    transform: scale(1.05);
}

/* SVG trigger styles */
.modal-trigger .modal-trigger-svg {
    max-width: 100%;
    height: auto;
    transition: transform 0.3s ease;
}

.modal-trigger .modal-trigger-svg svg {
    width: 100%;
    height: auto;
}

.modal-trigger:hover .modal-trigger-svg {
    transform: scale(1.05);
}

/* Modal overlay - ensure it covers entire viewport */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 999999 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin: 0 !important;
    padding: 0 !important;
}

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

.modal-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    background-color: white;
    margin: 20px;
}

/* Close button styling with new options */
.modal-close-external {
    position: absolute;
    z-index: 1000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    border: none;
    outline: none;
    transition: all 0.3s ease;
}

/* Close button positions */
.modal-close-top-right {
    top: 0;
    right: 0;
}

.modal-close-top-left {
    top: 0;
    left: 0;
}

.modal-close-bottom-right {
    bottom: 0;
    right: 0;
}

.modal-close-bottom-left {
    bottom: 0;
    left: 0;
}

.modal-close-center-top {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.modal-close-center-bottom {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Close button shape variations */
.modal-close-external[data-shape="circle"] {
    border-radius: 50%;
}

.modal-close-external[data-shape="square"] {
    border-radius: 0;
}

.modal-close-external[data-shape="rounded"] {
    border-radius: 8px;
}

/* Close button hover effects */
.modal-close-external:hover {
    transform: scale(1.1);
}

.modal-close-external[data-shape="circle"]:hover,
.modal-close-external[data-shape="square"]:hover,
.modal-close-external[data-shape="rounded"]:hover {
    transform: scale(1.1);
}

/* Close button image and SVG styling */
.modal-close-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.modal-close-svg {
    width: 100%;
    height: 100%;
}

.modal-close-svg svg {
    width: 100%;
    height: 100%;
}

.modal-content {
    padding: 30px;
    border-radius: 8px;
    width: 100%;
    height: 100%;
    text-align: center;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100%;
}

.modal-image {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
    border-radius: 4px;
}

.modal-title {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

.modal-text {
    margin-bottom: 25px;
    color: #666;
    line-height: 1.6;
    font-size: 16px;
    text-align: left;
    overflow-y: visible;
}

.modal-text p {
    margin-bottom: 15px;
}

.modal-text p:last-child {
    margin-bottom: 0;
}

/* Inner blocks content styling */
.modal-text .wp-block {
    margin-bottom: 15px;
}

.modal-text .wp-block:last-child {
    margin-bottom: 0;
}

.modal-text .wp-block-image {
    text-align: center;
}

.modal-text .wp-block-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.modal-text .wp-block-heading {
    margin-top: 20px;
    margin-bottom: 15px;
}

.modal-text .wp-block-heading:first-child {
    margin-top: 0;
}

.modal-text .wp-block-paragraph {
    margin-bottom: 15px;
}

.modal-text .wp-block-list {
    margin-bottom: 15px;
    padding-left: 20px;
}

.modal-text .wp-block-list li {
    margin-bottom: 5px;
}

.modal-button {
    background-color: #0073aa;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.modal-button:hover {
    background-color: #005a87;
    color: white;
    text-decoration: none;
}

/* iOS Zoom Prevention for iframes */
.modal-text iframe {
    /* Prevent iOS zoom on iframe inputs */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    
    /* Ensure proper scaling */
    max-width: 100%;
    width: 100%;
    height: 100%;
    border: none;
    
    /* Prevent zoom on iOS */
    -webkit-transform: scale(1);
    transform: scale(1);
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
}

/* Container for iframes to prevent zoom */
.modal-text .iframe-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    /* Prevent iOS zoom */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Prevent zoom */
    -webkit-transform: scale(1);
    transform: scale(1);
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
}

/* Specific styling for donation forms and embedded content */
.modal-text .donation-form-container,
.modal-text .embed-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    /* Prevent iOS zoom */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Prevent zoom */
    -webkit-transform: scale(1);
    transform: scale(1);
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
}

/* Force iframe content to prevent zoom */
.modal-text iframe,
.modal-text .iframe-container iframe {
    /* Critical iOS zoom prevention */
    font-size: 16px !important;
    -webkit-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
    
    /* Prevent touch zoom */
    touch-action: manipulation !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    
    /* Prevent scaling */
    -webkit-transform: scale(1) !important;
    transform: scale(1) !important;
    -webkit-transform-origin: 0 0 !important;
    transform-origin: 0 0 !important;
}

/* Specific styles for Zeffy and other donation forms */
.modal-text div[style*="position:relative"],
.modal-text div[style*="overflow:hidden"] {
    /* Prevent zoom on the container */
    -webkit-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
    font-size: 16px !important;
    
    /* Force iframe inside to prevent zoom */
    iframe {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100% !important;
        -ms-text-size-adjust: 100% !important;
        text-size-adjust: 100% !important;
        touch-action: manipulation !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
    }
}

/* Override any inline styles that might cause zoom */
.modal-text iframe[src*="zeffy.com"],
.modal-text iframe[src*="donation-form"] {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
    touch-action: manipulation !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    transform: scale(1) !important;
    -webkit-transform: scale(1) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-container {
        max-width: 95vw;
        max-height: 95vh;
        margin: 10px;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-close-external {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }
    
    .modal-close-top-right,
    .modal-close-top-left {
        top: 10px;
    }
    
    .modal-close-top-right,
    .modal-close-bottom-right {
        right: 10px;
    }
    
    .modal-close-top-left,
    .modal-close-bottom-left {
        left: 10px;
    }
    
    .modal-close-bottom-right,
    .modal-close-bottom-left {
        bottom: 10px;
    }
    
    .modal-title {
        font-size: 20px;
    }
    
    .modal-text {
        font-size: 14px;
    }
    
    /* Mobile-specific iframe handling */
    .modal-text iframe {
        /* Ensure minimum font size to prevent zoom */
        font-size: 16px;
        /* Prevent iOS zoom */
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
}

/* Animation for modal appearance */
.modal-overlay {
    animation-duration: 0.3s;
    animation-fill-mode: both;
}

.modal-overlay.modal-fade-in {
    animation-name: modalFadeIn;
}

.modal-overlay.modal-fade-out {
    animation-name: modalFadeOut;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

.modal-content {
    animation-duration: 0.3s;
    animation-fill-mode: both;
}

.modal-fade-in .modal-content {
    animation-name: modalContentFadeIn;
}

@keyframes modalContentFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}