/* =================================================================
   Floating Buttons Layout System
   Manages positioning of multiple floating action buttons
   ================================================================= */

/* ---------------------------------------------
   Floating Button Container
   Groups all floating buttons with proper spacing
   --------------------------------------------- */
.floating-buttons-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  z-index: 999;
  pointer-events: none; /* Allow clicks to pass through container */
}

.floating-buttons-container > * {
  pointer-events: auto; /* Enable clicks on individual buttons */
}

/* ---------------------------------------------
   Back to Top Button Adjustments
   --------------------------------------------- */
.back-to-top-btn {
  position: relative !important; /* Override fixed positioning */
  bottom: auto !important;
  right: auto !important;
  margin: 0;
  order: 2; /* Appears below chat button */
}

/* ---------------------------------------------
   AI Chat Button Adjustments
   --------------------------------------------- */
#aiChatButton,
button#aiChatButton.manual-help-button {
  position: relative !important; /* Override fixed positioning */
  bottom: auto !important;
  right: auto !important;
  left: auto !important;
  margin: 0;
  order: 1; /* Appears above back-to-top button */
}

/* ---------------------------------------------
   Manual Help Button Adjustments
   Ensures proper positioning without overlap
   --------------------------------------------- */
#manualHelpButton,
button#manualHelpButton.manual-help-button {
  position: relative !important; /* Override fixed positioning */
  bottom: auto !important;
  right: auto !important;
  left: auto !important;
  margin: 0;
  order: 0; /* Appears at the top of the stack */
}

/* ---------------------------------------------
   Alternative: Side-by-Side Layout (if preferred)
   Uncomment to use horizontal layout instead
   --------------------------------------------- */
/*
.floating-buttons-container.horizontal {
  flex-direction: row;
  gap: var(--space-sm);
}
*/

/* ---------------------------------------------
   Smart Visibility Based on Scroll
   Hide back-to-top when near top of page
   --------------------------------------------- */
.back-to-top-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-to-top-btn:not(.visible) {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

/* ---------------------------------------------
   Responsive Adjustments
   --------------------------------------------- */
@media (max-width: 768px) {
  .floating-buttons-container {
    bottom: var(--space-lg);
    right: var(--space-lg);
    gap: var(--space-sm);
  }
  
  /* Smaller buttons on mobile */
  .back-to-top-btn {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }
  
  #aiChatButton,
  button#aiChatButton.manual-help-button,
  #manualHelpButton,
  button#manualHelpButton.manual-help-button {
    width: 56px !important;
    height: 56px !important;
  }
}

@media (max-width: 480px) {
  .floating-buttons-container {
    bottom: var(--space-md);
    right: var(--space-md);
  }
  
  /* Even smaller on very small screens */
  .back-to-top-btn {
    width: 2.25rem !important;
    height: 2.25rem !important;
  }
  
  #aiChatButton,
  button#aiChatButton.manual-help-button,
  #manualHelpButton,
  button#manualHelpButton.manual-help-button {
    width: 48px !important;
    height: 48px !important;
  }
  
  #aiChatButton i,
  button#aiChatButton.manual-help-button i,
  #manualHelpButton .help-icon,
  button#manualHelpButton.manual-help-button .help-icon {
    font-size: 1.125rem !important;
  }
}

/* ---------------------------------------------
   Animation for Button Entry
   --------------------------------------------- */
@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.floating-buttons-container > * {
  animation: floatIn 0.3s ease-out backwards;
}

.floating-buttons-container > *:nth-child(1) {
  animation-delay: 0.1s;
}

.floating-buttons-container > *:nth-child(2) {
  animation-delay: 0.2s;
}

/* ---------------------------------------------
   Tooltip Adjustments for New Layout
   --------------------------------------------- */
.floating-ai-tooltip {
  bottom: 50% !important; /* Center vertically */
  right: calc(100% + var(--space-sm)) !important; /* Position to the left */
  transform: translateY(50%) !important;
}

#aiChatButton:hover .floating-ai-tooltip,
button#aiChatButton.manual-help-button:hover .floating-ai-tooltip {
  transform: translateY(50%) translateX(-5px) !important;
}

/* ---------------------------------------------
   Focus States for Accessibility
   --------------------------------------------- */
.floating-buttons-container button:focus-visible {
  outline: 3px solid var(--ai-icon-blue);
  outline-offset: 2px;
}

/* ---------------------------------------------
   Print Styles
   --------------------------------------------- */
@media print {
  .floating-buttons-container {
    display: none !important;
  }
}