/* =========================================== */
/* BACK TO TOP BUTTON - SHARED STYLES */
/* Smart button that only appears when needed */
/* Loads LAST to override all hiding rules */
/* =========================================== */

/* Maximum specificity to override all hiding rules */
html body .back-to-top,
.back-to-top {
  position: fixed !important;
  bottom: 2rem !important;
  right: 2rem !important;
  width: 56px !important;
  height: 56px !important;
  background: #6366f1 !important;
  border: none !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: white !important;
  font-size: 1.5rem !important;
  font-weight: bold !important;
  cursor: pointer !important;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  z-index: 100000 !important;
  opacity: 0 !important;
  transform: translateY(20px) scale(0.8) !important;
  pointer-events: none !important;
  min-width: 44px !important;
  min-height: 44px !important;
  visibility: visible !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  left: auto !important;
  top: auto !important;
}

html body .back-to-top.visible,
.back-to-top.visible {
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto !important;
  visibility: visible !important;
  display: flex !important;
}

.back-to-top:hover {
  background: #4f46e5;
  transform: translateY(-4px) scale(1.05);
  box-shadow: 
    0 8px 25px rgba(99, 102, 241, 0.4),
    0 4px 10px rgba(0, 0, 0, 0.2);
  animation: pulseGlow 2s ease-in-out infinite;
}

.back-to-top:active {
  transform: translateY(-2px) scale(1.02);
  transition: all 0.1s ease;
}

.back-to-top:focus-visible {
  outline: 3px solid #6366f1;
  outline-offset: 4px;
  box-shadow: 
    0 0 0 4px rgba(99, 102, 241, 0.2),
    0 8px 25px rgba(99, 102, 241, 0.4);
}

/* Pulse glow animation */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 
      0 4px 12px rgba(99, 102, 241, 0.3),
      0 0 0 0 rgba(99, 102, 241, 0.4);
  }
  50% {
    box-shadow: 
      0 4px 12px rgba(99, 102, 241, 0.3),
      0 0 0 8px rgba(99, 102, 241, 0);
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  html body .back-to-top,
  .back-to-top {
    bottom: calc(2rem + env(safe-area-inset-bottom)) !important;
    right: 1rem !important;
    width: 48px !important;
    height: 48px !important;
    font-size: 1.25rem !important;
    display: flex !important;
    visibility: visible !important;
  }
  
  /* Hide when mobile bottom nav is visible */
  .mobile-bottom-nav:not(.hidden) ~ .back-to-top {
    bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  }
}

/* Dark mode support */
[data-bs-theme="dark"] .back-to-top {
  background: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
}

[data-bs-theme="dark"] .back-to-top:hover {
  background: #818cf8;
  box-shadow: 
    0 8px 25px rgba(99, 102, 241, 0.6),
    0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  
  @keyframes pulseGlow {
    0%, 100% {
      box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    }
  }
}

