/* ========================================================
   TrailTrack Stories — Chat Styles (Discord/Slack style)
   ======================================================== */

/* ---- Chat Panel Layout ---- */
.chat-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---- Room Header ---- */
.chat-room-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-room-header-info {
  flex: 1;
  min-width: 0;
}

.chat-room-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-room-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-online-count {
  display: flex;
  align-items: center;
  gap: 3px;
}

.chat-online-dot {
  width: 6px;
  height: 6px;
  background: var(--green-light);
  border-radius: 50%;
}

/* ---- Chat Room List ---- */
.chat-room-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.chat-room-item:hover {
  background: var(--surface-hover);
}

.chat-room-item.active {
  background: var(--surface-active);
  border-left: 3px solid var(--green-light);
}

.chat-room-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.chat-room-item-info {
  flex: 1;
  min-width: 0;
}

.chat-room-item-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-room-item-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-room-unread {
  flex-shrink: 0;
}

/* ---- Chat Messages Area ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chat-messages-date-divider {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 12px 0;
  position: relative;
}

.chat-messages-date-divider::before,
.chat-messages-date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}

.chat-messages-date-divider::before { left: 0; }
.chat-messages-date-divider::after { right: 0; }

/* ---- Chat Message — Discord/Slack style ---- */
.chat-msg {
  display: flex;
  gap: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  animation: fade-in 0.15s ease;
  transition: background 0.1s;
}

.chat-msg:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Grouped messages (same user, consecutive) — collapse avatar */
.chat-msg-grouped {
  padding-left: 56px;
  padding-top: 0;
  margin-top: -2px;
}

.chat-msg-grouped .chat-msg-avatar,
.chat-msg-grouped .chat-msg-header {
  display: none;
}

.chat-msg-avatar {
  flex-shrink: 0;
  width: 36px;
  padding-top: 2px;
}

.chat-msg-avatar .avatar {
  width: 36px;
  height: 36px;
  font-size: 0.8rem;
}

.chat-msg-content {
  flex: 1;
  min-width: 0;
}

.chat-msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

/* Username colors — each user gets a distinct color */
.chat-msg-name {
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.chat-msg-name:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* Color palette for usernames */
.chat-name-color-0 { color: #f87171; }
.chat-name-color-1 { color: #34d399; }
.chat-name-color-2 { color: #60a5fa; }
.chat-name-color-3 { color: #fbbf24; }
.chat-name-color-4 { color: #c084fc; }
.chat-name-color-5 { color: #f472b6; }
.chat-name-color-6 { color: #2dd4bf; }
.chat-name-color-7 { color: #fb923c; }
.chat-name-color-8 { color: #a78bfa; }
.chat-name-color-9 { color: #4ade80; }
.chat-name-color-10 { color: #38bdf8; }
.chat-name-color-11 { color: #e879f9; }

.chat-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s;
}

.chat-msg:hover .chat-msg-time {
  opacity: 1;
}

/* Message body — no bubbles, just clean text */
.chat-msg-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-msg-body a {
  color: var(--green-light);
}

/* NO special own-message styling — all messages look the same */
.chat-msg-own {
  /* intentionally empty — same layout as everyone else */
}

.chat-msg-photo {
  max-width: 400px;
  max-height: 300px;
  border-radius: var(--radius);
  margin-top: 4px;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.chat-msg-photo:hover {
  opacity: 0.9;
}

/* Drag and drop overlay */
.chat-drag-over {
  outline: 3px dashed var(--green-light, #10b981);
  outline-offset: -6px;
  background: rgba(16, 185, 129, 0.05);
}

.chat-drag-over::after {
  content: '📷 Drop photos here';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 16px 32px;
  background: var(--surface);
  border: 2px solid var(--green-light, #10b981);
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--green-light, #10b981);
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.chat-messages {
  position: relative;
}

/* System message */
.chat-msg-system {
  text-align: center;
  padding: 6px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Pinned message */
.chat-msg-pinned {
  background: rgba(245, 158, 11, 0.08);
  border-left: 2px solid var(--amber);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin: 4px 0;
}

.chat-msg-pinned-label {
  font-size: 0.7rem;
  color: var(--amber);
  font-weight: 600;
  margin-bottom: 4px;
}

/* Map share in chat */
.chat-map-preview {
  width: 280px;
  height: 160px;
  border-radius: var(--radius);
  margin-top: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.chat-map-preview:hover {
  opacity: 0.9;
}

.chat-map-preview-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  font-size: 0.75rem;
  color: white;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- Typing Indicator ---- */
.chat-typing {
  padding: 4px 16px 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  height: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s ease infinite;
}

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

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Chat Input ---- */
.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: border-color var(--transition-fast);
}

.chat-input-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-glow);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.4;
  padding: 2px 4px;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input-actions {
  display: flex;
  gap: 2px;
  align-items: center;
}

.chat-input-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.chat-input-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.chat-send-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--green);
  color: white;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.chat-send-btn:hover {
  background: var(--green-light);
  box-shadow: var(--shadow-glow-green);
}

/* ---- Chat Full Page Layout ---- */
.chat-page {
  display: flex;
  height: 100%;
}

.chat-page-rooms {
  width: 240px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  flex-shrink: 0;
}

.chat-page-rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.chat-page-rooms-header h3 {
  font-size: 1rem;
}

.chat-page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Chat + Right Panel layout */
.chat-layout {
  display: flex;
  height: 100%;
}

.chat-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Right Panel ---- */
.chat-right-panel {
  width: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--surface);
  transition: width 0.25s ease;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.chat-right-panel.open {
  width: 560px;
  overflow-y: auto;
  min-width: 250px;
  max-width: 800px;
}

/* Right panel sections */
.chat-rp-section {
  border-bottom: 1px solid var(--border);
}

.chat-rp-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.chat-rp-section-header:hover {
  background: rgba(255,255,255,0.02);
}

.chat-rp-toggle {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.chat-rp-section-body {
  padding: 0 14px 12px;
}

.chat-rp-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}

/* Members */
.chat-rp-member {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}

.chat-rp-member:hover {
  background: rgba(255,255,255,0.03);
}

.chat-rp-member-avatar {
  position: relative;
  flex-shrink: 0;
}

.chat-rp-member-avatar .avatar {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

.chat-rp-status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid var(--surface);
}

.chat-rp-status.online {
  background: var(--green-light);
}

.chat-rp-member-name {
  font-size: 0.82rem;
  font-weight: 600;
}

/* Shared Media Grid */
.chat-rp-media-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.chat-rp-media-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.chat-rp-media-thumb:hover {
  transform: scale(1.05);
  opacity: 0.85;
}

.chat-rp-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Room Map */
.chat-rp-map {
  height: 350px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
}

.chat-rp-map-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.chat-rp-map-search {
  display: flex;
  gap: 4px;
}

.chat-rp-map-search input {
  flex: 1;
  font-size: 0.8rem !important;
  padding: 6px 8px !important;
}

.chat-rp-map-coords {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chat-rp-map-coords input {
  flex: 1;
  font-size: 0.8rem !important;
  font-family: monospace;
  text-align: center;
  padding: 6px 4px !important;
}

.chat-rp-map-coords span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-rp-map-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chat-rp-map-actions .btn {
  flex: 1;
  font-size: 0.72rem;
  min-width: 0;
  padding: 6px 8px;
}

.chat-rp-map-info {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
  padding: 2px 0;
}

/* Pin creation row */
.chat-rp-map-pin-row {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.chat-rp-map-pin-row input,
.chat-rp-map-pin-row select {
  font-size: 0.8rem !important;
  padding: 5px 8px !important;
}

/* Layer dropdown */
.chat-rp-layer-dropdown {
  position: relative;
}

.chat-rp-layer-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  padding: 8px;
  min-width: 180px;
  z-index: 500;
}

.chat-rp-layer-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}

.chat-rp-layer-menu label:hover {
  background: var(--surface-hover);
}

.chat-rp-layer-menu input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green, #059669);
}

/* Map control bar */
.map-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  margin-bottom: 6px;
  gap: 8px;
}

.map-control-status {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-control-bar .btn {
  flex-shrink: 0;
}

/* Empty state */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}

.chat-empty-state-icon {
  font-size: 3rem;
  opacity: 0.3;
}

/* ---- Create Room Form ---- */
.create-room-form {
  padding: 16px;
}

.create-room-form .form-group {
  margin-bottom: 12px;
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
  .chat-right-panel.open {
    width: 420px;
  }
}

@media (max-width: 1024px) {
  .chat-right-panel.open {
    width: 340px;
  }
}

@media (max-width: 768px) {
  .chat-page {
    flex-direction: column;
  }

  .chat-page-rooms {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border);
    transition: max-height 0.25s ease;
  }

  .chat-page-rooms.open {
    max-height: 40vh;
    overflow-y: auto;
  }

  .chat-page-rooms-header {
    cursor: pointer;
  }

  /* Add toggle indicator */
  .chat-page-rooms-header::after {
    content: '▼';
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
  }

  .chat-page-rooms.open .chat-page-rooms-header::after {
    transform: rotate(180deg);
  }

  .chat-right-panel.open {
    width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .chat-layout {
    flex-direction: column;
  }

  .chat-rp-map {
    height: 150px;
  }

  /* Chat input pinned at bottom */
  .chat-input-area {
    position: sticky;
    bottom: 0;
    z-index: 10;
  }

  /* Chat messages adjustments */
  .chat-messages {
    padding: 10px;
  }

  .chat-msg {
    gap: 8px;
  }

  .chat-msg-grouped {
    padding-left: 48px;
  }

  .chat-msg-body {
    font-size: 0.85rem;
  }

  .chat-msg-photo {
    max-width: 240px;
  }

  .chat-map-preview {
    width: 220px;
    height: 130px;
  }

  /* Chat input touch targets */
  .chat-input-btn {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  .chat-send-btn {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  /* Room items touch targets */
  .chat-room-item {
    padding: 12px;
    min-height: 44px;
  }

  /* Chat msg timestamp always visible on mobile */
  .chat-msg .chat-msg-time {
    opacity: 0.6;
  }
}

@media (max-width: 480px) {
  .chat-msg-photo {
    max-width: 180px;
  }

  .chat-map-preview {
    width: 180px;
    height: 110px;
  }

  .chat-page-rooms.open {
    max-height: 35vh;
  }
}

/* ========================================================
   Feature 1: Emoji Reactions
   ======================================================== */
.chat-msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.chat-reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.chat-reaction-pill:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.chat-reaction-mine {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--green);
}

.chat-reaction-picker {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.chat-reaction-picker-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.1s;
}

.chat-reaction-picker-btn:hover {
  background: var(--surface-hover);
  transform: scale(1.2);
}

/* Message hover action bar */
.chat-msg-actions-bar {
  position: absolute;
  top: 0;
  right: 8px;
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10;
}

.chat-msg {
  position: relative;
}

.chat-msg-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
}

.chat-msg-action-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ========================================================
   Feature 2: Message Replies
   ======================================================== */
.chat-reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--green);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chat-reply-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-reply-preview-label {
  font-size: 0.75rem;
  color: var(--green-light);
}

.chat-reply-preview-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-reply-preview-close {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-reply-preview-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.chat-reply-quote {
  padding: 4px 10px;
  margin-bottom: 4px;
  border-left: 3px solid var(--green);
  background: rgba(16, 185, 129, 0.05);
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.15s;
}

.chat-reply-quote:hover {
  background: rgba(16, 185, 129, 0.1);
}

.chat-reply-quote-name {
  color: var(--green-light);
  font-weight: 600;
  margin-right: 6px;
}

.chat-reply-quote-body {
  color: var(--text-muted);
}

/* Message highlight when scrolled to */
.chat-msg-highlight {
  animation: msg-highlight-pulse 2s ease;
}

@keyframes msg-highlight-pulse {
  0%, 100% { background: transparent; }
  20%, 60% { background: rgba(245, 158, 11, 0.1); }
}

/* ========================================================
   Feature 3: User Status
   ======================================================== */
.chat-msg-status {
  font-size: 0.75rem;
  margin-left: 2px;
}

.chat-member-status-indicator {
  font-size: 0.7rem;
  margin-left: 4px;
}

/* ========================================================
   Feature 4: Badges
   ======================================================== */
.chat-badge-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 0.65rem;
  margin-left: 2px;
  vertical-align: middle;
  line-height: 1;
}

/* ========================================================
   Feature 5: Polls
   ======================================================== */
.chat-poll-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-top: 4px;
  max-width: 400px;
}

.chat-poll-question {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 10px;
}

.chat-poll-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-poll-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  transition: border-color 0.15s;
  text-align: left;
  width: 100%;
}

.chat-poll-option:hover {
  border-color: var(--green);
}

.chat-poll-voted {
  border-color: var(--green);
  background: rgba(16, 185, 129, 0.08);
}

.chat-poll-option-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(16, 185, 129, 0.12);
  border-radius: 6px;
  transition: width 0.3s ease;
  pointer-events: none;
}

.chat-poll-option-text {
  position: relative;
  z-index: 1;
  flex: 1;
}

.chat-poll-option-count {
  position: relative;
  z-index: 1;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 8px;
  white-space: nowrap;
}

.chat-poll-footer {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: right;
}

/* ========================================================
   Feature 6: Chat Commands
   ======================================================== */
.chat-command-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 2px solid;
  background: rgba(0,0,0,0.15);
  font-weight: 800;
  font-size: 1.1rem;
  animation: command-pop 0.3s ease;
  margin: 4px 0;
}

.chat-command-emoji {
  font-size: 1.4rem;
}

.chat-command-text {
  letter-spacing: 0.5px;
}

@keyframes command-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* Embedded images in message body */
.chat-msg-embedded-img {
  max-width: 360px;
  max-height: 260px;
  border-radius: var(--radius);
  margin: 4px 0;
  display: block;
}

/* ========================================================
   Voice Chat — Walkie-Talkie Bar
   ======================================================== */
/* ---- Universal Voice Bar (fixed, always on screen) ---- */
.voice-bar-global {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  min-width: 340px;
  max-width: 620px;
  width: auto;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(16, 185, 129, 0.3);
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.voice-bar-global-active {
  display: block;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.voice-open-mic-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-sm, 6px);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--green-light);
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  white-space: nowrap;
}

.voice-call-member-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.chat-rp-member:hover .voice-call-member-btn {
  opacity: 1;
}
.voice-call-member-btn:hover {
  background: rgba(16, 185, 129, 0.15);
}

/* Inline join button in chat header */
.voice-join-inline {
  font-size: 1rem !important;
}
.voice-join-inline.voice-join-active {
  color: var(--green-light) !important;
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: var(--green) !important;
}

.voice-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
}

.voice-bar-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.voice-bar-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--green-light);
  text-transform: uppercase;
}

.voice-bar-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.voice-bar-speakers {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.voice-speaker-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  animation: voice-pulse 1.5s ease infinite;
}

.voice-speaker-me {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green-light);
  border-color: rgba(16, 185, 129, 0.3);
}

@keyframes voice-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.voice-channels-open {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-left: 4px;
}

.voice-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.voice-join-btn {
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s;
}

.voice-join-btn:hover {
  border-color: var(--green);
  color: var(--green-light);
  background: rgba(16, 185, 129, 0.05);
}

.voice-ptt-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.15s;
  white-space: nowrap;
}

.voice-ptt-btn:hover:not(:disabled) {
  border-color: var(--green);
  color: var(--green-light);
}

.voice-ptt-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.voice-ptt-active {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #f87171;
  animation: voice-live-pulse 1s ease infinite;
}

@keyframes voice-live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.voice-leave-btn {
  padding: 6px 12px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: none;
  color: #f87171;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.15s;
}

.voice-leave-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

.voice-mic-viz {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
  padding: 0 4px;
  flex-shrink: 0;
}

.voice-mic-bar {
  display: block;
  width: 3px;
  height: 8%;
  min-height: 2px;
  border-radius: 2px;
  background: var(--green-light);
  transition: height 0.06s linear;
}

.voice-mic-muted .voice-mic-bar {
  background: var(--text-muted);
  height: 8% !important;
  opacity: 0.3;
}

@media (max-width: 768px) {
  .voice-bar-inner {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  .voice-bar-speakers {
    order: 3;
    width: 100%;
  }

  .voice-ptt-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
}
