/* Ecomdrive Modern Loading Component */

/* Overlay */
.ecomdrive-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.ecomdrive-loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Spinner */
.ecomdrive-loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #f0f0f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: ecomdrive-spin 0.8s linear infinite;
}

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

/* Message */
.ecomdrive-loading-message {
  margin-top: 16px;
  font-size: 15px;
  font-weight: 500;
  color: #374151;
  text-align: center;
  max-width: 280px;
  line-height: 1.5;
}

/* Sub message */
.ecomdrive-loading-submessage {
  margin-top: 8px;
  font-size: 13px;
  color: #6b7280;
  text-align: center;
}

/* Inline indicator (non-blocking) */
.ecomdrive-inline-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  color: #475569;
  margin-top: 8px;
}

.ecomdrive-inline-loader .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: ecomdrive-spin 0.8s linear infinite;
}

/* Phone validation indicator */
.ecomdrive-phone-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  transition: all 0.2s ease;
}

.ecomdrive-phone-status.validating {
  color: #6b7280;
}

.ecomdrive-phone-status.validating::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: ecomdrive-spin 0.8s linear infinite;
}

.ecomdrive-phone-status.valid {
  color: #059669;
}

.ecomdrive-phone-status.valid::before {
  content: '✓';
  font-weight: bold;
}

.ecomdrive-phone-status.invalid {
  color: #dc2626;
}

.ecomdrive-phone-status.invalid::before {
  content: '✕';
  font-weight: bold;
}

/* Button loading state */
#place_order.ecomdrive-btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

#place_order.ecomdrive-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: #fff;
  border-radius: 50%;
  animation: ecomdrive-spin 0.8s linear infinite;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .ecomdrive-loading-overlay {
    padding: 20px;
  }

  .ecomdrive-loading-spinner {
    width: 40px;
    height: 40px;
  }

  .ecomdrive-loading-message {
    font-size: 14px;
    max-width: 90%;
  }

  .ecomdrive-loading-submessage {
    font-size: 12px;
  }
}

/* Toast notification for quick feedback */
.ecomdrive-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1f2937;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 999999;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 90%;
  text-align: center;
}

.ecomdrive-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.ecomdrive-toast.success {
  background: #059669;
}

.ecomdrive-toast.error {
  background: #dc2626;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .ecomdrive-loading-overlay {
    background: rgba(17, 24, 39, 0.95);
  }

  .ecomdrive-loading-spinner {
    border-color: #374151;
    border-top-color: #60a5fa;
  }

  .ecomdrive-loading-message {
    color: #f3f4f6;
  }

  .ecomdrive-loading-submessage {
    color: #9ca3af;
  }

  .ecomdrive-inline-loader {
    background: #1f2937;
    border-color: #374151;
    color: #d1d5db;
  }
}
