/**
 * WeizeRouter Live Telemetry Floating Comment Engine
 * Cyber Obsidian Dark Theme with Gold & Cyan Accents
 */

/* ============================================================
   1. FLOATING BUBBLE (MINIMIZED / CLOSED STATE)
   ============================================================ */
.wr-chat-bubble-wrap {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 9950;
  display: flex;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Desktop minimized pill */
.wr-chat-bubble-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 14, 23, 0.92);
  color: #f1f5f9;
  border: 1px solid rgba(240, 192, 64, 0.4);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75), 0 0 20px rgba(240, 192, 64, 0.15);
  border-radius: 999px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.25s ease;
  user-select: none;
}

.wr-chat-bubble-btn:hover {
  border-color: #f0c040;
  background: rgba(15, 21, 35, 0.95);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.85), 0 0 28px rgba(240, 192, 64, 0.3);
  transform: translateY(-2px);
}

.wr-chat-bubble-icon {
  font-size: 16px;
  line-height: 1;
}

.wr-chat-bubble-text {
  letter-spacing: 0.3px;
}

.wr-chat-unread-badge {
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.7);
  display: none;
}
.wr-chat-unread-badge.active {
  display: inline-block;
  animation: wrBadgePulse 1.5s infinite;
}

@keyframes wrBadgePulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); box-shadow: 0 0 14px rgba(239, 68, 68, 0.9); }
  100% { transform: scale(1); }
}

/* ============================================================
   2. NEW COMMENT PREVIEWS (ABOVE BUBBLE)
   ============================================================ */
.wr-chat-previews-container {
  position: fixed;
  bottom: 132px;
  right: 24px;
  z-index: 9940;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 320px;
}

.wr-chat-preview-item {
  background: rgba(10, 14, 23, 0.94);
  border: 1px solid rgba(112, 197, 212, 0.35);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(112, 197, 212, 0.12);
  border-radius: 12px;
  padding: 9px 13px;
  color: #e2e8f0;
  font-size: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: wrPreviewSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.wr-chat-preview-item.fade-out {
  opacity: 0;
  transform: translateY(-8px);
}

.wr-chat-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 11px;
}

.wr-chat-preview-author {
  font-weight: 700;
  color: #70c5d4;
}
.wr-chat-preview-author.is-admin {
  color: #facc15;
}

.wr-chat-preview-time {
  color: #64748b;
  font-size: 10px;
}

.wr-chat-preview-body {
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

@keyframes wrPreviewSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ============================================================
   3. FLOATING CHAT PANEL (DESKTOP)
   ============================================================ */
.wr-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  height: 480px;
  max-height: calc(100vh - 48px);
  background: rgba(9, 13, 20, 0.95);
  border: 1px solid rgba(240, 192, 64, 0.3);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.88), 0 0 32px rgba(240, 192, 64, 0.15);
  border-radius: 16px;
  z-index: 9960;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  overflow: hidden;
}

.wr-chat-panel.hidden {
  display: none !important;
}

/* Panel Header */
.wr-chat-header {
  padding: 12px 16px;
  background: rgba(14, 20, 31, 0.9);
  border-bottom: 1px solid rgba(240, 192, 64, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.wr-chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wr-chat-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wr-chat-status-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wr-chat-status-pill.closed {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.wr-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}
.wr-chat-status-pill.closed .wr-chat-status-dot {
  background: #ef4444;
}

.wr-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wr-chat-hdr-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
}

.wr-chat-hdr-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

/* Admin Quick Banner */
.wr-chat-admin-bar {
  background: rgba(240, 192, 64, 0.08);
  border-bottom: 1px solid rgba(240, 192, 64, 0.2);
  padding: 6px 14px;
  font-size: 11px;
  display: none;
  justify-content: space-between;
  align-items: center;
}
.wr-chat-admin-bar.active {
  display: flex;
}

.wr-admin-action-btn {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(240, 192, 64, 0.4);
  color: #facc15;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.wr-admin-action-btn:hover {
  background: rgba(240, 192, 64, 0.2);
  color: #fff;
}

/* Closed Banner */
.wr-chat-closed-notice {
  background: rgba(239, 68, 68, 0.12);
  border-bottom: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  font-size: 11.5px;
  padding: 8px 14px;
  text-align: center;
  font-weight: 600;
  display: none;
}
.wr-chat-closed-notice.active {
  display: block;
}

/* Slow mode indicator */
.wr-chat-slowmode-badge {
  font-size: 10px;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
  display: none;
}
.wr-chat-slowmode-badge.active {
  display: inline-block;
}

/* ============================================================
   4. CHAT MESSAGES LIST
   ============================================================ */
.wr-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.wr-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.wr-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.wr-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 11px;
  background: rgba(18, 25, 38, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  word-break: break-word;
  transition: all 0.2s ease;
  position: relative;
}

.wr-chat-msg:hover {
  background: rgba(24, 34, 52, 0.8);
  border-color: rgba(240, 192, 64, 0.2);
}

.wr-chat-msg.is-admin-msg {
  background: rgba(240, 192, 64, 0.07);
  border: 1px solid rgba(240, 192, 64, 0.35);
  box-shadow: 0 0 16px rgba(240, 192, 64, 0.06);
}

.wr-chat-msg-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.wr-chat-msg-author {
  font-weight: 700;
  font-size: 12px;
  color: #70c5d4;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.wr-chat-msg-author.is-admin {
  color: #facc15;
}

.wr-admin-badge {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #000;
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-shadow: none;
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.6);
}

.wr-chat-msg-time {
  font-size: 10px;
  color: #64748b;
  white-space: nowrap;
}

.wr-chat-msg-text {
  color: #e2e8f0;
}

.wr-chat-msg.deleted {
  opacity: 0.45;
  font-style: italic;
  color: #94a3b8;
}

/* Mod gear icon visible to admin on hover */
.wr-chat-msg-mod-btn {
  display: none;
  position: absolute;
  top: 6px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(240, 192, 64, 0.4);
  color: #facc15;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  cursor: pointer;
}
.wr-chat-panel.is-admin-view .wr-chat-msg:hover .wr-chat-msg-mod-btn {
  display: block;
}

/* ============================================================
   5. CHAT INPUT BAR
   ============================================================ */
.wr-chat-input-area {
  padding: 10px 14px;
  background: rgba(14, 20, 31, 0.95);
  border-top: 1px solid rgba(240, 192, 64, 0.15);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wr-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wr-chat-input {
  flex: 1;
  background: rgba(8, 12, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 12px;
  color: #f8fafc;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: all 0.2s ease;
}

.wr-chat-input:focus {
  border-color: #f0c040;
  box-shadow: 0 0 10px rgba(240, 192, 64, 0.2);
}

.wr-chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wr-chat-send-btn {
  background: linear-gradient(135deg, #f0c040, #d97706);
  border: none;
  color: #0a0e17;
  font-size: 14px;
  font-weight: 700;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.wr-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 0 14px rgba(240, 192, 64, 0.5);
}

.wr-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.wr-chat-input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #64748b;
  padding: 0 2px;
}

.wr-chat-char-counter.limit-near {
  color: #f59e0b;
}
.wr-chat-char-counter.limit-reached {
  color: #ef4444;
}

.wr-chat-cooldown-text {
  color: #f59e0b;
  font-weight: 600;
}

/* ============================================================
   6. MODERATION POPUP & MODALS
   ============================================================ */
.wr-chat-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.wr-chat-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.wr-chat-modal-card {
  background: rgba(14, 20, 31, 0.98);
  border: 1px solid rgba(240, 192, 64, 0.4);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(240, 192, 64, 0.2);
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.wr-chat-modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wr-chat-modal-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #f8fafc;
}

.wr-chat-modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 12.5px;
  color: #cbd5e1;
}

.wr-chat-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wr-modal-btn {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #f1f5f9;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.wr-modal-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.wr-modal-btn.danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.wr-modal-btn.danger:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fff;
}

.wr-modal-btn.gold {
  background: rgba(240, 192, 64, 0.15);
  border-color: rgba(240, 192, 64, 0.4);
  color: #facc15;
}
.wr-modal-btn.gold:hover {
  background: rgba(240, 192, 64, 0.25);
  color: #fff;
}

/* ============================================================
   7. RESPONSIVE MOBILE (BOTTOM-SHEET 55% - 65% HEIGHT)
   ============================================================ */
@media (max-width: 768px) {
  .wr-chat-bubble-wrap {
    bottom: 74px;
    right: 16px;
  }

  .wr-chat-bubble-btn {
    padding: 10px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    justify-content: center;
  }

  .wr-chat-bubble-text {
    display: none;
  }

  .wr-chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
  }

  .wr-chat-previews-container {
    bottom: 130px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  /* Mobile Bottom-Sheet */
  .wr-chat-panel {
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 60vh !important;
    max-height: 65vh !important;
    min-height: 380px !important;
    border-radius: 20px 20px 0 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-top: 1px solid rgba(240, 192, 64, 0.35) !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.85) !important;
  }

  /* Mobile handle bar */
  .wr-chat-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    margin: 8px auto 2px;
  }
}
