/* =========================================================
   Care Navigator — Loading States & Micro-interactions
   Version: 1.0
   Engaging animations for better UX
   ========================================================= */

/* ============================================
   SKELETON LOADING SCREENS
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #e0e0e0 20%,
    #f0f0f0 40%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(
    90deg,
    #1e293b 0%,
    #334155 20%,
    #1e293b 40%,
    #1e293b 100%
  );
  background-size: 200% 100%;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Skeleton shapes */
.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-text.large {
  height: 1.5em;
  width: 60%;
}

.skeleton-text.medium {
  height: 1.25em;
  width: 80%;
}

.skeleton-text.small {
  height: 0.875em;
  width: 40%;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-card {
  height: 200px;
  margin-bottom: 1rem;
}

.skeleton-button {
  height: 44px;
  width: 120px;
  border-radius: 10px;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.loading-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(14, 165, 233, 0.1);
  border-top-color: #0ea5e9;
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}

.loading-spinner.small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.loading-spinner.large {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

@keyframes spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(15, 23, 42, 0.9);
}

.loading-overlay.is-active {
  opacity: 1;
  pointer-events: all;
}

.loading-overlay-text {
  margin-top: 1.5rem;
  font-size: 1.125rem;
  font-weight: 500;
  color: #475569;
}

[data-theme="dark"] .loading-overlay-text {
  color: #cbd5e1;
}

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

[data-theme="dark"] .progress-bar {
  background: #334155;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9 0%, #06b6d4 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar-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: progress-shine 2s ease-in-out infinite;
}

@keyframes progress-shine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Circular progress */
.progress-circle {
  width: 80px;
  height: 80px;
  position: relative;
}

.progress-circle svg {
  transform: rotate(-90deg);
}

.progress-circle-bg {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 8;
}

[data-theme="dark"] .progress-circle-bg {
  stroke: #334155;
}

.progress-circle-fill {
  fill: none;
  stroke: #0ea5e9;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 251.2; /* 2 * π * r where r = 40 */
  stroke-dashoffset: 251.2;
  transition: stroke-dashoffset 0.5s ease;
}

.progress-circle-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}

[data-theme="dark"] .progress-circle-text {
  color: #f8fafc;
}

/* ============================================
   SUCCESS ANIMATIONS
   ============================================ */

.success-checkmark {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #22c55e;
  position: relative;
  animation: success-pop 0.5s ease;
}

@keyframes success-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.success-checkmark::after {
  content: '';
  position: absolute;
  top: 28px;
  left: 24px;
  width: 16px;
  height: 32px;
  border: solid white;
  border-width: 0 4px 4px 0;
  transform: rotate(45deg);
  animation: checkmark-draw 0.3s ease 0.2s forwards;
  opacity: 0;
}

@keyframes checkmark-draw {
  to {
    opacity: 1;
  }
}

/* Error animation */
.error-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #ef4444;
  position: relative;
  animation: error-shake 0.5s ease;
}

@keyframes error-shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

.error-icon::before,
.error-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 40px;
  background: white;
  border-radius: 2px;
}

.error-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.error-icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* ============================================
   BUTTON LOADING STATES
   ============================================ */

.btn-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}

.btn-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: spinner-rotate 0.6s linear infinite;
}

/* ============================================
   PULSE ANIMATIONS
   ============================================ */

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.pulse-ring {
  position: relative;
}

.pulse-ring::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border: 2px solid #0ea5e9;
  border-radius: 50%;
  animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}

/* ============================================
   BOUNCE ANIMATIONS
   ============================================ */

.bounce {
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* ============================================
   FADE & SLIDE ANIMATIONS
   ============================================ */

.fade-in {
  animation: fade-in 0.5s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.slide-in-up {
  animation: slide-in-up 0.5s ease;
}

@keyframes slide-in-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-in-right {
  animation: slide-in-right 0.5s ease;
}

@keyframes slide-in-right {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  min-width: 300px;
  padding: 1rem 1.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: toast-slide-in 0.3s ease;
  z-index: 10000;
}

[data-theme="dark"] .toast {
  background: #1e293b;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

@keyframes toast-slide-in {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.toast-success {
  border-left: 4px solid #22c55e;
}

.toast.toast-error {
  border-left: 4px solid #ef4444;
}

.toast.toast-warning {
  border-left: 4px solid #f59e0b;
}

.toast.toast-info {
  border-left: 4px solid #0ea5e9;
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0 0 0.25rem 0;
  color: #0f172a;
}

[data-theme="dark"] .toast-title {
  color: #f8fafc;
}

.toast-message {
  font-size: 0.875rem;
  margin: 0;
  color: #64748b;
}

[data-theme="dark"] .toast-message {
  color: #cbd5e1;
}

.toast-close {
  flex-shrink: 0;
  padding: 0.25rem;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.2s ease;
}

.toast-close:hover {
  color: #64748b;
}

/* ============================================
   RIPPLE EFFECT
   ============================================ */

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.ripple:active::after {
  width: 300px;
  height: 300px;
}

/* ============================================
   SHIMMER EFFECT
   ============================================ */

.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  to {
    left: 100%;
  }
}
