/* ═══════════════════════════════════════════════════════════════════
   Tooltip Engine — Body-appended tooltip styles
   Works with tooltip-engine.js. Immune to overflow/stacking issues.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --te-bg: #1E293B;
    --te-text: #F1F5F9;
    --te-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    --te-radius: 8px;
}

body.dark-mode {
    --te-bg: #334155;
    --te-text: #F1F5F9;
    --te-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ─── Tooltip container (appended to body) ──────────────────────── */
.te-tooltip {
    position: fixed;
    z-index: 99999;
    display: none;
    max-width: 300px;
    min-width: 80px;
    padding: 8px 14px;
    background: var(--te-bg);
    color: var(--te-text);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    border-radius: var(--te-radius);
    box-shadow: var(--te-shadow);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

/* ─── Arrow ─────────────────────────────────────────────────────── */
.te-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid transparent;
}

/* Top position — arrow points down (at bottom of tooltip) */
.te-tooltip[data-pos="top"] .te-arrow {
    bottom: -6px;
    border-top-color: var(--te-bg);
    border-bottom: none;
}

/* Bottom position — arrow points up (at top of tooltip) */
.te-tooltip[data-pos="bottom"] .te-arrow {
    top: -6px;
    border-bottom-color: var(--te-bg);
    border-top: none;
}

/* Left position — arrow points right (at right of tooltip) */
.te-tooltip[data-pos="left"] .te-arrow {
    right: -6px;
    border-left-color: var(--te-bg);
    border-right: none;
}

/* Right position — arrow points left (at left of tooltip) */
.te-tooltip[data-pos="right"] .te-arrow {
    left: -6px;
    border-right-color: var(--te-bg);
    border-left: none;
}

/* ─── Mini-markdown tooltip ──────────────────────────────────────── */
.te-tooltip.te-md {
    text-align: left;
    max-width: 360px;
}
.te-md-content ul {
    margin: 4px 0;
    padding-left: 16px;
}
.te-md-content li {
    margin-bottom: 3px;
}
.te-md-content li:last-child {
    margin-bottom: 0;
}

/* ─── Rich HTML tooltip variant ──────────────────────────────────── */
.te-tooltip.te-html {
    text-align: left;
    max-width: 380px;
}

.te-html-content p {
    margin: 0 0 4px;
}
.te-html-content p:last-child {
    margin-bottom: 0;
}
.te-html-content strong,
.te-html-content b {
    font-weight: 700;
}
.te-html-content ul,
.te-html-content ol {
    margin: 4px 0;
    padding-left: 18px;
}
.te-html-content li {
    margin-bottom: 2px;
}

/* ─── Disable old pseudo-element tooltips when engine is active ── */
/* Any element with data-tip or data-tip-html handled by the engine
   must not show pseudo-element tooltips. The engine adds .te-active to body. */
.te-active [data-tip]::before,
.te-active [data-tip]::after,
.te-active [data-tip-html]::before,
.te-active [data-tip-html]::after {
    display: none !important;
}
