/* ═══════════════════════════════════════════════════
   ADMIN DASHBOARD — Live updates
   ═══════════════════════════════════════════════════ */

/* ─── Live Indicator (top-right of header) ─── */
.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(40,199,111,.1);
    border: 1px solid rgba(40,199,111,.25);
    border-radius: 50px;
    font-size: .72rem;
    font-weight: 700;
    color: #28c76f;
    margin-inline-start: 8px;
}
.live-indicator .live-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #28c76f;
    animation: live-pulse 1.5s ease-in-out infinite;
}
.live-indicator.paused {
    background: rgba(143,147,163,.1);
    border-color: rgba(143,147,163,.25);
    color: #8f93a3;
}
.live-indicator.paused .live-dot {
    background: #8f93a3;
    animation: none;
}
@keyframes live-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: .5; }
}

/* ─── Refresh Button ─── */
.live-refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(var(--bs-primary-rgb), .08);
    border: 1px solid rgba(var(--bs-primary-rgb), .15);
    color: var(--bs-primary);
    cursor: pointer;
    transition: all .2s;
    margin-inline-start: 8px;
}
.live-refresh-btn:hover {
    background: rgba(var(--bs-primary-rgb), .15);
    transform: rotate(180deg);
}
.live-refresh-btn.spinning {
    animation: live-spin .8s linear infinite;
}
@keyframes live-spin {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

/* ─── Animated Number ─── */
[data-live-stat] {
    transition: color .3s, background .3s, transform .3s;
    display: inline-block;
    min-width: 1ch;
}
[data-live-stat].flash-up {
    animation: flash-up .8s ease-out;
}
[data-live-stat].flash-down {
    animation: flash-down .8s ease-out;
}
@keyframes flash-up {
    0% { color: #28c76f; transform: scale(1.15); }
    100% { color: inherit; transform: scale(1); }
}
@keyframes flash-down {
    0% { color: #ea5455; transform: scale(1.15); }
    100% { color: inherit; transform: scale(1); }
}

/* ─── Update pulse dot ─── */
[data-live-stat].updating::after {
    content: '';
    display: inline-block;
    width: 5px; height: 5px;
    background: currentColor;
    border-radius: 50%;
    margin-inline-start: 4px;
    opacity: .5;
    animation: live-pulse 1s ease-in-out infinite;
}

/* ─── Skeleton (while updating) ─── */
.kpi-card.updating .stat-value {
    opacity: .6;
}

/* ─── Last update timestamp ─── */
.live-last-update {
    font-size: .7rem;
    color: var(--bs-secondary-color);
    margin-inline-start: 10px;
    font-weight: 500;
}

/* ─── Mini sparkles on update ─── */
.stat-value.updated-burst {
    position: relative;
}
.stat-value.updated-burst::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 8px;
    background: radial-gradient(circle, rgba(40,199,111,.3) 0%, transparent 70%);
    animation: burst .6s ease-out;
    pointer-events: none;
    z-index: -1;
}
@keyframes burst {
    from { transform: scale(.3); opacity: 1; }
    to { transform: scale(1.4); opacity: 0; }
}

/* ─── Manual indicator for error ─── */
.live-indicator.error {
    background: rgba(234,84,85,.1);
    border-color: rgba(234,84,85,.3);
    color: #ea5455;
}
.live-indicator.error .live-dot {
    background: #ea5455;
    animation: none;
}

/* ─── Pause when tab is hidden ─── */
@media (prefers-reduced-motion: reduce) {
    .live-indicator .live-dot { animation: none; }
    [data-live-stat].flash-up,
    [data-live-stat].flash-down { animation: none; }
}

/* ═══════════════════════════════════════════════════
   WELCOME CARD LIVE PILL (in-place design)
   ═══════════════════════════════════════════════════ */
.welcome-live {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, .18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, .25);
}
.welcome-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: rgba(40, 199, 111, .9);
    color: #fff;
    border-radius: 50px;
    font-size: .72rem;
    font-weight: 700;
    transition: all .3s;
}
.welcome-live-badge .live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: live-pulse 1.5s ease-in-out infinite;
}
.welcome-live-badge.paused {
    background: rgba(143, 147, 163, .9);
}
.welcome-live-badge.paused .live-dot {
    animation: none;
}
.welcome-live-badge.error {
    background: rgba(234, 84, 85, .9);
}
.welcome-live-badge.error .live-dot {
    animation: none;
}
.welcome-live-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .78rem;
    color: rgba(255, 255, 255, .95);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.welcome-live-time i {
    opacity: .8;
    font-size: .85rem;
}
.welcome-live-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, .25);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: all .2s;
    font-size: .85rem;
}
.welcome-live-refresh:hover {
    background: rgba(255, 255, 255, .4);
    transform: rotate(180deg);
}
.welcome-live-refresh.spinning {
    animation: live-spin .8s linear infinite;
}

@media (max-width: 767px) {
    .welcome-live {
        width: 100%;
        justify-content: space-between;
    }
}
