/* ========================================
   CSS Variables - Design System
   ======================================== */
:root {
  /* Colors */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-elevated: #1e293b;
  --bg-overlay: rgba(15, 23, 42, 0.85);

  --border-color: rgba(51, 65, 85, 0.6);
  --border-color-light: rgba(71, 85, 105, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-danger-hover: #dc2626;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  /* Z-index layers */
  --z-video: 1;
  --z-overlay: 10;
  --z-sidebar: 20;
  --z-topbar: 30;
  --z-controls: 40;
  --z-modal: 50;
  --z-tooltip: 60;
}

/* ========================================
   Reset & Base Styles
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans Arabic', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  direction: rtl;
}

/* ========================================
   App Shell Layout
   ======================================== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ========================================
   Top Bar
   ======================================== */
.top-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  min-height: 56px;
  position: relative;
  z-index: var(--z-topbar);
  backdrop-filter: blur(8px);
}

.top-bar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.top-bar-title i {
  color: var(--accent-primary);
  font-size: 1.2rem;
}

#call-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

#callTimer {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.encryption-badge {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 0.75rem;
  color: var(--accent-success);
}

.encryption-badge i {
  font-size: 0.9rem;
}

/* ========================================
   Main Content Area
   ======================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-width: 0;
}

.main-video-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  order: 1;
}

/* ========================================
   Video Container
   ======================================== */
#videosContainer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  overflow: hidden;
  min-height: 200px;
}

.main-video-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#mainVideo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.main-video-label {
  position: absolute;
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  z-index: var(--z-overlay);
  border: 1px solid var(--border-color-light);
}

/* ========================================
   Translation Caption Bar
   ======================================== */
.translation-caption-bar {
  display: none;
  width: 100%;
  background: var(--bg-overlay);
  backdrop-filter: blur(12px);
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  z-index: var(--z-overlay);
  overflow: hidden;
}

.translation-caption-bar.is-visible {
  display: block;
}

.translation-caption-bar span {
  display: block;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-primary);
  text-align: center;
}

/* ========================================
   Active Speaker Bar
   ======================================== */
#activeSpeakerBar {
  background: var(--bg-overlay);
  backdrop-filter: blur(12px);
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  z-index: var(--z-overlay);
}

.speaker-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-success);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

/* ========================================
   Video Thumbnails Strip (Left Sidebar)
   ======================================== */
#videos {
  display: flex;
  flex-direction: column;
  width: 140px;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: var(--bg-secondary);
  overflow-x: hidden;
  overflow-y: auto;
  align-items: center;
  border-right: 1px solid var(--border-color);
  order: 2; /* Move to left in RTL */
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) transparent;
}

#videos::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

#videos::-webkit-scrollbar-track {
  background: transparent;
}

#videos::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

.thumb-wrapper,
.video-wrapper {
  position: relative;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 2px solid transparent;
  transition: all var(--transition-normal);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 120px;
}

.thumb-wrapper video,
.video-wrapper video {
  width: 100%;
  height: 80px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.thumb-wrapper .video-name,
.video-wrapper .video-name {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  width: 100%;
  background: var(--bg-tertiary);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.thumb-wrapper:hover,
.video-wrapper:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.thumb-wrapper.is-featured,
.video-wrapper.is-featured {
  border-color: var(--accent-success);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

/* ========================================
   Sidebar - Participants & Chat
   ======================================== */
#userListContainer {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  width: 280px;
  min-width: 280px;
  overflow: hidden;
  z-index: var(--z-sidebar);
}

.sidebar-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.sidebar-header h3 i {
  color: var(--accent-primary);
}

#participantsCount {
  font-size: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Tabs */
.nav-pills {
  padding: var(--spacing-sm) var(--spacing-md);
  gap: var(--spacing-xs);
}

.nav-pills .nav-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border-radius: var(--radius-md);
  padding: var(--spacing-xs) var(--spacing-sm);
  transition: all var(--transition-fast);
}

.nav-pills .nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-pills .nav-link.active {
  color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.15);
}

/* Participant List */
#userList {
  list-style: none;
  padding: 0 var(--spacing-sm);
  margin: 0;
  overflow-y: auto;
  flex: 1;
}

#userList li {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

#userList li:hover {
  background: var(--bg-tertiary);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}

.user-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-success);
  flex-shrink: 0;
}

#userList li span:last-child {
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chat */
.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chatMessages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.chat-message {
  max-width: 85%;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
  line-height: 1.5;
}

.chat-message.me {
  align-self: flex-end;
  background: var(--accent-primary);
  color: white;
  border-bottom-right-radius: var(--radius-sm);
}

.chat-message:not(.me) {
  align-self: flex-start;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

#chatForm {
  padding: var(--spacing-sm);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: var(--spacing-xs);
}

#chatInput {
  flex: 1;
  font-size: 0.85rem;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}

#chatInput:focus {
  outline: none;
  border-color: var(--accent-primary);
}

#chatInput::placeholder {
  color: var(--text-muted);
}

/* ========================================
   Translation Panel (non-blocking dropdown)
   ======================================== */
.translation-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-md);
  width: 340px;
  max-width: calc(100vw - 2 * var(--spacing-md));
  max-height: 70vh;
  overflow-y: auto;
}

.translation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.translation-panel-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.translation-panel-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.translation-panel .form-select,
.translation-panel .form-check-input {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.translation-panel .form-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.translation-panel .form-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

#translationStatusText {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ========================================
   Control Bar
   ======================================== */
#controls {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  min-height: 72px;
  z-index: var(--z-controls);
  flex-wrap: wrap;
}

.controls-left {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  justify-content: center;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
}

.control-item span {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}

.control-icon-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  position: relative;
}

.control-icon-btn:hover:not(:disabled) {
  background: var(--bg-elevated);
  transform: scale(1.05);
}

.control-icon-btn:active:not(:disabled) {
  transform: scale(0.95);
}

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

.control-icon-btn.active {
  background: var(--accent-primary);
  color: white;
}

.control-icon-btn.danger {
  background: var(--accent-danger);
  color: white;
}

.control-icon-btn.danger:hover:not(:disabled) {
  background: var(--accent-danger-hover);
}

.btn-leave {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  background: var(--accent-danger);
  border: none;
  color: white;
  transition: all var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-leave:hover {
  background: var(--accent-danger-hover);
  transform: scale(1.02);
}

/* ========================================
   Video Overlay (Name & Voice Indicator)
   ======================================== */
.video-overlay {
  position: absolute;
  top: var(--spacing-sm);
  left: var(--spacing-sm);
  right: var(--spacing-sm);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-full);
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  z-index: var(--z-overlay);
}

.voice-indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  position: relative;
}

.voice-indicator.active {
  background: var(--accent-success);
  animation: voicePulse 0.8s infinite;
}

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.video-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Large screens (desktops) */
@media (min-width: 1200px) {
  #userListContainer {
    width: 320px;
    min-width: 320px;
  }
}

/* Medium screens (tablets & small desktops) */
@media (max-width: 1199.98px) {
  #userListContainer {
    width: 260px;
    min-width: 260px;
  }
}

/* Tablets */
@media (max-width: 991.98px) {
  .sidebar-hidden-mobile {
    display: flex !important;
  }

  .main-content {
    width: 100%;
    flex-direction: column;
  }

  #userListContainer {
    position: fixed;
    right: 0;
    top: 56px;
    bottom: 72px;
    width: 280px;
    z-index: var(--z-sidebar);
    transition: transform var(--transition-normal);
    transform: translateX(100%);
  }

  #userListContainer.sidebar-visible {
    transform: translateX(0);
  }

  #videoSidebar {
    display: none !important;
  }

  .sidebar-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  #videos {
    flex-direction: row;
    width: 100%;
    max-height: 110px;
    min-height: 90px;
    order: 2;
    border-right: none;
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .thumb-wrapper video,
  .video-wrapper video {
    width: 120px;
    height: 75px;
  }
}

  /* Mobile phones */
  @media (max-width: 767.98px) {
    :root {
      --spacing-md: 0.75rem;
    }

    body {
      height: 100vh;
      height: -webkit-fill-available;
      overflow: hidden;
    }

    .app-shell {
      height: 100vh;
      height: -webkit-fill-available;
    }

    .top-bar {
      padding: var(--spacing-xs) var(--spacing-sm);
      min-height: 48px;
      flex-shrink: 0;
    }

    .top-bar-title {
      font-size: 0.9rem;
    }

    .top-bar-title i {
      display: none;
    }

    #call-info {
      font-size: 0.7rem;
    }

    #callTimer {
      font-size: 0.75rem;
      padding: 2px 6px;
    }

    .encryption-badge {
      display: none;
    }

    /* Main Video Area - Fixed Layout */
    #videosContainer {
      flex: 1;
      min-height: 0;
      flex-shrink: 1;
      position: relative;
    }

    .main-video-wrapper {
      width: 100%;
      height: 100%;
    }

    .main-video-label {
      font-size: 0.75rem;
      padding: 2px var(--spacing-sm);
      bottom: var(--spacing-sm);
      right: var(--spacing-sm);
    }

    #activeSpeakerBar {
      font-size: 0.8rem;
      padding: var(--spacing-xs) var(--spacing-sm);
      flex-shrink: 0;
    }

    .translation-caption-bar {
      padding: var(--spacing-xs) var(--spacing-sm);
    }

    .translation-caption-bar span {
      font-size: 0.85rem;
    }

    /* Participant Thumbnails - Below Main Video */
    #videos {
      flex-direction: row;
      width: 100%;
      flex-shrink: 0;
      max-height: 90px;
      min-height: 80px;
      padding: var(--spacing-xs);
      gap: var(--spacing-xs);
      border-top: 1px solid var(--border-color);
      overflow-x: auto;
      overflow-y: hidden;
      order: 2;
    }

    .thumb-wrapper video,
    .video-wrapper video {
      width: 90px;
      height: 55px;
    }

    /* Mobile Control Bar - Fixed at Bottom with Safe Area */
    #controls {
      padding: var(--spacing-sm) var(--spacing-sm) max(var(--spacing-sm), env(safe-area-inset-bottom));
      min-height: 72px;
      gap: var(--spacing-xs);
      flex-shrink: 0;
      position: sticky;
      bottom: 0;
      z-index: var(--z-controls);
      background: var(--bg-secondary);
      border-top: 1px solid var(--border-color);
    }

    .controls-left {
      gap: var(--spacing-xs);
      flex-wrap: nowrap;
      overflow-x: auto;
      overflow-y: hidden;
      scrollbar-width: none;
      padding-bottom: 4px;
    }

    .controls-left::-webkit-scrollbar {
      display: none;
    }

    .controls-right {
      gap: var(--spacing-xs);
      flex-wrap: nowrap;
      align-items: center;
      flex-shrink: 0;
    }

    .control-icon-btn {
      width: 48px;
      height: 48px;
      font-size: 1.2rem;
      flex-shrink: 0;
    }

    .control-item span {
      font-size: 0.6rem;
      white-space: nowrap;
    }

    .btn-leave {
      padding: var(--spacing-xs) var(--spacing-sm);
      font-size: 0.75rem;
      font-weight: 700;
      border-radius: var(--radius-md);
      background: var(--accent-danger);
      border: none;
      color: white;
      transition: all var(--transition-normal);
      white-space: nowrap;
      box-shadow: var(--shadow-md);
      height: 32px;
      flex-shrink: 0;
    }

    .btn-leave:hover {
      background: var(--accent-danger-hover);
      transform: translateY(-1px);
      box-shadow: var(--shadow-lg);
    }

    .translation-panel {
      padding: var(--spacing-sm);
    }

    .translation-panel .form-select {
      font-size: 0.75rem;
      padding: var(--spacing-xs);
    }

    /* Mobile Sidebar - Overlay Drawer */
    #userListContainer {
      width: 280px;
      max-width: 85vw;
      box-shadow: var(--shadow-xl);
      transform: translateX(100%);
      transition: transform var(--transition-normal);
      position: fixed;
      top: 48px;
      bottom: 72px;
      z-index: var(--z-sidebar);
      right: 0;
      display: flex !important;
    }

    #userListContainer.sidebar-visible {
      transform: translateX(0);
    }

    .sidebar-toggle-btn {
      width: 40px;
      height: 40px;
      position: fixed;
      top: 56px;
      left: var(--spacing-sm);
      z-index: var(--z-sidebar);
      background: var(--bg-secondary);
      border: 1px solid var(--border-color);
      box-shadow: var(--shadow-lg);
    }

    .sidebar-header {
      padding: var(--spacing-sm) var(--spacing-md);
    }

    .sidebar-header h3 {
      font-size: 0.9rem;
    }

    #participantsCount {
      font-size: 0.7rem;
      padding: 1px 6px;
    }

    .nav-pills {
      padding: var(--spacing-xs) var(--spacing-sm);
      gap: var(--spacing-xs);
    }

    .nav-pills .nav-link {
      font-size: 0.75rem;
      padding: var(--spacing-xs) var(--spacing-sm);
    }

    #userList {
      padding: var(--spacing-xs);
    }

    #userList li {
      padding: var(--spacing-xs);
      gap: var(--spacing-xs);
    }

    .user-avatar {
      width: 28px;
      height: 28px;
      font-size: 0.75rem;
    }

    .user-status-dot {
      width: 6px;
      height: 6px;
    }

    #userList li span:last-child {
      font-size: 0.75rem;
    }

    /* Mobile Chat */
    #chatMessages {
      padding: var(--spacing-sm);
    }

    #chatForm {
      padding: var(--spacing-xs);
    }

    #chatInput {
      font-size: 0.8rem;
      padding: var(--spacing-xs) var(--spacing-sm);
    }

    #sendChatBtn {
      width: 36px;
      height: 36px;
      font-size: 1rem;
    }

    /* Mobile Overlay for Sidebar */
    .sidebar-overlay {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.5);
      z-index: var(--z-sidebar);
      backdrop-filter: blur(2px);
    }

    .sidebar-visible + .sidebar-overlay {
      display: block;
    }
  }

/* Small mobile phones */
@media (max-width: 400px) {
  .control-icon-btn {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .control-item {
    min-width: 48px;
  }

  .controls-left {
    gap: 1px;
  }

  #videos {
    flex-direction: row;
    max-height: 85px;
  }

  .thumb-wrapper video,
  .video-wrapper video {
    width: 85px;
    height: 55px;
  }
}

/* Landscape mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
  #videosContainer {
    flex: 1;
    min-height: auto;
  }

  #videos {
    flex-direction: row;
    max-height: 80px;
    min-height: 70px;
  }

  .thumb-wrapper video,
  .video-wrapper video {
    width: 90px;
    height: 55px;
  }
}

/* ========================================
   Modern Toggle Switch / Checkbox Styles
   ======================================== */

/* Hide default checkbox */
.form-check-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  transition: all var(--transition-normal);
  outline: none;
}

/* Toggle knob */
.form-check-input::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-normal);
}

/* Checked state */
.form-check-input:checked {
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  border-color: var(--accent-primary);
}

.form-check-input:checked::before {
  transform: translateX(20px);
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Hover state */
.form-check-input:hover {
  border-color: var(--accent-primary);
}

/* Focus state */
.form-check-input:focus-visible {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Disabled state */
.form-check-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Toggle label */
.form-check-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  margin-left: var(--spacing-xs);
}

.form-check-label:hover {
  color: var(--text-primary);
}

/* ========================================
   Utility Classes
   ======================================== */
.translation-hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Smooth scrolling for chat */
#chatMessages {
  scroll-behavior: smooth;
}

/* Focus styles for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Loading state */
.loading {
  opacity: 0.6;
  pointer-events: none;
}


/* ========================================
   Entry Language Flow + Language Badges
   ======================================== */
.entry-language-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(12px);
  padding: var(--spacing-md);
}

.entry-language-overlay.is-hidden {
  display: none;
}

.entry-language-card {
  width: min(420px, 100%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--spacing-xl);
  text-align: center;
}

.entry-language-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-primary);
  font-size: 2rem;
  margin-bottom: var(--spacing-md);
}

.entry-language-card h1 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: var(--spacing-sm);
}

.entry-language-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: var(--spacing-md);
}

.entry-language-card .form-label,
.my-language-box .form-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-align: start;
  display: block;
}

.entry-language-card .form-select,
.my-language-box .form-select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.my-language-box {
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.my-language-box small {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
}

.user-language-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  margin-inline-start: 6px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.16);
  color: #bfdbfe;
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.68rem;
  white-space: nowrap;
}

.translation-simple-options {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.translation-mode-switch {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(51, 65, 85, 0.35);
}

.translation-mode-switch .form-check-label {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.85rem;
}


/* ========================================
   Direct Translation Toggles
   ======================================== */
.translation-mode-hidden {
  display: none !important;
}

.translation-control-item .control-icon-btn.active,
.translation-toggle-btn.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.translation-inline-status {
  align-self: center;
  color: var(--text-secondary);
  font-size: 0.72rem;
  max-width: 190px;
  line-height: 1.35;
  text-align: center;
}

.translation-inline-status.text-danger {
  color: var(--accent-danger) !important;
}

.translation-inline-status.text-success {
  color: var(--accent-success) !important;
}

@media (max-width: 767.98px) {
  .translation-inline-status {
    display: none;
  }
}

/* ========================================
   V4: Fixed bottom controls + responsive participant strip
   ======================================== */
:root {
  --controls-fixed-height: 88px;
}

html,
body,
.app-shell {
  height: 100dvh;
  min-height: 100dvh;
}

.app-shell {
  padding-bottom: var(--controls-fixed-height);
}

.app-main {
  min-height: 0;
  padding-bottom: 0;
}

#controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  min-height: var(--controls-fixed-height);
  z-index: 1040;
  background: rgba(30, 41, 59, 0.98);
  backdrop-filter: blur(12px);
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.35);
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
}

#controls .controls-left {
  width: 100%;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  padding: 2px 4px;
}

#controls .control-item {
  flex: 0 0 auto;
}

#videos {
  scrollbar-width: thin;
}

@media (min-width: 992px) {
  .main-video-area {
    min-height: 0;
  }

  #videos {
    max-height: calc(100dvh - var(--controls-fixed-height) - 56px);
  }
}

@media (max-width: 991.98px) {
  :root {
    --controls-fixed-height: 86px;
  }

  .app-main {
    padding-bottom: 0;
  }

  #videos {
    flex-direction: row !important;
    width: 100% !important;
    min-height: 86px;
    max-height: 96px;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    align-items: center;
    justify-content: flex-start;
    border-top: 1px solid var(--border-color);
    border-right: none !important;
    padding: 6px 8px;
    gap: 8px;
    flex-shrink: 0;
  }

  .thumb-wrapper,
  .video-wrapper {
    width: 112px;
    min-width: 112px;
  }

  .thumb-wrapper video,
  .video-wrapper video {
    width: 112px;
    height: 64px;
  }

  #controls .controls-left {
    justify-content: flex-start;
    gap: 8px;
  }

  .control-icon-btn {
    width: 46px;
    height: 46px;
    font-size: 1.15rem;
  }

  .control-item {
    min-width: 58px;
  }

  .control-item span {
    font-size: 0.58rem;
  }

  #userListContainer {
    bottom: var(--controls-fixed-height) !important;
  }
}

@media (max-width: 575.98px) {
  :root {
    --controls-fixed-height: 82px;
  }

  #controls {
    padding-inline: 6px;
  }

  #controls .controls-left {
    gap: 6px;
  }

  .control-icon-btn {
    width: 42px;
    height: 42px;
    font-size: 1.05rem;
  }

  .control-item {
    min-width: 50px;
  }

  .thumb-wrapper,
  .video-wrapper {
    width: 96px;
    min-width: 96px;
  }

  .thumb-wrapper video,
  .video-wrapper video {
    width: 96px;
    height: 58px;
  }
}

@media (max-width: 380px) {
  .control-icon-btn {
    width: 39px;
    height: 39px;
  }

  .control-item {
    min-width: 46px;
  }

  .control-item span {
    font-size: 0.54rem;
  }
}

/* ========================================
   Admin speaking control
   ======================================== */
.admin-speaking-panel {
  margin: var(--spacing-sm) var(--spacing-md);
  padding: var(--spacing-sm);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-lg);
}

.admin-speaking-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.admin-speaking-title i {
  color: var(--accent-danger);
}

.admin-speaking-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-xs);
}

.user-row-main {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  min-width: 0;
  flex: 1;
}

.user-row-name {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.user-admin-badge,
.user-speaking-badge,
.user-hand-badge,
.user-language-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  white-space: nowrap;
}

.user-language-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.user-admin-badge {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}

.user-speaking-badge.allowed {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
}

.user-speaking-badge.muted {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

.user-hand-badge {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  animation: pulse 1.5s infinite;
}

.speaking-toggle-btn {
  margin-inline-start: auto;
  flex-shrink: 0;
  padding: 2px 8px;
  font-size: 0.7rem;
  border-radius: var(--radius-full);
}

.hand-accept-btn {
  animation: pulse 1.5s infinite;
}

.hand-raised-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--accent-warning);
  color: #1e293b;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}

/* موضع مرجعي لشارة تنبيه اليد المرفوعة داخل زر المشاركين/القائمة الجانبية */
.nav-pills .nav-link,
#toggleSidebarMobile {
  position: relative;
}

.control-icon-btn.permission-locked {
  opacity: 0.85;
  cursor: not-allowed;
  background: rgba(239, 68, 68, 0.28) !important;
}

@media (max-width: 767.98px) {
  .admin-speaking-panel {
    margin: var(--spacing-xs) var(--spacing-sm);
  }
  .admin-speaking-actions .btn {
    font-size: 0.72rem;
    padding: 0.2rem 0.45rem;
  }
  .user-row-name {
    font-size: 0.72rem;
  }
  .speaking-toggle-btn {
    font-size: 0.65rem;
    padding: 1px 6px;
  }
}
