/* ================================================
   RDFRLTM Data Loading Enhancements
   Better visual feedback during CSV & map loading
   ================================================ */

/* ===== LOADING ANIMATIONS ===== */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

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

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== ENHANCED STATUS INDICATOR ===== */
#status {
  transition: color 0.3s ease;
}

/* Pulsing text while loading */
#status.loading {
  animation: pulse 2s ease-in-out infinite;
  color: #666;
}

/* Success state */
#status.loaded {
  color: #10b981;
  font-weight: 600;
  animation: fadeIn 0.4s ease-out;
}

/* Error state */
#status.error {
  color: #ef4444;
  font-weight: 600;
}

/* ===== SKELETON LOADING FOR PANELS ===== */
.panel.loading {
  min-height: 200px;
  position: relative;
  pointer-events: none;
}

.panel.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.8) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite linear;
  border-radius: 12px;
  pointer-events: none;
}

/* Skeleton elements */
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #e0e0e0 50%,
    #f0f0f0 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite linear;
  border-radius: 6px;
  margin: 8px 0;
}

.skeleton-title {
  height: 20px;
  width: 60%;
  margin-bottom: 12px;
}

.skeleton-text {
  height: 14px;
  width: 100%;
}

.skeleton-text.short {
  width: 40%;
}

.skeleton-button {
  height: 40px;
  width: 80px;
  display: inline-block;
  margin: 4px;
  border-radius: 10px;
}

/* ===== MAP LOADING STATE ===== */
#map.loading {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

#map.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border: 4px solid rgba(0,0,0,0.1);
  border-top-color: #2D68C4;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10000;
  background: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ===== LOADING OVERLAY FOR FULL PAGE ===== */
.data-loading-overlay {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 9999;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeIn 0.3s ease-out;
  max-width: 300px;
}

.data-loading-overlay .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e0e0e0;
  border-top-color: #2D68C4;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.data-loading-overlay .text {
  font-size: 13px;
  color: #666;
  font-weight: 600;
  line-height: 1.3;
}

.data-loading-overlay.hiding {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ===== PROGRESS STEPS ===== */
.loading-steps {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9999;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 280px;
  max-width: 320px;
  animation: fadeIn 0.3s ease-out;
}

.loading-steps .title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #111;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: #666;
  transition: color 0.3s ease;
}

.loading-step .icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.loading-step.loading .icon {
  border-color: #2D68C4;
  animation: spin 0.8s linear infinite;
}

.loading-step.loading .icon::after {
  content: '';
  width: 8px;
  height: 8px;
  background: #2D68C4;
  border-radius: 50%;
}

.loading-step.complete .icon {
  border-color: #10b981;
  background: #10b981;
  color: white;
}

.loading-step.complete .icon::after {
  content: '✓';
  font-weight: 900;
}

.loading-step.complete {
  color: #10b981;
}

.loading-step.loading {
  color: #2D68C4;
  font-weight: 600;
}

/* ===== SMOOTH TRANSITIONS ===== */
.panel,
.record,
.filter-btn,
.cam-btn {
  transition: opacity 0.3s ease;
}

.panel.hidden,
.record.hidden {
  opacity: 0.3;
  pointer-events: none;
}

/* ===== FADE IN CONTENT WHEN LOADED ===== */
.fade-in-ready {
  animation: fadeIn 0.5s ease-out;
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 900px) {
  .data-loading-overlay {
    top: 70px;
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .loading-steps {
    bottom: 12px;
    left: 12px;
    right: 12px;
    max-width: none;
  }
}

/* ===== PROGRESS BAR ===== */
.loading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #f0f0f0;
  z-index: 10001;
  overflow: hidden;
}

.loading-progress .bar {
  height: 100%;
  background: linear-gradient(90deg, #2D68C4, #4F8EF7);
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(45, 104, 196, 0.5);
}

.loading-progress .bar.indeterminate {
  width: 30%;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}