/* ========================
   FF — Moderation & Communication Styles
   Waveform player, delivery ticks, recording states,
   report wizard, reputation badges, keyboard shortcuts
   ======================== */

/* ── Waveform Player ── */
.waveform-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-width: 200px;
  max-width: 300px;
  border-radius: 20px;
  margin-bottom: 4px;
}

.waveform-sent {
  background: rgba(255, 255, 255, 0.08);
}

.waveform-received {
  background: rgba(0, 0, 0, 0.04);
}

.waveform-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--primary, #3D7EFF);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.2s;
  box-shadow: 0 2px 8px rgba(61, 126, 255, 0.25);
}

.waveform-play-btn:hover {
  transform: scale(1.08);
}

.waveform-play-btn:active {
  transform: scale(0.95);
}

.waveform-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.waveform-canvas {
  width: 100%;
  height: 40px;
  cursor: pointer;
  border-radius: 4px;
}

.waveform-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.waveform-time {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.waveform-speed-btns {
  display: flex;
  gap: 2px;
}

.waveform-speed-btn {
  background: none;
  border: 1px solid transparent;
  color: inherit;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  cursor: pointer;
  opacity: 0.5;
  font-weight: 600;
  transition: all 0.15s;
}

.waveform-speed-btn.active {
  opacity: 1;
  border-color: currentColor;
}

.waveform-speed-btn:hover {
  opacity: 0.8;
}

/* ── Live Waveform (Recording) ── */
.live-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 0 4px;
}

.live-waveform-bar {
  width: 3px;
  min-height: 4px;
  background: #ff3b30;
  border-radius: 2px;
  transition: height 0.08s ease;
}

/* ── Recording Indicator (Enhanced) ── */
.recording-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  flex: 1;
  color: #ff3b30;
  font-weight: 700;
  font-size: 13px;
}

.recording-state .rec-dot {
  width: 10px;
  height: 10px;
  background: #ff3b30;
  border-radius: 50%;
  animation: rec-pulse 1.2s ease-in-out infinite;
}

.recording-state .rec-timer {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.recording-state .rec-cancel-hint {
  font-size: 11px;
  opacity: 0.6;
  margin-left: auto;
  font-weight: 400;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ── Delivery Ticks (Enhanced) ── */
.msg-ticks {
  font-size: 12px;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  transition: color 0.3s ease, transform 0.2s ease;
}

.tick-pending {
  color: var(--text-muted, #999);
  animation: tick-spin 1.5s linear infinite;
}

.tick-sent {
  color: var(--text-muted, #999);
}

.tick-delivered {
  color: var(--text-secondary, #666);
}

.tick-read {
  color: #3D7EFF;
  font-weight: 700;
}

.tick-failed {
  color: #ef4444;
  font-weight: 700;
}

@keyframes tick-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── Recording State in Header ── */
.chat-status.recording {
  color: #ff3b30 !important;
  animation: rec-text-pulse 1.5s ease infinite;
}

@keyframes rec-text-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Report Wizard ── */
.report-wizard {
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
}

.report-progress {
  margin-bottom: 20px;
}

.report-progress-bar {
  height: 4px;
  background: var(--bg-sunken, #f0f0f0);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.report-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary, #3D7EFF), #8B5CF6);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.report-step-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.report-step-labels .active {
  color: var(--primary, #3D7EFF);
  font-weight: 600;
}

.report-header {
  margin-bottom: 16px;
}

.report-categories {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.report-category-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.report-category-item:hover {
  border-color: var(--primary, #3D7EFF);
  background: var(--primary-ghost, rgba(61, 126, 255, 0.05));
}

.report-category-item.selected {
  border-color: var(--primary, #3D7EFF);
  background: var(--primary-ghost, rgba(61, 126, 255, 0.08));
}

.report-cat-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.report-cat-text {
  flex: 1;
  min-width: 0;
}

.report-cat-label {
  font-weight: 600;
  font-size: 14px;
}

.report-cat-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.report-cat-check {
  color: var(--primary, #3D7EFF);
  font-weight: 700;
  font-size: 16px;
}

/* ── Reputation Badges ── */
.reputation-badge {
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  cursor: help;
}

.rep-progress {
  width: 100%;
  max-width: 200px;
}

.rep-progress-bar {
  height: 6px;
  background: var(--bg-sunken, #f0f0f0);
  border-radius: 3px;
  overflow: hidden;
}

.rep-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.rep-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Correction Cards ── */
.correction-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 12px;
  margin: 8px 0;
}

.correction-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.correction-author {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.native-badge {
  font-size: 12px;
  cursor: help;
}

.correction-diff {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-sunken, #f7f7f7);
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.6;
}

.correction-original del {
  color: #ef4444;
  text-decoration: line-through;
  opacity: 0.7;
}

.correction-corrected ins {
  color: #22c55e;
  text-decoration: none;
  font-weight: 600;
}

.correction-explanation {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

.correction-actions {
  display: flex;
  gap: 8px;
}

.correction-vote-btn {
  background: var(--bg-sunken, #f5f5f5);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.correction-vote-btn:hover {
  border-color: var(--primary);
}

.correction-vote-btn.voted {
  background: var(--primary-ghost);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* ── Keyboard Shortcut Overlay ── */
.keyboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.keyboard-overlay-content {
  background: var(--bg-surface, #fff);
  border-radius: 20px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
}

.keyboard-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.keyboard-overlay-header h3 {
  margin: 0;
  font-size: 18px;
}

.keyboard-shortcuts-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}

.shortcut-row:hover {
  background: var(--bg-sunken, #f7f7f7);
}

.shortcut-keys {
  display: flex;
  align-items: center;
  gap: 4px;
}

.shortcut-plus {
  font-size: 11px;
  opacity: 0.4;
}

.shortcut-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  background: var(--bg-sunken, #f0f0f0);
  border: 1px solid var(--border, #ddd);
  border-bottom-width: 2px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
}

.shortcut-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.keyboard-overlay-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.keyboard-overlay-footer kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  margin: 0 2px;
}

/* ── Connection Status Banner ── */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 6px 16px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.connection-banner.ws-reconnecting {
  background: linear-gradient(90deg, #f59e0b, #f97316);
  color: white;
}

.connection-banner.polling-active {
  background: linear-gradient(90deg, #f97316, #ef4444);
  color: white;
}

.connection-banner.offline {
  background: linear-gradient(90deg, #ef4444, #dc2626);
  color: white;
}

/* ── Muted/Archived Chat Indicators ── */
.chat-item-muted {
  opacity: 0.7;
}

.chat-item-muted .chat-item-name::after {
  content: '🔇';
  font-size: 12px;
  margin-left: 6px;
}

.chat-item-archived {
  opacity: 0.5;
}

.archived-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border-top: 1px solid var(--border);
}

.archived-section-header:hover {
  background: var(--bg-sunken);
}

/* ── Pending Message States ── */
.msg-bubble-wrapper.pending {
  opacity: 0.7;
}

.msg-bubble-wrapper.pending .msg-bubble {
  position: relative;
}

.msg-bubble-wrapper.pending .msg-bubble::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  animation: pending-shimmer 1.5s infinite;
}

@keyframes pending-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.msg-bubble-wrapper.failed .msg-bubble {
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Desktop Enhancements (≥1024px) ── */
@media (min-width: 1024px) {
  .waveform-player {
    max-width: 360px;
  }

  .report-wizard {
    min-width: 400px;
  }

  .keyboard-overlay-content {
    animation: scale-in 0.2s ease;
  }

  @keyframes scale-in {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }
}
