/* ==========================================================================
   IONITY CENTRAL - VISUAL ENHANCEMENTS SYSTEM
   Particle effects, advanced glassmorphism, micro-interactions, and cinematic animations
   Brand: Ionity Global / Antwerp Designs
   ========================================================================== */

/* ==================== PARTICLE CANVAS OVERLAY ==================== */
#particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

/* ==================== ANIMATED GRID BACKGROUND ==================== */
.animated-grid-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(51, 102, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(51, 102, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: gridShift 20s linear infinite;
}

@keyframes gridShift {
  0% { background-position: 0 0; }
  100% { background-position: 48px 48px; }
}

/* ==================== AURORA GLOW EFFECTS ==================== */
.aurora-glow {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  z-index: -1;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(51, 102, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 229, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 40% 80%, rgba(0, 230, 118, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(157, 78, 221, 0.05) 0%, transparent 50%);
  animation: auroraShift 15s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes auroraShift {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); }
  33% { transform: translate(2%, -1%) rotate(1deg) scale(1.02); }
  66% { transform: translate(-1%, 2%) rotate(-0.5deg) scale(0.98); }
  100% { transform: translate(1%, -2%) rotate(0.5deg) scale(1.01); }
}

/* ==================== ENHANCED GLASSMORPHISM ==================== */
.glass-card {
  background: rgba(34, 34, 34, 0.55);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
}

.glass-card:hover {
  border-color: rgba(51, 102, 255, 0.3);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(51, 102, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

/* Glass card accent variants */
.glass-card.accent-blue { border-left: 3px solid var(--accent-primary); }
.glass-card.accent-green { border-left: 3px solid var(--status-green); }
.glass-card.accent-gold { border-left: 3px solid var(--accent-8bit-gold); }
.glass-card.accent-red { border-left: 3px solid var(--status-red); }
.glass-card.accent-purple { border-left: 3px solid var(--status-purple); }
.glass-card.accent-cyan { border-left: 3px solid var(--status-cyan); }

/* ==================== NEON GLOW UTILITIES ==================== */
.glow-blue { text-shadow: 0 0 10px rgba(51, 102, 255, 0.6), 0 0 20px rgba(51, 102, 255, 0.3); }
.glow-green { text-shadow: 0 0 10px rgba(0, 230, 118, 0.6), 0 0 20px rgba(0, 230, 118, 0.3); }
.glow-gold { text-shadow: 0 0 10px rgba(255, 160, 0, 0.6), 0 0 20px rgba(255, 160, 0, 0.3); }
.glow-red { text-shadow: 0 0 10px rgba(255, 61, 113, 0.6), 0 0 20px rgba(255, 61, 113, 0.3); }
.glow-cyan { text-shadow: 0 0 10px rgba(0, 229, 255, 0.6), 0 0 20px rgba(0, 229, 255, 0.3); }

.glow-box-blue { box-shadow: 0 0 20px rgba(51, 102, 255, 0.3), 0 0 40px rgba(51, 102, 255, 0.1); }
.glow-box-green { box-shadow: 0 0 20px rgba(0, 230, 118, 0.3), 0 0 40px rgba(0, 230, 118, 0.1); }
.glow-box-gold { box-shadow: 0 0 20px rgba(255, 160, 0, 0.3), 0 0 40px rgba(255, 160, 0, 0.1); }

/* ==================== ANIMATED BORDER GRADIENT ==================== */
.animated-border {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.animated-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: conic-gradient(
    from var(--border-angle, 0deg),
    transparent 0%,
    var(--accent-primary) 10%,
    var(--status-cyan) 20%,
    transparent 30%
  );
  animation: borderRotate 4s linear infinite;
  border-radius: inherit;
  z-index: -1;
}

.animated-border::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: var(--bg-surface);
  border-radius: calc(var(--radius-lg) - 2px);
  z-index: -1;
}

@property --border-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes borderRotate {
  to { --border-angle: 360deg; }
}

/* ==================== KPI METRIC CARDS ==================== */
.kpi-card {
  background: rgba(34, 34, 34, 0.6);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}

.kpi-card.kpi-blue::before { background: linear-gradient(90deg, #3366FF, #60A5FA); }
.kpi-card.kpi-green::before { background: linear-gradient(90deg, #00E676, #69F0AE); }
.kpi-card.kpi-gold::before { background: linear-gradient(90deg, #FFA000, #FFD54F); }
.kpi-card.kpi-red::before { background: linear-gradient(90deg, #FF3D71, #FF7096); }
.kpi-card.kpi-purple::before { background: linear-gradient(90deg, #9D4EDD, #C084FC); }
.kpi-card.kpi-cyan::before { background: linear-gradient(90deg, #00E5FF, #67E8F9); }

.kpi-card:hover {
  transform: translateY(-4px);
  border-color: rgba(51, 102, 255, 0.3);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(51, 102, 255, 0.1);
}

.kpi-card .kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.kpi-card.kpi-blue .kpi-icon { background: rgba(51, 102, 255, 0.15); color: #60A5FA; }
.kpi-card.kpi-green .kpi-icon { background: rgba(0, 230, 118, 0.15); color: #69F0AE; }
.kpi-card.kpi-gold .kpi-icon { background: rgba(255, 160, 0, 0.15); color: #FFD54F; }
.kpi-card.kpi-red .kpi-icon { background: rgba(255, 61, 113, 0.15); color: #FF7096; }
.kpi-card.kpi-purple .kpi-icon { background: rgba(157, 78, 221, 0.15); color: #C084FC; }
.kpi-card.kpi-cyan .kpi-icon { background: rgba(0, 229, 255, 0.15); color: #67E8F9; }

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-card .kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 10px;
}

.kpi-card .kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}

.kpi-trend.up {
  background: rgba(0, 230, 118, 0.12);
  color: var(--status-green);
}

.kpi-trend.down {
  background: rgba(255, 61, 113, 0.12);
  color: var(--status-red);
}

.kpi-trend.neutral {
  background: rgba(255, 160, 0, 0.12);
  color: var(--accent-8bit-gold);
}

/* ==================== SPARKLINE MINI CHART ==================== */
.sparkline-container {
  height: 32px;
  margin-top: 8px;
  position: relative;
}

.sparkline-container svg {
  width: 100%;
  height: 100%;
}

/* ==================== ANIMATED COUNTER ==================== */
.counter-animate {
  display: inline-block;
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==================== PULSE RING ANIMATION ==================== */
.pulse-ring {
  position: relative;
}

.pulse-ring::before,
.pulse-ring::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  animation: pulseRing 2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.pulse-ring::after {
  animation-delay: 1s;
}

@keyframes pulseRing {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ==================== SHIMMER LOADING ==================== */
.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 50%,
    transparent 100%
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ==================== ENHANCED BUTTONS ==================== */
.btn-glow {
  position: relative;
  overflow: hidden;
}

.btn-glow::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.2), transparent 70%);
  transform: translate(-50%, -50%);
  transition: width 0.5s, height 0.5s;
  border-radius: 50%;
}

.btn-glow:hover::before {
  width: 300px;
  height: 300px;
}

.btn-glow::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(51,102,255,0.5), rgba(0,229,255,0.5), rgba(51,102,255,0.5));
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-glow:hover::after {
  opacity: 1;
  animation: borderGlow 2s linear infinite;
}

@keyframes borderGlow {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* ==================== FLOATING ACTION BUTTON ==================== */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-primary), #254EDB);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(51, 102, 255, 0.4);
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.fab:hover {
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 12px 32px rgba(51, 102, 255, 0.6);
}

.fab:active {
  transform: scale(0.95);
}

/* ==================== TOAST NOTIFICATIONS ENHANCED ==================== */
.toast-enhanced {
  background: rgba(34, 34, 34, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.toast-enhanced::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent-primary);
  animation: toastTimer 4s linear forwards;
}

.toast-enhanced.success::before { background: var(--status-green); }
.toast-enhanced.error::before { background: var(--status-red); }
.toast-enhanced.warning::before { background: var(--accent-8bit-gold); }

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

@keyframes toastTimer {
  from { width: 100%; }
  to { width: 0%; }
}

/* ==================== MICRO-INTERACTIONS ==================== */
.hover-lift {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.hover-scale {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.hover-scale:hover {
  transform: scale(1.03);
}

.hover-glow {
  transition: all 0.25s ease;
}

.hover-glow:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 20px rgba(51, 102, 255, 0.3);
}

/* ==================== STAGGER ANIMATION ==================== */
.stagger-in > * {
  opacity: 0;
  transform: translateY(16px);
  animation: staggerFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-in > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-in > *:nth-child(8) { animation-delay: 0.4s; }

@keyframes staggerFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ==================== PROGRESS RING ==================== */
.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-circle {
  transition: stroke-dashoffset 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  stroke-linecap: round;
}

/* ==================== GRADIENT TEXT ==================== */
.gradient-text-blue {
  background: linear-gradient(135deg, #3366FF, #00E5FF);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-green {
  background: linear-gradient(135deg, #00E676, #69F0AE);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-gold {
  background: linear-gradient(135deg, #FFA000, #FFD54F);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-rainbow {
  background: linear-gradient(135deg, #3366FF, #00E5FF, #00E676, #FFA000, #FF3D71, #9D4EDD);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ==================== SIDEBAR ENHANCEMENTS ==================== */
.sidebar .nav-item {
  position: relative;
  overflow: hidden;
}

.sidebar .nav-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(51, 102, 255, 0.06), transparent);
  transform: translateX(-100%);
  transition: transform 0.4s ease;
}

.sidebar .nav-item:hover::after {
  transform: translateX(100%);
}

/* ==================== ENHANCED SCROLLBAR ==================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(26, 26, 26, 0.5);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-primary), #254EDB);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--accent-hover), var(--accent-primary));
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* ==================== VIEW TRANSITION EFFECTS ==================== */
.view-section.active {
  animation: viewEnter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* ==================== STATUS INDICATORS ==================== */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
}

.status-dot.online {
  background: var(--status-green);
  box-shadow: 0 0 8px var(--status-green);
}

.status-dot.online::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--status-green);
  animation: statusPing 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes statusPing {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2); opacity: 0; }
}

/* ==================== SKELETON LOADER ==================== */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.03) 0%,
    rgba(255,255,255,0.06) 50%,
    rgba(255,255,255,0.03) 100%
  );
  background-size: 200% 100%;
  animation: skeletonLoad 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

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

/* ==================== RESPONSIVE ENHANCEMENTS ==================== */
@media (max-width: 768px) {
  .kpi-card .kpi-value {
    font-size: 22px;
  }

  .fab {
    bottom: 80px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
}

/* ==================== DARK MODE REFINEMENTS ==================== */
@media (prefers-color-scheme: dark) {
  .glass-card {
    background: rgba(26, 26, 26, 0.7);
  }
}

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .aurora-glow, .animated-grid-bg, #particle-canvas {
    display: none;
  }
}
