/**
 * Composant : Statut de connexion Moodle
 *
 * Badge affichant l'état de la connexion à Moodle avec tooltip informatif
 * Utilisable partout dans l'application
 */

.moodle-status {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius-full);
    white-space: nowrap;
    transition: all 300ms ease;
    cursor: help;
    position: relative;
}

.moodle-status:hover {
    opacity: 0.85;
}

.moodle-status svg {
    flex-shrink: 0;
}

/* Tooltip au survol */
.moodle-status::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--color-black);
    color: var(--color-white);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-lg);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    line-height: 1.4;
    white-space: normal;
    max-width: 280px;
    width: max-content;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

/* Flèche du tooltip */
.moodle-status::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--color-black);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

/* Afficher le tooltip au survol */
.moodle-status:hover::before,
.moodle-status:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Success - Configuré et fonctionnel */
.moodle-status--success {
    background: color-mix(in srgb, var(--color-success) 10%, transparent);
    color: var(--color-success);
    border: 1px solid color-mix(in srgb, var(--color-success) 20%, transparent);
}

/* Error - Non configuré ou non fonctionnel */
.moodle-status--error {
    background: color-mix(in srgb, var(--color-error) 10%, transparent);
    color: var(--color-error);
    border: 1px solid color-mix(in srgb, var(--color-error) 20%, transparent);
}

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 768px) {
    .moodle-status {
        font-size: var(--font-size-xs);
        padding: 6px var(--spacing-md);
    }

    .moodle-status svg {
        width: 14px;
        height: 14px;
    }

    /* Tooltip responsive */
    .moodle-status::before {
        max-width: 240px;
        font-size: 11px;
        padding: 6px var(--spacing-sm);
        left: 0;
        right: 0;
        margin: 0 auto;
        transform: translateY(-8px);
    }

    .moodle-status::after {
        left: 50%;
        transform: translateX(-50%) translateY(-8px);
    }

    .moodle-status:hover::before {
        transform: translateY(0);
    }

    .moodle-status:hover::after {
        transform: translateX(-50%) translateY(0);
    }
}
