/* components/topup-modal/topup-modal.css */

/* ── Modal shell ──────────────────────────────────────────── */
.topup-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
}

.topup-modal.is-open {
    display: flex;
}

/* Fully visible state — added by JS after display:flex is set */
.topup-modal.is-visible {
    opacity: 1;
}

/* Fading out — added by JS before removing is-open */
.topup-modal.is-closing {
    opacity: 0;
    pointer-events: none;
}

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

/* ── Card ─────────────────────────────────────────────────── */
.topup-modal__card {
    position: relative;
    background: #fff;
    border-radius: var(--radius-xl, 12px);
    width: min(420px, 92vw);
    max-height: 90dvh;
    overflow-y: auto;
    padding: 1.5rem;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

/* ── Header ───────────────────────────────────────────────── */
.topup-modal__header {
    display: flex;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 0.5rem;
}

.topup-modal__title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-text, #333);
    margin: 0;
    flex: 1;
    text-align: center;
}

/* ── Back arrow ───────────────────────────────────────────── */
.topup-modal__back {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text, #333);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, transform 0.2s;
    flex-shrink: 0;
}

.topup-modal__back:hover {
    background: #f0f0f0;
    transform: translateX(-2px);
}

.topup-modal__back:active {
    transform: translateX(-4px);
}

.topup-modal__back svg {
    display: block;
}

/* ── Balance / shortfall rows ─────────────────────────────── */
.topup-modal__balance-row,
.topup-modal__shortfall-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-md, 6px);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.topup-modal__balance-row {
    background: #f5f7ff;
}

.topup-modal__shortfall-row {
    background: #fff5f5;
}

.topup-modal__balance-label,
.topup-modal__shortfall-label {
    color: var(--color-text-light, #666);
}

.topup-modal__balance-value {
    font-weight: 700;
    color: var(--color-secondary, #667eea);
}

.topup-modal__shortfall-value {
    font-weight: 700;
    color: #e74c3c;
}

/* ── Section label ────────────────────────────────────────── */
.topup-modal__section-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-light, #999);
    margin: 1rem 0 0.5rem;
}

/* ── Quick-amount buttons ─────────────────────────────────── */
.topup-modal__quick-amounts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.topup-modal__quick-btn {
    flex: 1 1 calc(33% - 0.5rem);
    min-width: 60px;
    padding: 0.55rem 0.5rem;
    border: 1.5px solid var(--color-border, #e0e0e0);
    border-radius: var(--radius-md, 6px);
    background: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--color-text, #333);
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.topup-modal__quick-btn:hover,
.topup-modal__quick-btn.is-selected {
    border-color: var(--color-secondary, #667eea);
    background: var(--color-secondary, #667eea);
    color: #fff;
}

.topup-modal__quick-btn--exact {
    border-color: #e74c3c;
    color: #e74c3c;
}

.topup-modal__quick-btn--exact:hover,
.topup-modal__quick-btn--exact.is-selected {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
}

/* ── Custom input ─────────────────────────────────────────── */
.topup-modal__custom-row {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--color-border, #e0e0e0);
    border-radius: var(--radius-md, 6px);
    overflow: hidden;
    transition: border-color 0.15s;
}

.topup-modal__custom-row:focus-within {
    border-color: var(--color-secondary, #667eea);
}

.topup-modal__currency {
    padding: 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-light, #666);
    background: #f8f9fa;
    align-self: stretch;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--color-border, #e0e0e0);
}

.topup-modal__custom-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    color: var(--color-text, #333);
    background: transparent;
}

.topup-modal__custom-input::placeholder {
    color: #bbb;
}

/* ── Cooling-off notice (ECTA s44) ────────────────────────── */
.topup-modal__terms-notice {
    margin: 1rem 0 0;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--color-text-muted, #888);
    text-align: center;
}

.topup-modal__terms-notice a {
    color: inherit;
    text-decoration: underline;
}

/* ── Pay button ───────────────────────────────────────────── */
.topup-modal__pay-btn {
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.85rem;
    background: linear-gradient(135deg, var(--color-secondary, #667eea), #764ba2);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg, 8px);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    letter-spacing: 0.02em;
}

.topup-modal__pay-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.topup-modal__pay-btn:not(:disabled):hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.topup-modal__pay-btn:not(:disabled):active {
    transform: translateY(0);
}

/* ── Spinner overlay ──────────────────────────────────────── */
.topup-modal__processing {
    display: none;
    border-radius: var(--radius-xl, 12px);
}

.topup-modal__processing.is-visible {
    display: flex;
}

/* ── Payment success overlay ──────────────────────────────── */
/* Sits in the same stacking context as the processing overlay. */
.topup-modal__success-overlay {
    display: none;
    position: absolute;
    inset: 0;
    border-radius: var(--radius-xl, 12px);
    background: #fff;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    z-index: 10;
}

.topup-modal__success-overlay.is-visible {
    display: flex;
}

.topup-modal__success-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    background: #18c07a;
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topup-modal__success-msg {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111;
    margin: 0;
}

.topup-modal__success-sub {
    font-size: 0.875rem;
    color: #555;
    margin: 0;
}

/* ── Inline error message ─────────────────────────────────── */
/* Shown by _showError() — no alert(), keeps user in context. */
.topup-modal__error {
    display: none;
    margin: 0.75rem 0;
    padding: 0.6rem 0.875rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #dc2626;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* ── Card picker (multi-card users) ──────────────────────── */
.topup-modal__card-picker {
    margin-top: 1rem;
}

.topup-modal__card-picker-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6f7a8a;
    margin-bottom: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.topup-modal__card-picker-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.topup-modal__card-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #f8fafd;
    border: 1.5px solid #e0e8f0;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.topup-modal__card-option.is-default {
    border-color: #2165c4;
    background: #edf3fc;
}

.topup-modal__card-option:active {
    background: #dce9fa;
}

.topup-modal__card-option-type {
    font-weight: 700;
    color: #1a1a1a;
    text-transform: capitalize;
}

.topup-modal__card-option-last4 {
    flex: 1;
    color: #3a4560;
}

.topup-modal__card-option-bank {
    font-size: 0.8rem;
    color: #6f7a8a;
}

.topup-modal__card-option-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: #2165c4;
    background: #dce9fa;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    white-space: nowrap;
}

/* ── Decline recovery ────────────────────────────────────── */
/* Shown by _showDeclineRecovery() — gives the user a clear next step
   without leaving the modal. Sits between the error message and pay button. */
.topup-modal__decline-recovery {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.5rem 0 0.25rem;
}

.topup-modal__recovery-btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-lg, 8px);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}

.topup-modal__recovery-btn:active {
    transform: translateY(1px);
}

/* Primary — "Use a different card" — calls Paystack popup */
.topup-modal__recovery-btn--primary {
    background: linear-gradient(135deg, var(--color-secondary, #667eea), #764ba2);
    color: #fff;
    border: none;
}

.topup-modal__recovery-btn--primary:hover {
    opacity: 0.9;
}

/* Secondary — "Try another saved card" — re-opens picker */
.topup-modal__recovery-btn--secondary {
    background: #f0f4ff;
    color: #2165c4;
    border: 1.5px solid #c0d4f0;
}

.topup-modal__recovery-btn--secondary:hover {
    background: #dce9fa;
}