/* ═══════════════════════════════════════════════
   NovaCalls — Premium Call Screen for FF App
   Native WebRTC Call UI (replaces Jitsi)
   Full-screen optimized for PC↔PC, PC↔Mobile, Mobile↔Mobile
   ═══════════════════════════════════════════════ */

/* ── CALL OVERLAY (full-screen call container) ── */
.nova-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #080c10;
  font-family: 'Syne', var(--font-display), system-ui, sans-serif;
  animation: nova-fade-in 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  /* Fill entire viewport including mobile browser chrome */
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
@keyframes nova-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── CALL HEADER ── */
.nova-call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(8,12,16,0.92) 0%, rgba(8,12,16,0.6) 80%, transparent 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  /* Safe area for notch devices */
  padding-top: max(10px, env(safe-area-inset-top, 10px));
}
.nova-call-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nova-call-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}
.nova-call-name {
  font-weight: 700;
  font-size: 15px;
  color: #e8edf4;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.nova-call-status {
  font-size: 11px;
  color: #8899aa;
  font-family: 'DM Mono', var(--font-body), monospace;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.nova-call-status.connected { color: #00ff88; }
.nova-call-timer {
  font-family: 'DM Mono', var(--font-body), monospace;
  font-size: 14px;
  color: #e8edf4;
  letter-spacing: 1px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* ── VIDEO AREA (legacy — kept for compatibility) ── */
.nova-call-video-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #080c10;
}

/* Remote Video (fills the area) */
.nova-remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Avatar fallback when video is off */
.nova-avatar-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: nova-avatar-breathe 4s ease-in-out infinite;
}
@keyframes nova-avatar-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
.nova-avatar-big {
  width: 120px; height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 0 40px rgba(0,229,255,0.15);
}
.nova-avatar-name {
  font-size: 20px;
  font-weight: 700;
  color: #e8edf4;
}
.nova-avatar-status-text {
  font-size: 13px;
  color: #556677;
  font-family: 'DM Mono', var(--font-body), monospace;
}

/* Animated background rings behind avatar */
.nova-bg-rings {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 0;
}
.nova-bg-ring {
  position: absolute;
  border: 1.5px solid rgba(0,229,255,0.08);
  border-radius: 50%;
  animation: nova-ring-expand 4s ease-out infinite;
}
.nova-bg-ring:nth-child(1) { width: 200px; height: 200px; animation-delay: 0s; }
.nova-bg-ring:nth-child(2) { width: 300px; height: 300px; animation-delay: 1.3s; }
.nova-bg-ring:nth-child(3) { width: 400px; height: 400px; animation-delay: 2.6s; }
@keyframes nova-ring-expand {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Speaking glow on remote */
.nova-call-video-area.speaking {
  box-shadow: inset 0 0 40px rgba(0,255,136,0.06);
}
.nova-call-video-area.speaking .nova-remote-video {
  box-shadow: 0 0 0 3px rgba(0,255,136,0.25);
}

/* ── CALL CONTROLS BAR (floating over video) ── */
.nova-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(0deg, rgba(8,12,16,0.92) 0%, rgba(8,12,16,0.6) 80%, transparent 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  /* Safe area for bottom bar devices */
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
}
.nova-ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  background: rgba(20, 26, 34, 0.85);
  color: #8899aa;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 60px;
  font-family: inherit;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.nova-ctrl-btn:hover {
  background: rgba(26, 34, 48, 0.9);
  color: #e8edf4;
  border-color: rgba(255,255,255,0.2);
}
.nova-ctrl-btn.active {
  background: rgba(0,229,255,0.15);
  border-color: rgba(0,229,255,0.35);
  color: #00e5ff;
  box-shadow: 0 0 20px rgba(0,229,255,0.1);
}
.nova-ctrl-btn.danger {
  border-color: rgba(255,59,92,0.3);
}
.nova-ctrl-btn.danger:hover {
  background: rgba(255,59,92,0.2);
  border-color: rgba(255,59,92,0.5);
  color: #ff3b5c;
}
.nova-ctrl-icon { font-size: 22px; line-height: 1; }
.nova-ctrl-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── CONNECTION QUALITY ── */
.nova-quality-indicator {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.nova-quality-bar {
  width: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  transition: background 0.3s;
}
.nova-quality-bar:nth-child(1) { height: 4px; }
.nova-quality-bar:nth-child(2) { height: 7px; }
.nova-quality-bar:nth-child(3) { height: 10px; }
.nova-quality-bar:nth-child(4) { height: 14px; }
.nova-quality-bar.good { background: #00ff88; }
.nova-quality-bar.ok   { background: #fbbf24; }
.nova-quality-bar.bad  { background: #ff3b5c; }

/* ── INCOMING CALL FULLSCREEN (UPGRADED) ── */
.nova-incoming-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(180deg, #080c10 0%, #0f1419 40%, #0a0f1e 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', var(--font-display), system-ui, sans-serif;
  animation: nova-fade-in 0.4s ease both;
}
.nova-incoming-rings-container {
  position: absolute;
  width: 200px; height: 200px;
}
.nova-incoming-ring {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(0,255,136,0.2);
  border-radius: 50%;
  animation: nova-incoming-pulse 2.5s ease-out infinite;
}
.nova-incoming-ring:nth-child(2) { animation-delay: 0.6s; inset: -25px; }
.nova-incoming-ring:nth-child(3) { animation-delay: 1.2s; inset: -50px; }
@keyframes nova-incoming-pulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.nova-incoming-avatar {
  width: 120px; height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 800;
  color: #fff;
  position: relative;
  z-index: 2;
  animation: nova-avatar-glow 2s ease-in-out infinite;
}
@keyframes nova-avatar-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,255,136,0.3); }
  50% { box-shadow: 0 0 40px 10px rgba(0,255,136,0.12); }
}

.nova-incoming-name {
  color: #e8edf4;
  font-size: 28px;
  font-weight: 700;
  margin-top: 28px;
  z-index: 2;
}
.nova-incoming-type {
  color: #8899aa;
  font-size: 14px;
  margin-top: 8px;
  z-index: 2;
  font-family: 'DM Mono', var(--font-body), monospace;
}
.nova-incoming-actions {
  display: flex;
  gap: 60px;
  margin-top: 60px;
  z-index: 2;
}
.nova-incoming-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: white;
  font-family: inherit;
}
.nova-incoming-btn-circle {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}
.nova-incoming-btn-circle:hover { transform: scale(1.08); }
.nova-incoming-btn-circle.accept {
  background: linear-gradient(135deg, #00ff88, #059669);
  box-shadow: 0 4px 30px rgba(0,255,136,0.35);
  animation: nova-slide-hint 1.5s ease-in-out infinite;
}
.nova-incoming-btn-circle.decline {
  background: linear-gradient(135deg, #ff3b5c, #dc2626);
  box-shadow: 0 4px 30px rgba(255,59,92,0.3);
}
@keyframes nova-slide-hint {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(6px); }
}
.nova-incoming-btn-label {
  font-size: 12px;
  color: #8899aa;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════════
   VIDEO GRID — Full-Screen Optimized Layout
   Supports: PC↔PC, PC↔Mobile, Mobile↔Mobile
   ═══════════════════════════════════════════════ */

.nova-video-grid {
  /* Fill entire overlay — header/controls float on top */
  position: absolute;
  inset: 0;
  display: grid;
  gap: 2px;
  overflow: hidden;
  background: #080c10;
  z-index: 1;
  /* Default: single tile fills entire screen */
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

/* ── Video Tile ── */
.nova-video-tile {
  position: relative;
  background: #0f1419;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  border: 1px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.nova-video-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: absolute;
  inset: 0;
}
.nova-video-tile.is-local video {
  transform: scaleX(-1);
}

/* Tile avatar fallback */
.nova-tile-avatar-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 2;
}
.nova-tile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
}
.nova-tile-name-fallback {
  font-size: 13px;
  color: #8899aa;
  font-weight: 600;
}

/* Tile label (bottom overlay) */
.nova-tile-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 6px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #e8edf4;
  font-weight: 600;
  z-index: 3;
}
.nova-tile-label .nova-tile-mic {
  font-size: 12px;
}
.nova-tile-label .nova-tile-mic.muted {
  filter: grayscale(1);
  opacity: 0.5;
}

/* "YOU" badge on local tile */
.nova-tile-you-badge {
  position: absolute;
  top: 8px; left: 10px;
  font-size: 8px;
  font-weight: 700;
  color: #080c10;
  background: #00e5ff;
  padding: 2px 8px;
  border-radius: 99px;
  z-index: 5;
  letter-spacing: 0.5px;
}

/* Active speaker glow */
.nova-video-tile.speaking {
  border-color: rgba(0, 255, 136, 0.5);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.15), inset 0 0 20px rgba(0, 255, 136, 0.03);
}

/* Reconnecting State */
.nova-video-tile.reconnecting::after {
  content: "Reconnecting...";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fbbf24;
  font-family: inherit;
  font-weight: 700;
  z-index: 20;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ── Participant Count Badge ── */
.nova-participant-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #e8edf4;
  background: rgba(255,255,255,0.1);
  padding: 3px 10px;
  border-radius: 99px;
  font-family: 'DM Mono', var(--font-body), monospace;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* ── Flip Camera button active state ── */
.nova-ctrl-btn.flip-active {
  background: rgba(124, 58, 237, 0.15);
  border-color: rgba(124, 58, 237, 0.3);
  color: #a855f7;
}

/* ── PiP button ── */
.nova-ctrl-btn.pip-active {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.3);
  color: #fbbf24;
}


/* ═══════════════════════════════════════════════
   GRID LAYOUTS BY PARTICIPANT COUNT
   ═══════════════════════════════════════════════ */

/* 2 participants: side by side on desktop, stacked on mobile handled below */
.nova-video-grid[data-count="2"] {
  grid-template-columns: 1fr 1fr;
}
/* 3-4 participants */
.nova-video-grid[data-count="3"],
.nova-video-grid[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
/* 5-6 participants */
.nova-video-grid[data-count="5"],
.nova-video-grid[data-count="6"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
/* 7-9 participants */
.nova-video-grid[data-count="7"],
.nova-video-grid[data-count="8"],
.nova-video-grid[data-count="9"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}
/* 10+ participants: scrollable 4-col grid */
.nova-video-grid.many-participants {
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(120px, 1fr);
  align-content: start;
  overflow-y: auto;
}


/* ═══════════════════════════════════════════════
   PIP MODE (2 Participants) — FULL SCREEN REMOTE
   Remote video fills 100% of screen.
   Local video is a small floating overlay.
   ═══════════════════════════════════════════════ */
.nova-video-grid.pip-mode {
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
  padding: 0 !important;
  gap: 0 !important;
}

.nova-video-grid.pip-mode .nova-video-tile {
  position: absolute !important;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: none !important;
  border-radius: 0 !important;
}

/* Remote video: FULL SCREEN — covers entire viewport */
.nova-video-grid.pip-mode .nova-video-tile:not(.is-local) {
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 1 !important;
  border-radius: 0 !important;
}
.nova-video-grid.pip-mode .nova-video-tile:not(.is-local) video {
  object-fit: contain;
  width: 100%;
  height: 100%;
}

/* Local self-view: Small floating PiP overlay */
.nova-video-grid.pip-mode .nova-video-tile.is-local {
  top: auto !important;
  left: auto !important;
  bottom: 100px !important;
  right: 16px !important;
  width: 120px !important;
  height: 160px !important;
  border-radius: 16px !important;
  z-index: 50 !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.12) !important;
  border: none !important;
  overflow: hidden !important;
  display: flex !important;
}
.nova-video-grid.pip-mode .nova-video-tile.is-local video {
  object-fit: cover;
  border-radius: 16px;
}

/* ── RESPONSIVE: Mobile Call Screen ── */
@media (max-width: 600px) {
  .nova-call-overlay {
    height: 100vh;
    height: 100dvh;
  }
  
  .nova-call-header {
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top, 8px));
  }
  .nova-call-avatar {
    width: 32px; height: 32px;
    font-size: 11px;
  }
  .nova-call-name {
    font-size: 14px;
  }

  .nova-controls-bar {
    gap: 6px;
    padding: 8px 6px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
  }
  .nova-ctrl-btn {
    min-width: 48px;
    padding: 8px 10px;
    border-radius: 12px;
  }
  .nova-ctrl-btn .nova-ctrl-icon { font-size: 18px; }
  .nova-ctrl-btn .nova-ctrl-label { font-size: 7px; }

  .nova-tile-avatar {
    width: 56px; height: 56px;
    font-size: 20px;
  }

  /* PIP mode on mobile: even smaller self-view */
  .nova-video-grid.pip-mode .nova-video-tile.is-local {
    width: 90px !important;
    height: 120px !important;
    bottom: 80px !important;
    right: 10px !important;
    border-radius: 12px !important;
  }
  .nova-video-grid.pip-mode .nova-video-tile.is-local video {
    border-radius: 12px;
  }

  /* Grid adjustments for mobile */
  .nova-video-grid {
    gap: 1px;
  }
  .nova-video-grid[data-count="2"] {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .nova-video-grid[data-count="5"],
  .nova-video-grid[data-count="6"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
  }
  .nova-video-grid.many-participants {
    grid-template-columns: repeat(3, 1fr);
  }

  .nova-avatar-big {
    width: 96px; height: 96px;
    font-size: 34px;
  }
  .nova-incoming-btn-circle {
    width: 60px; height: 60px;
    font-size: 26px;
  }
  .nova-incoming-actions { gap: 40px; }
}

/* ── LANDSCAPE MODE (rotated phone or small laptops) ── */
@media (max-height: 500px) and (orientation: landscape) {
  .nova-call-header {
    padding: 4px 12px;
  }
  .nova-controls-bar {
    padding: 6px 8px;
  }
  .nova-ctrl-btn {
    padding: 6px 10px;
    min-width: 44px;
  }
  .nova-ctrl-btn .nova-ctrl-label { display: none; }
  .nova-ctrl-btn .nova-ctrl-icon { font-size: 18px; }

  /* In landscape, PiP local should be smaller */
  .nova-video-grid.pip-mode .nova-video-tile.is-local {
    width: 100px !important;
    height: 75px !important;
    bottom: 60px !important;
    right: 10px !important;
    border-radius: 10px !important;
  }
}

/* ── LARGE SCREEN / DESKTOP ── */
@media (min-width: 1024px) {
  .nova-call-header {
    padding: 14px 24px;
  }
  .nova-controls-bar {
    padding: 16px 24px;
    gap: 12px;
  }
  .nova-ctrl-btn {
    min-width: 72px;
    padding: 12px 18px;
  }
  .nova-ctrl-icon { font-size: 24px; }
  .nova-ctrl-label { font-size: 10px; }

  /* Larger self-view on desktop */
  .nova-video-grid.pip-mode .nova-video-tile.is-local {
    width: 180px !important;
    height: 240px !important;
    bottom: 100px !important;
    right: 24px !important;
    border-radius: 18px !important;
    box-shadow: 0 12px 48px rgba(0,0,0,0.5), 0 0 0 2px rgba(255,255,255,0.15) !important;
  }
}

/* ── TABLET ── */
@media (min-width: 601px) and (max-width: 1023px) {
  .nova-video-grid.pip-mode .nova-video-tile.is-local {
    width: 140px !important;
    height: 187px !important;
    bottom: 90px !important;
    right: 16px !important;
  }
}

/* ═══════════════════════════════════════════════
   AUDIO WAVEFORM INDICATOR — Voice-only calls
   Shows animated bars when no video is active
   ═══════════════════════════════════════════════ */
.nova-audio-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
  margin-top: 16px;
}
.nova-audio-waveform .wave-bar {
  width: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, #00e5ff, #00ff88);
  animation: nova-wave 1.2s ease-in-out infinite;
}
.nova-audio-waveform .wave-bar:nth-child(1) { height: 12px; animation-delay: 0s; }
.nova-audio-waveform .wave-bar:nth-child(2) { height: 20px; animation-delay: 0.1s; }
.nova-audio-waveform .wave-bar:nth-child(3) { height: 32px; animation-delay: 0.2s; }
.nova-audio-waveform .wave-bar:nth-child(4) { height: 24px; animation-delay: 0.3s; }
.nova-audio-waveform .wave-bar:nth-child(5) { height: 16px; animation-delay: 0.4s; }
.nova-audio-waveform .wave-bar:nth-child(6) { height: 28px; animation-delay: 0.15s; }
.nova-audio-waveform .wave-bar:nth-child(7) { height: 10px; animation-delay: 0.35s; }
@keyframes nova-wave {
  0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ── Reconnecting Overlay with waveform ── */
.nova-reconnecting-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 16, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 20;
  animation: nova-fade-in 0.3s ease;
}
.nova-reconnecting-overlay .reconnect-text {
  color: #fbbf24;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: 'DM Mono', var(--font-body), monospace;
}
.nova-reconnecting-overlay .reconnect-wave {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 20px;
}
.nova-reconnecting-overlay .reconnect-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fbbf24;
  animation: nova-reconnect-bounce 1.4s ease-in-out infinite;
}
.nova-reconnecting-overlay .reconnect-dot:nth-child(2) { animation-delay: 0.2s; }
.nova-reconnecting-overlay .reconnect-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes nova-reconnect-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* ── Ensure controls are always above video in PIP mode ── */
.nova-call-overlay .nova-call-header {
  z-index: 100;
}
.nova-call-overlay .nova-controls-bar {
  z-index: 100;
}

/* ── Audio pipeline active indicator ── */
.nova-audio-enhanced-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 700;
  color: #00e5ff;
  background: rgba(0, 229, 255, 0.1);
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.nova-audio-enhanced-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #00e5ff;
  animation: nova-pulse-dot 2s ease-in-out infinite;
}
@keyframes nova-pulse-dot {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Fade-out keyframe */
@keyframes nova-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}


/* ═══════════════════════════════════════════════
   DEVICE CHECK SCREEN — Pre-Call Setup
   ═══════════════════════════════════════════════ */
.nova-device-check-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: linear-gradient(180deg, #080c10 0%, #0f1419 50%, #0a0f1e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', var(--font-display), system-ui, sans-serif;
  animation: nova-fade-in 0.35s ease both;
  padding: 16px;
}

.nova-dc-card {
  background: rgba(15, 20, 28, 0.85);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 32px;
  max-width: 480px;
  width: 100%;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  animation: nova-dc-slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes nova-dc-slide-up {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.nova-dc-header {
  text-align: center;
  margin-bottom: 24px;
}
.nova-dc-title {
  font-size: 24px;
  font-weight: 800;
  color: #e8edf4;
  margin: 0 0 4px;
}
.nova-dc-subtitle {
  font-size: 13px;
  color: #8899aa;
  margin: 0;
  font-family: 'DM Mono', monospace;
}

.nova-dc-preview-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.nova-dc-video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0a0f16;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}

.nova-dc-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  border-radius: 16px;
}

.nova-dc-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #0a0f16;
}

.nova-dc-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #00e5ff, #7c3aed);
}

.nova-dc-avatar-label {
  font-size: 12px;
  color: #556677;
  font-weight: 600;
}

.nova-dc-mirror-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 8px;
  font-weight: 700;
  color: #080c10;
  background: #00e5ff;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.5px;
}

.nova-dc-audio-meter-container {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nova-dc-meter-label {
  font-size: 11px;
  color: #8899aa;
  font-weight: 600;
  white-space: nowrap;
}
.nova-dc-audio-meter {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.nova-dc-audio-level {
  height: 100%;
  width: 0%;
  background: #22c55e;
  border-radius: 3px;
  transition: width 0.08s ease;
}

.nova-dc-devices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.nova-dc-device-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nova-dc-device-row label {
  font-size: 12px;
  color: #8899aa;
  font-weight: 600;
  min-width: 100px;
}
.nova-dc-select {
  flex: 1;
  background: rgba(20, 26, 34, 0.9);
  border: 1px solid rgba(255,255,255,0.1);
  color: #e8edf4;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  cursor: pointer;
}
.nova-dc-select:focus {
  border-color: rgba(0,229,255,0.4);
}
.nova-dc-test-btn {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(20,26,34,0.85);
  color: #8899aa;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.nova-dc-test-btn:hover {
  background: rgba(0,229,255,0.15);
  color: #00e5ff;
  border-color: rgba(0,229,255,0.3);
}

.nova-dc-network {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(20,26,34,0.5);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.04);
  margin-bottom: 20px;
}
.nova-dc-net-icon { font-size: 16px; }
#dc-net-label {
  font-size: 12px;
  color: #8899aa;
  font-family: 'DM Mono', monospace;
}

.nova-dc-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.nova-dc-btn {
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nova-dc-btn-primary {
  background: linear-gradient(135deg, #00e5ff, #0077b6);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 20px rgba(0,229,255,0.25);
}
.nova-dc-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,229,255,0.35);
}
.nova-dc-btn-secondary {
  background: rgba(255,255,255,0.06);
  color: #8899aa;
  border-color: rgba(255,255,255,0.1);
}
.nova-dc-btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  color: #e8edf4;
}
.nova-dc-btn-outline {
  background: transparent;
  color: #00e5ff;
  border-color: rgba(0,229,255,0.3);
}
.nova-dc-btn-outline:hover {
  background: rgba(0,229,255,0.1);
}
.nova-dc-btn-icon { font-size: 16px; }


/* ═══════════════════════════════════════════════
   EFFECTS PANEL — Slide-Up Glassmorphism
   ═══════════════════════════════════════════════ */
.nova-effects-panel {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(12, 16, 24, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 20px 24px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 420px;
  width: calc(100% - 32px);
  animation: nova-panel-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes nova-panel-slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.nova-effects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  color: #e8edf4;
}

.nova-effects-close {
  background: none;
  border: none;
  color: #556677;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
}
.nova-effects-close:hover {
  background: rgba(255,255,255,0.08);
  color: #e8edf4;
}

.nova-effects-section { display: flex; flex-direction: column; gap: 8px; }
.nova-effects-label {
  font-size: 10px;
  font-weight: 700;
  color: #556677;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nova-effects-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nova-effect-chip {
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  color: #8899aa;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.nova-effect-chip:hover {
  background: rgba(255,255,255,0.1);
  color: #e8edf4;
}
.nova-effect-chip[data-active="true"] {
  background: rgba(0,229,255,0.15);
  border-color: rgba(0,229,255,0.35);
  color: #00e5ff;
  box-shadow: 0 0 12px rgba(0,229,255,0.1);
}


/* ═══════════════════════════════════════════════
   NETWORK STATS OVERLAY
   ═══════════════════════════════════════════════ */
.nova-stats-overlay {
  position: absolute;
  top: 60px;
  right: 16px;
  z-index: 300;
  animation: nova-fade-in 0.25s ease both;
}

.nova-stats-card {
  background: rgba(8, 12, 20, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  min-width: 280px;
  font-family: 'DM Mono', monospace;
}

.nova-stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #e8edf4;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.nova-stats-quality-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.nova-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.nova-stats-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nova-stats-key {
  font-size: 9px;
  color: #556677;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.nova-stats-val {
  font-size: 13px;
  color: #e8edf4;
  font-weight: 600;
}

.nova-stats-graph-section {
  margin-bottom: 10px;
}
.nova-stats-graph-label {
  font-size: 9px;
  color: #556677;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 4px;
}
.nova-stats-graph {
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
}


/* ═══════════════════════════════════════════════
   BUTTON MICRO-ANIMATIONS
   ═══════════════════════════════════════════════ */

/* Mic active pulse */
.nova-ctrl-btn.active .nova-ctrl-icon {
  animation: nova-mic-pulse 2s ease-in-out infinite;
}
@keyframes nova-mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Button press feedback */
.nova-ctrl-btn:active {
  transform: scale(0.92);
  transition: transform 0.1s;
}

/* Danger button glow on hover */
.nova-ctrl-btn.danger:hover .nova-ctrl-icon {
  animation: nova-danger-shake 0.4s ease;
}
@keyframes nova-danger-shake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

/* Tile enter animation */
.nova-video-tile {
  animation: nova-tile-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes nova-tile-enter {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Quality badge transition */
.nova-quality-bar {
  transition: background 0.5s ease, height 0.3s ease;
}


/* ═══════════════════════════════════════════════
   LOW BANDWIDTH MODE
   ═══════════════════════════════════════════════ */
.nova-video-tile.low-bandwidth .nova-tile-avatar-fallback {
  filter: blur(3px);
  opacity: 0.7;
}
.nova-video-tile.low-bandwidth::after {
  content: "📶 Low Bandwidth";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.6);
  color: #fbbf24;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 99px;
  z-index: 10;
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
}


/* ═══════════════════════════════════════════════
   RESPONSIVE — Device Check
   ═══════════════════════════════════════════════ */
@media (max-width: 600px) {
  .nova-dc-card {
    padding: 20px;
    border-radius: 20px;
  }
  .nova-dc-title { font-size: 20px; }
  .nova-dc-device-row {
    flex-wrap: wrap;
  }
  .nova-dc-device-row label {
    min-width: auto;
    width: 100%;
  }
  .nova-dc-actions {
    flex-direction: column;
  }
  .nova-dc-btn {
    width: 100%;
    justify-content: center;
  }

  .nova-effects-panel {
    bottom: 70px;
    padding: 16px;
    border-radius: 16px;
  }

  .nova-stats-overlay {
    top: auto;
    bottom: 70px;
    right: 8px;
    left: 8px;
  }
  .nova-stats-card {
    min-width: auto;
  }
}

/* ═══════════════════════════════════════════════
   PORTRAIT MODE FOR REMOTE MOBILE STREAMS
   ═══════════════════════════════════════════════ */
.nova-video-tile.portrait-mode {
  aspect-ratio: 9/16;
  max-width: 400px; /* Limit width on PC */
  margin: 0 auto;
  border-radius: 16px; /* nice mobile card look */
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  background: transparent;
}
.nova-video-tile.portrait-mode video {
  object-fit: contain !important; /* Never crop */
}


/* ═══════════════════════════════════════════════
   LAYOUT MODE — Dynamic Device-Pairing Styles
   Applied via JS: layout-mobile, layout-pc-viewing-mobile, layout-pc-to-pc
   ═══════════════════════════════════════════════ */

/* ── MOBILE LAYOUT ──
   Full-screen immersive: cover mode fills the device screen.
   Optimized for head-to-torso portrait viewing.
   ─────────────────── */
.layout-mobile {
  height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available;
}

.layout-mobile .nova-video-grid.pip-mode .nova-video-tile:not(.is-local) video {
  object-fit: cover; /* Full screen on mobile device */
}

/* On mobile, remove portrait card styling — video fills naturally */
.layout-mobile .nova-video-tile.portrait-mode {
  aspect-ratio: unset;
  max-width: none;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}
.layout-mobile .nova-video-tile.portrait-mode video {
  object-fit: cover !important; /* Cover fills mobile screen */
}

/* Mobile local PiP: portrait selfie ratio */
.layout-mobile .nova-video-grid.pip-mode .nova-video-tile.is-local {
  width: 100px !important;
  height: 140px !important;
  bottom: 100px !important;
  right: 14px !important;
  border-radius: 14px !important;
}
.layout-mobile .nova-video-grid.pip-mode .nova-video-tile.is-local video {
  object-fit: cover;
}


/* ── PC VIEWING MOBILE ──
   Remote mobile stream shown centered with black pillar bars.
   Uses contain to show full frame (head to torso). Never crops.
   ─────────────────────── */
.layout-pc-viewing-mobile .nova-video-grid.pip-mode .nova-video-tile:not(.is-local) {
  background: #080c10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.layout-pc-viewing-mobile .nova-video-grid.pip-mode .nova-video-tile:not(.is-local) video {
  object-fit: contain !important; /* Show full video, pillar bars on sides */
  width: auto !important;
  height: 100% !important;
  max-width: 100%;
  margin: 0 auto;
  display: block;
}

/* Portrait mode tile on PC: nice centered card with subtle glow */
.layout-pc-viewing-mobile .nova-video-tile.portrait-mode {
  aspect-ratio: 9/16;
  max-width: 420px;
  max-height: 90%;
  margin: 0 auto;
  border-radius: 20px;
  box-shadow: 0 12px 60px rgba(0,229,255,0.08), 0 8px 40px rgba(0,0,0,0.6);
  overflow: hidden;
  background: #0a0f16;
  border: 1px solid rgba(255,255,255,0.06);
}
.layout-pc-viewing-mobile .nova-video-tile.portrait-mode video {
  object-fit: contain !important;
  border-radius: 20px;
}

/* Local self-view on PC: landscape small PiP */
.layout-pc-viewing-mobile .nova-video-grid.pip-mode .nova-video-tile.is-local {
  width: 180px !important;
  height: 135px !important; /* 4:3 for desktop webcam */
  bottom: 100px !important;
  right: 24px !important;
}


/* ── PC-TO-PC LAYOUT ──
   Standard landscape cover mode. Both parties on desktop.
   ─────────────────── */
.layout-pc-to-pc .nova-video-grid.pip-mode .nova-video-tile:not(.is-local) video {
  object-fit: cover; /* Full cover for landscape-to-landscape */
}

/* Remove portrait styling for pc-to-pc */
.layout-pc-to-pc .nova-video-tile.portrait-mode {
  aspect-ratio: unset;
  max-width: none;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}
.layout-pc-to-pc .nova-video-tile.portrait-mode video {
  object-fit: cover !important;
}


/* ── MOBILE FULL-SCREEN FIX ──
   Prevent address bar issues on mobile browsers
   ─────────────────────────── */
@media screen and (max-width: 768px) {
  .nova-call-overlay.layout-mobile {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    height: 100dvh;
  }
}

/* ── ORIENTATION CHANGE HANDLING ── */
@media screen and (orientation: portrait) and (max-width: 768px) {
  .layout-mobile .nova-video-grid.pip-mode .nova-video-tile:not(.is-local) video {
    object-fit: cover;
  }
}

@media screen and (orientation: landscape) and (max-width: 768px) {
  .layout-mobile .nova-video-grid.pip-mode .nova-video-tile:not(.is-local) video {
    object-fit: contain;
  }
  .layout-mobile .nova-video-grid.pip-mode .nova-video-tile.is-local {
    width: 120px !important;
    height: 90px !important;
    bottom: 70px !important;
  }
}

