/* ============================================================
   Ayuda contextual — tooltips didácticos (EllaSuite 360)
   ============================================================ */

.form-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
}

.form-label-row .form-label {
    margin-bottom: 0;
    flex: 1 1 auto;
    min-width: 0;
}

/* Contenedor del ícono (? ) — sube la pila cuando la burbuja está visible para quedar por encima de vecinos en flex/grid */
.help-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    vertical-align: middle;
}

.help-tip:hover,
.help-tip:focus-within,
.help-tip.is-open {
    z-index: var(--z-tooltip, 600);
}

.help-tip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(219, 80, 165, 0.12), rgba(216, 143, 237, 0.15));
    color: var(--primary);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.help-tip-trigger:hover,
.help-tip-trigger:focus-visible {
    background: linear-gradient(135deg, rgba(219, 80, 165, 0.22), rgba(216, 143, 237, 0.25));
    box-shadow: 0 2px 8px rgba(219, 80, 165, 0.25);
    outline: none;
}

.help-tip-trigger:focus-visible {
    box-shadow: 0 0 0 3px rgba(219, 80, 165, 0.35);
}

.help-tip-trigger i {
    font-size: 0.95rem;
}

.help-tip.is-open .help-tip-trigger {
    background: var(--primary);
    color: var(--white);
}

/* Burbuja — por encima de topbar / bottom-nav (--z-sticky 200) y barras flotantes POS; alineado con --z-tooltip en app.css */
.help-tip-bubble {
    position: absolute;
    z-index: var(--z-tooltip, 600);
    bottom: calc(100% + 10px);
    right: 0;
    left: auto;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 2rem));
    padding: var(--space-3);
    background: var(--white);
    border: 1px solid var(--gray-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--fs-sm);
    font-weight: 400;
    line-height: 1.45;
    color: var(--gray-dark);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
}

/* Flecha */
.help-tip-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 10px;
    border: 8px solid transparent;
    border-top-color: var(--white);
    filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.06));
}

.help-tip-bubble-inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.help-tip-text {
    display: block;
}

.help-tip-example {
    display: block;
    padding: var(--space-2) var(--space-3);
    background: linear-gradient(135deg, rgba(219, 80, 165, 0.06), rgba(216, 143, 237, 0.08));
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
    font-size: var(--fs-sm);
    color: var(--dark);
}

.help-tip-example strong {
    color: var(--primary);
    font-weight: 600;
}

/* Desktop: hover + focus */
@media (hover: hover) and (pointer: fine) {
    .help-tip:hover .help-tip-bubble,
    .help-tip:focus-within .help-tip-bubble {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }
}

/* Abierto por clic (móvil o toggle) */
.help-tip.is-open .help-tip-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Pantallas muy estrechas: centrar burbuja */
@media (max-width: 400px) {
    .help-tip-bubble {
        right: auto;
        left: 50%;
        margin-left: 0;
        transform: translateX(-50%) translateY(6px) scale(0.98);
    }

    .help-tip-bubble::after {
        left: 50%;
        right: auto;
        margin-left: -8px;
    }

    .help-tip.is-open .help-tip-bubble {
        transform: translateX(-50%) translateY(0) scale(1);
    }

    @media (hover: hover) and (pointer: fine) {
        .help-tip:hover .help-tip-bubble,
        .help-tip:focus-within .help-tip-bubble {
            transform: translateX(-50%) translateY(0) scale(1);
        }
    }
}

/* Las tarjetas usan overflow:hidden para bordes redondeados; eso recorta las burbujas. Solo aflojamos mientras el tooltip está activo. */
.card:has(.help-tip:hover),
.card:has(.help-tip:focus-within),
.card:has(.help-tip.is-open) {
    overflow: visible;
}
