/**
 * Inbound message cards (iMessage / WhatsApp Personal).
 *
 * Visual language matches `.meeting-summary-card` and `.call-summary-card`:
 *   - Subtle glass surface, channel-tinted left border
 *   - Avatar + sender header, channel chip, timestamp
 *   - Message body that wraps cleanly
 *   - Inline Reply button that morphs into a composer on click
 *
 * Channel theme variables:
 *   --imc-accent       — channel accent (iMessage blue / WhatsApp green)
 *   --imc-accent-soft  — 12% alpha tint of accent (chip/avatar bg)
 *   --imc-accent-line  — 35% alpha line for border highlights
 */

.inbound-msg-card {
  --imc-accent:      #38bdf8;
  --imc-accent-soft: rgba(56, 189, 248, 0.12);
  --imc-accent-line: rgba(56, 189, 248, 0.35);

  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid var(--imc-accent);
  transition: border-color 0.15s ease, background 0.15s ease;
  max-width: 600px;
  width: 100%;
}

/* Content column to the right of the avatar — holds header, handle, body, actions. */
.inbound-msg-card__content {
  flex: 1 1 0;
  min-width: 0;     /* critical: lets the body text wrap inside flex */
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inbound-msg-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  border-left-color: var(--imc-accent);
}

/* Channel themes — bind via .inbound-msg-card[data-channel="..."] */
.inbound-msg-card[data-channel="imessage"] {
  --imc-accent:      #0a84ff;
  --imc-accent-soft: rgba(10, 132, 255, 0.14);
  --imc-accent-line: rgba(10, 132, 255, 0.38);
}
.inbound-msg-card[data-channel="whatsapp_personal"] {
  --imc-accent:      #25d366;
  --imc-accent-soft: rgba(37, 211, 102, 0.14);
  --imc-accent-line: rgba(37, 211, 102, 0.4);
}

/* ── Avatar (initials over a gradient deterministically derived from handle) ─── */

.inbound-msg-card__avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  user-select: none;
  background: var(--imc-avatar-bg, linear-gradient(135deg, #4f46e5, #06b6d4));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: visible;   /* allows the channel badge to overflow */
}

.inbound-msg-card__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Channel badge floating bottom-right of the avatar */
.inbound-msg-card__avatar-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--imc-accent);
  border: 2px solid #0a0a14;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
}

/* ── Header row: name, channel chip, timestamp ───────────────────────────── */

.inbound-msg-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.inbound-msg-card__name {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.94);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.inbound-msg-card__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--imc-accent-soft);
  border: 1px solid var(--imc-accent-line);
  border-radius: 999px;
  color: var(--imc-accent);
  flex-shrink: 0;
}

.inbound-msg-card__time {
  margin-left: auto;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ── Sub-header: handle (truncated, tooltip shows full) ──────────────────── */

.inbound-msg-card__handle {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.42);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.01em;
}

.inbound-msg-card__handle-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.inbound-msg-card__handle-group::before {
  content: '·';
  color: rgba(255, 255, 255, 0.3);
  margin-right: 2px;
}

/* ── Body ───────────────────────────────────────────────────────────────── */

.inbound-msg-card__body {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
  white-space: pre-wrap;
  word-break: break-word;
}

.inbound-msg-card__body--muted {
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

.inbound-msg-card__body a {
  color: var(--imc-accent);
  text-decoration: underline;
  text-decoration-color: var(--imc-accent-line);
  text-underline-offset: 2px;
  word-break: break-all;
  transition: text-decoration-color 0.12s ease;
}

.inbound-msg-card__body a:hover {
  text-decoration-color: var(--imc-accent);
}

/* ── Actions row ────────────────────────────────────────────────────────── */

.inbound-msg-card__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.inbound-msg-card__btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 16px;
  background: transparent;
  color: var(--imc-accent);
  border: 1px solid var(--imc-accent-line);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.inbound-msg-card__btn:hover {
  background: var(--imc-accent-soft);
  border-color: var(--imc-accent);
}

.inbound-msg-card__btn:active {
  transform: translateY(1px);
}

.inbound-msg-card__btn--primary {
  background: var(--imc-accent);
  color: #fff;
  border-color: var(--imc-accent);
}

.inbound-msg-card__btn--primary:hover {
  filter: brightness(1.1);
  background: var(--imc-accent);
}

.inbound-msg-card__btn--ghost {
  color: rgba(255, 255, 255, 0.6);
  border-color: rgba(255, 255, 255, 0.12);
}

.inbound-msg-card__btn--ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
}

/* ── Reply composer (collapsed by default; expands on click) ─────────────── */

.inbound-msg-card__composer {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  animation: imc-fade-in 0.18s ease;
}

.inbound-msg-card__composer.is-open {
  display: flex;
}

@keyframes imc-fade-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

.inbound-msg-card__textarea {
  width: 100%;
  min-height: 44px;
  max-height: 160px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.12s ease;
}

.inbound-msg-card__textarea:focus {
  outline: none;
  border-color: var(--imc-accent);
}

.inbound-msg-card__textarea::placeholder {
  color: rgba(255, 255, 255, 0.32);
}

.inbound-msg-card__composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.inbound-msg-card__hint {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-right: auto;
  display: flex;
  align-items: center;
}

.inbound-msg-card__hint kbd {
  font-family: inherit;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
}

/* ── Outbound reply bubble (compact pill below the inbound card) ─────────── */

.outbound-reply {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px;
  border-radius: 14px 14px 4px 14px;
  background: var(--out-accent, #0a84ff);
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  max-width: 540px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.outbound-reply[data-channel="imessage"] { --out-accent: #0a84ff; }
.outbound-reply[data-channel="whatsapp_personal"] { --out-accent: #25d366; color: #0b1f15; }

.outbound-reply__hint {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
}

.outbound-reply__body {
  white-space: pre-wrap;
  word-break: break-word;
}
