/**
 * Estilos Globales para Tooltips
 * Suite Education
 *
 * Sistema de tooltips unificado para todo el sistema.
 */

/* =====================================================================
   TOOLTIP CONTAINER
   ===================================================================== */

.global-tooltip {
    position: absolute;
    z-index: 100000;
    max-width: 300px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.global-tooltip--visible {
    opacity: 1;
    visibility: visible;
}

/* =====================================================================
   TOOLTIP CONTENT
   ===================================================================== */

.global-tooltip__content {
    background-color: #1f2937;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
}

/* =====================================================================
   TOOLTIP ARROW
   ===================================================================== */

.global-tooltip__arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid transparent;
}

/* Flecha cuando tooltip está arriba */
.global-tooltip--top .global-tooltip__arrow {
    bottom: -12px;
    border-top-color: #1f2937;
    border-bottom: none;
}

/* Flecha cuando tooltip está abajo */
.global-tooltip--bottom .global-tooltip__arrow {
    top: -6px;
    border-bottom-color: #1f2937;
    border-top: none;
}

/* =====================================================================
   HELP ICON STYLES
   ===================================================================== */

/* Icono de ayuda inline en labels */
.label-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 0.25rem;
    background-color: #9ca3af;
    color: white;
    border-radius: 50%;
    font-size: 0.625rem;
    font-weight: 700;
    cursor: help;
    transition: background-color 0.2s ease, transform 0.2s ease;
    vertical-align: middle;
    flex-shrink: 0;
}

.label-help-icon:hover,
.label-help-icon:focus {
    background-color: #2563eb;
    transform: scale(1.1);
    outline: none;
}

.label-help-icon:focus-visible {
    box-shadow: 0 0 0 2px white, 0 0 0 4px #2563eb;
}

/* =====================================================================
   FORM HINT AS HELP ICON (modern-forms.css override)
   ===================================================================== */

/* Asegurar que .form-hint se vea como icono de ayuda consistente */
.form-hint {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    border-radius: 50% !important;
    background-color: #9ca3af !important;
    color: white !important;
    font-size: 0.625rem !important;
    font-weight: 700 !important;
    cursor: help !important;
    margin-left: 0.25rem !important;
    transition: background-color 0.2s ease, transform 0.2s ease !important;
    vertical-align: middle !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    border: none !important;
    line-height: 1 !important;
    /* Posicionar inline con el label anterior */
    position: relative !important;
    top: -2px !important;
}

/* Solo agregar ? si el elemento está vacío */
.form-hint:empty::before {
    content: '?' !important;
}

.form-hint:hover,
.form-hint:focus {
    background-color: #2563eb !important;
    transform: scale(1.1) !important;
    outline: none !important;
}

/* Cuando .form-hint es un <p> debajo de un checkbox, reposicionarlo al lado del label */
.checkbox-label + .form-hint,
.form-group > .form-hint,
label + .form-hint {
    display: inline-flex !important;
    margin-top: -1.5em !important;
    margin-left: auto !important;
    float: right !important;
}

/* =====================================================================
   HELP TEXT STYLING (cuando se muestra como texto)
   ===================================================================== */

.help-text,
.helptext,
.form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.4;
}

/* Ocultar textos de ayuda largos que ya tienen tooltip */
.help-text[data-tooltip-source="true"],
.helptext[data-tooltip-source="true"] {
    display: none;
}

/* =====================================================================
   ACCESIBILIDAD
   ===================================================================== */

/* Asegurar suficiente contraste y visibilidad */
@media (prefers-reduced-motion: reduce) {
    .global-tooltip,
    .label-help-icon,
    .form-hint {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .global-tooltip__content {
        background-color: black;
        border: 2px solid white;
    }

    .label-help-icon,
    .form-hint {
        background-color: black !important;
        border: 2px solid white !important;
    }
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

@media (max-width: 640px) {
    .global-tooltip {
        max-width: calc(100vw - 20px);
    }

    .global-tooltip__content {
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
    }
}
