/* Need Help floating launcher — additive only, does not modify dashboard_header.css.
   z-index is kept below .modal-overlay's 1000 (see dashboard.css / employee_dashboard.css
   / companies.css) so the open Need Help modal always covers the launcher.
   Sits in the bottom-right corner with a gap that scales with the viewport
   (12px on phones up to 24px at ≥1920px) plus the notch/home-indicator inset,
   and moves up only while the guidance pill (contextual_guidance.css) or the
   phone translation helper (translation_onboarding.css) is showing. */

.need-help-button {
  position: fixed;
  right: calc(clamp(12px, 1.25vw, 24px) + env(safe-area-inset-right, 0px));
  bottom: calc(clamp(12px, 1.25vw, 24px) + env(safe-area-inset-bottom, 0px));
  z-index: 999;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: none;
  border-radius: 9999px;
  background: #00008b;
  color: #ffffff;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.need-help-button:hover {
  background: #00006e;
}

.need-help-button:focus-visible {
  outline: 3px solid rgba(0, 0, 139, 0.3);
  outline-offset: 2px;
}

/* The pill is shown by guidance_controller.js setting an inline display: flex
   (its markup starts at display: none). 88px = the pill's 24px + its height + gap. */
body:has(.guidance-floating-pill[style*="display: flex"]) .need-help-button {
  bottom: 88px;
}

/* Phones: the corner is the top of the bottom nav (pwa_base.css §7b).
   The launcher is a 44px circle here: the labelled pill (~170px wide) covered
   the cards and buttons it floated over. Its label stays in the accessibility
   tree, visually hidden. It no longer climbs above the translation helper —
   the helper leaves it the corner instead (translation_onboarding.css) — so a
   longer helper text can no longer slide under it and hide the helper's close
   button. */
@media (max-width: 768px) {
  .need-help-button {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 12px);
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .need-help-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* Above the pill, which sits at the same nav + 12px. */
  body:has(.guidance-floating-pill[style*="display: flex"]) .need-help-button {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 64px);
  }

  /* Content can scroll clear of the launcher (nav 64 + 12 + 44 + 12), or of the
     launcher stacked above the guidance pill. pwa_base.css §10 only clears the
     nav, so the last card's actions used to stay under the launcher. */
  .pwa-root:has([data-mobile-nav]):has(.need-help-button) .dashboard-main,
  .pwa-root:has([data-mobile-nav]):has(.need-help-button) .employee-dashboard-main {
    padding-bottom: calc(132px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .pwa-root:has([data-mobile-nav]):has(.need-help-button):has(.guidance-floating-pill[style*="display: flex"]) .dashboard-main,
  .pwa-root:has([data-mobile-nav]):has(.need-help-button):has(.guidance-floating-pill[style*="display: flex"]) .employee-dashboard-main {
    padding-bottom: calc(184px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Browsers without :has() (Safari < 15.4, Chrome < 105, Firefox < 121) drop
     every rule above that uses it. Without this, the translation helper would
     run under the launcher's corner and the page would keep only pwa_base's
     clearance. They get the side-by-side layout and the largest clearance. */
  @supports not selector(:has(*)) {
    .translation-helper-wrapper {
      right: calc(12px + 44px + 8px);
    }

    .dashboard-main,
    .employee-dashboard-main {
      padding-bottom: calc(214px + env(safe-area-inset-bottom, 0px)) !important;
    }
  }

  /* The translation helper is the tallest of the three (translation_onboarding.css,
     214px); same specificity as the pill rule above and later, so it wins. */
  .pwa-root:has([data-mobile-nav]):has(.need-help-button):has(.translation-helper-wrapper:not(.is-hidden)) .dashboard-main,
  .pwa-root:has([data-mobile-nav]):has(.need-help-button):has(.translation-helper-wrapper:not(.is-hidden)) .employee-dashboard-main {
    padding-bottom: calc(214px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
