/* LexiGlobal Messenger Chat — Facebook-Messenger style + Wi-Fi & 3 Offline/Relay/Sound Options */

#bottomNav a[data-route="messenger"] {
  position: relative;
}
.msg-nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff3b5c, #e11d48);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.45);
  pointer-events: none;
}
.msg-nav-badge[hidden] {
  display: none !important;
}

#v-messenger {
  max-width: 1260px;
  margin: 0 auto;
  padding: 8px 10px 88px;
}

.lx-msg-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(165deg, rgba(14, 29, 58, 0.96), rgba(9, 20, 42, 0.98));
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  overflow: hidden;
  color: #f4f7fb;
}

/* Top bar: Identity + 4 Transmission Modes (Own Wi-Fi + 3 Offline/Relay Options) */
.lx-msg-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(20, 40, 78, 0.95), rgba(14, 29, 58, 0.95));
  border-bottom: 1px solid rgba(212, 175, 55, 0.22);
}

.lx-msg-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lx-msg-brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0084ff, #00c6ff);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 19px;
  box-shadow: 0 4px 14px rgba(0, 132, 255, 0.38);
}

.lx-msg-brand-text h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 7px;
}

.lx-msg-mycode {
  font-size: 0.76rem;
  color: #ebd084;
  background: rgba(212, 175, 55, 0.14);
  border: 1px solid rgba(212, 175, 55, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
  user-select: all;
}

.lx-msg-brand-sub {
  margin: 2px 0 0;
  font-size: 0.74rem;
  color: rgba(226, 234, 248, 0.76);
}

/* 4-Mode Status Pills */
.lx-msg-modes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.lx-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #dbe7ff;
  cursor: pointer;
  transition: all 0.18s ease;
}

.lx-mode-pill:hover {
  background: rgba(212, 175, 55, 0.16);
  border-color: rgba(212, 175, 55, 0.45);
}

.lx-mode-pill.is-online {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.48);
  color: #6ee7b7;
}

.lx-mode-pill.is-offline {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.55);
  color: #fcd34d;
}

.lx-mode-pill.is-active {
  background: rgba(0, 132, 255, 0.22);
  border-color: rgba(56, 189, 248, 0.55);
  color: #7dd3fc;
}

.lx-mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* Smart Outbox Queue Banner (Option 1) */
.lx-outbox-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.18), rgba(217, 119, 6, 0.12));
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 0.78rem;
  color: #fde68a;
}
.lx-outbox-bar[hidden] {
  display: none !important;
}
.lx-outbox-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Main 2-column Messenger body */
.lx-msg-body {
  display: grid;
  grid-template-columns: 310px 1fr;
  min-height: 560px;
  max-height: calc(100vh - 210px);
}

@media (max-width: 820px) {
  .lx-msg-body {
    grid-template-columns: 1fr;
    max-height: none;
  }
  .lx-msg-shell[data-mobile-pane="chat"] .lx-msg-sidebar {
    display: none;
  }
  .lx-msg-shell[data-mobile-pane="list"] .lx-msg-main {
    display: none;
  }
}

/* Left Sidebar: Friends, Groups, Nearby Relay */
.lx-msg-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(212, 175, 55, 0.18);
  background: rgba(10, 22, 46, 0.75);
}

.lx-side-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lx-side-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: #f4f7fb;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.lx-side-btn:hover {
  background: rgba(212, 175, 55, 0.18);
  transform: translateY(-1px);
}
.lx-side-btn span.ic {
  font-size: 1rem;
}

.lx-side-tabs {
  display: flex;
  padding: 6px 10px 0;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.lx-side-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(226, 234, 248, 0.68);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 4px;
  cursor: pointer;
}
.lx-side-tab.is-active {
  color: #ebd084;
  border-bottom-color: #d4af37;
}

.lx-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lx-conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  color: #f4f7fb;
  transition: background 0.15s ease;
}
.lx-conv-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
.lx-conv-item.is-active {
  background: linear-gradient(90deg, rgba(0, 132, 255, 0.24), rgba(212, 175, 55, 0.14));
  border-color: rgba(56, 189, 248, 0.45);
}

.lx-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a8a, #0284c7);
  border: 1.5px solid rgba(212, 175, 55, 0.45);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff;
  flex-shrink: 0;
}
.lx-avatar.is-group {
  background: linear-gradient(135deg, #7c3aed, #db2777);
}
.lx-presence-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0b1833;
}
.lx-presence-dot.is-away {
  background: #94a3b8;
}

.lx-conv-meta {
  flex: 1;
  min-width: 0;
}
.lx-conv-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.lx-conv-sub {
  font-size: 0.74rem;
  color: rgba(226, 234, 248, 0.68);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Right Main Chat Pane */
.lx-msg-main {
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top right, rgba(0, 132, 255, 0.1), transparent 60%),
              rgba(8, 17, 36, 0.9);
  min-height: 520px;
}

.lx-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(14, 29, 58, 0.92);
  border-bottom: 1px solid rgba(212, 175, 55, 0.18);
}

.lx-chat-peer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lx-mobile-back {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 0.8rem;
  cursor: pointer;
}
@media (max-width: 820px) {
  .lx-mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
}

.lx-chat-peer-info h3 {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: #fff;
}
.lx-chat-peer-info p {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: #7dd3fc;
}

/* Call & Group Action Buttons in Chat Header */
.lx-chat-callbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lx-call-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lx-call-btn:hover {
  background: rgba(0, 132, 255, 0.28);
  border-color: #38bdf8;
}
.lx-call-btn.is-video {
  background: linear-gradient(135deg, rgba(0, 132, 255, 0.32), rgba(14, 165, 233, 0.25));
  border-color: rgba(56, 189, 248, 0.5);
}
.lx-call-btn.is-group-call {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.28), rgba(5, 150, 105, 0.25));
  border-color: rgba(52, 211, 153, 0.5);
}

/* Messages Stream */
.lx-chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lx-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.lx-msg-row.is-mine {
  align-self: flex-end;
  align-items: flex-end;
}
.lx-msg-row.is-theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.lx-msg-sender {
  font-size: 0.69rem;
  color: rgba(226, 234, 248, 0.66);
  margin: 0 6px 3px;
}

.lx-msg-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
}
.lx-msg-row.is-mine .lx-msg-bubble {
  background: linear-gradient(135deg, #0084ff, #0284c7);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.lx-msg-row.is-theirs .lx-msg-bubble {
  background: rgba(30, 49, 89, 0.92);
  border: 1px solid rgba(212, 175, 55, 0.22);
  color: #f4f7fb;
  border-bottom-left-radius: 4px;
}
.lx-msg-row.is-queued .lx-msg-bubble {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.85), rgba(180, 83, 9, 0.85));
  border: 1px dashed #fcd34d;
}

.lx-msg-media {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 280px;
}
.lx-msg-media img,
.lx-msg-media video {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 10px;
}
.lx-msg-media audio {
  width: 230px;
  height: 36px;
}

.lx-msg-ram-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.22);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.lx-msg-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.67rem;
  color: rgba(226, 234, 248, 0.62);
  margin: 3px 4px 0;
}

.lx-msg-via {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #ebd084;
}

/* Composer Bar */
.lx-chat-composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(14, 29, 58, 0.96);
  border-top: 1px solid rgba(212, 175, 55, 0.2);
}

.lx-composer-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.lx-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lx-tool-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  color: #fff;
}
.lx-tool-btn.is-recording {
  background: rgba(239, 68, 68, 0.28);
  border-color: #f87171;
  color: #fca5a5;
  animation: lxPulse 1.1s infinite;
}
.lx-tool-btn.is-camera {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(5, 150, 105, 0.18));
  border-color: rgba(52, 211, 153, 0.45);
  color: #6ee7b7;
}

@keyframes lxPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.lx-composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lx-composer-input {
  flex: 1;
  background: rgba(7, 15, 32, 0.85);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 999px;
  padding: 9px 15px;
  color: #fff;
  font-size: 0.88rem;
  outline: none;
}
.lx-composer-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.lx-send-btn {
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #0084ff, #00c6ff);
  color: #fff;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 132, 255, 0.35);
}
.lx-send-btn:hover {
  filter: brightness(1.08);
}

/* Modals (Camera RAM-Only Studio, Add Friend, Create Group, QR/Sound Modem, Active Call) */
.lx-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(4, 10, 24, 0.82);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 14px;
}
.lx-modal-backdrop[hidden] {
  display: none !important;
}

.lx-modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(165deg, #102347, #09152e);
  border: 1px solid rgba(212, 175, 55, 0.42);
  border-radius: 18px;
  padding: 16px;
  color: #f4f7fb;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.6);
}

.lx-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
}
.lx-modal-head h3 {
  margin: 0;
  font-size: 1rem;
  color: #ebd084;
}
.lx-modal-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}

/* In-App Camera Viewfinder (Send Without Saving in Gallery) */
.lx-cam-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.4);
}
.lx-cam-stage video,
.lx-cam-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lx-cam-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.88);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.lx-cam-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

/* QR & Ultrasonic/Audible Sound Modem Studio */
.lx-qr-box {
  display: grid;
  place-items: center;
  padding: 14px;
  background: #fff;
  border-radius: 14px;
  width: fit-content;
  margin: 10px auto;
}
.lx-qr-box svg {
  width: 190px;
  height: 190px;
  display: block;
}

.lx-sound-canvas {
  width: 100%;
  height: 76px;
  background: #061024;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 10px;
  display: block;
  margin: 8px 0;
}

/* WebRTC Call Overlay (1-on-1 & Group Audio/Video Call) */
.lx-call-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 10px 0;
}
.lx-call-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #050d1e;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(212, 175, 55, 0.35);
}
.lx-call-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lx-call-tile-label {
  position: absolute;
  bottom: 6px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.72rem;
}

.lx-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.lx-form-field label {
  font-size: 0.76rem;
  color: #cbd5e1;
  font-weight: 600;
}
.lx-form-field input,
.lx-form-field textarea,
.lx-form-field select {
  background: rgba(7, 15, 32, 0.9);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 10px;
  padding: 8px 11px;
  color: #fff;
  font-size: 0.85rem;
}
