/* ============================================
   Loading Screens & Spinners
   ============================================ */

/* Global Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.loading-overlay.hidden {
  display: none;
}

/* Dashboard Loading Screen */
.dashboard-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  border-radius: var(--radius);
}

/* Content Loading Overlay */
.content-loading {
  position: relative;
  min-height: 200px;
}

.content-loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  border-radius: var(--radius);
}

/* Spinner Animations */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-large {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

.spinner-small {
  width: 24px;
  height: 24px;
  border-width: 3px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Pulsing Dots Loader */
.dots-loader {
  display: flex;
  gap: 4px;
  align-items: center;
}

.dots-loader .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.4s ease-in-out infinite both;
}

.dots-loader .dot:nth-child(1) { animation-delay: -0.32s; }
.dots-loader .dot:nth-child(2) { animation-delay: -0.16s; }
.dots-loader .dot:nth-child(3) { animation-delay: 0s; }

@keyframes pulse {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Loading Text */
.loading-text {
  margin-top: 1rem;
  color: var(--gray-600);
  font-size: 1rem;
  font-weight: 500;
}

.loading-text-small {
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton Shapes */
.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-text.large {
  height: 24px;
}

.skeleton-text.small {
  height: 12px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-button {
  height: 36px;
  width: 100px;
  border-radius: var(--radius-sm);
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

/* Table Loading */
.table-loading {
  position: relative;
  min-height: 200px;
}

.table-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  border-radius: var(--radius);
}

/* Skeleton Table Rows */
.skeleton-table {
  width: 100%;
  border-spacing: 0;
}

.skeleton-table td {
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.skeleton-row {
  display: table-row;
}

/* Calendar Loading */
.calendar-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
}

/* Gallery Loading */
.gallery-loading {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  padding: 1rem;
}

.skeleton-image {
  aspect-ratio: 1;
  border-radius: var(--radius);
}

/* Loading States for Specific Components */
.booking-form-loading {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

.booking-form-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 4px;
  background: #f0f0f0;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 1rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  animation: progress-indeterminate 2s infinite;
}

@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Loading Button States */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .loading-overlay {
    padding: 2rem;
  }
  
  .spinner-large {
    width: 50px;
    height: 50px;
    border-width: 5px;
  }
  
  .loading-text {
    font-size: 0.9rem;
    text-align: center;
  }
  
  .gallery-loading {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    padding: 0.75rem;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .loading-overlay {
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
  }
  
  .dashboard-loading {
    background: rgba(30, 30, 30, 0.9);
    color: #fff;
  }
  
  .skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
  }
  
  .table-loading-overlay {
    background: rgba(30, 30, 30, 0.9);
    color: #fff;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .spinner,
  .dots-loader .dot,
  .skeleton,
  .progress-bar-fill,
  .btn-loading::after {
    animation: none;
  }
  
  .loading-text::after {
    content: ' (Loading...)';
  }
}

/* Loading Message Variations */
.loading-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.loading-message .icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.loading-tips {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--radius);
  max-width: 300px;
  text-align: center;
}

.loading-tips .tip {
  font-size: 0.85rem;
  color: var(--gray-600);
  font-style: italic;
}