/* =====================================================================
   Serva — Wallet History page
   Full-width financial timeline with type tabs, search, expandable cards,
   per-type icons & colors, skeleton loaders, and receipt lightbox.
   ===================================================================== */

/* --- Page shell ----------------------------------------------------------- */

.wallet-history-page-wrap {
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(0, 180, 255, 0.06), transparent 40%),
        radial-gradient(circle at bottom left, rgba(123, 47, 255, 0.05), transparent 50%),
        #030816;
}

.wallet-history-page-shell {
    max-width: none;
    margin: 0;
    padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem;
}

/* --- Hero ----------------------------------------------------------------- */

.wallet-history-page-hero {
    border: 1px solid rgba(0, 180, 255, 0.16);
    border-radius: 28px;
    background:
        radial-gradient(circle at top left, rgba(0, 180, 255, 0.16), transparent 34%),
        linear-gradient(140deg, rgba(6, 14, 32, 0.96), rgba(4, 8, 20, 0.98));
    box-shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
    padding: 2rem;
    margin-bottom: 1.25rem;
}

.wallet-history-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(0, 180, 255, 0.12);
    border: 1px solid rgba(0, 180, 255, 0.28);
    color: #5ed3ff;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.85rem;
}

.wallet-history-page-hero h1 {
    margin: 0 0 0.8rem;
    font-size: clamp(1.85rem, 4.6vw, 3rem);
    line-height: 1.08;
}

.wallet-history-page-hero p {
    margin: 0;
    max-width: 720px;
    color: var(--text-secondary);
    line-height: 1.85;
}

.wallet-history-hero-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.35rem;
}

.wallet-history-hero-actions .btn-primary,
.wallet-history-hero-actions .btn-secondary {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Summary cards (4 stats) --------------------------------------------- */

.wallet-history-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.wallet-summary-card {
    border-radius: 20px;
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--border-color);
    background: linear-gradient(150deg, rgba(8, 16, 36, 0.96), rgba(4, 8, 20, 0.92));
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.wallet-summary-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.6;
    background: linear-gradient(140deg, transparent 60%, rgba(255, 255, 255, 0.04) 100%);
}

.wallet-summary-card:hover {
    transform: translateY(-2px);
}

.wallet-summary-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.wallet-summary-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.wallet-summary-card--balance {
    border-color: rgba(0, 200, 200, 0.28);
    background:
        radial-gradient(circle at top right, rgba(0, 200, 200, 0.18), transparent 50%),
        linear-gradient(150deg, rgba(8, 24, 32, 0.96), rgba(4, 12, 18, 0.92));
}

.wallet-summary-card--balance .wallet-summary-label { color: #5fe5e0; }

.wallet-summary-card--deposits {
    border-color: rgba(34, 197, 94, 0.28);
    background:
        radial-gradient(circle at top right, rgba(34, 197, 94, 0.16), transparent 50%),
        linear-gradient(150deg, rgba(6, 24, 14, 0.96), rgba(2, 12, 6, 0.92));
}

.wallet-summary-card--deposits .wallet-summary-label { color: #6ee59f; }

.wallet-summary-card--spent {
    border-color: rgba(168, 85, 247, 0.28);
    background:
        radial-gradient(circle at top right, rgba(168, 85, 247, 0.16), transparent 50%),
        linear-gradient(150deg, rgba(20, 8, 32, 0.96), rgba(10, 4, 16, 0.92));
}

.wallet-summary-card--spent .wallet-summary-label { color: #c7a3ff; }

.wallet-summary-card--pending {
    border-color: rgba(245, 158, 11, 0.32);
    background:
        radial-gradient(circle at top right, rgba(245, 158, 11, 0.16), transparent 50%),
        linear-gradient(150deg, rgba(28, 18, 4, 0.96), rgba(14, 10, 2, 0.92));
}

.wallet-summary-card--pending .wallet-summary-label { color: #f5be4f; }

/* --- Toolbar (tabs + status + search + refresh) -------------------------- */

.wallet-history-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: rgba(6, 12, 24, 0.6);
    backdrop-filter: blur(8px);
}

.wallet-filter-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex: 1 1 auto;
}

.wallet-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
    white-space: nowrap;
}

.wallet-filter-btn:hover {
    border-color: rgba(0, 180, 255, 0.4);
    color: #cfeeff;
    background: rgba(0, 180, 255, 0.06);
}

.wallet-filter-btn.active {
    border-color: rgba(0, 200, 200, 0.55);
    background: linear-gradient(135deg, rgba(0, 200, 200, 0.22), rgba(0, 120, 200, 0.18));
    color: #fff;
    box-shadow: 0 0 0 1px rgba(0, 200, 200, 0.25) inset;
}

.wallet-filter-btn i { font-size: 0.85em; }

.wallet-status-filter {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.5rem 0.7rem;
    border-radius: 14px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px dashed rgba(245, 158, 11, 0.28);
    width: 100%;
}

.wallet-status-filter[hidden] { display: none !important; }

.wallet-status-filter-label {
    color: #f5be4f;
    font-size: 0.83rem;
    font-weight: 700;
    margin-inline-end: 0.25rem;
}

.wallet-status-btn {
    display: inline-flex;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.28);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
}

.wallet-status-btn:hover { color: #f5be4f; }

.wallet-status-btn.active {
    background: rgba(245, 158, 11, 0.18);
    color: #fff;
    border-color: rgba(245, 158, 11, 0.55);
}

.wallet-toolbar-trailing {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    margin-inline-start: auto;
}

.wallet-search-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 240px;
}

.wallet-search-icon {
    position: absolute;
    inset-inline-start: 0.85rem;
    color: var(--text-secondary);
    pointer-events: none;
}

#walletSearchInput {
    flex: 1;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    font-size: 0.9rem;
    transition: 0.18s ease;
    width: 100%;
}

/* RTL: icon belongs on the right (inset-inline-start) — adjust input padding accordingly */
[dir="rtl"] #walletSearchInput {
    padding: 0.6rem 2.5rem 0.6rem 1rem;
}

#walletSearchInput:focus {
    outline: none;
    border-color: rgba(0, 200, 200, 0.55);
    box-shadow: 0 0 0 3px rgba(0, 200, 200, 0.18);
}

.wallet-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

/* --- Skeleton loaders ----------------------------------------------------- */

.wallet-history-skeleton {
    display: grid;
    gap: 0.85rem;
}

.wallet-card-skeleton {
    height: 88px;
    border-radius: 18px;
    border: 1px solid var(--border-color);
    background:
        linear-gradient(90deg,
            rgba(255, 255, 255, 0.03) 0%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.03) 100%);
    background-size: 200% 100%;
    animation: walletShimmer 1.5s infinite linear;
}

@keyframes walletShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Empty state ---------------------------------------------------------- */

.wallet-history-empty {
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: rgba(6, 12, 24, 0.45);
}

.wallet-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 0.85rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 180, 255, 0.1);
    color: #5ed3ff;
    font-size: 1.6rem;
}

.wallet-history-empty h4 {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
}

.wallet-history-empty p {
    margin: 0 0 1rem;
    color: var(--text-secondary);
}

.wallet-empty-actions {
    display: inline-flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.wallet-empty-actions .btn-primary,
.wallet-empty-actions .btn-secondary {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

/* --- Grouped list + headings --------------------------------------------- */

.wallet-grouped-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.wallet-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.wallet-group-heading {
    margin: 0;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.wallet-group-heading-count {
    margin-inline-start: auto;
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
}

/* --- Item card (summary + details) --------------------------------------- */

.wallet-item-card {
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: linear-gradient(150deg, rgba(8, 16, 36, 0.92), rgba(4, 8, 20, 0.88));
    overflow: hidden;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.wallet-item-card:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 180, 255, 0.32);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.wallet-item-summary {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.85rem;
    padding: 0.95rem 1.1rem;
    cursor: pointer;
    user-select: none;
}

.wallet-item-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex: 0 0 auto;
}

/* Type color variants */
.wallet-item-card[data-wallet-type="deposit"] .wallet-item-icon {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 6px 18px rgba(34, 197, 94, 0.3);
}
.wallet-item-card[data-wallet-type="purchase"] .wallet-item-icon {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    box-shadow: 0 6px 18px rgba(168, 85, 247, 0.3);
}
.wallet-item-card[data-wallet-type="refund"] .wallet-item-icon {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.3);
}
.wallet-item-card[data-wallet-type="bonus"] .wallet-item-icon {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    box-shadow: 0 6px 18px rgba(6, 182, 212, 0.3);
}
.wallet-item-card[data-wallet-type="withdrawal"] .wallet-item-icon {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.3);
}

.wallet-item-main {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.wallet-item-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.wallet-item-meta {
    font-size: 0.83rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.wallet-item-meta .dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.5;
}

.wallet-item-amount {
    font-size: 1.05rem;
    font-weight: 800;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.wallet-item-amount.is-positive { color: #6ee59f; }
.wallet-item-amount.is-negative { color: #ff8b8b; }
.wallet-item-amount.is-neutral { color: #cfeeff; }

.wallet-item-chevron {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 0.75rem;
    transition: transform 0.2s ease, background 0.2s ease;
}

.wallet-item-card.is-expanded .wallet-item-chevron {
    transform: rotate(180deg);
    background: rgba(0, 180, 255, 0.18);
    color: #fff;
}

/* Status pill (for deposits) */
.wallet-item-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.wallet-item-status.is-pending {
    background: rgba(245, 158, 11, 0.14);
    color: #f5be4f;
    border-color: rgba(245, 158, 11, 0.4);
}
.wallet-item-status.is-approved {
    background: rgba(34, 197, 94, 0.14);
    color: #6ee59f;
    border-color: rgba(34, 197, 94, 0.4);
}
.wallet-item-status.is-rejected {
    background: rgba(239, 68, 68, 0.14);
    color: #ff8b8b;
    border-color: rgba(239, 68, 68, 0.4);
}

/* Details (expanded) */
.wallet-item-details {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.95rem 1.1rem 1.1rem;
    background: rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.wallet-item-card:not(.is-expanded) .wallet-item-details {
    display: none;
}

.wallet-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.85rem;
    font-size: 0.88rem;
    line-height: 1.55;
}

.wallet-detail-row > span:first-child {
    color: var(--text-secondary);
    flex: 0 0 auto;
}

.wallet-detail-row > span:last-child {
    color: #e6f3ff;
    text-align: end;
    overflow-wrap: anywhere;
}

.wallet-detail-row--rejection > span:last-child { color: #ff8b8b; }

.wallet-detail-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

.wallet-detail-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    color: #cfeeff;
    font-size: 0.83rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: 0.18s ease;
}

.wallet-detail-btn:hover {
    border-color: rgba(0, 180, 255, 0.5);
    background: rgba(0, 180, 255, 0.08);
    color: #fff;
}

.wallet-detail-btn.is-primary {
    background: linear-gradient(135deg, rgba(0, 180, 255, 0.22), rgba(0, 120, 200, 0.18));
    border-color: rgba(0, 180, 255, 0.45);
    color: #fff;
}

/* --- Receipt lightbox ---------------------------------------------------- */

.receipt-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 14, 0.88);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    cursor: zoom-out;
}

.receipt-lightbox-overlay.is-active {
    display: flex;
    animation: walletFadeIn 0.18s ease-out;
}

@keyframes walletFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.receipt-lightbox-content {
    position: relative;
    max-width: min(92vw, 900px);
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.receipt-lightbox-content img {
    max-width: 100%;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    background: rgba(0, 0, 0, 0.5);
}

.receipt-lightbox-close {
    position: fixed;
    top: 1.25rem;
    inset-inline-end: 1.25rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 1;
    transition: 0.18s ease;
}

.receipt-lightbox-close:hover {
    background: rgba(239, 68, 68, 0.4);
    border-color: rgba(239, 68, 68, 0.7);
}

/* --- New item flash (realtime) ------------------------------------------- */

.wallet-item-card.just-arrived {
    animation: walletPulseNew 1.6s ease-out;
}

@keyframes walletPulseNew {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 200, 200, 0.6);
        border-color: rgba(0, 200, 200, 0.7);
    }
    70% {
        box-shadow: 0 0 0 18px rgba(0, 200, 200, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 200, 200, 0);
        border-color: var(--border-color);
    }
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1100px) {
    .wallet-history-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .wallet-history-page-shell {
        padding: 1.5rem clamp(0.85rem, 4vw, 1.5rem) 3rem;
    }
    .wallet-history-page-hero {
        padding: 1.5rem;
        border-radius: 22px;
    }
    .wallet-toolbar-trailing {
        margin-inline-start: 0;
        width: 100%;
    }
    .wallet-search-wrap {
        flex: 1;
        min-width: 0;
        width: 100%;
    }
    .wallet-filter-btn {
        font-size: 0.82rem;
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 640px) {
    .wallet-history-page-hero {
        padding: 1.25rem;
    }
    .wallet-history-summary {
        grid-template-columns: 1fr;
        gap: 0.7rem;
    }
    .wallet-summary-value {
        font-size: 1.55rem;
    }
    .wallet-toolbar-trailing {
        flex-direction: column;
        align-items: stretch;
    }
    .wallet-refresh-btn {
        width: 100%;
        justify-content: center;
    }
    .wallet-item-summary {
        grid-template-columns: auto 1fr auto;
        gap: 0.65rem;
    }
    .wallet-item-chevron {
        display: none;
    }
    .wallet-item-amount {
        font-size: 0.95rem;
    }
}

@media (max-width: 460px) {
    .wallet-filter-btn i { display: none; }
    .wallet-status-filter {
        padding: 0.5rem;
    }
    .wallet-status-filter-label {
        flex: 1 0 100%;
    }
}
