/* ============================================================
   WALLET HUB — drawer/dropdown desde el header
   Camino medio (Task #80)
   ============================================================ */

/* ---------- Balance pill como botón clickeable ---------- */
.cl-balance-pill {
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.cl-balance-pill:hover[data-authed="true"] {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(255, 200, 80, .25);
}
.cl-balance-pill:focus-visible {
    outline: 2px solid var(--cl-color-gold, #ffc850);
    outline-offset: 2px;
}
.cl-balance-pill[aria-expanded="true"] {
    background-color: rgba(255, 200, 80, .12);
}
.cl-balance-pill__chev {
    margin-left: 4px;
    transition: transform .2s ease;
    opacity: .7;
}
.cl-balance-pill[aria-expanded="true"] .cl-balance-pill__chev {
    transform: rotate(180deg);
}

/* ---------- Wallet Hub container ---------- */
.cl-wallet-hub {
    position: fixed;
    inset: 0;
    z-index: 9000;
    pointer-events: none;
    visibility: hidden;
}
.cl-wallet-hub[data-open="true"] {
    pointer-events: auto;
    visibility: visible;
}

/* Backdrop */
.cl-wallet-hub__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 5, 22, .55);
    opacity: 0;
    transition: opacity .2s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.cl-wallet-hub[data-open="true"] .cl-wallet-hub__backdrop {
    opacity: 1;
}

/* Panel — desktop: dropdown anclado a la derecha; mobile: drawer */
.cl-wallet-hub__panel {
    position: absolute;
    top: 76px;
    right: 16px;
    width: 420px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 96px);
    background: linear-gradient(180deg, #1a0f3a 0%, #15092e 100%);
    border: 1px solid rgba(255, 200, 80, .2);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .03);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(-12px) scale(.98);
    opacity: 0;
    transition: transform .22s cubic-bezier(.2, .9, .3, 1), opacity .22s ease;
    color: #fff;
}
.cl-wallet-hub[data-open="true"] .cl-wallet-hub__panel {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Mobile: drawer slide desde la derecha a pantalla completa */
@media (max-width: 720px) {
    .cl-wallet-hub__panel {
        top: 0;
        right: 0;
        bottom: 0;
        width: min(420px, 100vw);
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        border-left: 1px solid rgba(255, 200, 80, .2);
        border-top: 0;
        border-right: 0;
        border-bottom: 0;
        transform: translateX(100%);
    }
    .cl-wallet-hub[data-open="true"] .cl-wallet-hub__panel {
        transform: translateX(0);
    }
}

/* ---------- Header del hub ---------- */
.cl-wallet-hub__header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    background: linear-gradient(180deg, rgba(255, 200, 80, .06) 0%, transparent 100%);
}
.cl-wallet-hub__title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.cl-wallet-hub__title-row > .cl-icon {
    color: var(--cl-color-gold, #ffc850);
}
.cl-wallet-hub__title {
    flex: 1;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: .2px;
}
.cl-wallet-hub__close {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.cl-wallet-hub__close:hover,
.cl-wallet-hub__close:focus-visible {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 200, 80, .4);
    outline: none;
}

/* Saldo total */
.cl-wallet-hub__balance {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.cl-wallet-hub__balance-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: rgba(255, 255, 255, .55);
}
.cl-wallet-hub__balance-amount {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(120deg, #ffd76a 0%, #ffc850 60%, #fff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}

/* Sub-saldos Lotería / Casino */
.cl-wallet-hub__sub-balances {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}
.cl-wallet-hub__sub {
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cl-wallet-hub__sub-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: rgba(255, 255, 255, .5);
}
.cl-wallet-hub__sub-amount {
    font-size: .95rem;
    font-weight: 600;
    color: #fff;
}

/* Acciones primarias (Depositar / Comprar boleto) */
.cl-wallet-hub__primary-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}
.cl-wallet-hub__action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 6px;
    border-radius: 12px;
    border: 1px solid rgba(255, 200, 80, .25);
    background: linear-gradient(180deg, rgba(255, 200, 80, .12) 0%, rgba(255, 200, 80, .04) 100%);
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.cl-wallet-hub__action i,
.cl-wallet-hub__action svg {
    width: 22px;
    height: 22px;
    color: var(--cl-color-gold, #ffc850);
}
.cl-wallet-hub__action:hover,
.cl-wallet-hub__action:focus-visible {
    background: linear-gradient(180deg, rgba(255, 200, 80, .22) 0%, rgba(255, 200, 80, .08) 100%);
    border-color: rgba(255, 200, 80, .55);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(255, 200, 80, .15);
    outline: none;
}
.cl-wallet-hub__action--primary[data-wallet-hub-action="buy-ticket"] {
    background: linear-gradient(135deg, #ffc850 0%, #ff9f3d 100%);
    border-color: transparent;
    color: #1a0f3a;
}
.cl-wallet-hub__action--primary[data-wallet-hub-action="buy-ticket"] i,
.cl-wallet-hub__action--primary[data-wallet-hub-action="buy-ticket"] svg {
    color: #1a0f3a;
}
.cl-wallet-hub__action--primary[data-wallet-hub-action="buy-ticket"]:hover {
    background: linear-gradient(135deg, #ffd76a 0%, #ffae50 100%);
}

/* Acción secundaria destacada (Swap) */
.cl-wallet-hub__action--secondary {
    flex-direction: row;
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .1);
    color: #fff;
    font-size: .85rem;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.cl-wallet-hub__action--secondary i,
.cl-wallet-hub__action--secondary svg {
    width: 18px;
    height: 18px;
    color: var(--cl-color-gold, #ffc850);
}
.cl-wallet-hub__action--secondary:hover,
.cl-wallet-hub__action--secondary:focus-visible {
    background: rgba(255, 200, 80, .12);
    border-color: rgba(255, 200, 80, .35);
    outline: none;
}

/* ---------- Body con accordions inyectados ---------- */
.cl-wallet-hub__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 16px;
    background: rgba(0, 0, 0, .15);
}
.cl-wallet-hub__body:empty::before {
    content: attr(data-empty-msg, "Inicia sesión para ver tu wallet");
    display: block;
    text-align: center;
    color: rgba(255, 255, 255, .45);
    font-size: .85rem;
    padding: 20px;
}
/* Compactar accordions reusados dentro del hub */
.cl-wallet-hub__body .wallet-accordion {
    margin-bottom: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .06);
}
.cl-wallet-hub__body .wallet-accordion:last-child {
    margin-bottom: 0;
}
.cl-wallet-hub__body .wallet-accordion-header {
    padding: 12px 14px;
    cursor: pointer;
}
.cl-wallet-hub__body .wallet-accordion-body {
    padding: 0 12px 12px;
}
/* ============================================================
   Lista nativa de tokens dentro del hub
   (reemplaza el reuso del .wallet-accordion legacy)
   ============================================================ */
.cl-hub-section {
    padding: 14px 16px 8px;
}
.cl-hub-section + .cl-hub-section {
    border-top: 1px solid rgba(255, 255, 255, .06);
    margin-top: 4px;
}
.cl-hub-section__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    color: #d9d4ea;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.cl-hub-section__header [data-lucide] {
    width: 16px;
    height: 16px;
    color: #f5c64c;
}
.cl-hub-section__title {
    flex: 1 1 auto;
    min-width: 0;
}
.cl-hub-section__amount {
    color: #f5c64c;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-transform: none;
    letter-spacing: 0;
    font-size: 14px;
}

.cl-hub-tokens {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cl-token-row {
    display: grid;
    grid-template-columns: 36px 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 12px;
    transition: background .15s ease, border-color .15s ease;
}
.cl-token-row:hover {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(245, 198, 76, .25);
}
.cl-token-row__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(0, 0, 0, .25);
    padding: 4px;
}
.cl-token-row__info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.cl-token-row__name {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.1;
}
.cl-token-row__full {
    color: #aaa3c4;
    font-size: 11px;
    margin-top: 2px;
}
.cl-token-row__balance {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    min-width: 0;
}
.cl-token-row__amount {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}
.cl-token-row__usd {
    color: #aaa3c4;
    font-size: 11px;
    margin-top: 2px;
    white-space: nowrap;
}
.cl-token-row__actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.cl-token-row__btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(245, 198, 76, .35);
    background: rgba(245, 198, 76, .1);
    color: #f5c64c;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background .15s ease, transform .1s ease;
}
.cl-token-row__btn:hover {
    background: rgba(245, 198, 76, .2);
}
.cl-token-row__btn:active {
    transform: scale(.95);
}
.cl-token-row__btn [data-lucide] {
    width: 16px;
    height: 16px;
}

@media (max-width: 480px) {
    .cl-token-row {
        grid-template-columns: 32px 1fr auto;
        grid-template-areas:
            "icon info balance"
            "icon actions actions";
        gap: 8px 10px;
        padding: 10px;
    }
    .cl-token-row__icon { grid-area: icon; align-self: center; }
    .cl-token-row__info { grid-area: info; }
    .cl-token-row__balance { grid-area: balance; }
    .cl-token-row__actions {
        grid-area: actions;
        justify-content: flex-end;
        margin-top: 4px;
    }
    .cl-token-row__amount { max-width: 100%; }
}

/* Ocultar los acordeones legacy (#walletAccordion, #casinoAccordion) cuando el
   hub está montado en la página. Mantienen los IDs internos
   (#walletBalanceSPS, etc.) como source of truth para balance-system.js, pero
   no se muestran al usuario para evitar UI duplicada y dobles desplegables.
   El js setea body.cl-has-wallet-hub en init(). */
body.cl-has-wallet-hub #walletAccordion,
body.cl-has-wallet-hub #casinoAccordion {
    display: none !important;
}

/* ---------- Footer del hub ---------- */
.cl-wallet-hub__footer {
    border-top: 1px solid rgba(255, 255, 255, .06);
    padding: 12px 16px 14px;
    background: rgba(0, 0, 0, .15);
}
.cl-wallet-hub__more {
    margin-bottom: 10px;
}
.cl-wallet-hub__more-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
    color: rgba(255, 255, 255, .75);
    font-size: .85rem;
    font-weight: 500;
    user-select: none;
}
.cl-wallet-hub__more-summary::-webkit-details-marker {
    display: none;
}
.cl-wallet-hub__more-summary i,
.cl-wallet-hub__more-summary svg {
    width: 16px;
    height: 16px;
    transition: transform .2s ease;
}
.cl-wallet-hub__more[open] .cl-wallet-hub__more-summary i,
.cl-wallet-hub__more[open] .cl-wallet-hub__more-summary svg {
    transform: rotate(180deg);
}
.cl-wallet-hub__more-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding-top: 8px;
}
.cl-wallet-hub__more-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .06);
    color: rgba(255, 255, 255, .85);
    font-size: .78rem;
    cursor: pointer;
    transition: background .15s ease;
}
.cl-wallet-hub__more-btn i,
.cl-wallet-hub__more-btn svg {
    width: 16px;
    height: 16px;
    color: var(--cl-color-gold, #ffc850);
}
.cl-wallet-hub__more-btn:hover,
.cl-wallet-hub__more-btn:focus-visible {
    background: rgba(255, 200, 80, .1);
    outline: none;
}
.cl-wallet-hub__open-full {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    color: var(--cl-color-gold, #ffc850);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    border-radius: 8px;
    transition: background .15s ease;
}
.cl-wallet-hub__open-full:hover {
    background: rgba(255, 200, 80, .08);
}
.cl-wallet-hub__open-full i,
.cl-wallet-hub__open-full svg {
    width: 14px;
    height: 14px;
}

/* ============================================================
   COMPACT WALLET SUMMARY — bajo el fold (sólo authed)
   ============================================================ */
.cl-wallet-summary {
    display: none;
    margin: 24px auto;
    padding: 0 16px;
    max-width: 1240px;
}
.cl-wallet-summary[data-authed="true"] {
    display: block;
}
.cl-wallet-summary__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1a0f3a 0%, #15092e 100%);
    border: 1px solid rgba(255, 200, 80, .18);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    color: #fff;
}
.cl-wallet-summary__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.cl-wallet-summary__label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: rgba(255, 255, 255, .55);
}
.cl-wallet-summary__total {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(120deg, #ffd76a 0%, #ffc850 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.cl-wallet-summary__sub {
    display: flex;
    gap: 14px;
    font-size: .82rem;
    color: rgba(255, 255, 255, .7);
    flex-wrap: wrap;
}
.cl-wallet-summary__sub strong {
    color: #fff;
    font-weight: 600;
}
.cl-wallet-summary__cta {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.cl-wallet-summary__cta i,
.cl-wallet-summary__cta svg {
    width: 16px;
    height: 16px;
}
@media (max-width: 640px) {
    .cl-wallet-summary__inner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .cl-wallet-summary__sub {
        justify-content: center;
    }
    .cl-wallet-summary__cta {
        justify-content: center;
    }
}

/* ============================================================
   SOLO JACKPOT EN HERO — asegurar layout estable sin tabs
   ============================================================ */
body.cl-home-v3 .cl-jackpot-card.cl-jackpot-card--solo {
    /* Restaurar layout sin necesidad de paneles */
    min-height: auto;
}
/* Defensa: ocultar cualquier residuo de tabs si CSS legacy intentara mostrarlos */
body.cl-home-v3 .cl-jackpot-card--solo .cl-jackpot-card__tabs,
body.cl-home-v3 .cl-jackpot-card--solo .cl-jackpot-card__panel {
    display: none !important;
}

/* Body lock cuando el hub está abierto (suave, no rompe drawer hamburger) */
body[data-wallet-hub-open="true"] {
    overflow: hidden;
}
