/* ===============================================
   VISUAL FEEDBACK STYLES
   Loading spinners, progress bars, animations
   =============================================== */

/* ================ Loading Overlay ================ */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.loading-overlay.fade-out {
  animation: fadeOut 0.3s ease;
}

.loading-content {
  text-align: center;
}

/* ================ Spinner ================ */
.spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 1rem;
  border: 4px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-large {
  width: 70px;
  height: 70px;
  border-width: 5px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-message {
  color: #6b7280;
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0;
}

/* ================ Progress Bar ================ */
.progress-bar-container {
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 12px;
  margin: 1rem 0;
  animation: slideDown 0.3s ease;
}

.progress-bar-container.fade-out {
  animation: fadeOut 0.3s ease;
}

.progress-bar-wrapper {
  width: 100%;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  border-radius: 6px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

.progress-fill.complete {
  background: linear-gradient(90deg, #10b981, #059669);
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.progress-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.progress-percentage {
  font-weight: 600;
  color: #2563eb;
}

.progress-message {
  color: #6b7280;
}

/* ================ Success Animation ================ */
.feedback-animation {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: white;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
              0 10px 10px -5px rgba(0, 0, 0, 0.04);
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.feedback-animation.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.feedback-content {
  text-align: center;
}

.success-icon,
.error-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
}

.success-icon svg,
.error-icon svg {
  width: 100%;
  height: 100%;
}

/* Success checkmark animation */
.success-circle {
  stroke: #10b981;
  stroke-width: 2;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-check {
  stroke: #10b981;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

/* Error cross animation */
.error-circle {
  stroke: #ef4444;
  stroke-width: 2;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.error-cross {
  stroke: #ef4444;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 54;
  stroke-dashoffset: 54;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

@keyframes stroke {
  100% {
    stroke-dashoffset: 0;
  }
}

.feedback-message {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

/* ================ Ripple Effect ================ */
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  transform: scale(0);
  animation: ripple 0.6s ease-out;
  pointer-events: none;
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Ensure buttons can contain ripples */
.btn,
button,
.tool-card,
.pill {
  position: relative;
  overflow: hidden;
}

/* ================ Pulse Animation ================ */
.pulse-animation {
  animation: pulse 1s ease-in-out;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* ================ Shake Animation ================ */
.shake-animation {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-10px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(10px);
  }
}

/* ================ Toast Notifications ================ */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  transform: translateX(400px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  border-right: 4px solid;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-success {
  border-right-color: #10b981;
}

.toast-error {
  border-right-color: #ef4444;
}

.toast-warning {
  border-right-color: #f59e0b;
}

.toast-info {
  border-right-color: #2563eb;
}

.toast-icon {
  font-size: 1.5rem;
  font-weight: bold;
  flex-shrink: 0;
}

.toast-success .toast-icon {
  color: #10b981;
}

.toast-error .toast-icon {
  color: #ef4444;
}

.toast-warning .toast-icon {
  color: #f59e0b;
}

.toast-info .toast-icon {
  color: #2563eb;
}

.toast-message {
  color: #1f2937;
  font-size: 0.95rem;
  font-weight: 500;
}

/* ================ Button Loading State ================ */
.btn.loading,
button.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after,
button.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ================ Skeleton Loading ================ */
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-title {
  height: 2em;
  width: 60%;
  margin-bottom: 1em;
}

.skeleton-card {
  height: 200px;
  border-radius: 12px;
}

/* ================ Fade Animations ================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================ Mobile Adjustments ================ */
@media (max-width: 767px) {
  #toast-container {
    right: 10px;
    left: 10px;
    top: 10px;
  }

  .toast {
    min-width: auto;
    width: 100%;
  }

  .feedback-animation {
    width: 90%;
    max-width: 400px;
    padding: 1.5rem;
  }

  .success-icon,
  .error-icon {
    width: 60px;
    height: 60px;
  }

  .spinner {
    width: 40px;
    height: 40px;
  }
}

/* ================ Reduced Motion ================ */
@media (prefers-reduced-motion: reduce) {
  .spinner,
  .progress-fill::after,
  .ripple-effect,
  .pulse-animation,
  .shake-animation,
  .skeleton {
    animation: none !important;
  }

  .feedback-animation,
  .toast {
    transition: opacity 0.1s ease;
  }
}

/* ================ High Contrast Mode ================ */
@media (prefers-contrast: high) {
  .loading-overlay {
    background: rgba(255, 255, 255, 1);
    border: 2px solid #000;
  }

  .spinner {
    border-color: #000;
    border-top-color: #2563eb;
  }

  .progress-bar {
    border: 1px solid #000;
  }

  .toast {
    border: 2px solid #000;
  }
}
