/* ── Payment Modal ─────────────────────────────────────────────────────────── */

/*
 * CRITICAL FIX: CSS `display: flex` on .pay-modal overrides the HTML `hidden`
 * attribute (which sets display:none). This caused the modal to appear on page
 * load. The [hidden] rule below restores the correct behaviour.
 */
.pay-modal[hidden] {
    display: none !important;
}

.pay-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.pay-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pay-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* ── Close button ── */

.pay-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.pay-modal__close:hover {
    background: #f3f4f6;
    color: #0f0f0f;
}

/* ── Title ── */

.pay-modal__title {
    font-size: 1.375rem;
    font-weight: 600;
    margin: 0 0 1.25rem;
    padding-right: 2rem;
    line-height: 1.3;
}

/* ── Amount + currency row ── */

.pay-modal__amount-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.pay-modal__desc-group {
    margin-bottom: 0;
}

.pay-modal__optional {
    color: #9ca3af;
    font-size: 0.8125rem;
    font-weight: 400;
}

/* ── Tabs ── */

.pay-modal__tabs {
    display: flex;
    gap: 0.375rem;
    margin: 1.25rem 0 1rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.625rem;
}

.pay-modal__tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.875rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}

.pay-modal__tab:hover {
    background: #f3f4f6;
    color: #0f0f0f;
}

.pay-modal__tab.is-active {
    background: #eff6ff;
    color: #1685ff;
}

/* ── Panels ── */

.pay-modal__panel {
    min-height: 180px;
}

.pay-modal__panel--hidden {
    display: none;
}

/* ── Submit button ── */

.pay-modal__submit {
    width: 100%;
    margin-top: 1rem;
    justify-content: center;
    gap: 0.5rem;
}

/* ── Inline loading row ── */

.pay-modal__inline-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #6b7280;
    font-size: 0.875rem;
    padding: 1.25rem 0;
}

.pay-modal__inline-loading .pay-modal__spinner {
    margin: 0;
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* ── Spinner ── */

.pay-modal__spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: #1685ff;
    border-radius: 50%;
    animation: pay-spin 0.65s linear infinite;
    flex-shrink: 0;
}

.pay-modal__spinner--sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

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

/* ── Error ── */

.pay-modal__error {
    background: #fef2f2;
    color: #dc2626;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-top: 0.75rem;
    line-height: 1.5;
}

/* ── Success ── */

.pay-modal__success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.875rem;
    padding: 2rem 1rem;
    text-align: center;
}

.pay-modal__success p {
    font-size: 1.125rem;
    font-weight: 500;
    color: #16a34a;
    margin: 0;
}

/* ── Crypto panel ── */

.pay-modal__crypto-desc {
    font-size: 0.9375rem;
    color: #4b5563;
    margin: 0 0 1.25rem;
    line-height: 1.55;
}

#whitepay-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #6b7280;
    font-size: 0.875rem;
    padding: 1.25rem 0;
}

#whitepay-loading .pay-modal__spinner {
    margin: 0;
    width: 20px;
    height: 20px;
    border-width: 2px;
}

#whitepay-frame-wrap {
    margin-top: 1rem;
}

#whitepay-iframe {
    width: 100%;
    border: none;
    min-height: 480px;
    border-radius: 8px;
    display: block;
}

.pay-modal__fallback-link {
    display: block;
    text-align: center;
    margin-top: 0.625rem;
    font-size: 0.8125rem;
    color: #1685ff;
    text-decoration: none;
}

.pay-modal__fallback-link:hover {
    text-decoration: underline;
}

/* ── Body scroll lock ── */

body.pay-modal-open {
    overflow: hidden;
}

/* ── Responsive ── */

@media (max-width: 540px) {
    .pay-modal__dialog {
        padding: 1.5rem 1rem;
        border-radius: 12px;
        max-height: 96vh;
    }

    .pay-modal__amount-row {
        grid-template-columns: 1fr;
    }

    .pay-modal__tabs {
        flex-wrap: wrap;
    }
}

/* ─── Append these styles to payment.css ───────────────────────────────────── */

/* ── WhitePay: currency picker ── */

.pay-modal__label-sm {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: 0 0 0.625rem;
}

.whitepay-currency-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.whitepay-currency-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.whitepay-currency-btn img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: contain;
}

.whitepay-currency-btn:hover {
    border-color: #1685ff;
    color: #1685ff;
}

.whitepay-currency-btn.is-selected {
    border-color: #1685ff;
    background: #eff6ff;
    color: #1685ff;
}

/* ── WhitePay: wallet info card ── */

.whitepay-wallet-info {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.875rem;
}

.whitepay-wallet-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.875rem;
}

.whitepay-wallet-row:last-child {
    border-bottom: none;
}

.whitepay-wallet-row--address {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
}

.whitepay-wallet-label {
    color: #6b7280;
    flex-shrink: 0;
    font-size: 0.8125rem;
}

.whitepay-wallet-value {
    color: #0f0f0f;
    text-align: right;
}

.whitepay-wallet-address {
    display: block;
    width: 100%;
    word-break: break-all;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    font-family: 'Courier New', Courier, monospace;
    color: #0f0f0f;
    user-select: all;
}

/* ── WhitePay: actions + note ── */

.whitepay-wallet-actions {
    display: flex;
    gap: 0.625rem;
    margin-bottom: 0.875rem;
}

.whitepay-wallet-note {
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.55;
    margin: 0;
}