/* Loading States */
.loading {
  opacity: 0.7;
  cursor: not-allowed !important;
  pointer-events: none;
}

.loading-spinner {
  display: none;
  animation: spin 1s linear infinite;
}

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

/* Button Loading States */
.btn.loading {
  position: relative;
  color: transparent !important;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

/* Error Notifications */
.error-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  background: #ff453a;
  color: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(255, 69, 58, 0.3);
  max-width: 400px;
  min-width: 300px;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out, opacity 0.3s ease;
  opacity: 0;
}

.error-notification.show {
  transform: translateX(0);
  opacity: 1;
}

.error-notification.hidden {
  transform: translateX(100%);
  opacity: 0;
}

.error-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.error-content svg {
  flex-shrink: 0;
  color: white;
}

.error-text {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.error-close {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.error-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Success Notifications */
.success-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  background: #30d158;
  color: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(48, 209, 88, 0.3);
  max-width: 400px;
  min-width: 300px;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out, opacity 0.3s ease;
  opacity: 0;
}

.success-notification.show {
  transform: translateX(0);
  opacity: 1;
}

/* Form Loading States */
form.loading input,
form.loading textarea,
form.loading select {
  opacity: 0.5;
  pointer-events: none;
}

/* Mobile-specific adjustments */
@media (max-width: 480px) {
  .error-notification,
  .success-notification {
    left: 16px;
    right: 16px;
    max-width: none;
    min-width: 0;
    top: 80px; /* Account for mobile headers */
  }
  
  .error-notification.show,
  .success-notification.show {
    transform: translateY(0);
  }
  
  .error-notification,
  .success-notification {
    transform: translateY(-100px);
  }
  
  .error-notification.hidden,
  .success-notification.hidden {
    transform: translateY(-100px);
  }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
  .error-notification {
    background: #ff6b5a;
    box-shadow: 0 4px 20px rgba(255, 107, 90, 0.4);
  }
  
  .success-notification {
    background: #32d74b;
    box-shadow: 0 4px 20px rgba(50, 215, 75, 0.4);
  }
}

/* Loading overlay for full-page loads */
.page-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.page-loading.show {
  opacity: 1;
  visibility: visible;
}

.page-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #333;
  border-top: 4px solid #007aff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* iOS-style loading states */
.ios-loading-button {
  position: relative;
  overflow: hidden;
}

.ios-loading-button.loading {
  color: transparent !important;
}

.ios-loading-button.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Skeleton loading for content */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

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

.skeleton-text {
  height: 1em;
  border-radius: 4px;
  margin-bottom: 0.5em;
}

.skeleton-text:last-child {
  margin-bottom: 0;
  width: 80%;
}

@media (prefers-color-scheme: dark) {
  .skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
  }
}