/* Video Interface Styles - Light Theme */

/* Scoped CSS reset for video interface only */
.video-container * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

/* Preserve character sheet styling */
.character-container * {
  box-sizing: border-box; /* Keep this for proper sizing */
}

/* Override body centering for video interface */
body.video-mode {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: #f8f9fa;
}

body.video-mode .app {
  max-width: none;
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
}

/* Main split-screen container */
.main-container {
  display: flex;
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
  gap: 0; /* Remove gap between sheet and video */
}

/* Character sheet container - fixed left side */
.character-container {
  flex: 0 0 400px;
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #5BA3E5 0%, #4A8BC2 100%);
  box-sizing: border-box;
  margin: 0;
  padding: 20px;
}

/* Video container - takes remaining space */
.video-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: url('smallername.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  margin: 0;
  padding: 0;
  border: none;
  border-left: none;
}

/* Make the blurred backdrop fill all the way to the edge */
.video-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0 !important;
  right: 0;
  bottom: 0;
  background: url('smallername.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(100px);
  z-index: -1;
}

.video-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0 !important;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(50px);
  z-index: 0;
}

/* Facilitator full-screen mode */
.video-container.facilitator-mode {
  width: 100%;
  height: 100vh;
}

/* Screen sharing mode styles */
.video-container.screen-sharing-mode {
  position: relative;
}

.screen-sharing-main {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: url('smallername.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  z-index: 10;
}

.screen-sharing-main::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('smallername.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(100px);
  z-index: -1;
}

/* Overlay participants on screen share */
.screen-sharing-participants {
  position: absolute;
  top: 20px;
  bottom: 100px;
  right: 20px;
  width: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.screen-sharing-participants::-webkit-scrollbar {
  width: 6px;
}

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

.screen-sharing-participants::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
}

.screen-sharing-participants::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.5);
}

.screen-sharing-participant {
  aspect-ratio: 16/9;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.3);
  transition: all 0.3s ease;
  position: relative;
  min-height: 100px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.screen-sharing-participant:hover {
  border-color: #4a9eff;
  transform: scale(1.02);
}

.screen-sharing-participant.local {
  border-color: #28a745;
}

.screen-sharing-participant video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.screen-sharing-participant.local video {
  transform: scaleX(-1);
}

.screen-sharing-participant .participant-name {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screen-share-video {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 5;
  background: transparent;
}

.screen-share-video video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 6;
}

/* Ensure proper z-index layering for screen sharing */
.screen-sharing-mode .screen-share-video {
  z-index: 5;
}

.screen-sharing-mode .screen-sharing-participants {
  z-index: 100;
}

/* Video header - Hidden to remove gray bar */
.video-header {
  display: none;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.room-code {
  font-size: 14px;
  font-weight: 600;
  color: #495057;
  background: #e9ecef;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #ced4da;
}

/* Hide connection status bar and video-specific gray elements only */
.video-container .connection-status,
.video-container .room-header,
.video-container .header-bar,
.video-container .status-bar,
.video-container .video-status,
.video-container .room-status,
.video-container .livekit-header,
.video-container .top-bar,
.video-container .navigation-bar,
.video-container .toolbar,
.video-container .menu-bar,
.video-container .title-bar,
.video-container .nav-bar,
.video-container .breadcrumb {
  display: none !important;
}

/* Remove all gray backgrounds and elements */
body.video-mode {
  background: #f8f9fa !important;
}

/* Force hide any remaining gray bars - but not in character sheet */
.video-container div[style*="background: #"], 
.video-container div[style*="background-color: #"],
.video-container .bg-gray,
.video-container .gray-bar,
.video-container .gray-header,
.video-container .gray-menu,
.bg-gray:not(.character-container *),
.gray-bar:not(.character-container *),
.gray-header:not(.character-container *),
.gray-menu:not(.character-container *) {
  display: none !important;
}

/* Participants grid - Flex-based video stage */
.participants-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  height: calc(100vh - 80px); /* Account for controls */
  padding: 20px;
  justify-content: center; /* Centers last row */
  align-content: center;   /* Vertical alignment if fewer rows */
  overflow-y: auto;
  background: transparent;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

/* Participant video tiles */
.participant {
  flex: 1 1 calc(33.33% - 12px);  /* Default ~3 per row */
  max-width: 33.33%;               /* Don't let it grow too large */
  aspect-ratio: 16 / 9;            /* Keep consistent video shape */
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Adjust tile sizes based on participant count */
.participants-grid:has(.participant:nth-child(1):last-child) .participant {
  flex: 1 1 60%;
  max-width: 60%;
}

.participants-grid:has(.participant:nth-child(2):last-child) .participant {
  flex: 1 1 calc(50% - 12px);
  max-width: 50%;
}

.participants-grid:has(.participant:nth-child(3):last-child) .participant,
.participants-grid:has(.participant:nth-child(4):last-child) .participant {
  flex: 1 1 calc(50% - 12px);
  max-width: 50%;
}

.participants-grid:has(.participant:nth-child(n+5)):has(.participant:nth-child(-n+6)) .participant {
  flex: 1 1 calc(33.33% - 12px);
  max-width: 33.33%;
}

.participants-grid:has(.participant:nth-child(n+7)):has(.participant:nth-child(-n+9)) .participant {
  flex: 1 1 calc(33.33% - 12px);
  max-width: 33.33%;
}

.participants-grid:has(.participant:nth-child(n+10)) .participant {
  flex: 1 1 calc(25% - 12px);
  max-width: 25%;
}

.participant:hover {
  border-color: #4a9eff;
  box-shadow: 0 8px 20px rgba(74, 158, 255, 0.4);
  transform: scale(1.02);
}

.participant.local {
  border-color: #28a745;
  border-width: 3px;
  box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

.participant video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.participant.local video {
  transform: scaleX(-1);
}

.participant-name {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  backdrop-filter: blur(10px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 6px;
  z-index: 10;
}

.participant.local .participant-name {
  background: rgba(40, 167, 69, 0.9);
  color: white;
}

.participant.local .participant-name::after {
  content: " (You)";
  opacity: 0.9;
  font-size: 11px;
}

/* Video controls - Fixed at bottom, slimmer */
.video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;         /* reduced vertical padding */
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-top: 2px solid #e9ecef;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  z-index: 1000;
}

.control-btn {
  width: 48px;              /* slightly smaller */
  height: 48px;
  border-radius: 50%;
  border: 3px solid #ced4da;
  background: #ffffff;
  color: #495057;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.control-btn .control-icon {
  width: 24px;
  height: 24px;
  filter: brightness(0) saturate(100%) invert(27%) sepia(12%) saturate(1019%) hue-rotate(177deg) brightness(95%) contrast(91%);
  transition: filter 0.3s ease;
}

.control-btn:hover .control-icon {
  filter: brightness(0) saturate(100%) invert(41%) sepia(85%) saturate(1352%) hue-rotate(204deg) brightness(103%) contrast(101%);
}

.control-btn.active .control-icon,
.control-btn.disabled .control-icon {
  filter: brightness(0) invert(1);
}

.control-btn.leave-btn .control-icon,
.control-btn.settings-btn .control-icon {
  filter: brightness(0) invert(1);
}

.control-btn:hover {
  background: #f8f9fa;
  border-color: #007bff;
  color: #007bff;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,123,255,0.2);
}

.control-btn.disabled {
  background: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

.control-btn.disabled:hover {
  background: #f5c6cb;
  border-color: #f1aeb5;
  transform: scale(1.02);
}

.control-btn.active {
  background: #007bff;
  border-color: #0056b3;
  color: white;
}

.control-btn.active:hover {
  background: #0056b3;
  border-color: #004085;
}

.control-btn.leave-btn {
  background: #dc3545;
  border-color: #c82333;
  color: white;
}

.control-btn.leave-btn:hover {
  background: #c82333;
  border-color: #bd2130;
  transform: scale(1.05);
}

.control-btn.settings-btn {
  background: #6c757d;
  border-color: #5a6268;
  color: white;
}

.control-btn.settings-btn:hover {
  background: #5a6268;
  border-color: #545b62;
}

/* Device settings panel */
.device-settings {
  position: absolute;
  bottom: 90px;
  right: 20px;
  background: linear-gradient(180deg, #5BA3E5 0%, #4A8BC2 100%);
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 12px;
  padding: 20px;
  min-width: 280px;
  backdrop-filter: blur(10px);
  z-index: 1000;
  box-shadow: 0 8px 25px rgba(0,0,0,0.25);
}

.device-group {
  margin-bottom: 15px;
}

.device-group:last-child {
  margin-bottom: 0;
}

.device-group label {
  display: block;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.device-group select {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255,255,255,0.9);
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 6px;
  color: #2b7ac6;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s ease;
}

.device-group select:focus {
  border-color: rgba(255,255,255,1);
  background: #ffffff;
}

.device-group select option {
  background: #ffffff;
  color: #2b7ac6;
}

/* Screen sharing controls overlay */
.screen-sharing-controls {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #e9ecef;
  border-radius: 25px;
  padding: 10px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1001;
}

.screen-sharing-indicator {
  color: #dc3545;
  font-weight: 600;
  font-size: 14px;
}

.stop-sharing-btn {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 15px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.stop-sharing-btn:hover {
  background: #c82333;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .character-container {
    flex: 0 0 400px; /* stays fixed */
  }
  
  .screen-sharing-sidebar {
    flex: 0 0 200px;
  }
}

@media (max-width: 768px) {
  .main-container {
    flex-direction: column;
  }
  
  .character-container {
    flex: 0 0 400px; /* stays fixed */
    padding: 0;
  }
  
  .participants-grid {
    padding: 15px;
    gap: 10px;
    margin-bottom: 70px;
  }
  
  .video-controls {
    padding: 8px 10px;
    gap: 10px;
  }
  
  .control-btn {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  
  .device-settings {
    right: 10px;
    left: 10px;
    min-width: auto;
  }
  
  .screen-sharing-sidebar {
    flex: 0 0 150px;
  }
  
  .screen-sharing-participants {
    padding: 10px;
    gap: 8px;
  }
  
  .screen-sharing-participant {
    min-height: 80px;
  }
}

/* Loading state */
.participant.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  font-size: 14px;
  background: #f8f9fa;
}

.participant.loading::before {
  content: "";
  width: 30px;
  height: 30px;
  border: 3px solid #e9ecef;
  border-top: 3px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error states */
.participant.error {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #721c24;
  font-size: 12px;
  text-align: center;
  padding: 10px;
  background: #f8d7da;
}

/* Accessibility improvements */
.control-btn:focus {
  outline: 3px solid rgba(0, 123, 255, 0.4);
  outline-offset: 2px;
}

/* Animation for layout changes */
.participants-grid,
.participant {
  transition: all 0.3s ease;
}

/* When screen sharing is active, hide main participants grid */
.video-container.screen-sharing-mode:not(.facilitator-screen-sharing) .participants-grid {
  display: none;
}

/* When facilitator is screen sharing, overlay the participants grid */
.video-container.facilitator-screen-sharing .participants-grid {
  position: absolute;
  top: 20px;
  bottom: 100px;
  right: 20px;
  width: 280px;
  height: auto;
  padding: 0;
  margin-bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 10px;
  align-content: flex-start;
  justify-content: flex-start;
  z-index: 100;
}

.video-container.facilitator-screen-sharing .participant {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16/9;
  background: #111;
  border: 2px solid rgba(255,255,255,0.3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* Screen share label overlay */
.screen-sharer-label {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
}
