/* CSP-safe tooltip styles (renders below icon by default, wraps, avoids viewport overflow) */
.tooltip-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0;
  margin-left: 0.5rem;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
}

/* Tooltip box - render below icon, wrap text, avoid scrollbars */
.tooltip-trigger::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);     /* render below icon */
  transform: translateX(-50%) translateY(6px);
  display: inline-block;
  box-sizing: border-box;
  min-width: 12rem;
  max-width: 48rem;          /* keep wide but constrained */
  padding: 0.35rem 0.5rem;   /* reduce height */
  border-radius: 0.35rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.95);
  font-size: 0.95rem;
  line-height: 1.18;         /* denser lines to reduce height */
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;         /* show all lines, no internal scrollbar */
  background-clip: padding-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 21000;            /* above modal layers */
  box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.28);
  text-align: left;
}

/* arrow position adjusted slightly to match new tooltip dimensions */
.tooltip-trigger::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(0,0,0,0.95) transparent transparent transparent;
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 21001;
}

/* Show on hover/focus/active */
.tooltip-trigger:hover::after,
.tooltip-trigger:focus::after,
.tooltip-trigger:active::after,
.tooltip-trigger:hover::before,
.tooltip-trigger:focus::before,
.tooltip-trigger:active::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Optional: flip above when .tooltip-top is present */
.tooltip-trigger.tooltip-top::after {
  top: auto;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(6px);
}
.tooltip-trigger.tooltip-top::before {
  top: auto;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
}

/* Accessibility focus outline */
.tooltip-trigger:focus {
  outline: 2px solid rgba(0,123,255,0.25);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Icon sizing */
.tooltip-trigger .bi {
  font-size: 1rem;
  vertical-align: middle;
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .tooltip-trigger::after {
    left: 50%;
    top: calc(100% + 8px);
    transform: translateX(-50%) translateY(0);
    max-width: calc(100% - 2rem);
  }
  .tooltip-trigger::before { display: none; }
}

/* Optional: small scrollbar styling for WebKit to make it less obtrusive */
.tooltip-trigger::after::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.tooltip-trigger::after::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 6px;
}
.tooltip-trigger::after::-webkit-scrollbar-track {
  background: transparent;
}

/* hide scrollbar rules (no longer needed) */
.tooltip-trigger::after::-webkit-scrollbar { display: none; }

/* Portal tooltip (used by JS) */
.tooltip-portal {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate3d(0,0,0);
  box-sizing: border-box;
  max-width: 90vw;
  min-width: 14rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.35rem;
  color: #fff;
  background: rgba(0,0,0,0.95);
  font-size: 0.95rem;
  line-height: 1.2;
  white-space: pre-wrap;
  word-break: break-word;
  z-index: 40000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  text-align: left;
  pointer-events: auto;
}

/* small arrow for portal (pseudo element on portal) */
.tooltip-portal::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-width: 8px;
  border-style: solid;
  border-color: rgba(0,0,0,0.95) transparent transparent transparent;
  top: -16px; /* arrow above portal when portal is below the trigger; JS flips class to .tooltip-portal.top to invert */
  z-index: 40001;
}

/* flipped arrow when portal sits above the trigger */
.tooltip-portal.top::after {
  top: auto;
  bottom: -16px;
  border-color: transparent transparent rgba(0,0,0,0.95) transparent;
}

/* make the portal content scroll vertically if extremely tall */
.tooltip-portal { max-height: 70vh; overflow-y: auto; }

/* keep original ::after fallback small but harmless (no changes if JS runs) */

/* When JS-driven portal tooltips are active, hide the CSS ::before/::after fallback to avoid duplicates.
   The JS marks individual triggers with `data-tooltip-js="1"`. Prefer per-element hiding so other
   non-JS (CSS-only) tooltips still work. Keep legacy `.tooltips-js` support for backward-compatibility. */
.tooltip-trigger[data-tooltip-js]::after,
.tooltip-trigger[data-tooltip-js]::before,
.tooltips-js .tooltip-trigger::after,
.tooltips-js .tooltip-trigger::before {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Removed earlier global .modal overflow/z-index overrides to preserve Bootstrap's backdrop/stacking. */
/* Tooltip portal (fixed) and .tooltip-trigger rules remain in this file. */

/* Allow tooltips to render in modals by removing overflow constraints */
#bookingModal .modal-dialog,
#bookingModal .modal-content,
#bookingModal .modal-body {
  overflow: visible !important;
}

/* Override for tooltips inside Bootstrap modals - force higher specificity */
#bookingModal .tooltip-trigger:hover::after,
#bookingModal .tooltip-trigger:focus::after,
#bookingModal .tooltip-trigger:active::after {
  content: attr(data-tooltip) !important;
  position: absolute !important;
  left: 50% !important;
  top: calc(100% + 8px) !important;
  opacity: 1 !important;
  transform: translateX(-50%) translateY(0) !important;
  pointer-events: auto !important;
  z-index: 99999 !important;
  display: inline-block !important;
  box-sizing: border-box !important;
  padding: 0.35rem 0.5rem !important;
  min-width: 12rem !important;
  max-width: 48rem !important;
  white-space: pre-wrap !important;
  word-break: break-word !important;
  height: auto !important;
  color: #ffffff !important;
  background: rgba(0, 0, 0, 0.95) !important;
  border-radius: 0.35rem !important;
  box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.28) !important;
  font-size: 0.95rem !important;
  line-height: 1.18 !important;
  text-align: left !important;
}

#bookingModal .tooltip-trigger:hover::before,
#bookingModal .tooltip-trigger:focus::before,
#bookingModal .tooltip-trigger:active::before {
  opacity: 1 !important;
  transform: translateX(-50%) !important;
  z-index: 100000 !important;
}