#openModalBtn {
    padding: 12px 25px;
    font-size: 17px;
    cursor: pointer;
    background-color: #007AFF; /* iOS blue */
    color: white;
    border: none;
    border-radius: 8px;
}

.modal {
    display: flex; /* Keep as flex for alignment, visibility will handle show/hide */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.3);
    align-items: flex-end;
    justify-content: center;
    opacity: 0; /* Initially transparent */
    visibility: hidden; /* Initially hidden and not interactive */
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out; /* Fade transition for overlay */
}

.modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: white;
    width: 100%;
    max-width: 100%;
    max-height: 80vh;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -6px 22px rgba(0,0,0,0.09);
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    display: flex;
    flex-direction: column;    
}

.modal.open .modal-content {
    transform: translateY(0);
}

.modal-fixed-header {
    flex-shrink: 0;
    padding: 8px 16px 0px 16px;
    position: relative;
}

.modal-scrollable-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 16px 16px 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    position: relative; /* For z-index context */
    z-index: 1; /* Ensure it's above siblings if any absolute positioning is at play */
    pointer-events: auto; /* Explicitly set */
}

.modal-scrollable-body::-webkit-scrollbar {
    width: 5px;
}
.modal-scrollable-body::-webkit-scrollbar-track {
    background: transparent;
}
.modal-scrollable-body::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid transparent;
}
.modal-scrollable-body::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

.modal-handlebar {
    width: 40px;
    height: 5px;
    background-color: #d1d1d6;
    border-radius: 2.5px;
    margin: 0 auto 12px auto;
}

.close-btn {
    color: #8e8e93;
    font-size: 22px;
    font-weight: normal;
    position: absolute;
    top: 12px;
    right: 16px;
    cursor: pointer;
    line-height: 1;
}
.close-btn:hover {
    color: #555;
}

.modal-content h2 {
    font-size: 1.1em;
    font-weight: 600;
    color: #000;    
    margin-bottom: 8px;
}

.modal-content p {
    font-size: 0.95em;
    color: #3c3c43;
    opacity: 0.9;
    margin-bottom: 12px; /* Regular paragraph spacing */
    line-height: 1.4;
}

/* Desktop and Tablet specific styles */
@media (min-width: 768px) { /* Breakpoint for tablets and larger */
    .modal-content {
        max-width: 700px; /* Max width for desktop/tablet modal */
        margin-left: auto; /* Horizontally center */
        margin-right: auto; /* Horizontally center */
        border-radius: 16px; /* Rounded corners on all sides for desktop */
        border-bottom-left-radius: 0; /* Keep bottom corners sharp to touch page bottom */
        border-bottom-right-radius: 0; /* Keep bottom corners sharp to touch page bottom */
        padding-left: 120px;
        padding-right: 120px;
    }

    .modal-handlebar {
        display: none; /* Hide handlebar on larger screens */
    }    
}

/* Default iframe styles, height acts as a fallback */
.modal-scrollable-body iframe {
    width: 100%;
    height: 1500px; /* Default/Fallback height */
    border: none;
    display: block; /* Prevents extra space below if inline */
    background-color: #fff; /* Optional: if iframe content is transparent */
    z-index: 9999999;
}

/* 
Styles for iframe fallback to full-screen. 
This class is applied to #paymentModal in the fallback scenario.
*/
.iframe-fallback-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    z-index: 2147483647 !important; /* Max z-index */
    background-color: white !important; /* Ensure modal background */
    padding: 0 !important; /* Remove any padding from the modal itself */
    border: none !important; /* Remove any border from the modal itself */
    border-radius: 0 !important; /* Ensure no rounded corners on the modal */
    display: flex !important; /* Use flex to help children fill height */
    flex-direction: column !important;
    /* Override any transforms that might be on the modal */
    transform: none !important; 
}

.iframe-fallback-fullscreen .modal-content {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important; /* Reset margins */
    transform: none !important; /* Override slide-up transform */
    display: flex !important;
    flex-direction: column !important;
    flex-grow: 1 !important; /* Ensure it grows to fill the flex container */
    overflow: hidden !important; /* Prevent modal-content from scrolling */
}

/* Hide original modal header elements in this fallback mode */
.iframe-fallback-fullscreen .modal-fixed-header,
.iframe-fallback-fullscreen .modal-handlebar,
.iframe-fallback-fullscreen .close-btn {
    display: none !important;
}

.iframe-fallback-fullscreen .modal-scrollable-body {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important; /* Ensure it doesn't exceed parent */
    padding: 0 !important;
    margin: 0 !important; /* Reset margins */
    overflow: hidden !important; /* The iframe will handle its own scroll if necessary */
    flex-grow: 1 !important; /* Take up available space */
    position: static !important; /* Override any relative positioning */
}

.iframe-fallback-fullscreen iframe#paymentIframe {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    border: none !important;
    background-color: white !important; /* Ensure iframe has a background */
}

/* Page Loading Overlay Styles */
#page-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    z-index: 9999;
    display: flex;
    flex-direction: column; /* Stack spinner and text vertically */
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden; /* Start hidden */
    pointer-events: none; /* Allow clicks through when hidden, and prevent interaction when overlay is invisible but still in DOM during transition out */
    transition: opacity 0.3s ease-in-out; /* Only transition opacity by default. Visibility will be handled by class presence. */
}

#page-loading-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Block clicks when visible */
    /* transition-delay: 0s; /* Not strictly needed anymore */
}

.spinner {
    border: 5px solid #f3f3f3; /* Light grey base */
    border-top: 5px solid #555555; /* Darker color for the spinning part */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px; /* Space between spinner and text */
}

.loading-text {
    font-size: 1.2em;
    color: #333333;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Order Summary Styles */
.order-summary {
    padding: 16px;
    padding-left: 0px;
    padding-right: 0px;
    padding-bottom: 0px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    color: #000;
    /* border-bottom: 1px solid #E5E5EA; */ /* Light grey line similar to iOS table views */
    display: flex; /* Added for layout */
    flex-direction: column; /* Make it a column flex container */
    /* align-items: flex-start; */ /* Align items to the start - REMOVED */
    background-color: #FFFFFF; /* Card background */
    border: 1px solid #E5E5EA; /* Subtle border */
    border-radius: 10px; /* Rounded corners */
    margin-bottom: 16px; /* Space below the card */
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); /* Subtle box shadow */        
    margin-left: 7px;
    margin-right: 7px;
    overflow: hidden; /* Restore: Add this line to clip child elements */
    /* pointer-events: none; */ /* Remove: Allow scroll events to pass through */
}

/* New wrapper for image and text */
.order-summary-content {
    display: flex;
    align-items: flex-start;
    max-width: 95%; /* Ensure it takes full width */
    margin-bottom: 5px; /* Space before the total section */
    margin-left: 12px;
    margin-right: 12px;
}

.order-image-placeholder {
    width: 100px;
    height: 100px;
    background-color: #f0f0f0; /* Placeholder color */
    border-radius: 8px; /* Slightly rounded corners */
    margin-right: 16px;
    flex-shrink: 0; /* Prevent shrinking */    
    background-size: cover;
}

.order-text-content {
    flex-grow: 1; /* Allow text content to take remaining space */
}

.order-title {
    font-size: 17px; /* Standard iOS title size */
    font-weight: 600; /* Semibold for titles in iOS */
    margin: 0 0 4px 0;
    color: #000;
}

.order-subtitle {
    font-size: 15px; /* Standard iOS subtitle/body text size */
    color: #8E8E93; /* Standard iOS secondary text color */
    margin: 0 0 0 0; /* Adjusted margin */
}

/* New container for the total section to ensure it's outside the flex layout of title/image */
.order-total-section-container {
    background-color: #FFF7F0; /* Light orange background */
    padding: 12px 16px; /* Padding around the total section */
    width: 100%; /* Make it take the full width of its parent */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    border-top: 1px solid #E5E5EA; /* Separator line */
}

.order-total-section {
    /* background-color: #FFEFE5; */ /* REMOVED - Will be handled by container */
    /* padding: 12px 16px; */ /* REMOVED - Will be handled by container */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-label {
    font-size: 17px;
    font-weight: 600;
    color: #FF6600; /* Updated to orange */
}

.price-details {
    text-align: right;
}

.price-amount {
    font-size: 22px; /* Larger for emphasis */
    font-weight: bold;
    color: #FF6600; /* Orange accent color from image */
    display: block;
}

.payment-schedule {
    font-size: 13px;
    color: #555555; /* Updated to dark gray */
    text-decoration: none;
}

.payment-schedule:hover {
    text-decoration: underline;
}

/* Trust and Security Section */
.trust-security-section {
    padding: 0 7px; /* Horizontal padding */
    margin-bottom: 16px; /* Space below this section */
    text-align: center; /* Center the image */
    /* pointer-events: none; */ /* Remove: Allow scroll events to pass through */
}

.trust-security-section img {
    max-width: 100%; /* Ensure image is responsive and doesn't overflow */
    height: auto; /* Maintain aspect ratio */
    display: block; /* Remove extra space below image */
    margin: 0 auto; /* Center the image if it's narrower than the container */    
}

/* Removed .secure-checkout-title, .lock-icon, .security-statement, .security-badges span */
/* Optional: If you use actual image badges */
/* .security-badges img { ... } */ /* This can be removed if not used elsewhere, or kept if other badges might be used */