/* ═══════════════════════════════════════════════════════
   COMPONENTS — Wallet Dropdown/Panel
   Extracted from layout_desktop.php & layout_mobile.php
   ═══════════════════════════════════════════════════════ */

/* ── Desktop Wallet Dropdown Animation ── */
@keyframes walletSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Premium Mobile Wallet Popover ── */
.mobile-balance-anchor {
    position: absolute;
    top: 50%;
    left: 55%;
    display: flex;
    align-items: center;
    transform: translate(-50%, -50%);
}

.mobile-wallet-trigger,
.mobile-wallet-popover {
    --wallet-gold: #f5d36d;
    --wallet-gold-deep: #c89d3c;
    --wallet-gold-rgb: 225, 180, 73;
    --wallet-ink: #080d14;
    --wallet-surface: #111923;
    --wallet-muted: #8d99aa;
}

body .balance-pill.mobile-wallet-trigger {
    position: relative;
    min-height: 38px;
    max-width: 46vw;
    margin: 0;
    padding: 6px 13px !important;
    appearance: none;
    border: 1px solid rgba(var(--wallet-gold-rgb), 0.46) !important;
    border-radius: 999px !important;
    background:
        linear-gradient(180deg, rgba(31, 35, 43, 0.98), rgba(10, 15, 22, 0.98)) !important;
    box-shadow:
        0 7px 20px rgba(0, 0, 0, 0.42),
        0 0 0 1px rgba(255, 255, 255, 0.035) inset,
        0 1px 0 rgba(255, 255, 255, 0.10) inset,
        0 0 16px rgba(var(--wallet-gold-rgb), 0.12) !important;
    color: #f7f8fa;
    cursor: pointer;
    font: inherit;
    font-size: 0.91rem;
    font-weight: 750;
    line-height: 1;
    isolation: isolate;
    touch-action: manipulation;
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

body .balance-pill.mobile-wallet-trigger::before {
    position: absolute;
    inset: 1px 10px auto;
    height: 1px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.32), transparent);
    content: "";
    pointer-events: none;
}

.mobile-wallet-trigger-amount {
    display: inline-flex;
    min-width: 0;
    align-items: baseline;
    gap: 3px;
    overflow: hidden;
}

body .mobile-wallet-trigger .balance-amount {
    overflow: hidden;
    color: var(--wallet-gold) !important;
    text-overflow: ellipsis;
    text-shadow: 0 0 10px rgba(var(--wallet-gold-rgb), 0.38) !important;
}

.mobile-wallet-trigger-currency {
    flex: 0 0 auto;
    color: #f4f0e4;
    font-size: 0.82em;
    font-weight: 800;
}

#mobileWalletChevron {
    flex: 0 0 auto;
    margin-left: 1px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.58rem;
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), color 180ms ease;
}

body .balance-pill.mobile-wallet-trigger[aria-expanded="true"] {
    border-color: rgba(var(--wallet-gold-rgb), 0.78) !important;
    box-shadow:
        0 9px 26px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(var(--wallet-gold-rgb), 0.12) inset,
        0 0 22px rgba(var(--wallet-gold-rgb), 0.20) !important;
    transform: translateY(-1px);
}

.mobile-wallet-trigger[aria-expanded="true"] #mobileWalletChevron {
    color: var(--wallet-gold);
    transform: rotate(180deg);
}

.mobile-wallet-trigger:focus-visible,
.mobile-wallet-close:focus-visible,
.mobile-wallet-action:focus-visible {
    outline: 2px solid var(--wallet-gold, #f5d36d);
    outline-offset: 3px;
}

.mobile-wallet-backdrop {
    position: fixed;
    z-index: 1160;
    inset: 0;
    visibility: hidden;
    background: rgba(2, 6, 11, 0.58);
    opacity: 0;
    pointer-events: none;
    touch-action: none;
    transition: opacity 180ms ease, visibility 180ms ease;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.mobile-wallet-backdrop.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

body.mobile-wallet-open {
    overflow: hidden;
}

body.mobile-wallet-open .mobile-header {
    z-index: 1180;
}

.mobile-wallet-popover {
    position: fixed;
    z-index: 1170;
    top: var(--mobile-wallet-top, calc(62px + env(safe-area-inset-top)));
    left: 50%;
    width: min(420px, calc(100vw - 24px));
    max-height: var(--mobile-wallet-max-height, calc(100dvh - 82px));
    padding: 17px;
    overflow-x: hidden;
    overflow-y: auto;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--wallet-gold-rgb), 0.34) transparent;
    touch-action: pan-y;
    transform: translate3d(-50%, -10px, 0) scale(0.975);
    transform-origin: var(--mobile-wallet-arrow-x, 55%) top;
    transition:
        opacity 190ms ease,
        transform 240ms cubic-bezier(0.2, 0.85, 0.3, 1),
        visibility 190ms ease;
}

body #mobileWalletPanel.mobile-wallet-popover {
    border: 1px solid rgba(var(--wallet-gold-rgb), 0.30) !important;
    border-bottom-color: rgba(var(--wallet-gold-rgb), 0.30) !important;
    border-radius: 20px !important;
    background:
        radial-gradient(circle at 78% -12%, rgba(var(--wallet-gold-rgb), 0.16), transparent 38%),
        linear-gradient(145deg, rgba(25, 32, 42, 0.985), rgba(8, 13, 20, 0.992)) !important;
    box-shadow:
        0 30px 70px rgba(0, 0, 0, 0.62),
        0 10px 26px rgba(0, 0, 0, 0.38),
        0 1px 0 rgba(255, 255, 255, 0.08) inset,
        0 0 0 1px rgba(255, 255, 255, 0.025) inset !important;
}

.mobile-wallet-popover.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(-50%, 0, 0) scale(1);
}

.mobile-wallet-popover::before {
    position: absolute;
    top: 0;
    left: var(--mobile-wallet-arrow-x, 55%);
    width: 52px;
    height: 2px;
    border-radius: 0 0 999px 999px;
    background: linear-gradient(90deg, transparent, var(--wallet-gold), transparent);
    box-shadow: 0 0 14px rgba(var(--wallet-gold-rgb), 0.42);
    content: "";
    transform: translateX(-50%);
}

.mobile-wallet-popover-shine {
    position: absolute;
    z-index: -1;
    top: -70px;
    right: -50px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(var(--wallet-gold-rgb), 0.055);
    filter: blur(20px);
    pointer-events: none;
}

.mobile-wallet-popover-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.mobile-wallet-eyebrow {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 5px;
    color: #f1f3f6;
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    line-height: 1;
    text-transform: uppercase;
}

.mobile-wallet-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--wallet-gold);
    box-shadow: 0 0 9px rgba(var(--wallet-gold-rgb), 0.75);
}

.mobile-wallet-total-label {
    color: var(--wallet-muted);
    font-size: 0.66rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mobile-wallet-close {
    display: inline-flex;
    flex: 0 0 auto;
    width: 31px;
    height: 31px;
    align-items: center;
    justify-content: center;
    margin: -3px -3px 0 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.045);
    color: #9da8b7;
    cursor: pointer;
    font-size: 0.72rem;
    transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.mobile-wallet-close:active {
    border-color: rgba(var(--wallet-gold-rgb), 0.24);
    background: rgba(var(--wallet-gold-rgb), 0.10);
    color: var(--wallet-gold);
}

body #mobileWalletPanel #mWalletTotal.mobile-wallet-total {
    margin: 4px 0 15px;
    color: var(--wallet-gold) !important;
    font-size: clamp(1.72rem, 7vw, 2.05rem);
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    letter-spacing: -0.045em;
    line-height: 1.1;
    text-shadow: 0 0 18px rgba(var(--wallet-gold-rgb), 0.20) !important;
}

.mobile-wallet-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 9px;
}

.mobile-wallet-card,
.mobile-wallet-wager {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.075);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.058), rgba(255, 255, 255, 0.025));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset;
}

.mobile-wallet-card {
    min-width: 0;
    padding: 12px;
    border-radius: 14px;
}

.mobile-wallet-card::after {
    position: absolute;
    right: -20px;
    bottom: -28px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: currentColor;
    content: "";
    opacity: 0.055;
    pointer-events: none;
}

.mobile-wallet-card-real {
    color: var(--wallet-gold);
}

.mobile-wallet-card-bonus {
    color: #bda7ff;
}

.mobile-wallet-card-label {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
    color: #929dad;
    font-size: 0.67rem;
    font-weight: 700;
    line-height: 1.2;
}

.mobile-wallet-card-icon {
    display: inline-flex;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    border: 1px solid currentColor;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    color: inherit;
    font-size: 0.62rem;
    opacity: 0.9;
}

.mobile-wallet-card-value {
    display: block;
    overflow: hidden;
    margin-top: 10px;
    color: currentColor;
    font-size: 0.98rem;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body #mobileWalletPanel #mWalletReal {
    color: var(--wallet-gold) !important;
}

body #mobileWalletPanel #mWalletBonus {
    color: #bda7ff !important;
}

.mobile-wallet-wager {
    margin-top: 9px;
    padding: 11px 12px 12px;
    border-radius: 14px;
}

.mobile-wallet-wager .mobile-wallet-card-icon {
    color: #75aef5;
}

.mobile-wallet-wager-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#mWalletWager {
    flex: 0 0 auto;
    color: #8bbcff;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

.mobile-wallet-progress {
    height: 4px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(3, 8, 14, 0.78);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35) inset;
}

.mobile-wallet-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--wallet-gold-deep), var(--wallet-gold), #8bbcff);
    box-shadow: 0 0 10px rgba(var(--wallet-gold-rgb), 0.34);
    transition: width 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mobile-wallet-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 11px;
}

body #mobileWalletPanel .mobile-wallet-action {
    display: inline-flex;
    min-width: 0;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 7px;
    border: 1px solid rgba(255, 255, 255, 0.085) !important;
    border-radius: 12px !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035)) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset !important;
    color: #e8ebef !important;
    font-size: 0.74rem;
    font-weight: 750;
    text-align: center;
    text-decoration: none;
    touch-action: manipulation;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

body #mobileWalletPanel .mobile-wallet-action-primary {
    border-color: rgba(var(--wallet-gold-rgb), 0.72) !important;
    background: linear-gradient(135deg, var(--wallet-gold), var(--wallet-gold-deep)) !important;
    box-shadow:
        0 8px 18px rgba(var(--wallet-gold-rgb), 0.20),
        0 1px 0 rgba(255, 255, 255, 0.28) inset !important;
    color: #161107 !important;
}

.mobile-wallet-action:active {
    transform: translateY(1px) scale(0.985);
}

@media (max-width: 359px) {
    .mobile-balance-anchor {
        left: 56.5%;
    }

    body .balance-pill.mobile-wallet-trigger {
        max-width: 42vw;
        min-height: 34px;
        padding: 5px 8px !important;
        font-size: 0.78rem;
    }

    .mobile-wallet-popover {
        width: calc(100vw - 16px);
        padding: 14px;
    }

    body #mobileWalletPanel.mobile-wallet-popover {
        border-radius: 17px !important;
    }

    .mobile-wallet-grid,
    .mobile-wallet-actions {
        gap: 6px;
    }

    .mobile-wallet-card {
        padding: 10px;
    }

    .mobile-wallet-card-label {
        gap: 5px;
        font-size: 0.62rem;
    }

    .mobile-wallet-card-value {
        font-size: 0.88rem;
    }

    body #mobileWalletPanel .mobile-wallet-action {
        gap: 5px;
        min-height: 38px;
        font-size: 0.70rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-wallet-trigger,
    #mobileWalletChevron,
    .mobile-wallet-backdrop,
    .mobile-wallet-popover,
    .mobile-wallet-progress-bar,
    .mobile-wallet-action {
        transition-duration: 0.01ms !important;
    }
}
