.button-tooltip {
  background-color: var(--vscode-editorHoverWidget-background);
  color: var(--vscode-editorHoverWidget-foreground);
  border: 1px solid var(--vscode-editorHoverWidget-border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: var(--vscode-font-family);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  opacity: 0;
  animation: tooltipFadeIn 0.15s ease-out forwards;
  max-width: 250px;
  word-wrap: break-word;
  white-space: normal;
}

.button-tooltip-top::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--vscode-editorHoverWidget-border);
}

.button-tooltip-top::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 3px solid transparent;
  border-top-color: var(--vscode-editorHoverWidget-background);
  z-index: 1;
}

.button-tooltip-bottom::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-bottom-color: var(--vscode-editorHoverWidget-border);
}

.button-tooltip-bottom::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 3px solid transparent;
  border-bottom-color: var(--vscode-editorHoverWidget-background);
  z-index: 1;
}

.button-tooltip-left::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-left-color: var(--vscode-editorHoverWidget-border);
}

.button-tooltip-left::before {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 3px solid transparent;
  border-left-color: var(--vscode-editorHoverWidget-background);
  z-index: 1;
}

.button-tooltip-right::after {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-right-color: var(--vscode-editorHoverWidget-border);
}

.button-tooltip-right::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 3px solid transparent;
  border-right-color: var(--vscode-editorHoverWidget-background);
  z-index: 1;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Ensure tooltip appears above other elements */
.button-tooltip {
  z-index: 10000;
}

/* Ensure tooltips work well with disabled buttons */
button:disabled + .button-tooltip {
  opacity: 0.7;
}

/* Adjust tooltip positioning for small buttons */
.cell-overlay-controls .button-tooltip {
  font-size: 11px;
  padding: 4px 6px;
}

/* Make sure tooltip arrows work correctly for overlay buttons */
.button-tooltip-top::after,
.button-tooltip-top::before {
  left: 50%;
  transform: translateX(-50%);
}

/* Ensure tooltip positioning works correctly with absolute positioned elements */
.button-tooltip {
  will-change: transform;
}

/* Ensure tooltips don't interfere with button interactions */
.button-tooltip {
  user-select: none;
  pointer-events: none;
}

/* Ensure tooltip wrapper doesn't interfere with flex layout */
.cell-overlay-controls > div {
  display: flex;
}

/* Maintain button sizing and positioning */
.cell-overlay-controls .cell-overlay-btn {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
