/* INLINE reactions styling: placed on the same line as message text (keep existing rules) */
.mchat-reactions {
    display: inline-flex;
    gap: 1px;
    align-items: center;
    vertical-align: middle;
    box-sizing: border-box;
    margin-left: 8px;
    line-height: 1;
    white-space: nowrap;
}

/* Reaction badge (existing) */
.mchat-reaction-badge {
    display: inline-flex;
    gap: 1px;
    align-items: center;
    padding: 2px 8px;
    border-radius: 14px;
    
    font-size: 12px;
    cursor: pointer;
    position: relative; /* required for positioned .mchat-reaction-names */
    line-height: 1;
    white-space: nowrap;
    
}

/* Inline names box (attached under the badge) */
.mchat-reaction-names {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(100% + 6px);
    white-space: nowrap;
    color: #fff;
    padding: 4px 6px;
    font-size: 11px;
    border-radius: 4px;
    z-index: 10000;
    pointer-events: none;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Show on hover (desktop) */
.mchat-reaction-badge:hover .mchat-reaction-names {
    display: block;
}

/* Show when toggled with JS (click-to-toggle) */
.mchat-reaction-badge.show-names .mchat-reaction-names {
    display: block;
}

/* Reaction emoji / count */
.mchat-reaction-emoji { font-size: 16px; line-height:1; margin-top: -5px !important; display:inline-block; margin-right: -4px; }
.mchat-reaction-count { font-size:11px; padding-left:4px; min-width:18px; margin-top: -5px !important; text-align:center; }

/* Keep the "+" exactly where the template puts the event (inline as well) */
.mchat-reaction-add-fixed {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 1px 2px;
    border-radius: 14px;
    background: rgba(0,0,0,0.02);
    font-size: 10px;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    white-space: nowrap;
}

/* Picker UI */
.mchat-reaction-picker {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.12);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    border-radius: 6px;
    width: 360px;
    max-width: calc(100% - 24px);
    box-sizing: border-box;
}
.mchat-picker-selected {
    display: flex;
    gap: 8px;
    padding: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}
.mchat-picker-selected .mchat-reaction-pill {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0,0,0,0.04);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.mchat-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 6px;
    max-height: 220px;
    overflow: auto;
    padding: 6px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}
.mchat-picker-grid button {
    cursor: pointer;
    border: 0;
    background: transparent;
    font-size: 18px;
    padding: 6px;
    border-radius: 6px;
}
.mchat-picker-grid button:hover { background: rgba(0,0,0,0.04); }

/* Tooltip (legacy / floating tooltip kept for other uses but not used for username display) */
.mchat-reaction-tooltip {
    position: absolute;
    z-index: 10000;
    background: rgba(0,0,0,0.88);
    color: #fff;
    padding: 4px 6px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    transform-origin: top center;
}

/* Responsive fallback if the inline area is too narrow */
@media (max-width:480px) {
    .mchat-reactions { display: inline-flex; gap:4px; margin-left:6px; }
    .mchat-reaction-badge { padding:2px 6px; font-size:11px; }
    .mchat-reaction-emoji { font-size:13px; }
    .mchat-reaction-count { font-size:10px; }
    .mchat-reaction-names {
        white-space: normal;
        left: 0;
        transform: none;
        top: calc(100% + 6px);
        min-width: 120px;
    }
}
