/* Simple API Help Icon and Tooltip Styles */

.api-help-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    cursor: pointer;
    color: #64748b;
    background: rgba(100, 116, 139, 0.1);
    border: 1px solid rgba(100, 116, 139, 0.2);
    border-radius: 50%;
    transition: all 0.2s ease;
    vertical-align: middle;
    z-index: 1;
}

.api-help-icon:hover {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    transform: scale(1.05);
    z-index: 10000;
}

.api-help-icon svg {
    width: 12px;
    height: 12px;
}

/* Simple Tooltip */
.api-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 3px;
    width: 280px;
    max-width: calc(100vw - 40px);
    min-width: 250px;
    background: white;
    color: #1f2937;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.api-help-icon:hover .api-tooltip,
.api-tooltip:hover {
    opacity: 1;
    pointer-events: auto;
}

/* Fix: Keep tooltip clickable but prevent scroll interference */
*[id*="unique"] .api-tooltip {
    pointer-events: auto !important;
}

/* Ensure tooltip stays visible when hovering over it */
*[id*="unique"] .api-tooltip:hover {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Keep "More Info" link clickable */
*[id*="unique"] .api-more-link {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Tooltip stays open when clicked (add .clicked class via JS) */
.api-help-icon.clicked .api-tooltip {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Override hover behavior when clicked */
.api-help-icon.clicked:not(:hover) .api-tooltip {
    opacity: 1 !important;
}

/* SPECIAL: Clicked state for unique tables - override all other rules */
*[id*="unique"] .api-help-icon.clicked .api-tooltip,
*[id*="unique"] * .api-help-icon.clicked .api-tooltip {
    opacity: 1 !important;
    display: block !important;
    pointer-events: auto !important;
    /* Keep the right-side positioning */
    left: 100% !important;
    right: auto !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    margin-left: 10px !important;
}

/* SPECIAL: Clicked state for unique tables - LAST ROW */
*[id*="unique"] tr:last-child .api-help-icon.clicked .api-tooltip,
*[id*="unique"] * tr:last-child .api-help-icon.clicked .api-tooltip {
    opacity: 1 !important;
    display: block !important;
    /* Keep above positioning for last row */
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 100% !important;
    transform: translateX(-50%) !important;
    margin-left: 0 !important;
    margin-bottom: 8px !important;
}

.api-help-icon:focus-within .api-tooltip {
    opacity: 1;
    pointer-events: auto;
}

.api-tooltip-content {
    padding: 12px;
}

.api-name {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 11px;
    font-weight: 600;
    color: #60a5fa;
    margin-bottom: 6px;
    background: rgba(96, 165, 250, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

.api-summary {
    color: #374151;
    line-height: 1.4;
    margin-bottom: 8px;
}

.api-more-link {
    color: #60a5fa;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #60a5fa;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.api-more-link:hover {
    background: #60a5fa;
    color: white;
}

/* Tooltip arrow */
.api-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid white;
}

/* Auto-position tooltip below for top rows */
tr:first-child .api-tooltip,
tr:nth-child(2) .api-tooltip,
tr:nth-child(3) .api-tooltip {
    bottom: auto;
    top: 100%;
    margin-bottom: 0;
    margin-top: 3px;
}

/* Adjust arrow for bottom-positioned tooltips */
tr:first-child .api-tooltip::after,
tr:nth-child(2) .api-tooltip::after,
tr:nth-child(3) .api-tooltip::after {
    top: auto;
    bottom: 100%;
    border-top: none;
    border-bottom: 6px solid white;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .api-tooltip {
        width: 240px;
        font-size: 11px;
    }
    
    .api-tooltip-content {
        padding: 10px;
    }
}

/* NUCLEAR OPTION - Override ALL tooltips to show on right for narrow tables */

/* Override for ANY element with "unique" in the ID hierarchy */
*[id*="unique"] .api-tooltip,
*[id*="unique"] * .api-tooltip {
    /* POSITION TO THE RIGHT SIDE, not above */
    left: 100% !important;
    right: auto !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    margin-left: 10px !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

/* Special positioning for LAST ROW - show above instead of beside */
*[id*="unique"] tr:last-child .api-tooltip,
*[id*="unique"] * tr:last-child .api-tooltip {
    /* Show ABOVE for last row to prevent cutoff */
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 100% !important;
    transform: translateX(-50%) !important;
    margin-left: 0 !important;
    margin-bottom: 8px !important;
    margin-top: 0 !important;
}

/* Adjust arrow for right-side positioning */
*[id*="unique"] .api-tooltip::after,
*[id*="unique"] * .api-tooltip::after {
    /* Arrow pointing LEFT (since tooltip is on right) */
    left: -6px !important;
    right: auto !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    border-top: 6px solid transparent !important;
    border-bottom: 6px solid transparent !important;
    border-right: 6px solid white !important;
    border-left: none !important;
}

/* Arrow for LAST ROW - pointing down (since tooltip is above) */
*[id*="unique"] tr:last-child .api-tooltip::after,
*[id*="unique"] * tr:last-child .api-tooltip::after {
    /* Arrow pointing DOWN for last row */
    left: 50% !important;
    right: auto !important;
    top: 100% !important;
    bottom: auto !important;
    transform: translateX(-50%) !important;
    border-top: 6px solid white !important;
    border-bottom: none !important;
    border-left: 6px solid transparent !important;
    border-right: 6px solid transparent !important;
}