/* ================================
 * SISTEMA DE TOOLTIPS
 * ================================ */

/* Clase para elementos que solo necesitan tooltip (sin estilos de icono) */
.has-tooltip {
    position: relative;
}

/* Help Icon */
.help-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    z-index: 10;
    pointer-events: all;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.help-icon:hover {
    color: var(--primary);
    background: var(--border-light);
}

.help-icon svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

/* Clase activa para feedback visual en táctil */
.help-icon.active {
    color: var(--primary);
    background: var(--border-light);
}

/* Tooltip container - Diseño elegante y minimalista */
.help-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.92);
    color: rgba(255, 255, 255, 0.95);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    line-height: 1.4;
    width: max-content;
    max-width: min(300px, 90vw);
    min-width: 60px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95) translateZ(0);
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    z-index: 99999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.15);
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    hyphens: auto;
    text-align: left;
    pointer-events: none;
    font-weight: 400;
    letter-spacing: 0.01em;
    will-change: opacity, transform;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.help-tooltip.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateZ(0);
    pointer-events: auto;
}

/* Sistema de flecha elegante y minimalista */
.tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    z-index: 1;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Estados de la flecha según dirección */
.help-tooltip[data-direction="top"] .tooltip-arrow {
    bottom: -12px;
    border-top-color: rgba(0, 0, 0, 0.92);
    border-bottom-width: 0;
    border-left-width: 5px;
    border-right-width: 5px;
}

.help-tooltip[data-direction="bottom"] .tooltip-arrow {
    top: -12px;
    border-bottom-color: rgba(0, 0, 0, 0.92);
    border-top-width: 0;
    border-left-width: 5px;
    border-right-width: 5px;
}

.help-tooltip[data-direction="left"] .tooltip-arrow {
    right: -12px;
    border-left-color: rgba(0, 0, 0, 0.92);
    border-right-width: 0;
    border-top-width: 5px;
    border-bottom-width: 5px;
}

.help-tooltip[data-direction="right"] .tooltip-arrow {
    left: -12px;
    border-right-color: rgba(0, 0, 0, 0.92);
    border-left-width: 0;
    border-top-width: 5px;
    border-bottom-width: 5px;
}

/* Tooltips cortos centrados, largos alineados */
.help-tooltip[data-length="short"] {
    text-align: center;
}

/* Responsive - Tablets */
@media (max-width: 768px) {
    .help-tooltip {
        max-width: min(75vw, 280px);
        font-size: 0.775rem;
        padding: 0.45rem 0.65rem;
    }
}

/* Responsive - Móviles */
@media (max-width: 480px) {
    .help-tooltip {
        max-width: min(85vw, 260px);
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }
    
    .help-icon {
        right: 0.5rem;
        width: 18px;
        height: 18px;
    }
    
    .help-icon svg {
        width: 14px;
        height: 14px;
    }
}

/* Responsive - Móviles pequeños */
@media (max-width: 320px) {
    .help-tooltip {
        max-width: calc(95vw - 20px);
        padding: 0.375rem 0.5rem;
        font-size: 0.7rem;
    }
}

/* Dispositivos táctiles - Sin efectos hover problemáticos */
@media (hover: none) and (pointer: coarse) {
    .help-icon:active {
        color: var(--primary);
        background: var(--border-light);
    }
    
    /* Mantener hover desactivado en táctil */
    .help-icon:hover {
        color: var(--text-tertiary);
        background: transparent;
    }
}

/* Prevenir problemas de scroll en iOS */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* Prevenir highlight en tap (móviles) */
* {
    -webkit-tap-highlight-color: transparent;
}