/* =========================================== */
/* FINAL POLISH - Award-Winning Details */
/* Loading States, Error Handling, SEO, A11y */
/* =========================================== */

/* ===== SKELETON LOADING STATES ===== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 0%,
    var(--bg-tertiary) 50%,
    var(--bg-secondary) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
  color: transparent;
  user-select: none;
  pointer-events: none;
}

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

.skeleton-text {
  height: 1em;
  margin: 0.5em 0;
  border-radius: var(--radius-sm);
}

.skeleton-title {
  height: 2em;
  width: 60%;
  margin-bottom: 1em;
}

.skeleton-card {
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  border: 2px solid var(--border-light);
}

.skeleton-button {
  height: 44px;
  width: 150px;
  border-radius: var(--radius-lg);
}

.skeleton-badge {
  height: 32px;
  width: 120px;
  border-radius: var(--radius-full);
}

/* ===== LOADING SPINNER - PREMIUM ===== */
.loading-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-primary-200);
  border-top-color: var(--color-primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-spinner.large {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

.loading-spinner.small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

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

/* ===== ERROR STATES - FRIENDLY & HELPFUL ===== */
.error-state {
  padding: var(--space-8);
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 2px solid #fca5a5;
  border-radius: var(--radius-2xl);
  text-align: center;
  animation: errorEntrance var(--transition-bounce);
}

.error-state-icon {
  font-size: var(--font-5xl);
  margin-bottom: var(--space-4);
  display: block;
}

.error-state-title {
  font-size: var(--font-xl);
  font-weight: var(--weight-bold);
  color: #991b1b;
  margin-bottom: var(--space-2);
}

.error-state-message {
  color: #7f1d1d;
  margin-bottom: var(--space-4);
}

.error-state-action {
  margin-top: var(--space-4);
}

@keyframes errorEntrance {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ===== SUCCESS STATES - CELEBRATORY ===== */
.success-state {
  padding: var(--space-8);
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 2px solid #86efac;
  border-radius: var(--radius-2xl);
  text-align: center;
  animation: successEntrance var(--transition-bounce);
}

.success-state-icon {
  font-size: var(--font-5xl);
  margin-bottom: var(--space-4);
  display: block;
  animation: successBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-state-title {
  font-size: var(--font-xl);
  font-weight: var(--weight-bold);
  color: #166534;
  margin-bottom: var(--space-2);
}

.success-state-message {
  color: #14532d;
  margin-bottom: var(--space-4);
}

@keyframes successEntrance {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes successBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.1); }
}

/* ===== EMPTY STATES - ENCOURAGING ===== */
.empty-state {
  padding: var(--space-12) var(--space-8);
  text-align: center;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: var(--font-6xl);
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--font-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state-message {
  font-size: var(--font-base);
  margin-bottom: var(--space-6);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== SKIP TO CONTENT - ACCESSIBILITY ===== */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 10000;
  padding: var(--space-3) var(--space-5);
  background: var(--color-primary-500);
  color: var(--text-inverse);
  text-decoration: none;
  border-radius: var(--radius-lg);
  font-weight: var(--weight-semibold);
  transition: top var(--transition-fast);
}

.skip-to-content:focus {
  top: var(--space-4);
  outline: 3px solid var(--color-primary-700);
  outline-offset: 2px;
}

/* ===== FOCUS VISIBLE ENHANCEMENTS ===== */
*:focus-visible {
  outline: 3px solid var(--color-primary-500);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--color-primary-500);
  outline-offset: 2px;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 400px;
  pointer-events: none;
}

.toast {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-primary);
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  pointer-events: auto;
  animation: toastSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
}

.toast.success {
  border-color: var(--color-success);
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.toast.error {
  border-color: #fca5a5;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.toast.info {
  border-color: var(--color-info);
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.toast-icon {
  font-size: var(--font-xl);
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: var(--font-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.toast-close {
  background: none;
  border: none;
  font-size: var(--font-lg);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  opacity: 1;
}

@keyframes toastSlideIn {
  0% {
    opacity: 0;
    transform: translateX(400px) rotateY(-15deg);
  }
  100% {
    opacity: 1;
    transform: translateX(0) rotateY(0deg);
  }
}

/* ===== PROGRESS INDICATORS ===== */
.progress-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary-300);
  animation: progressPulse 1.4s ease-in-out infinite;
}

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

.progress-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes progressPulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    max-width: none;
  }
  
  .toast {
    padding: var(--space-3) var(--space-4);
  }
  
  .error-state,
  .success-state {
    padding: var(--space-6);
  }
}

/* ===== PRINT OPTIMIZATIONS ===== */
@media print {
  .skip-to-content,
  .toast-container,
  .loading-spinner,
  .skeleton {
    display: none !important;
  }
  
  .error-state,
  .success-state {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .loading-spinner,
  .progress-dot,
  .toast {
    animation: none !important;
  }
  
  .error-state,
  .success-state {
    animation: none !important;
  }
}

