/* ==========================================================================
   REEBUX — withdraw.css | Mobile-First | --c-* token system
   ========================================================================== */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.6); }
    to   { opacity: 1; transform: scale(1); }
}

/* ---- Layout Root ---- */
.dashboard-content {
    padding: var(--sp-lg) var(--sp-md);
    box-sizing: border-box;
    width: 100%;
    overflow-x: hidden;
}

/* ---- Withdraw Container ---- */
#withdraw-container {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
    margin-bottom: var(--sp-xl);
}

/* ---- Balance Card ---- */
.balance-card {
    background: linear-gradient(135deg, var(--c-primary), #0055AA);
    border-radius: var(--r-lg);
    padding: var(--sp-lg);
    color: #fff;
    box-shadow: 0 0 24px rgba(0,191,255,0.2), 0 12px 32px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0,191,255,0.25);
    width: 100%;
    box-sizing: border-box;
}
/* Desktop-only quick-action strip. The base rule HIDES it on mobile so
   the mobile balance card keeps its original single-column layout
   exactly as before — desktop @media flips this to display:flex. */
.balance-card .balance-card-actions { display: none; }
.balance-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(255,255,255,0.07) 1px, transparent 1px),
        radial-gradient(circle at 80% 80%, rgba(255,255,255,0.07) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.5;
    pointer-events: none;
}
.balance-card h4 {
    margin: 0 0 var(--sp-xs) 0;
    font-size: 0.68rem;
    font-weight: 600;
    opacity: 0.85;
    position: relative;
    z-index: 1;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.balance-card .balance-amount {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 var(--sp-xs) 0;
    position: relative;
    z-index: 1;
    color: #fff;
    text-shadow: 0 4px 16px rgba(0,0,0,0.2);
    line-height: 1.05;
}
.balance-card .balance-note {
    font-size: 0.85rem;
    opacity: 0.85;
    margin: 0;
    position: relative;
    z-index: 1;
    color: #fff;
}

/* ---- Insufficient Funds ---- */
.insufficient-funds {
    background: var(--c-bg2);
    border: 1px solid var(--c-error);
    border-radius: var(--r-lg);
    padding: var(--sp-lg);
    text-align: center;
    box-shadow: 0 0 20px var(--c-error-g);
    width: 100%;
    box-sizing: border-box;
}
.insufficient-funds h2 {
    color: var(--c-error);
    margin-top: 0;
    font-size: 1.35rem;
}
.insufficient-funds p {
    font-size: 0.95rem;
    color: var(--c-txt2);
    margin-bottom: var(--sp-lg);
}

/* ---- Pending Limit Alert ---- */
#pending-limit-message {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    text-align: center;
}

/* ---- Withdraw Grid ---- */
.withdraw-grid {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
}

/* ---- Form Container ---- */
.withdraw-form-container {
    background: var(--c-bg2);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: var(--sp-lg);
    width: 100%;
    box-sizing: border-box;
}
#withdraw-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
}

.form-group {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
}
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-txt1);
    margin-bottom: var(--sp-xs);
}
/* Wallet address: input + icon now live inside a dedicated relative
   wrapper so the icon's vertical position is anchored to the INPUT,
   not to the full form-group. Previously the icon used `bottom: 12px`
   measured from form-group's bottom edge — the moment the error span
   below the input went visible, form-group grew and the icon drifted
   down off the input baseline. With the wrapper it stays put. */
.form-group .input-wrap {
    position: relative;
    width: 100%;
    display: block;
}
.form-group .input-wrap .form-control {
    width: 100%;
    box-sizing: border-box;
}
.form-group .icon-prefix {
    position: absolute;
    left: var(--sp-md);
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    opacity: 0.7;
    pointer-events: none;
    z-index: 1;
}
.form-group .form-control-icon {
    padding-left: calc(var(--sp-md) * 2 + 24px);
}
.form-group small.text-muted {
    display: block;
    margin-top: var(--sp-xs);
    font-size: 0.8rem;
    color: var(--c-txt2);
}
.form-error {
    display: block;
    font-size: 0.8125rem;
    color: var(--c-error);
    margin-top: var(--sp-xs);
}

/* ---- Price & Conversion Displays ---- */
.price-display {
    background: var(--c-bg1);
    border-radius: var(--r-md);
    padding: var(--sp-sm) var(--sp-md);
    font-size: 0.875rem;
    color: var(--c-txt2);
    text-align: center;
    border: 1px solid var(--c-border);
    width: 100%;
    box-sizing: border-box;
    margin: 0;
}
.conversion-display {
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-txt2);
    text-align: center;
    padding: var(--sp-md);
    background: var(--c-bg1);
    border-radius: var(--r-md);
    border: 1px solid var(--c-border);
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    line-height: 1.5;
}
.conversion-display strong {
    color: var(--c-primary);
    font-size: 1.3rem;
    font-weight: 700;
    display: block;
    margin-top: var(--sp-xs);
}

/* ---- Info Panel ---- */
.info-panel {
    background: var(--c-bg2);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: var(--sp-lg);
    width: 100%;
    box-sizing: border-box;
    position: static;
}
.info-panel h4 {
    margin: 0 0 var(--sp-md) 0;
    padding-bottom: var(--sp-md);
    color: var(--c-txt1);
    font-size: 1rem;
    font-weight: 700;
    border-bottom: 1px solid var(--c-border);
    text-align: center;
}
.info-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
}
.info-panel li {
    font-size: 0.85rem;
    color: var(--c-txt2);
    display: flex;
    gap: var(--sp-sm);
    align-items: flex-start;
    line-height: 1.6;
}
.info-panel li .icon {
    color: var(--c-primary);
    flex-shrink: 0;
    font-size: 1rem;
    margin-top: 2px;
}
.info-panel li strong { color: var(--c-txt1); }
.info-panel li:last-child {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--sp-xs);
    margin-top: var(--sp-sm);
    padding-top: var(--sp-sm);
    border-top: 1px dashed var(--c-border);
}
.info-panel li:last-child .icon { display: none; }
.info-panel li:last-child strong {
    display: block;
    font-size: 0.9rem;
}
.info-panel li:last-child a.btn-link {
    display: inline-block;
    margin-top: var(--sp-xs);
    padding: var(--sp-sm) var(--sp-lg);
    background: var(--c-bg3);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--c-txt1);
    transition: all var(--trans-fast);
}
.info-panel li:last-child a.btn-link:hover {
    background: var(--c-primary);
    color: #000;
    border-color: var(--c-primary);
}

/* ---- Summary Panel ---- */
.summary-panel {
    background: var(--c-bg1);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: var(--sp-md);
    width: 100%;
    box-sizing: border-box;
}
.summary-panel h4 {
    margin: 0 0 var(--sp-md) 0;
    color: var(--c-txt1);
    font-size: 1rem;
    font-weight: 700;
}
.summary-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.summary-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--sp-sm) 0;
    border-bottom: 1px solid var(--c-border);
}
.summary-list li:last-child { border-bottom: none; padding-bottom: 0; }
.summary-list .label {
    color: var(--c-txt2);
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.summary-list .value {
    color: var(--c-txt1);
    font-weight: 600;
    font-size: 0.9rem;
    word-break: break-all;
}
.summary-list .value.d-flex { display: flex; align-items: center; gap: var(--sp-xs); }
.summary-list .value .icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ---- Success Screen ---- */
#success-screen {
    text-align: center;
    padding: var(--sp-xl) 0;
    animation: fadeInUp 0.5s ease-out;
    width: 100%;
    box-sizing: border-box;
}
.success-icon {
    font-size: 4rem;
    color: var(--c-success);
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 0 20px rgba(57,255,20,0.4));
    margin-bottom: var(--sp-md);
    line-height: 1;
    display: block;
}
#success-screen h1 {
    color: var(--c-txt1);
    margin: 0 0 var(--sp-sm) 0;
    font-size: 1.5rem;
    line-height: 1.2;
}
#success-screen p {
    font-size: 0.95rem;
    color: var(--c-txt2);
    margin: 0 auto var(--sp-md);
    max-width: 100%;
}
#success-screen .summary-panel {
    text-align: left;
    margin-top: var(--sp-md);
}
.success-actions {
    margin-top: var(--sp-lg);
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
    align-items: stretch;
}

/* ---- Confirm Modal ---- */
#confirm-modal .modal-content { width: 100%; box-sizing: border-box; }
#confirm-modal .alert {
    margin-top: var(--sp-md);
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--r-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--sp-xs);
    font-size: 0.875rem;
}
#confirm-modal .alert strong {
    display: block;
    font-size: 0.95rem;
}
#confirm-modal .alert-error {
    background: var(--c-error-g);
    border: 1px solid var(--c-error);
    color: var(--c-txt1);
}
#confirm-modal .alert::before {
    content: '⚠️';
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1.7;
}

/* ---- History Table ---- */
#history-table-container {
    width: 100%;
    box-sizing: border-box;
    margin-top: var(--sp-xl);
}
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Desktop ≥ 992px ---- */
@media (min-width: 992px) {
    .dashboard-content { padding: var(--sp-xl); }
    #withdraw-container { gap: var(--sp-xl); }
    .balance-card { padding: var(--sp-xl); }
    .balance-card .balance-amount { font-size: 3rem; }

    /* ── Balance card → two-column flex on desktop: heading/amount/note
       on the left, three quick-action buttons centred in a row on the
       right. Mobile keeps the original stacked layout because the
       .balance-card-actions strip is hidden below 992px. */
    .balance-card {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: var(--sp-xl) !important;
    }
    .balance-card .balance-card-left {
        flex: 1 1 auto;
        min-width: 0;
        position: relative;
        z-index: 1;
    }
    .balance-card .balance-card-actions {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 10px !important;
        flex-shrink: 0 !important;
        position: relative;
        z-index: 1;
    }
    .balance-card .balance-action-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.14);
        border: 1px solid rgba(255,255,255,0.32);
        color: #fff;
        font-weight: 700;
        font-size: 0.85rem;
        padding: 10px 18px;
        border-radius: 999px;
        text-decoration: none;
        white-space: nowrap;
        line-height: 1;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
    }
    .balance-card .balance-action-btn:hover {
        background: rgba(255,255,255,0.26);
        border-color: rgba(255,255,255,0.65);
    }
    .balance-card .balance-action-btn:active { transform: scale(0.97); }

    .withdraw-grid {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: var(--sp-xl);
        align-items: stretch;            /* both cards fill the row height equally */
    }
    /* Make the form container a flex column on desktop so its inner
       form can stretch and push the submit button to the very bottom. */
    .withdraw-form-container {
        padding: var(--sp-xl);
        display: flex;
        flex-direction: column;
    }
    #withdraw-form {
        display: flex;
        flex-direction: column;
        gap: var(--sp-lg);
        flex: 1 1 auto;       /* form fills the card vertically */
    }
    /* Submit button — pinned to the bottom and centred horizontally.
       margin-top:auto eats every gap between the last field and the
       footer of the card, regardless of how tall the card grew. */
    #withdraw-form #submit-btn {
        margin-top: auto !important;
        align-self: center !important;
        width: auto !important;
        min-width: 280px !important;
    }
    /* ── Info panel: now stretches to match the form card's height
       instead of sticking to the top. Flex-column layout pushes the
       Security footer item to the very bottom via margin-top:auto. */
    .info-panel {
        padding: var(--sp-xl);
        align-self: stretch;             /* equal height with the form card */
        position: static;                /* drop sticky so it can stretch  */
        top: auto;
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    .info-panel ul {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        gap: var(--sp-md);
    }
    /* Footer item — pinned to the bottom of the card so any extra
       vertical space sits BETWEEN the 6th item and the footer. */
    .info-panel li:last-child {
        margin-top: auto !important;
    }
    /* The new chevron icons (› char in span.icon) — render as a thin
       cyan glyph so the list reads cleanly without emoji. */
    .info-panel li .icon {
        font-family: inherit;
        font-size: 1.05rem;
        line-height: 1;
        font-weight: 800;
        color: var(--c-primary);
        margin-top: 4px;
    }
    .conversion-display { font-size: 1.2rem; padding: var(--sp-lg); }
    .conversion-display strong { font-size: 1.5rem; }

    .summary-list li {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
        gap: var(--sp-md);
        padding: var(--sp-md) 0;
    }
    .summary-list .label {
        font-size: 0.875rem;
        text-transform: none;
        letter-spacing: 0;
        flex-shrink: 0;
    }
    .summary-list .value { text-align: right; }
    .summary-list .value.d-flex { justify-content: flex-end; }

    #success-screen h1 { font-size: 2.25rem; }
    #success-screen p { font-size: 1.1rem; max-width: 560px; }
    #success-screen .summary-panel { max-width: 560px; margin-left: auto; margin-right: auto; }
    .success-actions { flex-direction: row; justify-content: center; gap: var(--sp-md); }
    #confirm-modal .modal-content { max-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
