/**
 * Billing Page - Transaction History Table Styles
 * Cyberpunk table, monospace numbers, alternating rows, neon hover.
 */

/* ============================================================
   BILLING PAGE HEADER
   ============================================================ */

.billing-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.billing-header__info {
    flex: 1;
}

.billing-header__title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 var(--space-2) 0;
}

.billing-header__sub {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================================
   FILTER BAR
   ============================================================ */

.billing-filters {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.billing-filter-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.billing-filter-btn {
    padding: var(--space-2) var(--space-4);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.billing-filter-btn:hover {
    border-color: rgba(0, 245, 212, 0.4);
    color: var(--text-primary);
}

.billing-filter-btn.active {
    background: rgba(0, 245, 212, 0.1);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}

/* ============================================================
   TABLE CONTAINER
   ============================================================ */

.billing-table-wrap {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
    overflow: hidden;
}

.billing-table-scroll {
    overflow-x: auto;
}

.billing-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

/* ============================================================
   TABLE HEAD
   ============================================================ */

.billing-table thead {
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(0, 245, 212, 0.15);
}

.billing-table th {
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--neon-cyan);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-align: left;
    white-space: nowrap;
}

.billing-table th.col-amount,
.billing-table th.col-tokens,
.billing-table th.col-balance {
    text-align: right;
}

.billing-table th.col-invoice,
.billing-table td.col-invoice {
    text-align: center;
    width: 72px;
    white-space: nowrap;
}

.billing-invoice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid rgba(0, 245, 212, 0.3);
    background: rgba(0, 245, 212, 0.06);
    color: var(--neon-cyan);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.billing-invoice-btn:hover,
.billing-invoice-btn:focus-visible {
    border-color: var(--neon-cyan);
    background: rgba(0, 245, 212, 0.12);
    box-shadow: 0 0 12px rgba(0, 245, 212, 0.25);
    outline: none;
}

.billing-invoice-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.billing-invoice-btn svg {
    width: 16px;
    height: 16px;
}

.billing-invoice-empty {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* ============================================================
   TABLE ROWS
   ============================================================ */

.billing-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.billing-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

.billing-table tbody tr:hover {
    background: rgba(0, 245, 212, 0.04);
    border-bottom-color: rgba(0, 245, 212, 0.15);
}

.billing-table td {
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-secondary);
    vertical-align: middle;
}

/* Date column */
.billing-table td.col-date {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Type badge */
.tx-type-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 10px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 4px 100%, 0 calc(100% - 4px));
}

.tx-type-badge svg {
    width: 10px;
    height: 10px;
}

.tx-type-badge--purchase {
    background: rgba(0, 245, 212, 0.12);
    border: 1px solid rgba(0, 245, 212, 0.3);
    color: var(--neon-cyan);
}

.tx-type-badge--refund {
    background: rgba(247, 37, 133, 0.1);
    border: 1px solid rgba(247, 37, 133, 0.3);
    color: var(--neon-magenta);
}

.tx-type-badge--bonus {
    background: rgba(254, 228, 64, 0.1);
    border: 1px solid rgba(254, 228, 64, 0.3);
    color: var(--neon-yellow);
}

.tx-type-badge--consumption {
    background: rgba(123, 44, 191, 0.1);
    border: 1px solid rgba(123, 44, 191, 0.3);
    color: var(--neon-purple);
}

/* Consumption check-type badges — used in Consumption tab rows */
.tx-type-badge--check-html {
    background: rgba(76, 201, 240, 0.1);
    border: 1px solid rgba(76, 201, 240, 0.3);
    color: var(--neon-blue);
}

.tx-type-badge--check-serp {
    background: rgba(254, 228, 64, 0.1);
    border: 1px solid rgba(254, 228, 64, 0.3);
    color: var(--neon-yellow);
}

.tx-type-badge--check-other {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
}

/* Consumption token debit — muted red to signal spend */
.tx-tokens--consumption {
    color: var(--status-danger, #f72585);
    font-weight: 600;
}

/* Description column */
.billing-table td.col-description {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

/* Numeric columns */
.billing-table td.col-amount,
.billing-table td.col-tokens,
.billing-table td.col-balance {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-align: right;
    white-space: nowrap;
}

.tx-amount--positive {
    color: var(--neon-cyan);
}

.tx-amount--negative {
    color: var(--neon-magenta);
}

.tx-tokens--positive {
    color: var(--neon-cyan);
    font-weight: 600;
}

.tx-tokens--negative {
    color: var(--neon-magenta);
}

.tx-balance {
    color: var(--text-secondary);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.billing-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-10) var(--space-6);
    text-align: center;
}

.billing-empty__icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 245, 212, 0.05);
    border: 1px solid rgba(0, 245, 212, 0.2);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    margin-bottom: var(--space-5);
}

.billing-empty__icon svg {
    width: 28px;
    height: 28px;
    color: var(--neon-cyan);
    opacity: 0.5;
}

.billing-empty__title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-2) 0;
}

.billing-empty__text {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 var(--space-5) 0;
}

/* ============================================================
   LOAD MORE
   ============================================================ */

.billing-load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.billing-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    background: transparent;
    border: 1px solid rgba(0, 245, 212, 0.3);
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
    color: var(--neon-cyan);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.billing-load-more-btn svg {
    width: 16px;
    height: 16px;
}

.billing-load-more-btn:hover {
    background: rgba(0, 245, 212, 0.08);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 245, 212, 0.2);
}

.billing-load-more-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Count indicator */
.billing-count {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ============================================================
   LOADING STATE
   ============================================================ */

.billing-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-10);
}

.billing-loading__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 245, 212, 0.1);
    border-top-color: var(--neon-cyan);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.billing-loading__text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .billing-header {
        flex-direction: column;
    }

    .billing-filters {
        gap: var(--space-2);
    }

    .billing-filter-btn {
        font-size: 0.68rem;
        padding: var(--space-1) var(--space-3);
        /* Touch target: ensure minimum 44px height */
        min-height: 44px;
    }

    .billing-table td,
    .billing-table th {
        padding: var(--space-2) var(--space-3);
    }

    /* Disable hover transforms on mobile */
    .billing-load-more-btn:hover {
        transform: none;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .billing-loading__spinner,
    .val-loading {
        animation: none;
        border-top-color: var(--neon-cyan);
        border-color: rgba(0, 245, 212, 0.4);
    }
}
