/* ==========================================================================
   PSYCHIZEN CONNECT — WebRTC Calling & Real-Time Messaging Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Real-Time WebRTC Calling Interface (/call/{ref} & Session Room)
   -------------------------------------------------------------------------- */
.session-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Desktop 2-Column Telehealth Green Room Lounge */
.prejoin-grid-container {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 36px;
  align-items: stretch;
  max-width: 1080px;
  margin: 0 auto;
  background: rgba(14, 22, 19, 0.95);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 32px;
  padding: 36px 40px;
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: #FFF;
  transition: all 0.3s ease;
}

.prejoin-preview-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prejoin-video-monitor {
  position: relative;
  width: 100%;
  height: 310px;
  background: #070B09;
  border-radius: 20px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
}

.prejoin-video-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  background: #070B09;
}

.prejoin-self-tag {
  position: absolute;
  bottom: 12px;
  left: 14px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  color: #FFF;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.prejoin-monitor-tools {
  position: absolute;
  bottom: 10px;
  right: 12px;
  display: flex;
  gap: 8px;
}

.prejoin-tool-btn {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFF;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.prejoin-tool-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

.prejoin-diagnostics-box {
  background: #070B09;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px 20px;
}

.prejoin-info-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
}

/* Desktop Post-Session Grid */
.postsession-grid-container {
  display: grid;
  grid-template-columns: 0.88fr 1.12fr;
  gap: 32px;
  align-items: stretch;
  max-width: 960px;
  margin: 0 auto;
  padding: 40px;
  background: rgba(14, 22, 19, 0.95);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 32px;
  color: #FFF;
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8);
}

.call-viewport,
.mobile-app-session-container {
  position: relative;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  height: calc(100vh - 110px);
  min-height: 660px;
  max-height: 940px;
  background: #050807;
  border-radius: var(--radius-2xl, 28px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.room-stage-wrapper {
  display: flex;
  gap: 20px;
  position: relative;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.video-stage-main,
.call-media-stage {
  flex: 1;
  min-width: 0;
  position: relative;
  background: #050807;
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.media-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Subtle Vignettes so floating UI overlays are always crisp */
.media-canvas::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(180deg, rgba(5,8,7,0.75) 0%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}

.media-canvas::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 140px;
  background: linear-gradient(0deg, rgba(5,8,7,0.85) 0%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}

.call-remote-video.fit-contain {
  object-fit: contain !important;
  background: #000 !important;
}

/* Floating Top Header Bar */
.call-header-bar-floating,
.call-header-bar {
  position: absolute !important;
  top: 16px !important;
  left: 20px !important;
  right: 20px !important;
  z-index: 25 !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 10px 20px !important;
  background: rgba(8, 14, 11, 0.82) !important;
  backdrop-filter: blur(24px) !important;
  -webkit-backdrop-filter: blur(24px) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 999px !important;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.55) !important;
  color: #FFF !important;
  transition: all 0.25s ease !important;
}

.header-participant-info,
.call-participant-info {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  min-width: 0 !important;
}

.avatar-wrapper {
  position: relative !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  flex-shrink: 0 !important;
}

.header-avatar,
.call-avatar {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  max-width: 40px !important;
  max-height: 40px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  border: 2px solid var(--color-primary, #10B981) !important;
  display: block !important;
  flex-shrink: 0 !important;
}

.status-online-dot {
  position: absolute !important;
  bottom: 0 !important;
  right: 0 !important;
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  background: #10B981 !important;
  border: 2px solid #080E0B !important;
}

.header-meta h2,
.call-meta h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: #FFF;
  line-height: 1.25;
}

.header-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-name {
  font-size: 1.02rem;
  font-weight: 700;
  color: #FFF;
}

.header-role-pill {
  font-size: 0.72rem;
  color: #34D399;
  background: rgba(16, 185, 129, 0.15);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.header-sub-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #94A3B8;
  margin-top: 2px;
}

.e2ee-tag {
  color: #34D399;
  font-weight: 600;
  font-size: 0.72rem;
}

.header-status-text {
  font-size: 0.75rem;
  color: #CBD5E1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Speaking badges */
.speaking-badge,
.speaking-indicator-pill {
  display: none;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid #10B981;
  color: #34D399;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  animation: pulse-glow 1.5s infinite;
}

.local-mic-pill {
  border-color: #60A5FA;
  color: #93C5FD;
  background: rgba(59, 130, 246, 0.2);
}

.speaking-ring {
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.speaking-ring.is-speaking,
.video-stage-main.is-speaking {
  box-shadow: 0 0 0 3px #10B981, 0 0 30px rgba(16, 185, 129, 0.5) !important;
  border-color: #34D399 !important;
}

.session-timer-chip,
.call-timer-chip {
  background: rgba(0, 0, 0, 0.55);
  padding: 5px 14px;
  border-radius: 999px;
  font-family: ui-monospace, monospace;
  font-size: 0.92rem;
  font-weight: 700;
  color: #E2E8F0;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  animation: pulse-glow 1.5s infinite ease-in-out;
}

/* Media Elements */
.call-remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #050807;
  display: block;
}

.call-remote-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: radial-gradient(circle at center, #112019 0%, #050807 100%);
  color: #FFF;
  z-index: 2;
  text-align: center;
  padding: 20px;
}

.placeholder-avatar-wrap {
  position: relative;
  width: 120px;
  height: 120px;
}

.placeholder-halo {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px dashed rgba(16, 185, 129, 0.35);
  animation: spinHalo 16s linear infinite;
}

@keyframes spinHalo {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.call-remote-placeholder img,
.placeholder-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(16, 185, 129, 0.5);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
}

.call-waiting-text {
  font-size: 1.15rem;
  color: #F8FAFC;
  font-weight: 700;
}

.placeholder-subtext {
  font-size: 0.85rem;
  color: #94A3B8;
  max-width: 320px;
}

.connection-dots {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.connection-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  animation: wavePulse 1.2s infinite ease-in-out;
}
.connection-dots span:nth-child(2) { animation-delay: 0.2s; }
.connection-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Remote participant tag pill */
.remote-participant-pill {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.82rem;
  color: #FFF;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 12;
  font-weight: 600;
}
.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
}
.pill-hd {
  font-size: 0.68rem;
  color: #34D399;
  background: rgba(16, 185, 129, 0.2);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* Local Video PiP */
.call-local-pip {
  position: absolute;
  bottom: 92px;
  right: 24px;
  width: 220px;
  aspect-ratio: 16/9;
  background: #111B16;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.75);
  z-index: 15;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.call-local-pip:hover {
  transform: scale(1.03);
  box-shadow: 0 25px 55px rgba(0, 0, 0, 0.85);
}

.call-local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.call-pip-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #FFF;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  backdrop-filter: blur(6px);
}

.pip-flip-btn {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #FFF;
  font-size: 0.8rem;
  align-items: center;
  justify-content: center;
  z-index: 5;
  cursor: pointer;
}

/* Floating Controls Island */
.call-controls-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(8, 14, 11, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 8px 18px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
  transition: all 0.25s ease;
}

.call-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #FFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.call-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

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

.btn-tooltip {
  position: absolute !important;
  bottom: calc(100% + 12px) !important;
  top: auto !important;
  left: 50% !important;
  transform: translateX(-50%) translateY(4px) !important;
  background: rgba(0, 0, 0, 0.92) !important;
  color: #FFF !important;
  padding: 4px 10px !important;
  border-radius: 8px !important;
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  pointer-events: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transition: opacity 0.15s ease, transform 0.15s ease !important;
  white-space: nowrap !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  z-index: 50 !important;
}

.call-btn:hover .btn-tooltip {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateX(-50%) translateY(0) !important;
}

.call-btn.active-off {
  background: rgba(239, 68, 68, 0.25);
  border-color: #EF4444;
  color: #FCA5A5;
}

.call-btn.active-on {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10B981;
  color: #6EE7B7;
}

.call-btn-hangup {
  width: auto;
  height: 50px;
  padding: 0 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFF;
  font-weight: 700;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 25px rgba(220, 38, 38, 0.45);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.call-btn-hangup:hover {
  background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 30px rgba(220, 38, 38, 0.6);
}

.stage-tool-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #E2E8F0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stage-tool-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #FFF;
}

/* --------------------------------------------------------------------------
   2. Real-Time 1-on-1 Messages Inbox (/messages)
   -------------------------------------------------------------------------- */
.chat-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px;
}

.chat-card {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 180px);
  min-height: 600px;
  max-height: 840px;
  background: var(--color-surface, #FFFFFF);
  border-radius: var(--radius-2xl, 20px);
  border: 1px solid var(--color-border, #E2E8F0);
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

/* Chat Sidebar */
.chat-sidebar {
  border-right: 1px solid var(--color-border, #E2E8F0);
  display: flex;
  flex-direction: column;
  background: #FAFBFB;
}

.chat-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--color-border, #E2E8F0);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-sidebar-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-text-main, #0F172A);
}

.chat-search-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border, #E2E8F0);
}

.chat-search-input {
  width: 100%;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border, #CBD5E1);
  background: #FFF;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}

.chat-search-input:focus {
  border-color: var(--color-primary, #0D7E70);
}

.chat-conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.chat-conv-item:hover {
  background: #F1F5F5;
}

.chat-conv-item.active {
  background: #E8F5F3;
  border-left: 4px solid var(--color-primary, #0D7E70);
}

.chat-conv-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-conv-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #E2E8F0;
}

.chat-online-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10B981;
  border: 2px solid #FFF;
}

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

.chat-conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.chat-conv-name {
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--color-text-main, #0F172A);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conv-time {
  font-size: 0.75rem;
  color: var(--color-text-muted, #64748B);
  flex-shrink: 0;
}

.chat-conv-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  color: var(--color-text-muted, #64748B);
}

.chat-preview-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-unread-badge {
  background: var(--color-primary, #0D7E70);
  color: #FFF;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
  margin-left: 6px;
}

/* Chat Main Active Area */
.chat-main {
  display: flex;
  flex-direction: column;
  background: #FFF;
  position: relative;
}

.chat-main-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border, #E2E8F0);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FFF;
  z-index: 5;
}

.chat-recipient-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-recipient-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-recipient-name {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--color-text-main, #0F172A);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-verified-badge {
  color: #0284C7;
  font-size: 0.95rem;
}

.chat-recipient-status {
  font-size: 0.8rem;
  color: var(--color-text-muted, #64748B);
}

.chat-actions-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-btn-action {
  background: #F1F5F9;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.chat-btn-action:hover {
  background: #E2E8F0;
  color: var(--color-primary, #0D7E70);
}

/* Message Stream */
.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #F8FAFC;
}

.chat-msg-row {
  display: flex;
  gap: 10px;
  max-width: 72%;
}

.chat-msg-row.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-row.received {
  align-self: flex-start;
}

.chat-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
}

.chat-msg-row.sent .chat-msg-bubble {
  background: var(--color-primary, #0D7E70);
  color: #FFF;
  border-bottom-right-radius: 4px;
}

.chat-msg-row.received .chat-msg-bubble {
  background: #FFFFFF;
  color: #1E293B;
  border: 1px solid var(--color-border, #E2E8F0);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.chat-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.7rem;
  opacity: 0.8;
}

.chat-msg-row.sent .chat-msg-meta {
  color: rgba(255, 255, 255, 0.8);
}

.chat-msg-row.received .chat-msg-meta {
  color: #64748B;
}

.chat-msg-attachment {
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 280px;
}

.chat-msg-attachment img {
  width: 100%;
  display: block;
  border-radius: 12px;
  cursor: pointer;
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 16px 20px;
  background: #FFF;
  border-top: 1px solid var(--color-border, #E2E8F0);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-input-field {
  flex: 1;
  padding: 12px 18px;
  border-radius: 24px;
  border: 1px solid var(--color-border, #CBD5E1);
  outline: none;
  font-size: 0.94rem;
  transition: border-color 0.15s;
}

.chat-input-field:focus {
  border-color: var(--color-primary, #0D7E70);
}

.chat-send-btn {
  background: var(--color-primary, #0D7E70);
  color: #FFF;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-send-btn:hover {
  background: #0B6B5F;
}

/* --------------------------------------------------------------------------
   3. Universal Incoming Call Ringing Modal
   -------------------------------------------------------------------------- */
.incoming-call-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 13, 0.85);
  backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.incoming-call-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.incoming-call-box {
  background: #111B16;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  padding: 40px 32px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  animation: scale-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.incoming-caller-ring {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 0 auto 24px;
}

.incoming-caller-ring::before,
.incoming-caller-ring::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--color-primary, #0D7E70);
  animation: ring-pulse 2s infinite ease-out;
}

.incoming-caller-ring::after {
  animation-delay: 0.6s;
}

@keyframes ring-pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.5); opacity: 0; }
}

.incoming-caller-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #111B16;
  position: relative;
  z-index: 2;
}

.incoming-caller-name {
  color: #FFF;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.incoming-caller-type {
  color: #94A3B8;
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.incoming-actions {
  display: flex;
  justify-content: center;
  gap: 36px;
}

.incoming-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #FFF;
  cursor: pointer;
  transition: transform 0.15s;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.incoming-btn:hover {
  transform: scale(1.1);
}

.incoming-btn-decline {
  background: #EF4444;
}

.incoming-btn-accept {
  background: #10B981;
}

/* --------------------------------------------------------------------------
   4. Universal Active Calling UI (Desktop & Mobile Fullscreen Telehealth Stage)
   -------------------------------------------------------------------------- */
body.in-call-active {
  overflow: hidden !important;
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #050807 !important;
}

body.in-call-active header:not(.call-header-bar):not(.call-header-bar-floating),
body.in-call-active footer,
body.in-call-active .top-nav,
body.in-call-active .site-header,
body.in-call-active #siteHeader,
body.in-call-active .site-footer,
body.in-call-active .mobile-app-header,
body.in-call-active .announcement-bar,
body.in-call-active .site-announcement-bar,
body.in-call-active .crisis-banner,
body.in-call-active .mobile-bottom-nav,
body.in-call-active .navbar {
  display: none !important;
}

body.in-call-active .section {
  padding: 0 !important;
  margin: 0 !important;
  min-height: 100vh !important;
  height: 100vh !important;
  width: 100vw !important;
  background: #050807 !important;
  overflow: hidden !important;
}

body.in-call-active .session-container {
  padding: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
}

body.in-call-active .room-stage-wrapper {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  display: flex !important;
}

body.in-call-active .call-viewport,
body.in-call-active .mobile-app-session-container,
body.in-call-active .video-stage-main {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  box-shadow: none !important;
  background: #050807 !important;
  z-index: 10 !important;
}

.mobile-flip-btn {
  display: none;
}

@media (max-width: 768px) {
  body.in-call-active {
    touch-action: none;
  }

  .session-container {
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .prejoin-card,
  .prejoin-grid-container {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
    padding: 20px 16px !important;
    border-radius: 20px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6) !important;
  }

  .prejoin-video-monitor {
    height: 210px !important;
  }

  .postsession-card,
  .postsession-grid-container {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
    padding: 24px 16px !important;
    border-radius: 20px !important;
    width: 100% !important;
  }

  .mobile-app-session-container,
  .call-viewport {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    z-index: 9999999 !important;
    background: #050807 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border: none !important;
    box-shadow: none !important;
  }

  .mobile-flip-btn {
    display: flex !important;
  }

  .desktop-only,
  .screen-share-btn {
    display: none !important;
  }

  .remote-participant-pill {
    display: none !important;
  }

  .room-stage-wrapper {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow: hidden !important;
  }

  .video-stage-main,
  .call-media-stage {
    position: absolute !important;
    inset: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    min-height: 100% !important;
    height: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
    background: #050807 !important;
  }

  .call-remote-video {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    background: #050807 !important;
    z-index: 1 !important;
  }

  #audioConsultStage {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 5 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 24px !important;
    background: radial-gradient(circle at center, #0F261E 0%, #050807 100%) !important;
  }

  .call-header-bar-floating,
  .call-header-bar {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: calc(env(safe-area-inset-top, 12px) + 8px) 16px 14px 16px !important;
    background: linear-gradient(180deg, rgba(5,8,7,0.94) 0%, rgba(5,8,7,0.5) 75%, transparent 100%) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    z-index: 25 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    box-shadow: none !important;
  }

  .call-local-pip {
    position: absolute !important;
    top: calc(env(safe-area-inset-top, 16px) + 68px) !important;
    right: 14px !important;
    bottom: auto !important;
    width: 96px !important;
    height: 144px !important;
    aspect-ratio: auto !important;
    border-radius: 16px !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8) !important;
    z-index: 26 !important;
    cursor: pointer !important;
    overflow: hidden !important;
  }

  .pip-flip-btn {
    display: flex !important;
  }

  .call-controls-bar {
    position: absolute !important;
    bottom: calc(env(safe-area-inset-bottom, 12px) + 12px) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 24px) !important;
    max-width: 400px !important;
    background: rgba(10, 16, 13, 0.9) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 999px !important;
    padding: 8px 12px !important;
    gap: 8px !important;
    display: flex !important;
    justify-content: space-around !important;
    align-items: center !important;
    z-index: 30 !important;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.75) !important;
  }

  .call-btn {
    width: 44px !important;
    height: 44px !important;
    font-size: 1.15rem !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #FFF !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
  }

  .btn-tooltip {
    display: none !important;
  }

  .call-btn.active-off {
    background: rgba(239, 68, 68, 0.25) !important;
    border-color: #EF4444 !important;
    color: #FCA5A5 !important;
  }

  .call-btn.active-on {
    background: rgba(16, 185, 129, 0.25) !important;
    border-color: #10B981 !important;
    color: #6EE7B7 !important;
  }

  .call-btn-hangup {
    width: 48px !important;
    height: 48px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: #DC2626 !important;
    color: #FFF !important;
    border: none !important;
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5) !important;
  }

  .hangup-text {
    display: none !important;
  }

  /* Native Slide-Up Bottom Sheet for Chat on Mobile */
  .chat-drawer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 80dvh !important;
    height: 72dvh !important;
    border-radius: 28px 28px 0 0 !important;
    z-index: 99999999 !important;
    box-shadow: 0 -20px 60px rgba(0,0,0,0.9) !important;
    background: rgba(10, 16, 13, 0.98) !important;
    backdrop-filter: blur(28px) !important;
    -webkit-backdrop-filter: blur(28px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-bottom: none !important;
    transform: translateY(0%) !important;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .chat-drawer.collapsed {
    display: flex !important;
    transform: translateY(105%) !important;
    pointer-events: none !important;
  }

  .chat-sheet-handle {
    width: 44px;
    height: 5px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    margin: 10px auto 4px auto;
  }

  .chat-input-bar {
    padding-bottom: calc(env(safe-area-inset-bottom, 12px) + 10px) !important;
  }

  .chat-card {
    grid-template-columns: 1fr;
    height: calc(100vh - 120px);
  }
  .chat-sidebar {
    display: none;
  }
  .chat-sidebar.mobile-open {
    display: flex;
  }
}

