/**
 * GLOBAL DYNAMIC REFRESH STYLING
 * =============================
 */

/* Loading indicator animations */
@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
  border-radius: inherit;
  pointer-events: none;
}

/* Smooth transitions for content updates */
[data-refresh-section] {
  transition: opacity 0.3s ease;
}

[data-refresh-section].updating {
  opacity: 0.7;
}

/* Style for AJAX links */
a[data-ajax] {
  cursor: pointer;
}

a[data-ajax]:hover {
  text-decoration: underline;
}

/* Form styling for AJAX submission */
form[data-ajax] {
  transition: all 0.3s ease;
}

form[data-ajax].submitting {
  opacity: 0.6;
  pointer-events: none;
}

/* Auto-refresh indicator */
[data-auto-refresh] {
  position: relative;
}

[data-auto-refresh]::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
  animation: pulse 2s infinite;
  opacity: 0.7;
}

/* Refresh button styling */
[data-refresh] {
  position: relative;
  overflow: hidden;
}

[data-refresh]:hover::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: slideInRefresh 0.6s;
}

@keyframes slideInRefresh {
  to {
    left: 100%;
  }
}

/* Notification styling */
.notification {
  animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.notification.success {
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
}

.notification.error {
  background: linear-gradient(135deg, #f44336 0%, #e53935 100%);
}

.notification.info {
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
}

.notification.warning {
  background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
}

/* Skeleton loading state */
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

/* Scroll restoration for dynamic navigation */
html {
  scroll-behavior: smooth;
}

/* Content placeholder during loading */
.placeholder {
  background: #f5f5f5;
  border-radius: 0.5rem;
  height: 20px;
  margin: 0.5rem 0;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Badge styling for notifications */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 2rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
}

.badge.bg-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.badge.bg-success {
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
}

.badge.bg-danger {
  background: linear-gradient(135deg, #f44336 0%, #e53935 100%);
}

/* Spinner for loading states */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(37, 99, 235, 0.3);
  border-radius: 50%;
  border-top-color: #2563eb;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Smooth page transitions */
.page-transition-enter {
  animation: fadeInUp 0.5s ease;
}

.page-transition-exit {
  animation: fadeOutDown 0.5s ease;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  [data-auto-refresh]::after {
    width: 6px;
    height: 6px;
  }

  .notification {
    bottom: 10px !important;
    right: 10px !important;
    max-width: calc(100vw - 20px) !important;
  }

  [data-refresh] {
    padding: 0.75rem 1rem;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .skeleton {
    background: linear-gradient(
      90deg,
      #333 25%,
      #444 50%,
      #333 75%
    );
  }

  .placeholder {
    background: #2a2a2a;
  }

  .notification {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  }
}
