.tooltip-wrapper {
    position: relative;
    display: inline-block;
}

/* The actual tooltip */
.tooltip {
    position: absolute;
    background-color: rgba(39, 39, 42, 0.95);
    color: white;
    text-align: center;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 100;
    font-weight: normal;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    /* Prevents the tooltip from interfering with clicks */
}

/* Position the tooltip above the element */
.tooltip-top {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
}

.tooltip-top::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(39, 39, 42, 0.95) transparent transparent transparent;
}

/* Show the tooltip when hovering over the container */
.tooltip-wrapper:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* Position classes to handle edge cases */
.tooltip-left {
    left: 0;
    transform: translateX(0);
}

.tooltip-left::after {
    left: 10px;
    margin-left: 0;
}

.tooltip-right {
    right: 0;
    left: auto;
    transform: translateX(0);
}

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

/* Specific handling for button positions */
/* Left-most buttons in a row */
.relative>.tooltip-wrapper:first-child .tooltip {
    left: 0;
    transform: translateX(0);
}

.relative>.tooltip-wrapper:first-child .tooltip::after {
    left: 10px;
    margin-left: 0;
}

/* Right-most buttons in a row */
.relative>.tooltip-wrapper:last-child .tooltip {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.relative>.tooltip-wrapper:last-child .tooltip::after {
    left: auto;
    right: 10px;
    margin-left: 0;
}

/* For specific positions in the action buttons row */
.actions-col .tooltip-wrapper:nth-child(1) .tooltip {
    left: 0;
    transform: translateX(0);
}

.actions-col .tooltip-wrapper:nth-child(1) .tooltip::after {
    left: 10px;
    margin-left: 0;
}

.actions-col .tooltip-wrapper:nth-child(3) .tooltip {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.actions-col .tooltip-wrapper:nth-child(3) .tooltip::after {
    left: auto;
    right: 10px;
    margin-left: 0;
}