/* ----- Classic checkout container ----- */
#whop-checkout-container {
    margin-top: 16px;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
    min-height: 360px;
}

/* Loader shown while we fetch the plan_id */
.whopy-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #64748b;
}

.whopy-loader::after {
    content: "";
    width: 22px;
    height: 22px;
    margin-left: 10px;
    border: 3px solid #cbd5e1;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: whopy-spin 1s linear infinite;
}

@keyframes whopy-spin {
    to { transform: rotate(360deg); }
}

/* ----- Blocks checkout mount host ----- */
.whopy-checkout-wrapper .whopy-mount-host {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
}

.whopy-checkout-wrapper .whopy-status {
    margin: 12px 0 0;
    text-align: center;
    font-size: 14px;
    color: #64748b;
}

.whopy-checkout-wrapper .whopy-status--error {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 12px;
    border-radius: 8px;
}

/* ----- Make Payment button (shared between Classic + Blocks) ----- */
.whopy-pay-button {
    display: block;
    width: 100%;
    margin: 16px 0 0;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: #4f46e5;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.whopy-pay-button:hover:not(:disabled) {
    background: #4338ca;
}

.whopy-pay-button:disabled,
.whopy-pay-button.is-busy {
    background: #94a3b8;
    cursor: not-allowed;
}

/* Status line below the Make Payment button */
.whopy-pay-status {
    margin: 10px 2px 0;
    font-size: 14px;
    min-height: 18px;
}

/* Cancel-and-try-again link shown during processing */
.whopy-cancel-link {
    display: block;
    margin: 8px auto 0;
    padding: 4px 12px;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

.whopy-cancel-link:hover {
    color: #1e293b;
}

.whopy-pay-status.is-error {
    color: #dc2626;
}

.whopy-pay-status.is-info {
    color: #059669;
}

/* ----- Hide WC's Place Order on Blocks checkout while Whop is active -----
   We can't display:none the button because our JS needs to programmatically
   .click() it after Whop authorises. display:none prevents dispatch in some
   browsers. So we take it off-screen instead — still in the DOM, still clickable.
*/
body.whopy-active .wc-block-components-checkout-place-order-button {
    position: absolute !important;
    left: -10000px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ----- Gateway label ----- */
.payment_method_whop label img {
    max-height: 24px;
    margin-left: 10px;
    vertical-align: middle;
}

/* Processing overlay for the Whop iframe */
.whopy-processing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    display: none;
    pointer-events: none;
}

.whopy-processing-overlay.is-active {
    display: flex;
    pointer-events: all;
}

/* Verifying mode: stay visible but allow interaction with the iframe underneath */
.whopy-processing-overlay.is-verifying {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: none;
    pointer-events: none;
}

.whopy-processing-overlay.is-verifying .whopy-spinner {
    width: 30px;
    height: 30px;
    position: absolute;
    top: 20px;
    right: 20px;
    margin: 0;
}

.whopy-processing-overlay.is-verifying .whopy-text {
    position: absolute;
    top: 25px;
    right: 60px;
    font-size: 13px;
    background: #ffffff;
    padding: 4px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.whopy-processing-overlay .whopy-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #cbd5e1;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: whopy-spin 1s linear infinite;
    margin-bottom: 12px;
}

.whopy-processing-overlay .whopy-text {
    font-size: 15px;
    font-weight: 500;
    color: #1e293b;
}

#whop-checkout-container, 
.whopy-checkout-wrapper .whopy-mount-host {
    position: relative;
}


/* Mobile-safe Whop iframe sizing. Some mobile themes initially render the
   payment box with a narrow/hidden width; giving the mount and iframe a stable
   block size prevents the embedded card form from collapsing. */
#whopy-embed,
#whopy-blocks-embed {
    display: block;
    width: 100%;
    min-height: 360px;
}

#whopy-embed iframe,
#whopy-blocks-embed iframe {
    display: block !important;
    width: 100% !important;
    min-height: 360px !important;
    border: 0 !important;
}

@media (max-width: 600px) {
    #whop-checkout-container,
    .whopy-checkout-wrapper .whopy-mount-host,
    #whopy-embed,
    #whopy-blocks-embed,
    #whopy-embed iframe,
    #whopy-blocks-embed iframe {
        min-height: 420px !important;
    }

    .whopy-pay-button {
        padding: 15px 16px;
        font-size: 16px;
    }
}
