/* Message reactions: the badge under a bubble, the smiley beside it, and the
   floating bar of emoji. Shared by the visitor chat and the inbox. */

.bubble[data-id] { position: relative; }
.bubble.has-rx { margin-bottom: 15px; }

/* The reaction(s) on a message, overlapping the bubble's bottom edge */
.rx-badge {
  position: absolute;
  bottom: -14px;
  padding: 1px 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #efeeea;
  color: #1c1b19;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  cursor: pointer;
}
.bubble.them .rx-badge { left: 10px; }
.bubble.me .rx-badge { right: 10px; }

/* The smiley that appears beside a bubble under a mouse */
.rx-btn {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: -14px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #8a8883;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.12s;
}
.bubble.them .rx-btn { left: calc(100% + 4px); }
.bubble.me .rx-btn { right: calc(100% + 4px); }
.bubble:hover .rx-btn, .rx-btn:focus-visible { opacity: 1; }
.rx-btn:hover { background: rgba(0, 0, 0, 0.06); color: #1c1b19; }

/* On a phone there is no hover: tapping the bubble opens the bar instead. */
@media (hover: none) {
  .rx-btn { display: none; }
  .bubble[data-id] { cursor: pointer; }
}

/* The floating bar */
.rx-bar {
  position: fixed;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.06);
  animation: rx-pop 0.14s ease-out;
}
.rx-bar.rx-grid {
  display: grid;
  grid-template-columns: repeat(7, 40px);
  gap: 2px;
  padding: 10px;
  border-radius: 22px;
}
.rx-emoji, .rx-more {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.1s;
}
.rx-emoji:hover { transform: scale(1.2); }
.rx-emoji[aria-pressed="true"] { background: rgba(0, 122, 255, 0.16); }
.rx-more { margin-left: 4px; background: #efeeea; color: #1c1b19; font-size: 24px; font-weight: 300; }

@keyframes rx-pop {
  from { opacity: 0; transform: scale(0.85); }
}
@media (prefers-reduced-motion: reduce) {
  .rx-bar { animation: none; }
  .rx-emoji, .rx-btn { transition: none; }
}

/* ---------- Links and attachments inside a message (see files.js) ---------- */

.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.b-text { display: block; }
.b-files { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.b-text + .b-files { margin-top: 8px; }
.b-img { display: block; overflow: hidden; border-radius: 12px; background: rgba(0, 0, 0, 0.08); line-height: 0; }
/* A set width, not a percentage: the bubble shrinks to fit its contents, and a
   percentage of that collapses a lone photo to nothing. The 4:3 box holds its
   place until the photo loads and brings its own shape. */
.b-img img { display: block; width: 220px; max-width: 100%; max-height: 260px; aspect-ratio: auto 4 / 3; object-fit: cover; }
.b-files:has(.b-img + .b-img) .b-img img { width: 104px; height: 104px; }
.bubble .b-file {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  color: #1c1b19;
  text-decoration: none;
}
.bubble.me .b-file { background: rgba(255, 255, 255, 0.92); }
.b-icon { flex: none; display: grid; color: #6b6964; }
.b-label { display: grid; min-width: 0; line-height: 1.25; }
.b-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.b-size { color: #6b6964; font-size: 12px; }
.b-save {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.12);
  color: #0066d6;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.bubble.me .b-save { background: rgba(255, 255, 255, 0.9); }
.b-save:disabled { opacity: 0.6; }
