/* Estilo para la palabra subrayada */
.wiki-term {
    text-decoration: underline dotted #007bff; /* Subrayado punteado azul */
    text-underline-offset: 3px;
    cursor: pointer;
    color: inherit; /* Mantiene el color del texto original */
    transition: background-color 0.2s, color 0.2s;
    position: relative;
}

.wiki-term:hover {
    background-color: rgba(0, 123, 255, 0.1);
    color: #007bff;
}

/* Contenedor del Tooltip */
.wiki-tooltip {
    position: absolute;
    display: none; /* Oculto por defecto */
    width: 300px;
    background-color: #ffffff;
    border: 1px solid #ddd;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 15px;
    z-index: 9999;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #333;
    pointer-events: none; /* Evita que el tooltip interfiera con el mouse */
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.wiki-tooltip.visible {
    display: block;
    opacity: 1;
}

.wiki-tooltip h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1rem;
    color: #007bff;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.wiki-tooltip p {
    margin: 0;
    color: #555;
}

/* --- MODO OSCURO --- */

/* Definición de estilos oscuros para reutilizar */
@mixin dark-mode-styles {
    .wiki-tooltip {
        background-color: #1b1b1e; /* Color de fondo del tema */
        border-color: #444;
        color: #e0e0e0;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    }
    .wiki-tooltip h4 {
        color: #58a6ff; /* Azul más claro y legible en oscuro */
        border-bottom-color: #444;
    }
    .wiki-tooltip p {
        color: #b0b0b0;
    }
    .wiki-term {
        text-decoration-color: #58a6ff;
    }
    .wiki-term:hover {
        background-color: rgba(88, 166, 255, 0.2);
        color: #58a6ff;
    }
}

/* 1. Soporte para preferencia del sistema operativo */
@media (prefers-color-scheme: dark) {
    /* Aplicar solo si no hay override explícito en HTML (opcional, pero buena práctica) */
    html:not([data-mode="light"]) .wiki-tooltip {
        background-color: #1b1b1e;
        border-color: #444;
        color: #e0e0e0;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    }
    html:not([data-mode="light"]) .wiki-tooltip h4 {
        color: #58a6ff;
        border-bottom-color: #444;
    }
    html:not([data-mode="light"]) .wiki-tooltip p {
        color: #b0b0b0;
    }
    html:not([data-mode="light"]) .wiki-term {
        text-decoration-color: #58a6ff;
    }
    html:not([data-mode="light"]) .wiki-term:hover {
        background-color: rgba(88, 166, 255, 0.2);
        color: #58a6ff;
    }
}

/* 2. Soporte para el selector de tema del sitio (Jekyll theme mode) */
html[data-mode="dark"] .wiki-tooltip {
    background-color: #1b1b1e;
    border-color: #444;
    color: #e0e0e0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

html[data-mode="dark"] .wiki-tooltip h4 {
    color: #58a6ff;
    border-bottom-color: #444;
}

html[data-mode="dark"] .wiki-tooltip p {
    color: #b0b0b0;
}

html[data-mode="dark"] .wiki-term {
    text-decoration-color: #58a6ff;
}

html[data-mode="dark"] .wiki-term:hover {
    background-color: rgba(88, 166, 255, 0.2);
    color: #58a6ff;
}
