/**
 * Loading States & Skeleton UI
 * Production-grade loading indicators and skeleton screens
 */

/* ============================================
   BUTTON LOADING STATES
   ============================================ */

.btn-loading,
button.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn-loading::after,
button.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}

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

/* Heart button loading state */
.project-save-btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

.project-save-btn.loading svg {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.95);
  }
}

/* ============================================
   SKELETON LOADING
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--gray-100) 25%,
    var(--gray-200) 50%,
    var(--gray-100) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}

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

/* Basket skeleton */
.basket-skeleton {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.skeleton-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--gray-200);
}

.skeleton-image {
  width: 120px;
  height: 90px;
  border-radius: 8px;
  flex-shrink: 0;
}

.skeleton-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.skeleton-title {
  height: 20px;
  width: 60%;
  border-radius: 4px;
}

.skeleton-text {
  height: 14px;
  width: 40%;
  border-radius: 4px;
}

.skeleton-price {
  height: 18px;
  width: 30%;
  border-radius: 4px;
  margin-top: auto;
}

/* Property card skeleton */
.property-skeleton {
  background: var(--white);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.property-skeleton .skeleton-image {
  width: 100%;
  height: 240px;
}

.property-skeleton .skeleton-content {
  padding: 1.5rem;
}

.property-skeleton .skeleton-title {
  height: 24px;
  width: 80%;
}

.property-skeleton .skeleton-text {
  height: 16px;
  width: 50%;
}

/* ============================================
   NAVBAR LOADING STATE
   ============================================ */

.navbar-auth-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.navbar-auth-loading .skeleton {
  height: 40px;
  width: 40px;
  border-radius: 50%;
}

.navbar-auth-loading .skeleton-text {
  height: 16px;
  width: 100px;
  border-radius: 4px;
}

/* ============================================
   FORM LOADING STATE
   ============================================ */

.form-loading {
  position: relative;
  pointer-events: none;
}

.form-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 10;
  border-radius: inherit;
}

.form-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
  z-index: 11;
}

/* ============================================
   DISABLED STATES
   ============================================ */

button:disabled,
.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================
   NETWORK STATUS NOTIFICATIONS
   ============================================ */

.network-status {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideDown 0.3s ease-out;
}

.network-status.online {
  background: #10b981;
  color: white;
}

.network-status.offline {
  background: #ef4444;
  color: white;
}

.network-status.error {
  background: #f59e0b;
  color: white;
}

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

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .btn-loading::after,
  button.loading::after,
  .form-loading::after {
    animation: none;
  }
  
  .skeleton {
    background: var(--gray-200);
  }
}
