/* Modal-style tooltip that appears in a fixed location */
.tooltip {
  position: relative;
  display: inline;
  cursor: help;
  color: #0066cc;
  font-weight: 500;
  border-bottom: 1px dotted #0066cc;
  text-decoration: none;
}

.tooltip:hover {
  color: #0052a3;
}

/* Modal tooltip - always appears in top-right corner */
.tooltip .tooltiptext {
  visibility: hidden;
  width: 350px;
  max-width: 350px;
  background-color: #2c3e50 !important;
  color: #ffffff !important;
  text-align: left;
  border-radius: 8px;
  padding: 16px;
  position: fixed;
  z-index: 10000;
  top: 20px;
  right: 20px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.9em !important;
  line-height: 1.6 !important;
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
  font-weight: 400 !important;
  border: 2px solid #34495e;
  white-space: normal;
  word-wrap: break-word;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* Add a small indicator to show which term the tooltip refers to */
.tooltip .tooltiptext::before {
  content: "💡 ";
  font-size: 1.1em;
  margin-right: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .tooltip .tooltiptext {
    width: calc(100vw - 40px);
    max-width: 320px;
    top: 10px;
    right: 10px;
    left: 10px;
    font-size: 0.85em;
  }
}

@media (max-width: 480px) {
  .tooltip .tooltiptext {
    width: calc(100vw - 20px);
    max-width: 280px;
    top: 10px;
    right: 10px;
    left: 10px;
    padding: 12px;
    font-size: 0.8em;
  }
}



/* Left-edge tooltip positioning */
.tooltip.tooltip-left .tooltiptext {
  top: -100px;
  left: 0px;
  bottom: auto;
  margin-left: 0px;
  width: 280px;
  max-width: 280px;
  background-color: #2c3e50 !important;
  color: #ffffff !important;
  border: 2px solid #34495e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  font-size: 0.85em !important;
  font-weight: 400 !important;
  transform: none;
  position: absolute;
  z-index: 10001;
  box-sizing: border-box;
}

/* Fallback for when tooltip would go off right edge */
@media (max-width: 480px) {
  .tooltip.tooltip-left .tooltiptext {
    left: 5px !important;
    top: -90px !important;
    margin-left: 0px !important;
    transform: none !important;
    width: calc(100vw - 30px) !important;
    max-width: 240px !important;
  }
  
  .tooltip.tooltip-left .tooltiptext::after {
    left: 20px !important;
    top: 100% !important;
    right: auto !important;
    margin-left: -8px !important;
    border-color: #2c3e50 transparent transparent transparent !important;
  }
}

.tooltip.tooltip-left .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 30px;
  margin-left: -8px;
  border-width: 8px;
  border-style: solid;
  border-color: #2c3e50 transparent transparent transparent;
}

/* Right-edge tooltip positioning */
.tooltip.tooltip-right .tooltiptext {
  right: 0;
  left: auto;
  margin-left: 0;
  margin-right: 0;
}

.tooltip.tooltip-right .tooltiptext::after {
  right: 20px;
  left: auto;
  margin-left: 0;
}

/* Top positioning for tooltips at bottom of screen */
.tooltip.tooltip-top .tooltiptext {
  top: -130%;
  bottom: auto;
}

.tooltip.tooltip-top .tooltiptext::after {
  top: auto;
  bottom: 100%;
  border-color: transparent transparent #2c3e50 transparent;
}