/* ===== REALTIME DASHBOARD ANIMATIONS & STYLES ===== */

/* Live indicator styles */
.live-indicator-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  animation: fadeIn 0.3s ease-out;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.4);
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.live-dot.live-dot-active {
  background: var(--green);
  opacity: 1;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Pulsing animation for live indicator */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* KPI flash animation when updated */
.kpi-flash {
  animation: kpiFlash 0.6s ease-out;
}

@keyframes kpiFlash {
  0% {
    background: rgba(34, 197, 94, 0.15);
    transform: scale(1);
  }
  50% {
    background: rgba(34, 197, 94, 0.25);
    transform: scale(1.02);
  }
  100% {
    background: var(--glass);
    transform: scale(1);
  }
}

/* Alert slide-in animation */
.alert-slide-in {
  animation: slideInAlert 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInAlert {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Alert update flash */
.alert-update-flash {
  animation: alertUpdateFlash 0.4s ease-out;
}

@keyframes alertUpdateFlash {
  0% {
    background: inherit;
    border-left-color: var(--green);
  }
  50% {
    background: rgba(34, 197, 94, 0.15);
    border-left-color: var(--green);
  }
  100% {
    background: inherit;
    border-left-color: inherit;
  }
}

/* Badge pulse animation */
.sb-badge.badge-pulse {
  animation: badgePulse 0.6s ease-out;
}

@keyframes badgePulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Connection status indicator */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--dim3);
}

.live-indicator .live-dot {
  width: 6px;
  height: 6px;
  background: var(--amber);
  border-radius: 50%;
}

.live-indicator.connected .live-dot {
  background: var(--green);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Enhanced KPI hover with live update indication */
.kpi.kpi-updating {
  border-color: rgba(34, 197, 94, 0.3);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.1);
}

/* Alert item improvements */
.alert-item {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.alert-item:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .live-indicator-container {
    padding: 4px 8px;
    font-size: 11px;
  }

  .live-dot {
    width: 6px;
    height: 6px;
  }
}

/* Accessibility: respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .live-dot.live-dot-active,
  .kpi-flash,
  .alert-slide-in,
  .alert-update-flash,
  .sb-badge.badge-pulse,
  .live-indicator.connected .live-dot,
  .alert-item {
    animation: none !important;
    transition: none !important;
  }

  .kpi.kpi-updating {
    border-color: inherit;
    box-shadow: none;
  }
}

/* Real-time data flowing indicator */
.realtime-data-flow {
  position: relative;
  overflow: hidden;
}

.realtime-data-flow::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  animation: dataFlow 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes dataFlow {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Timestamp styling for real-time events */
.alert-time.realtime {
  color: var(--green);
  font-weight: 600;
}

.alert-time.realtime::before {
  content: '🔴 ';
  margin-right: 4px;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
