/* ═══════════════════════════════════════════
   ChatLens — Chat Bubble Styles
   ═══════════════════════════════════════════ */

/* ── Message Row ── */
.message-row {
  display: flex;
  margin-bottom: 2px;
  animation: fadeInUp 0.25s var(--ease) both;
  padding: 0 var(--sp-md);
}

.message-row.out {
  justify-content: flex-end;
}

.message-row.in {
  justify-content: flex-start;
}

.message-row.system {
  justify-content: center;
}

/* Stagger animation */
.message-row:nth-child(1) { animation-delay: 0s; }
.message-row:nth-child(2) { animation-delay: 0.02s; }
.message-row:nth-child(3) { animation-delay: 0.04s; }
.message-row:nth-child(4) { animation-delay: 0.06s; }
.message-row:nth-child(5) { animation-delay: 0.08s; }

/* ── Chat Bubble ── */
.bubble {
  max-width: min(520px, 75%);
  padding: 7px 10px 6px;
  border-radius: var(--r-md);
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.45;
  font-size: 0.9rem;
}

/* Outgoing Bubble */
.bubble.out {
  background: var(--bubble-out-bg);
  border: 1px solid var(--bubble-out-border);
  border-radius: var(--r-md) var(--r-md) 4px var(--r-md);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Incoming Bubble */
.bubble.in {
  background: var(--bubble-in-bg);
  border: 1px solid var(--bubble-in-border);
  border-radius: var(--r-md) var(--r-md) var(--r-md) 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* ── Bubble Tail ── */
.bubble.out::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: -7px;
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-bottom-color: rgba(0, 92, 75, 0.45);
  border-right: 0;
  border-top: 0;
}

.bubble.in::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -7px;
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-bottom-color: rgba(20, 32, 42, 0.8);
  border-left: 0;
  border-top: 0;
}

/* Show tail only on last message in group */
.message-row.grouped .bubble::after {
  display: none;
}

/* ── Sender Name ── */
.bubble-sender {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 2px;
  display: block;
}

/* Color-code different senders */
.sender-0 { color: #00d4a1; }
.sender-1 { color: #00b4d8; }
.sender-2 { color: #e879f9; }
.sender-3 { color: #fb923c; }
.sender-4 { color: #f87171; }
.sender-5 { color: #a78bfa; }
.sender-6 { color: #4ade80; }
.sender-7 { color: #fbbf24; }

/* Hide sender for outgoing or consecutive same-sender */
.message-row.out .bubble-sender { display: none; }
.message-row.grouped .bubble-sender { display: none; }

/* ── Bubble Text ── */
.bubble-text {
  color: var(--text-primary);
  white-space: pre-wrap;
}

.bubble-text a {
  color: #5cb8ff;
  text-decoration: underline;
  text-decoration-color: rgba(92, 184, 255, 0.3);
}

.bubble-text a:hover {
  text-decoration-color: rgba(92, 184, 255, 0.7);
}

/* ── Timestamp ── */
.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  float: right;
  margin-left: 12px;
  position: relative;
  bottom: -2px;
}

.bubble-time {
  font-size: 0.65rem;
  color: var(--text-timestamp);
  white-space: nowrap;
}

.bubble-edited {
  font-size: 0.65rem;
  color: var(--text-timestamp);
  font-style: italic;
  white-space: nowrap;
  opacity: 0.8;
  margin-right: 2px;
}

/* ── System Message ── */
.system-msg {
  display: inline-block;
  max-width: 85%;
  padding: 5px 16px;
  background: var(--system-bg);
  border: 1px solid var(--system-border);
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  margin: var(--sp-sm) 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── Date Separator ── */
.date-separator {
  display: flex;
  justify-content: center;
  margin: var(--sp-lg) 0 var(--sp-md);
  animation: fadeIn 0.3s var(--ease) both;
}

.date-pill {
  padding: 5px 16px;
  background: rgba(15, 22, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border-light);
  border-radius: var(--r-pill);
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

/* ── Media in Bubbles ── */
.bubble-media {
  margin: -3px -4px 4px;
  border-radius: var(--r-sm);
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.bubble-media img {
  width: 100%;
  max-width: 320px;
  border-radius: var(--r-sm);
  transition: transform var(--duration) var(--ease);
  display: block;
}

.bubble-media:hover img {
  transform: scale(1.02);
}

.bubble-media video {
  width: 100%;
  max-width: 320px;
  border-radius: var(--r-sm);
}

.bubble-media audio {
  width: 260px;
  max-width: 100%;
  height: 40px;
  filter: invert(1) hue-rotate(180deg) brightness(0.8);
}

.bubble-media-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
  border-radius: var(--r-sm);
}

.bubble-media:hover .bubble-media-overlay {
  opacity: 1;
}

.bubble-media-overlay svg {
  width: 44px;
  height: 44px;
  fill: white;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

/* Media omitted style */
.bubble-omitted {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--r-sm);
  margin-bottom: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.bubble-omitted svg {
  width: 18px;
  height: 18px;
  opacity: 0.5;
}

/* Document attachment */
.bubble-document {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--r-sm);
  margin-bottom: 4px;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}

.bubble-document:hover {
  background: rgba(255, 255, 255, 0.07);
}

.bubble-document-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, #00b4d8, #0077b6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.bubble-document-name {
  font-size: 0.82rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ── Search Highlight ── */
.search-highlight {
  background: rgba(255, 200, 0, 0.3);
  border-radius: 2px;
  padding: 0 1px;
}

.search-highlight.active {
  background: rgba(255, 200, 0, 0.6);
  outline: 2px solid rgba(255, 200, 0, 0.4);
}

/* ── Scroll to bottom FAB ── */
.scroll-fab {
  position: absolute;
  bottom: 20px;
  right: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(15, 22, 32, 0.9);
  border: 1px solid var(--glass-border-light);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  z-index: 5;
  transition: all var(--duration) var(--ease);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.scroll-fab.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}

.scroll-fab:hover {
  background: rgba(0, 212, 161, 0.15);
  color: var(--accent);
  border-color: rgba(0, 212, 161, 0.3);
}

/* ── Loading More Indicator ── */
.load-more-indicator {
  display: flex;
  justify-content: center;
  padding: var(--sp-md);
}

.load-more-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 3px;
  animation: pulse 1s ease infinite;
}

.load-more-indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.load-more-indicator .dot:nth-child(3) { animation-delay: 0.3s; }

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: var(--sp-xl);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: var(--sp-md);
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ── Call Bubble ── */
.bubble-call {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(0, 212, 161, 0.06);
  border: 1px solid rgba(0, 212, 161, 0.12);
  border-radius: var(--r-sm);
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 500;
}

.bubble-call svg {
  flex-shrink: 0;
  color: var(--accent);
}

/* Light theme overrides for call bubble */
[data-theme="light"] .bubble-call {
  background: rgba(0, 168, 132, 0.08);
  border-color: rgba(0, 168, 132, 0.15);
  color: #00795b;
}

[data-theme="light"] .bubble-call svg {
  color: #00795b;
}
