/* Loading Spinner Styles */

/* Main Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.loading-overlay.active {
  display: flex;
}

/* Spinner Container */
.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Main Rotating Spinner */
.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #a855f7;
  border-right-color: #ec4899;
  border-bottom-color: #f59e0b;
  border-radius: 50%;
  animation: spin 1.5s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Pulsing Spinner Variant */
.spinner-pulse {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  border-radius: 50%;
  animation: pulse-spin 2s ease-in-out infinite;
}

@keyframes pulse-spin {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.5;
  }
  100% {
    transform: scale(0.8);
    opacity: 1;
  }
}

/* Dots Spinner */
.spinner-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  height: 40px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
  animation-delay: -0.32s;
}

.dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Loading Text */
.loading-text {
  color: white;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 2px;
  animation: fade-pulse 1.5s ease-in-out infinite;
}

@keyframes fade-pulse {
  0%, 100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

/* Loading Text with Dots Animation */
.loading-text.dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% {
    content: '';
  }
  40% {
    content: '.';
  }
  60% {
    content: '..';
  }
  80%, 100% {
    content: '...';
  }
}

/* Page Transition Loader (Top Bar) - Now Center Progress with Percentage */
.page-loader-bar {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  max-width: 80%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  padding: 30px;
  border-radius: 15px;
  z-index: 99999;
  display: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.page-loader-bar.active {
  display: block !important;
}

.page-loader-bar-content {
  text-align: center;
}

.page-loader-bar-title {
  color: white;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.page-loader-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  margin-bottom: 15px;
}

.page-loader-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #a855f7, #ec4899, #f59e0b);
  border-radius: 10px;
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.8);
  animation: progress-fill 1.5s ease-in-out forwards;
}

.page-loader-bar-percentage {
  color: white;
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, #a855f7, #ec4899, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes progress-fill {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

/* Button Loading State */
.btn.loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
  opacity: 0.8;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin-fast 0.8s linear infinite;
}

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

/* Mini Spinner for Button */
.mini-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin-fast 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

/* Smooth Fade In/Out */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

.fade-out {
  animation: fadeOut 0.3s ease-out;
}

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

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

/* Progress Ring Spinner */
.progress-ring {
  transform: rotate(-90deg);
  width: 60px;
  height: 60px;
}

.progress-ring-circle {
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.35s;
  stroke-dashoffset: 0;
  stroke-dasharray: 188.4;
  stroke-linecap: round;
}

.progress-ring-circle.loading {
  animation: ring-progress 2s linear infinite;
}

@keyframes ring-progress {
  0% {
    stroke-dashoffset: 188.4;
  }
  50% {
    stroke-dashoffset: 94.2;
  }
  100% {
    stroke-dashoffset: 188.4;
  }
}

/* Different Color Variations */
.spinner-primary {
  border-top-color: #0d6efd;
}

.spinner-success {
  border-top-color: #198754;
}

.spinner-danger {
  border-top-color: #dc3545;
}

.spinner-warning {
  border-top-color: #ffc107;
}

.spinner-info {
  border-top-color: #0dcaf0;
}

.spinner-custom {
  border-top-color: #a855f7;
}

/* Mobile Responsive */
@media (max-width: 576px) {
  .spinner {
    width: 50px;
    height: 50px;
    border-width: 3px;
  }

  .loading-text {
    font-size: 16px;
  }

  .spinner-container {
    gap: 15px;
  }
}

/* Accessibility - Prefers Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .spinner,
  .spinner-pulse,
  .dot,
  .loading-text,
  .page-loader-bar,
  .btn.loading::after,
  .mini-spinner,
  .progress-ring-circle.loading {
    animation: none !important;
  }

  .spinner {
    opacity: 0.7;
  }

  .spinner-pulse {
    opacity: 0.7;
  }
}
