/* ============================================
   COMPOSANT TOOLTIPS — FICHE-PAIE.FR
   Aide contextuelle sur les champs du formulaire

   Créé le : 20/02/2026
   ============================================ */

/* -----------------------------------------------
   BOUTON DÉCLENCHEUR (?)
   ----------------------------------------------- */
.help-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0;
    flex-shrink: 0;
    vertical-align: middle;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 50%;
    background: transparent;
    color: var(--primary, #1e3a5f);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    /* Eviter toute interférence avec la mise en page */
    position: relative;
    top: -1px;
}

.help-trigger:hover,
.help-trigger:focus-visible {
    background: var(--primary, #1e3a5f);
    border-color: var(--primary, #1e3a5f);
    color: #fff;
}

.help-trigger:focus-visible {
    outline: 2px solid var(--primary, #1e3a5f);
    outline-offset: 2px;
}

/* Zone tactile suffisante sur mobile (WCAG 2.5.5) */
@media (max-width: 767px) {
    .help-trigger {
        width: 22px;
        height: 22px;
        font-size: 12px;
    }

    .help-trigger::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 44px;
        height: 44px;
    }
}

/* Label contenant un bouton d'aide */
.label-with-help {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
}

/* -----------------------------------------------
   POPOVER TOOLTIP (#ui-tooltip)
   ----------------------------------------------- */
#ui-tooltip {
    position: fixed;
    z-index: 10100;
    max-width: min(320px, calc(100vw - 16px));
    padding: 10px 14px;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    border: 1px solid #e2e8f0;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    pointer-events: none;
    /* État caché par défaut */
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.1s ease-in, transform 0.1s ease-in, visibility 0.1s;
}

#ui-tooltip[data-state="shown"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.15s ease-out, transform 0.15s ease-out, visibility 0s;
    pointer-events: auto;
}

/* Flèche du popover */
#ui-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

/* Flèche pointant vers le bas (popover au-dessus du trigger) */
#ui-tooltip.tooltip-arrow-bottom::after {
    bottom: -6px;
    border-top: 6px solid #f8fafc;
    border-bottom: none;
}

/* Flèche pointant vers le haut (popover en dessous du trigger) */
#ui-tooltip.tooltip-arrow-top::after {
    top: -6px;
    border-bottom: 6px solid #f8fafc;
    border-top: none;
}

/* Mots-clés en gras bleu dans les tooltips */
.tooltip-popover strong,
#ui-tooltip strong {
    color: #2563eb;
    font-weight: 600;
}
