/* Tooltip styling */
.feature-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.tooltip-icon {
    width: 16px;
    height: 16px;
    color: #6b7280;
    margin-left: 5px;
    flex-shrink: 0;
}

.tooltip-text {
    visibility: hidden;
    position: absolute;
    bottom: 100%; /* Position above the icon */
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    text-align: center;
    padding: 10px 15px;
    border-radius: 6px;
    width: 250px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    line-height: 1.4;
    font-weight: normal;
    margin-bottom: 10px; /* Space between tooltip and icon */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --arrow-x: 50%; /* Default arrow position: center */
}

/* Arrow pointing to the icon */
.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%; /* At the bottom of the tooltip */
    left: 50%;
    margin-left: -6px; /* Center the arrow precisely */
    border-width: 6px;
    border-style: solid;
    border-color: #1f2937 transparent transparent transparent;
}

/* Ensure the tooltip text is visible when hovering over the tooltip container */
.feature-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Responsiveness - keep tooltip within the table/screen boundaries */
@media (max-width: 768px) {
    .tooltip-text {
        width: 200px;
    }
}

/* Handle edge cases when tooltip would go off-screen to the left */
.feature-tooltip:first-child .tooltip-text {
    left: 0;
    transform: translateX(0);
    --arrow-x: 20px; /* Arrow points to the icon, not the left edge */
}

.feature-tooltip:first-child .tooltip-text::after {
    left: 21px; /* Align arrow with icon */
    margin-left: 0; /* Reset margin-left for arrow */
}

/* Handle edge cases when tooltip would go off-screen to the right */
td:last-child .feature-tooltip .tooltip-text {
    left: auto;
    right: 0;
    transform: translateX(0);
    --arrow-x: calc(100% - 20px); /* Arrow points to the icon, not the right edge */
}

td:last-child .feature-tooltip .tooltip-text::after {
    left: auto;
    right: 21px; /* Align arrow with icon */
    margin-left: 0; /* Reset margin-left for arrow */
}
