/**
 * FLUX Platform - Global Styles & Animations
 */

/* ============================================
   SKELETON ANIMATION
   ============================================ */
@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.animate-skeleton {
  background: linear-gradient(
    90deg,
    #f1f5f9 0%,
    #e2e8f0 25%,
    #f1f5f9 50%,
    #e2e8f0 75%,
    #f1f5f9 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* ============================================
   TOAST ANIMATIONS
   ============================================ */
@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast-enter {
  animation: toast-slide-in 0.3s ease-out forwards;
}

.toast-exit {
  animation: toast-slide-out 0.2s ease-in forwards;
}

/* ============================================
   MODAL ANIMATIONS
   ============================================ */
@keyframes modal-backdrop-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-content-scale {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-backdrop {
  animation: modal-backdrop-fade 0.2s ease-out forwards;
}

.modal-content {
  animation: modal-content-scale 0.3s ease-out forwards;
}

/* ============================================
   STAGGERED ANIMATIONS
   ============================================ */
@keyframes stagger-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stagger-animation > * {
  opacity: 0;
  animation: stagger-fade-in 0.4s ease-out forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0ms; }
.stagger-animation > *:nth-child(2) { animation-delay: 50ms; }
.stagger-animation > *:nth-child(3) { animation-delay: 100ms; }
.stagger-animation > *:nth-child(4) { animation-delay: 150ms; }
.stagger-animation > *:nth-child(5) { animation-delay: 200ms; }
.stagger-animation > *:nth-child(6) { animation-delay: 250ms; }
.stagger-animation > *:nth-child(7) { animation-delay: 300ms; }
.stagger-animation > *:nth-child(8) { animation-delay: 350ms; }

/* ============================================
   FLOATING ANIMATION
   ============================================ */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-6px);
  }
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* ============================================
   PULSE GLOW ANIMATION
   ============================================ */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
  }
}

.animate-pulse-glow {
  animation: pulse-glow 2s ease-in-out infinite;
}

/* ============================================
   PROGRESS BAR ANIMATION
   ============================================ */
@keyframes progress-stripe {
  0% {
    background-position: 1rem 0;
  }
  100% {
    background-position: 0 0;
  }
}

.progress-striped {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
  background-size: 1rem 1rem;
  animation: progress-stripe 1s linear infinite;
}

/* ============================================
   RIPPLE EFFECT
   ============================================ */
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple-effect {
  position: relative;
  overflow: hidden;
}

.ripple-effect::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.3) 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 0.5s;
}

.ripple-effect:active::after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}

/* ============================================
   CARD HOVER EFFECTS
   ============================================ */
.card-hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ============================================
   NUMBER COUNTER TRANSITION
   ============================================ */
.number-transition {
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

/* ============================================
   GRADIENT TEXT
   ============================================ */
.gradient-text {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   STATUS INDICATORS
   ============================================ */
@keyframes status-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.9);
  }
}

.status-indicator {
  position: relative;
}

.status-indicator::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  top: 50%;
  left: -16px;
  transform: translateY(-50%);
}

.status-indicator.active::before {
  background-color: #10b981;
  animation: status-pulse 2s ease-in-out infinite;
}

.status-indicator.pending::before {
  background-color: #f59e0b;
  animation: status-pulse 1.5s ease-in-out infinite;
}

.status-indicator.error::before {
  background-color: #ef4444;
}

/* ============================================
   TABLE ROW ANIMATION
   ============================================ */
@keyframes table-row-enter {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.table-row-animated {
  animation: table-row-enter 0.3s ease-out forwards;
}

/* ============================================
   LOADING DOTS
   ============================================ */
@keyframes loading-dots {
  0%, 20% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-6px);
  }
  60%, 100% {
    transform: translateY(0);
  }
}

.loading-dots span {
  display: inline-block;
  animation: loading-dots 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ============================================
   FORM FOCUS ANIMATION
   ============================================ */
.input-focus-animated {
  position: relative;
}

.input-focus-animated::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  transition: all 0.3s ease;
  transform: translateX(-50%);
}

.input-focus-animated:focus-within::after {
  width: 100%;
}

/* ============================================
   BADGE PULSE
   ============================================ */
.badge-pulse {
  position: relative;
}

.badge-pulse::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background-color: #ef4444;
  border-radius: 50%;
  animation: status-pulse 1.5s ease-in-out infinite;
}

/* ============================================
   CHART ANIMATIONS
   ============================================ */
@keyframes chart-bar-grow {
  from {
    transform: scaleY(0);
    transform-origin: bottom;
  }
  to {
    transform: scaleY(1);
    transform-origin: bottom;
  }
}

.chart-bar-animated {
  animation: chart-bar-grow 0.6s ease-out forwards;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.transition-smooth {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.hover-brightness:hover {
  filter: brightness(1.05);
}

/* Prevent layout shift during loading */
.min-h-card {
  min-height: 180px;
}

.min-h-table-row {
  min-height: 64px;
}

/* Scrollbar for modals and panels */
.custom-scrollbar::-webkit-scrollbar {
  width: 4px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

/* Dark mode base styles */
.dark {
  color-scheme: dark;
}

.dark body {
  background-color: #0B1120;
  color: #e2e8f0;
}

/* Dark mode skeleton */
.dark .animate-skeleton {
  background: linear-gradient(
    90deg,
    #1e293b 0%,
    #334155 25%,
    #1e293b 50%,
    #334155 75%,
    #1e293b 100%
  );
}

/* Dark mode scrollbar */
.dark .custom-scrollbar::-webkit-scrollbar-track {
  background: #1e293b;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
  background: #475569;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Dark mode glass effect */
.dark .glass {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
}

.dark .glass-card {
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(51, 65, 85, 0.5);
}

/* Dark mode card hover */
.dark .card-hover-lift:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* ============================================
   RIPPLE ANIMATION FOR BUTTONS
   ============================================ */
@keyframes ripple-expand {
  from {
    transform: scale(0);
    opacity: 0.5;
  }
  to {
    transform: scale(4);
    opacity: 0;
  }
}

.animate-ripple {
  animation: ripple-expand 0.6s ease-out forwards;
}

/* ============================================
   FADE IN UP ANIMATION
   ============================================ */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fade-in-up 0.4s ease-out forwards;
}

/* ============================================
   FADE IN ANIMATION
   ============================================ */
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.animate-fade-in {
  animation: fade-in 0.3s ease-out forwards;
}

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

/* ============================================
   FOCUS VISIBLE STYLES
   ============================================ */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.dark *:focus-visible {
  outline-color: #60a5fa;
}

/* ============================================
   SCREEN READER ONLY
   ============================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only:focus,
.not-sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}
