/**
 * Balance Widget Styles
 * Displays token balance, burn rate, progress bar, and top-up CTA.
 * Design: Dark Cyberpunk - neon cyan/yellow/magenta per threshold.
 */

/* ============================================================
   BALANCE WIDGET CARD
   ============================================================ */

.balance-widget {
    background: var(--bg-card);
    border: 1px solid rgba(0, 245, 212, 0.2);
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.balance-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
    opacity: 0.6;
}

.balance-widget:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 20px rgba(0, 245, 212, 0.15);
}

/* Out of tokens state */
.balance-widget--empty {
    border-color: rgba(247, 37, 133, 0.4);
}

.balance-widget--empty::before {
    background: linear-gradient(90deg, transparent, var(--neon-magenta), transparent);
}

.balance-widget--empty:hover {
    border-color: var(--neon-magenta);
    box-shadow: 0 0 20px rgba(247, 37, 133, 0.15);
}

/* Warning state (3-7 days) */
.balance-widget--warning {
    border-color: rgba(254, 228, 64, 0.3);
}

.balance-widget--warning::before {
    background: linear-gradient(90deg, transparent, var(--neon-yellow), transparent);
}

/* ============================================================
   WIDGET LAYOUT
   ============================================================ */

.balance-widget__inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-6);
}

.balance-widget__main {
    flex: 1;
    min-width: 0;
}

.balance-widget__actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-3);
    flex-shrink: 0;
}

/* ============================================================
   TOKEN AMOUNT DISPLAY
   ============================================================ */

.balance-widget__label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--space-2);
}

.balance-widget__amount {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--neon-cyan);
    text-shadow: 0 0 20px rgba(0, 245, 212, 0.4);
    line-height: 1;
    margin-bottom: var(--space-2);
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
}

.balance-widget--empty .balance-widget__amount {
    color: var(--neon-magenta);
    text-shadow: 0 0 20px rgba(247, 37, 133, 0.4);
}

.balance-widget--warning .balance-widget__amount {
    color: var(--neon-yellow);
    text-shadow: 0 0 20px rgba(254, 228, 64, 0.3);
}

.balance-widget__amount-unit {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ============================================================
   BURN RATE / DAYS REMAINING
   ============================================================ */

.balance-widget__meta {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.balance-widget__meta svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.balance-widget__meta .days-value {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--neon-cyan);
}

.balance-widget--warning .balance-widget__meta .days-value {
    color: var(--neon-yellow);
}

.balance-widget--empty .balance-widget__meta .days-value {
    color: var(--neon-magenta);
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */

.balance-widget__progress {
    margin-top: var(--space-3);
}

.balance-widget__progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    position: relative;
}

.balance-widget__progress-fill {
    height: 100%;
    width: 0%;
    background: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 245, 212, 0.6);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Warning threshold (3-7 days) */
.balance-widget__progress-fill--warning {
    background: var(--neon-yellow);
    box-shadow: 0 0 8px rgba(254, 228, 64, 0.5);
}

/* Critical threshold (<3 days) */
.balance-widget__progress-fill--critical {
    background: var(--neon-magenta);
    box-shadow: 0 0 8px rgba(247, 37, 133, 0.5);
    animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.balance-widget__progress-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-1);
}

.balance-widget__progress-text {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================
   TOP UP BUTTON (CTA)
   ============================================================ */

.balance-widget__topup-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue));
    border: none;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
    color: var(--bg-deep);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.balance-widget__topup-btn svg {
    width: 16px;
    height: 16px;
}

.balance-widget__topup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 245, 212, 0.4), 0 4px 15px rgba(0, 245, 212, 0.2);
}

/* Emergency top-up (empty state) */
.balance-widget__topup-btn--urgent {
    background: linear-gradient(135deg, var(--neon-magenta), #c7196d);
    animation: urgent-pulse 2s ease-in-out infinite;
}

.balance-widget__topup-btn--urgent:hover {
    box-shadow: 0 0 25px rgba(247, 37, 133, 0.5), 0 4px 15px rgba(247, 37, 133, 0.25);
}

@keyframes urgent-pulse {
    0%, 100% { box-shadow: 0 0 15px rgba(247, 37, 133, 0.3); }
    50% { box-shadow: 0 0 25px rgba(247, 37, 133, 0.5); }
}

/* ============================================================
   EMPTY STATE OVERLAY
   ============================================================ */

.balance-widget__empty-state {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: rgba(247, 37, 133, 0.08);
    border: 1px solid rgba(247, 37, 133, 0.3);
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
    margin-top: var(--space-3);
}

.balance-widget__empty-state svg {
    width: 18px;
    height: 18px;
    color: var(--neon-magenta);
    filter: drop-shadow(0 0 6px rgba(247, 37, 133, 0.5));
    flex-shrink: 0;
}

.balance-widget__empty-state span {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--neon-magenta);
    letter-spacing: 0.3px;
}

/* ============================================================
   LOADING SKELETON
   ============================================================ */

.balance-widget--loading .balance-widget__amount {
    color: transparent;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% auto;
    animation: skeleton-shimmer 1.5s linear infinite;
    border-radius: 4px;
    min-width: 120px;
    min-height: 2.2rem;
    text-shadow: none;
}

@keyframes skeleton-shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

/* ============================================================
   REFRESH INDICATOR
   ============================================================ */

.balance-widget__refresh {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
}

.balance-widget__refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid rgba(0, 245, 212, 0.2);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 4px 100%, 0 calc(100% - 4px));
}

.balance-widget__refresh-btn:hover {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 245, 212, 0.2);
}

.balance-widget__refresh-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.5s ease;
}

.balance-widget__refresh-btn.refreshing svg {
    animation: rotate-360 0.6s linear infinite;
}

@keyframes rotate-360 {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .balance-widget__inner {
        flex-direction: column;
        gap: var(--space-4);
    }

    .balance-widget__actions {
        flex-direction: row;
        align-items: center;
        width: 100%;
    }

    .balance-widget__topup-btn {
        flex: 1;
        justify-content: center;
    }

    .balance-widget__amount {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .balance-widget {
        padding: var(--space-4);
    }

    .balance-widget__amount {
        font-size: 1.5rem;
    }
}
