/**
 * Call Page Base Styles
 * Video area, panels, controls bar, titlebar
 */

:root {
  --accent-primary: #5bc0be;
  --accent-secondary: #47a2a0;
  --accent-tertiary: #3d8b89;
  --accent-danger: #e74c3c;
  --accent-warning: #f39c12;
  --bg-primary: #0a0e14;
  --bg-secondary: #131920;
  --bg-tertiary: #1a222c;
  --text-primary: #e8edf3;
  --text-secondary: #8b95a5;
  --border-color: rgba(91, 192, 190, 0.2);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --transition-fast: 0.2s ease;
}

/* ==========================================
   CALL PAGE CONTAINER
   ========================================== */
.call-page {
  display: none;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
  position: relative;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Disable text selection globally when in call mode */
body.in-call {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.call-page.active {
  display: flex;
}

/* ==========================================
   TITLEBAR - Recessed design matching landing page
   ========================================== */
.call-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  height: 48px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  /* Recessed effect: inset shadows create depth */
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.03),
    inset 0 -1px 4px rgba(0, 0, 0, 0.2);
}

/* Subtle light rim on top inner edge */
.call-titlebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255, 255, 255, 0.04) 20%, 
    rgba(255, 255, 255, 0.06) 50%, 
    rgba(255, 255, 255, 0.04) 80%, 
    transparent 100%
  );
  pointer-events: none;
}

.titlebar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.titlebar-logo {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 
    0 2px 6px rgba(0, 0, 0, 0.3),
    inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

.titlebar-logo::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, transparent 60%);
}

.titlebar-logo:hover {
  transform: scale(1.05);
  box-shadow: 
    0 3px 8px rgba(0, 0, 0, 0.35),
    inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.titlebar-logo svg {
  width: 16px;
  height: 16px;
  fill: #fff;
  position: relative;
  z-index: 1;
}

.titlebar-room-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.titlebar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ecc71;
}

.status-indicator.connecting {
  background: var(--accent-warning);
  animation: pulse 1.5s ease infinite;
}

.status-indicator.error {
  background: var(--accent-danger);
}

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

/* ==========================================
   VIDEO AREA
   ========================================== */
.video-area {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  height: 100%;
}

/* ==========================================
   VIDEO PANELS
   ========================================== */
.video-panel {
  flex: 1;
  position: relative;
  background: var(--bg-primary);
  overflow: hidden;
}

.video-panel-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.video-title-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  pointer-events: none;
}

.video-title-content {
  position: relative;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-title-content .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
}

.status-dot.speaking {
  background: #2ecc71;
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

.status-dot.mic-off {
  background: #e74c3c;
}

.video-title-text {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================
    SELF-PANEL SPLIT LAYOUT (screen share mode)
    ========================================== */

/* Self content container - holds webcam and screen share */
.self-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Webcam container - takes available space when no screen share */
.self-webcam-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  transition: opacity 0.3s ease, height 0.3s ease;
}

.self-webcam-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}

/* Main panel video mirrors when displaying self content */
video#remote-video[data-content-type="self"] {
  transform: scaleX(-1);
}

/* Screen share container - hidden by default */
.self-screen-container {
  flex: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  transition: flex 0.3s ease, opacity 0.3s ease;
}

/* When screen sharing is active, screen container gets 50% of panel */
.self-screen-container.screen-sharing {
  flex: 0.5;
}

/* ==========================================
   REMOTE CONTENT CONTAINER (split layout)
   ========================================== */
.remote-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Remote webcam container - takes available space when no screen share */
.remote-webcam-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  transition: opacity 0.3s ease, height 0.3s ease;
}

.remote-webcam-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Remote screen share container - hidden by default */
.remote-screen-container {
  flex: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  transition: flex 0.3s ease, opacity 0.3s ease;
}

/* When remote screen sharing is active, screen container gets 50% of panel */
.remote-screen-container.screen-sharing {
  flex: 1;
  min-height: 120px;
}

/* Remote screen share video - uses contain to show full screen */
.remote-screen-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Screen share label */
.screen-share-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}

.screen-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ecc71;
  animation: pulse 1.5s ease infinite;
}

.screen-share-label span:last-child {
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.self-screen-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* When webcam is hidden (only screen sharing), center it */
.self-webcam-container.hidden {
  flex: 0;
  opacity: 0;
}

/* ==========================================
    EMPTY PLACEHOLDER
    ========================================== */
.empty-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  gap: 16px;
  padding: 24px;
}

.empty-placeholder-icon {
  width: 64px;
  height: 64px;
  background: rgba(91, 192, 190, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-placeholder-icon svg {
  width: 32px;
  height: 32px;
  stroke: var(--accent-primary);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-placeholder h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.empty-placeholder p {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
}

/* QR Code Container */
.qr-code-container {
  padding: 16px;
  background: #0a0e14;
  border: 1px solid rgba(91, 192, 190, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 182px;
  height: 182px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-code-container:hover {
  background: rgba(91, 192, 190, 0.1);
  border-color: rgba(91, 192, 190, 0.4);
  transform: scale(1.02);
}

.qr-code-container:active {
  transform: scale(0.98);
}

.qr-code-container canvas {
  display: none;
  border-radius: 4px;
}

.copy-link-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.copy-link-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(91, 192, 190, 0.3);
}

/* ==========================================
    SPLIT RESIZER - Subtle recessed design
    ========================================== */
.split-resizer {
  z-index: 100;
  cursor: col-resize;
  flex-shrink: 0;
  /* Subtle translucent bar */
  background: rgba(91, 192, 190, 0.15);
  transition: background 0.2s ease;
}

.split-resizer:hover {
  background: rgba(91, 192, 190, 0.25);
}

/* Shared resize handle style - smaller, more subtle */
.split-resizer .resizer-handle, .video-area.vertical .split-resizer .resizer-handle {
  position: relative;
  width: 25px;
  height: 25px;
  background: rgba(91, 192, 190, 0.3);
  border-radius: 20px;
  border: 1px solid rgba(91, 192, 190, 0.4);
  transition: all 0.2s ease;
}

.split-resizer:hover .resizer-handle {
  background: rgba(91, 192, 190, 0.4);
  box-shadow: 0 0 8px rgba(91, 192, 190, 0.3);
}

.split-resizer .resizer-touch {
    position: relative;
    left: -10px;
    height: 100%;
    width: 20px;
}

.video-area.vertical .split-resizer .resizer-touch {
    position: relative;
    top: -10px;
    height: 20px;
    width: 100%;
}

/* Resizer track - subtle line */
.split-resizer .resizer-track {
    position: relative;
    left: 9px;
    height: 100%;
    width: 2px;
    background-color: rgba(91, 192, 190, 0.3);
    border-radius: 1px;
}
.video-area.vertical .split-resizer .resizer-track {
    position: relative;
    top: 9px;
    width: 100%;
    height: 2px;
    background-color: rgba(91, 192, 190, 0.3);
    border-radius: 1px;
}

.split-resizer .resizer-handle {
  left: -11px;
  top: 50%;
}

.video-area.vertical .split-resizer .resizer-handle {
  left: 50%;
  top: -11px;
}

/* Ensure resizer-track is the containing block for absolutely positioned handles */
.split-resizer .resizer-track {
  position: relative;
}

.split-resizer .resizer-handle::after {
  content: '⟷';
  padding: 2px;
  color: var(--accent-primary);
}

.video-area.vertical .split-resizer .resizer-handle::after {
  content: '↕';
  padding: 8px;
  color: var(--accent-primary);
}

/* Horizontal mode - vertical resizer strip */
.video-area:not(.vertical) .split-resizer {
  top: 0;
  bottom: 0;
  width: 0;
}

/* Vertical mode - horizontal resizer strip */
.video-area.vertical .split-resizer {
  top: var(--resizer-pos, 50%);
  bottom: auto;
  left: 0;
  right: 0;
  width: 100%;
  height: 0;
}

/* ==========================================
    CONTROLS BAR - FLOATING OVERLAY
    ========================================== */

/* Controls bar - fixed position overlay, slides from right side */
.controls-bar {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%) translateX(100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: rgba(19, 25, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px 0 0 16px;
  gap: 16px;
  z-index: 9999;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  width: auto;
  height: auto;
  max-height: calc(100vh - 48px);
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Controls visible state - slide in from right */
.call-page:not(.ui-hidden) .controls-bar {
  transform: translateY(-50%) translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* When UI is hidden - controls slide right (off-screen) */
.call-page.ui-hidden .controls-bar {
  transform: translateY(-50%) translateX(100%);
  opacity: 0;
  pointer-events: none;
}

/* Split resizer hidden state */
.call-page.ui-hidden .split-resizer {
  opacity: 0;
  pointer-events: none;
  width: 0;
}

/* Video title headers hidden state */
.call-page.ui-hidden .video-panel-header {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-100%);
}

/* PiP headers hidden state - fade with main controls */
.call-page.ui-hidden .pip-panel-header,
.call-page.ui-hidden .pip-overlay-header {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-divider {
  width: 1px;
  height: 32px;
  background: var(--border-color);
}

.control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 56px;
  min-height: 48px;
}

.control-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.control-btn.active {
  background: rgba(91, 192, 190, 0.15);
  color: var(--accent-primary);
  border-color: rgba(91, 192, 190, 0.3);
}

.control-btn.danger {
  background: rgba(212, 84, 92, 0.15);
  color: #d4545c;
  border-color: rgba(212, 84, 92, 0.3);
}

.control-btn.danger:hover {
  background: rgba(212, 84, 92, 0.25);
  color: #d4545c;
  border-color: rgba(212, 84, 92, 0.5);
}

.control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon {
  font-size: 20px;
  line-height: 1;
}

.btn-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* End call button - styled same as other control buttons */
.end-call-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(212, 84, 92, 0.15);
  color: #d4545c;
  border: 1px solid rgba(212, 84, 92, 0.3);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 56px;
  min-height: 48px;
}

.end-call-btn:hover {
  background: rgba(212, 84, 92, 0.25);
  color: #d4545c;
  border-color: rgba(212, 84, 92, 0.5);
}

/* Quality buttons */
.quality-group {
  display: flex;
  gap: 4px;
}

.quality-btn {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quality-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.quality-btn.active {
  background: rgba(91, 192, 190, 0.15);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* ==========================================
    RESPONSIVE - PORTRAIT (controls on side)
    ========================================== */
@media (max-width: 768px) {
  .video-area {
    flex-direction: column;
  }

  .video-panel.self-panel {
    height: 200px;
  }

  .split-resizer {
    width: 100%;
    height: 8px;
    cursor: row-resize;
  }

  .resizer-track {
    width: 100%;
    height: 40px;
  }

  /* Controls move to right side in portrait - slide from right edge */
  .controls-bar {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%) translateX(100%);
    flex-direction: column;
    padding: 12px 8px;
    gap: 4px;
    background: rgba(19, 25, 32, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px 0 0 16px;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
  }

  /* Controls visible state in portrait */
  .call-page:not(.ui-hidden) .controls-bar {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .call-page.ui-hidden .controls-bar {
    transform: translateY(-50%) translateX(100%);
    opacity: 0;
    pointer-events: none;
  }

  .control-group {
    flex-direction: column;
    gap: 2px;
  }

  .control-btn {
    flex-direction: row;
    min-width: 48px;
    min-height: 44px;
    padding: 6px 8px;
  }

  .btn-label {
    display: none;
  }

  .control-divider {
    width: 40px;
    height: 1px;
    margin: 4px 0;
  }

  .quality-group {
    flex-direction: column;
  }

  .end-call-btn {
    flex-direction: row;
    padding: 8px 12px;
    font-size: 10px;
  }
}

/* ==========================================
    RESPONSIVE - LANDSCAPE (controls at bottom center)
    ========================================== */
@media (min-width: 768px) {
  .controls-bar {
    left: 50%;
    bottom: 16px;
    top: auto;
    right: auto;
    transform: translateX(-50%) translateY(100%);
    padding: 6px 12px;
    border-radius: 24px;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    width: auto;
    max-width: calc(100vw - 32px);
  }

  /* Controls visible state in landscape - slide up from bottom */
  .call-page:not(.ui-hidden) .controls-bar {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* Landscape hidden state - slide down to bottom (overrides base hidden state) */
  .call-page.ui-hidden .controls-bar {
    transform: translateX(-50%) translateY(100%);
    opacity: 0;
    pointer-events: none;
  }

  .control-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 6px 8px;
  }

  .btn-label {
    font-size: 9px;
  }

  /* Show visible dividers in landscape mode (matching portrait/mobile) */
  .control-divider {
    width: 1px;
    height: 32px;
    background: var(--border-color);
  }
}

/* ==========================================
    RESPONSIVE - TALL LANDSCAPE (compact)
    ========================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .video-panel.self-panel {
    width: 30%;
    height: 100%;
    border-bottom: none;
  }

  .video-area {
    flex-direction: row;
  }

  .split-resizer {
    width: 8px;
    height: 100%;
    cursor: col-resize;
  }

  .resizer-track {
    width: 40px;
    height: 100%;
  }

  .btn-label {
    display: none;
  }

  .call-status-bar {
    display: none;
  }
}

/* ==========================================
     PARTICIPANTS BUTTON (titlebar)
     ========================================== */

.participants-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0;
  position: relative;
}

.participants-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.participants-btn.active {
  background: rgba(91, 192, 190, 0.15);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.participants-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.participants-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.participants-dropdown-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  transition: transform var(--transition-fast);
}

.participants-btn.active .participants-dropdown-arrow {
  transform: rotate(180deg);
}

/* ==========================================
     PARTICIPANTS DROPDOWN PANEL
     ========================================== */

/* Dropdown wrapper - positioned in titlebar area */
.participants-dropdown-wrapper {
  position: fixed;
  top: 52px;
  right: 16px;
  z-index: 400;
  pointer-events: none;
}

/* Dropdown panel - compact popup */
.participants-dropdown-panel {
  width: 260px;
  max-height: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.participants-dropdown-wrapper.active .participants-dropdown-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Dropdown header */
.participants-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

/* ==========================================
   LOADING OVERLAY - Global, covers entire viewport
   ========================================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.loading-overlay.active {
  display: flex;
  opacity: 1;
}

.loading-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0;
  white-space: nowrap;
}

/* Large spinner variant (for landing page) */
.loading-spinner.large {
  width: 64px;
  height: 64px;
  border-width: 6px;
}

/* Status-specific text colors */
.loading-text.status-connecting {
  color: var(--accent-warning);
}

.loading-text.status-publishing {
  color: var(--accent-primary);
}

.loading-text.status-waiting {
  color: var(--text-secondary);
}

.loading-text.status-connected {
  color: #2ecc71;
}

.loading-text.status-error {
  color: var(--accent-danger);
}


.participants-dropdown-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: 0.3px;
}

.participants-dropdown-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.participants-dropdown-close:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.participants-dropdown-close svg {
  width: 12px;
  height: 12px;
}

/* ==========================================
   PARTICIPANT LIST STYLES (for updateParticipantsDropdownFromSession)
   ========================================== */

/* Dropdown list container */
.participants-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

/* Custom scrollbar for dropdown */
.participants-list::-webkit-scrollbar {
  width: 4px;
}

.participants-list::-webkit-scrollbar-track {
  background: transparent;
}

.participants-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.participants-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Individual participant item - compact layout */
.participant-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: default;
  transition: background var(--transition-fast);
}

.participant-item:hover {
  background: var(--bg-tertiary);
}

.participant-item.self-participant {
  border-left: 2px solid var(--accent-primary);
  padding-left: 12px;
}

/* Participant name - left aligned */
.participant-name {
  flex: 1;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

/* Status icons container - positioned to the right of name */
.participant-icons {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  opacity: 1;
}

/* Status badge base styles - compact square icons (inside participant-icons) */
.participant-icons .status-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  transition: all var(--transition-fast);
  opacity: 1;
  padding: 0;
  font-size: initial;
  font-weight: initial;
  letter-spacing: initial;
  text-transform: none;
  margin-left: 0;
}

.participant-icons .status-badge svg {
  width: 10px;
  height: 10px;
  display: block;
  stroke: currentColor;
}

/* Mic on - green */
.participant-icons .status-badge-mic-on {
  color: #2ecc71;
}

/* Mic off - red */
.participant-icons .status-badge-mic-off {
  color: #e74c3c;
}

/* Camera on - green */
.participant-icons .status-badge-cam-on {
  color: #2ecc71;
}

/* Camera off - red */
.participant-icons .status-badge-cam-off {
  color: #e74c3c;
}

/* Speaking - green with pulse animation */
.participant-icons .status-badge-speaking {
  color: #2ecc71;
  animation: pulse 1.5s ease infinite;
}

/* Text badges for e2ee and cbr */
.status-text-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 2px;
  letter-spacing: 0.3px;
  line-height: 1.4;
}

.status-badge-e2ee-text {
  color: #5bc0be;
}

.status-badge-cbr-text {
  color: #f39c12;
}

/* Speaking - green with pulse animation */
.status-badge-speaking {
  color: #2ecc71;
  animation: pulse 1.5s ease infinite;
}

/* "You" badge */
.you-badge {
  font-size: 9px;
  font-weight: 600;
  color: var(--accent-primary);
  background: rgba(91, 192, 190, 0.15);
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* Dropdown toggle button */
.participants-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 12px;
  font-weight: 500;
}

.participants-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.participants-toggle.active {
  background: rgba(91, 192, 190, 0.15);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-icon {
  font-size: 14px;
  line-height: 1;
}

.toggle-count {
  font-size: 11px;
  font-weight: 600;
  background: rgba(91, 192, 190, 0.2);
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 20px;
  text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) and (orientation: portrait) {
  .participants-dropdown {
    right: 8px;
    left: 8px;
    width: auto;
    top: 52px;
  }
}

@media (min-width: 768px) and (orientation: landscape) {
  .participants-dropdown {
    top: 56px;
    right: 16px;
    width: 260px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .participants-dropdown {
    top: 48px;
    width: 240px;
  }
  
  .participant-item {
    padding: 6px 12px;
  }
  
  .participant-name {
    font-size: 12px;
  }
}

/* =============================================
   MEDIA OFF OVERLAYS (Camera/Mic off icons)
   ============================================= */

/* Media off overlay container */
.media-off-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  color: var(--text-secondary);
  z-index: 5;
  pointer-events: none;
}

/* Camera off overlay - centered in video panel */
#self-camera-off-overlay,
#remote-camera-off-overlay {
  z-index: 6;
}

#self-camera-off-overlay svg,
#remote-camera-off-overlay svg {
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

/* Mic off overlay - smaller, positioned in corner */
#self-mic-off-overlay,
#remote-mic-off-overlay {
  position: absolute;
  margin: auto auto 90px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#self-mic-off-overlay svg,
#remote-mic-off-overlay svg {
  width: 24px;
  height: 24px;
  color: #ff4444;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

/* Control button icon styling */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

/* Mic icon container */
.mic-icon .mic-on-svg,
.mic-icon .mic-off-svg {
  width: 24px;
  height: 24px;
}

/* Camera icon container */
.camera-icon .camera-on-svg,
.camera-icon .camera-off-svg {
  width: 24px;
  height: 24px;
}

.mic-off-svg {
  display: none;
}

.camera-off-svg {
  display: none;
}

/* Active state for control buttons (mic/camera off) */
.control-btn.active-mic-off .mic-on-svg {
  display: none;
}

.control-btn.active-mic-off .mic-off-svg {
  display: block;
}

.control-btn.active-camera-off .camera-on-svg {
  display: none;
}

.control-btn.active-camera-off .camera-off-svg {
  display: block;
}

/* Mic off indicator on control button */
.control-btn.mic-off {
  color: #ff4444;
}

.control-btn.mic-off:hover {
  background: rgba(255, 68, 68, 0.1);
}

/* Camera off indicator on control button */
.control-btn.camera-off {
  color: #ff4444;
}

.control-btn.camera-off:hover {
  background: rgba(255, 68, 68, 0.1);
}

/* ============================================
   PIP MODE MEDIA OFF OVERLAYS
   ============================================ */

/* PiP main panel camera off overlay */
#pip-main-camera-off-overlay,
.pip-slot-camera-off-overlay {
  z-index: 6;
}

#pip-main-camera-off-overlay svg,
.pip-slot-camera-off-overlay svg {
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

/* PiP main panel mic off overlay */
#pip-main-mic-off-overlay,
.pip-slot-mic-off-overlay {
  position: absolute;
  margin: auto auto 90px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.pip-slot-mic-off-overlay {
  margin: auto auto 10px;
}

#pip-main-mic-off-overlay svg,
.pip-slot-mic-off-overlay svg {
  width: 24px;
  height: 24px;
  color: #ff4444;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

/* ==========================================
   E2EE INDICATOR STYLES
   ========================================== */

/* E2EE status container in titlebar */
.e2ee-status-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* E2EE status badge */
.e2ee-status-badge {
  font-size: 10px;
  font-weight: 600;
  color: #5bc0be;
  background: rgba(91, 192, 190, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(91, 192, 190, 0.3);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* E2EE safety code */
.e2ee-safety-code {
  font-size: 11px;
  font-weight: 500;
  color: #8b95a5;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  padding: 2px 6px;
  background: rgba(139, 149, 165, 0.1);
  border-radius: 4px;
  border: 1px solid rgba(139, 149, 165, 0.2);
  text-transform: uppercase;
}

/* E2EE waiting overlay on remote video */
.e2ee-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 20, 0.85);
  z-index: 20;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.e2ee-overlay.visible {
  display: flex;
}

.e2ee-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.e2ee-overlay-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(91, 192, 190, 0.2);
  border-top-color: #5bc0be;
  border-radius: 50%;
  animation: e2ee-spin 1s linear infinite;
}

@keyframes e2ee-spin {
  to { transform: rotate(360deg); }
}

.e2ee-overlay-text {
  font-size: 14px;
  font-weight: 500;
  color: #e8edf3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ==========================================
   TIME SYNC ERROR MODAL
   ========================================== */
#timesync-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#timesync-modal.active {
  display: flex;
}

.timesync-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  position: relative;
}

/* Subtle light rim on top inner edge */
.timesync-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 20%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.06) 80%,
    transparent 100%
  );
  pointer-events: none;
}

.timesync-content .modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  animation: timesync-pulse 2s ease-in-out infinite;
}

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

.timesync-content h3 {
  margin: 0 0 12px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.timesync-message {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 0 20px 0;
}

.timesync-details {
  background: rgba(91, 192, 190, 0.05);
  border: 1px solid rgba(91, 192, 190, 0.15);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 24px;
  text-align: left;
}

.timesync-details p {
  margin: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.timesync-details strong {
  color: var(--accent-primary);
  font-weight: 600;
}

.timesync-details a {
  color: var(--accent-primary);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-primary);
  transition: color 0.2s ease;
}

.timesync-details a:hover {
  color: var(--accent-secondary);
  border-bottom-style: solid;
}

#btn-timesync-ok {
  width: 100%;
  margin-top: 8px;
}


.media-status {
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  color: var(--accent-primary);
}
.media-status[data-state="securing"],
.media-status[data-state="reconnecting"],
.media-status[data-state="starting"] { color: var(--accent-warning); }
@media (max-width: 768px) {
  .call-titlebar { height: auto; min-height: 48px; flex-wrap: wrap; }
  .titlebar-right { flex-wrap: wrap; }
  .call-status-bar { flex-wrap: wrap; }
  .media-status { font-size: 11px; }
}


/* The participant popup must sit above the floating video stack. */
.participants-dropdown-wrapper { z-index: 1100; max-width: calc(100vw - 16px); }
.participants-dropdown-panel { max-width: calc(100vw - 16px); }


.e2ee-safety-code { cursor: pointer; }
.verification-dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  box-sizing: border-box;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.verification-dialog::backdrop { background: rgba(0, 0, 0, .7); }
.verification-dialog h2 { margin: 0 0 12px; font-size: 20px; }
.verification-dialog p { line-height: 1.5; color: var(--text-secondary); }
.verification-code {
  display: block;
  margin: 20px 0;
  padding: 16px;
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--accent-primary);
  font-family: monospace;
  font-size: 16px;
  line-height: 1.8;
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}
