/* Lock background scrolling - Chrome-safe version */
html.modal-open, 
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* Modal Overlay: Cover everything and stay fixed even if keyboard opens */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    /* Use dvh (dynamic viewport height) to stay within visible area */
    height: 100dvh !important;
    background: rgba(0, 0, 0, 0.9) !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: flex-end !important; /* Anchor to bottom on mobile */
    justify-content: center !important;
    overflow-y: auto !important; /* Allow scroll if content overflows */
}

/* Modal Content: Stability and centered scaling */
.modal-content {
    width: 100% !important;
    max-width: 450px !important;
    /* Let the content set its own height naturally */
    max-height: 92dvh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    position: relative !important;
    margin: auto !important; /* Center vertically when there's space */
    border-radius: 20px !important;
    background: #ffffff !important;
    color: var(--slate-900) !important;
    box-shadow: 0 0 40px rgba(0,0,0,0.6) !important;
    border: none !important;
    -webkit-overflow-scrolling: touch;
}

/* Mobile specific overrides */
@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-end !important; /* Sheet slides up from bottom */
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 95dvh !important;
        border-radius: 25px 25px 0 0 !important;
        margin: 0 !important; /* Stick to the bottom */
    }

    /* CRITICAL: Fix Huge Icons / Logos */
    /* Target the main logo in header */
    .modal-header img {
        max-height: 55px !important; /* Even smaller */
        width: auto !important;
        object-fit: contain !important;
        margin-left: auto !important;
    }

    /* Target ALL icons in payment methods and success screen */
    .radio-item img, 
    .payment-flags img,
    #pix-result img:not(#qr-code-img),
    .pix-security-reinforcement img {
        max-height: 18px !important;
        width: auto !important;
        object-fit: contain !important;
    }

    /* QR Code Responsivo e Grande */
    #qr-code-img {
        max-height: 80vw !important; /* Aproveita largura da tela */
        width: 100% !important;
        max-width: 340px !important;
        height: auto !important;
        margin: 0 auto !important;
        display: block !important;
    }

    /* Container do QR Code para evitar saltos de layout */
    .qr-container {
        min-height: 250px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;
        position: relative;
    }

    .summary-img {
        width: 95px !important;
        min-width: 95px !important;
        max-height: 150px !important;
        height: auto !important;
    }

    /* Fix text overflow in PIX result (JOAO PAULO name) */
    #pix-result p {
        word-break: break-word !important;
        max-width: 100% !important;
    }

    /* Prevent keyboard from pushing modal too high or distorting it */
    .modal-overlay.active {
        display: flex !important;
    }

    /* Hide help text/tooltips that cause overflow */
    .field-tooltip, .form-tip {
        display: none !important;
    }
    
    /* Input stability to prevent iOS drift and zoom */
    .form-input, 
    input[type="text"], 
    input[type="tel"], 
    input[type="email"] {
        height: 48px !important; /* Touch-friendly */
        font-size: 16px !important; /* CRITICAL: Prevent iOS auto-zoom shift */
        padding: 10px 12px !important;
        box-sizing: border-box !important;
    }
}


/* Floating CTA Bar */
.floating-cta-bar {
    position: fixed;
    bottom: -150px;
    left: 0;
    width: 100%;
    background: rgba(9, 9, 11, 0.95) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border-top: 2px solid var(--brand-red) !important;
    padding: 10px 15px !important;
    z-index: 9000 !important;
    transition: bottom 0.6s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.floating-cta-bar.visible {
    bottom: 0 !important;
}

.floating-cta-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
    width: 100% !important;
    max-width: 450px !important;
}

.floating-cta-btn {
    width: 100% !important;
    background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-hover) 100%) !important;
    color: #fff !important;
    border: none !important;
    padding: 14px 20px !important;
    border-radius: 12px !important;
    font-weight: 800 !important;
    font-size: 1rem !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    box-shadow: 0 4px 15px rgba(225, 29, 72, 0.3) !important;
    cursor: pointer !important;
    transition: transform 0.2s !important;
    font-family: inherit !important;
    line-height: 1 !important;
}

.floating-cta-btn:active {
    transform: scale(0.96) !important;
    background: var(--brand-red) !important;
}

.floating-cta-subtext {
    font-size: 0.8rem !important;
    color: var(--slate-400) !important;
    font-weight: 700 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* Ensure body padding when bar is visible to prevent footer occlusion */
body.cta-visible footer {
    padding-bottom: 140px !important;
}

/* Hide when modal is active */
body.modal-open .floating-cta-bar {
    display: none !important;
}

/* Hide toast container overflow */
.float-toast-container {
    max-width: 100vw !important;
    overflow: hidden !important;
}