/* =================================================================
   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;
  align-items: flex-end; /* Right-align children so buttons hug the corner */
  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
   --------------------------------------------- */
.floating-buttons-container .back-to-top-btn {
  position: relative !important; /* Only override when inside container */
  bottom: auto !important;
  right: auto !important;
  margin: 0;
  order: 2; /* Appears below chat button */
}

/* ---------------------------------------------
   AI Chat Button Adjustments
   --------------------------------------------- */
.floating-buttons-container #aiChatButton,
.floating-buttons-container 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
   --------------------------------------------- */
.floating-buttons-container #manualHelpButton,
.floating-buttons-container 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 */
}

/* ---------------------------------------------
   Manual Help Button - Base Component Styles
   Unified design for floating help buttons
   --------------------------------------------- */
.manual-help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: var(--ai-accent-gradient, linear-gradient(135deg, #6e8efb, #a777e3));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  pointer-events: auto; /* Enable clicks (container is pointer-events: none) */
}

.manual-help-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.manual-help-button:active { transform: translateY(0); }
.manual-help-button:focus-visible { outline: 3px solid rgba(99, 102, 241, 0.5); outline-offset: 2px; }

.manual-help-button .help-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
}

.manual-help-button .help-text {
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ---------------------------------------------
   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 */
  .floating-buttons-container .back-to-top-btn {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }
  
  .manual-help-button {
    padding: 0.75rem 1rem;
  }
  .manual-help-button .help-text { display: none; }
  
  .floating-buttons-container #aiChatButton,
  .floating-buttons-container button#aiChatButton.manual-help-button,
  .floating-buttons-container #manualHelpButton,
  .floating-buttons-container 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 */
  .floating-buttons-container .back-to-top-btn {
    width: 2.25rem !important;
    height: 2.25rem !important;
  }
  
  .floating-buttons-container #aiChatButton,
  .floating-buttons-container button#aiChatButton.manual-help-button,
  .floating-buttons-container #manualHelpButton,
  .floating-buttons-container button#manualHelpButton.manual-help-button {
    width: 48px !important;
    height: 48px !important;
  }
  
  .floating-buttons-container #aiChatButton i,
  .floating-buttons-container button#aiChatButton.manual-help-button i,
  .floating-buttons-container #manualHelpButton .help-icon,
  .floating-buttons-container 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;
  }
  .manual-help-button { display: none !important; }
}
