/**
 * Video Participant Overlay Styles
 * Positions participant info as an overlay on video elements
 */

/* Video Container Setup */
.video-container {
  position: relative !important;
  /* background: rgba(10, 12, 16, 0.95); */
  overflow: visible; /* Changed from hidden to allow embedded overlays to show */
}

/* Parent containers need positioning context for sibling overlays */
#localVideoWrapper,
#remoteVideosContainer .video-container-wrapper {
  position: relative !important;
}

/* Participant Info Overlay - Positioned below video instead of overlaying */
.video-participant-overlay {
  position: relative; /* Changed from absolute to relative */
  margin-top: 8px; /* Add spacing between video and overlay */
  pointer-events: auto; /* Allow clicks since it's no longer overlaying video */
  background: linear-gradient(135deg,
    rgba(13, 15, 20, 0.85) 0%,
    rgba(20, 23, 30, 0.85) 100%);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(110, 120, 140, 0.4);
  border-radius: 4px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
  width: 220px; /* Fixed width */
  align-self: flex-start; /* Align to left */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
  font-size: 12px; /* Smaller font size */
}

.video-participant-overlay:hover {
  background: linear-gradient(135deg, 
    rgba(20, 23, 30, 0.95) 0%, 
    rgba(30, 35, 45, 0.95) 100%);
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
  transform: translateY(-2px);
}

/* Participant Avatar - Smaller size */
.video-participant-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.3) 0%, 
    rgba(139, 92, 246, 0.3) 100%);
  border: 1px solid rgba(139, 92, 246, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: rgba(196, 181, 253, 1);
  flex-shrink: 0;
}

/* Participant Name - Smaller text */
.video-participant-name {
  color: rgba(235, 240, 255, 0.95);
  font-size: 11px;
  font-weight: 500;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  overflow: hidden;
  max-width: 100%;
  flex: 1;
  line-height: 1.3;
}

/* Participant Status */
.video-participant-status {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.video-participant-status .status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.8);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  animation: pulse 2s infinite;
}

.video-participant-status.muted .status-indicator {
  background: rgba(239, 68, 68, 0.8);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  animation: none;
}

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

/* Audio/Video Icons - Smaller size */
.video-participant-icons {
  display: flex;
  gap: 4px;
  align-items: center;
}

.video-participant-icons i {
  font-size: 10px;
  color: rgba(175, 190, 225, 0.8);
}

.video-participant-icons i.active {
  color: rgba(74, 222, 128, 0.9);
}

.video-participant-icons i.muted {
  color: rgba(248, 113, 113, 0.9);
}

/* Compact Mode for Multiple Participants */
.video-container.compact .video-participant-overlay {
  padding: 6px 10px;
  min-width: 120px;
  bottom: 8px;
  right: 8px;
}

.video-container.compact .video-participant-avatar {
  width: 24px;
  height: 24px;
  font-size: 12px;
}

.video-container.compact .video-participant-name {
  font-size: 12px;
}

/* Hide on Small Videos */
.video-container.thumbnail .video-participant-overlay {
  padding: 4px 8px;
  min-width: auto;
}

.video-container.thumbnail .video-participant-name {
  display: none;
}

.video-container.thumbnail .video-participant-avatar {
  width: 20px;
  height: 20px;
  font-size: 10px;
}

/* Speaking Indicator */
.video-participant-overlay.speaking {
  border-color: rgba(74, 222, 128, 0.6);
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2),
              0 4px 12px rgba(0, 0, 0, 0.5);
}

.video-participant-overlay.speaking::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  background: linear-gradient(45deg, 
    rgba(74, 222, 128, 0.3),
    transparent,
    rgba(74, 222, 128, 0.3));
  border-radius: 6px;
  animation: speaking-glow 1.5s linear infinite;
  z-index: -1;
}

@keyframes speaking-glow {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* Screen Share Indicator */
.video-participant-overlay .screen-share-badge {
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.3) 0%, 
    rgba(96, 165, 250, 0.3) 100%);
  border: 1px solid rgba(96, 165, 250, 0.5);
  color: rgba(147, 197, 253, 1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ========== EMBEDDED MODE STYLES ========== */
/* Overlays positioned ON TOP of video (bottom-right) */
.video-participant-overlay[data-overlay-mode="embedded"] {
  position: absolute !important;
  bottom: 12px;
  right: 12px;
  margin: 0;
  pointer-events: auto;
  z-index: 50; /* Above video but below modals */
  width: 220px; /* Same as standalone */
  font-size: 12px; /* Same as standalone */
}

/* Embedded mode hover - slight transparency for better video visibility */
.video-participant-overlay[data-overlay-mode="embedded"]:hover {
  opacity: 0.95;
  transform: none; /* No translateY in embedded mode */
}

/* Minimize/Maximize button - only in embedded mode */
.overlay-minimize-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(30, 35, 45, 0.8);
  border: 1px solid rgba(100, 110, 130, 0.4);
  border-radius: 3px;
  padding: 2px 6px;
  cursor: pointer;
  color: rgba(175, 190, 225, 0.9);
  font-size: 10px;
  transition: all 0.2s ease;
  z-index: 10;
  line-height: 1;
}

.overlay-minimize-btn:hover {
  background: rgba(40, 45, 55, 0.9);
  border-color: rgba(139, 92, 246, 0.6);
  color: rgba(196, 181, 253, 1);
  transform: scale(1.1);
}

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

/* Minimized state - collapsed to icon-only */
.video-participant-overlay.minimized {
  width: auto !important;
  padding: 4px !important;
  transition: all 0.3s ease;
}

.video-participant-overlay.minimized .video-participant-name-container,
.video-participant-overlay.minimized .video-participant-info-btn {
  display: none;
}

.video-participant-overlay.minimized .video-participant-avatar {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

.video-participant-overlay.minimized .overlay-minimize-btn {
  position: static;
  margin-left: 4px;
}

/* ========== END EMBEDDED MODE STYLES ========== */

/* Local Video Special Styling */
#localVideoContainer {
  /* Remove forced relative positioning to allow natural flow */
  /* border: 2px solid rgba(59, 130, 246, 0.3); */
  /* box-shadow: 0 0 20px rgba(59, 130, 246, 0.2); */
  overflow: visible; /* Allow overlay to show properly */
}

/* Special styling for local video overlay - positioned below video */
#localVideoContainer + .video-participant-overlay,
.video-participant-overlay[data-for="localVideoContainer"] {
  background: linear-gradient(135deg,
    rgba(37, 99, 235, 0.25) 0%,
    rgba(59, 130, 246, 0.25) 100%);
  border-color: rgba(59, 130, 246, 0.5);
  /* No positioning rules - uses default relative positioning */
}

/* Add (You) label to local participant overlay */
#localVideoContainer + .video-participant-overlay .video-participant-name::after,
.video-participant-overlay[data-for="localVideoContainer"] .video-participant-name::after {
  content: ' (You)';
  color: rgba(147, 197, 253, 0.9);
  font-size: 10px; /* Smaller to match overlay size */
  font-weight: normal;
  font-style: italic;
}

/* Local participant badge */
.video-participant-overlay.local-participant {
  background: linear-gradient(135deg, 
    rgba(37, 99, 235, 0.25) 0%, 
    rgba(59, 130, 246, 0.25) 100%);
  border-color: rgba(59, 130, 246, 0.5);
}

/* Ensure video element fills container */
.video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Name container for multi-line layout */
.video-participant-name-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

/* Phone number styling */
.video-participant-phone {
  color: rgba(156, 163, 175, 0.9);
  font-size: 10px;
  font-weight: 400;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
  max-width: 100%;
  line-height: 1.3;
}

/* Info button styling */
.video-participant-info-btn {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  color: rgba(147, 197, 253, 1);
  font-size: 12px;
  transition: all 0.2s ease;
  margin-left: 4px;
}

.video-participant-info-btn:hover {
  background: rgba(59, 130, 246, 0.4);
  border-color: rgba(59, 130, 246, 0.6);
  transform: scale(1.1);
}

.video-participant-info-btn i {
  pointer-events: none;
}

/* Participant Info Tooltip - Glass Morphism Design */
.participant-info-tooltip {
  position: fixed;
  background: linear-gradient(135deg,
    rgba(13, 15, 20, 0.95) 0%,
    rgba(20, 23, 30, 0.95) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(110, 120, 140, 0.4);
  border-radius: 6px;
  padding: 12px;
  min-width: 200px;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6),
              0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  animation: tooltipFadeIn 0.2s ease;
  font-size: 12px;
}

/* Tooltip animation */
@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Tooltip content container */
.participant-info-tooltip .tooltip-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Tooltip header (name) */
.participant-info-tooltip .tooltip-header {
  font-size: 13px;
  font-weight: 600;
  color: rgba(235, 240, 255, 0.95);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(110, 120, 140, 0.3);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Tooltip rows */
.participant-info-tooltip .tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(55, 65, 81, 0.3);
}

.participant-info-tooltip .tooltip-row:last-child {
  border-bottom: none;
}

/* Tooltip labels */
.participant-info-tooltip .tooltip-label {
  color: rgba(156, 163, 175, 0.9);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  min-width: 60px;
}

/* Tooltip values */
.participant-info-tooltip .tooltip-value {
  color: rgba(235, 240, 255, 0.92);
  font-size: 11px;
  text-align: right;
  flex: 1;
  word-break: break-word;
  max-width: 200px;
}

/* Special styling for certain value types */
.participant-info-tooltip .tooltip-value.priority-high {
  color: rgba(239, 68, 68, 0.9);
  font-weight: 600;
}

.participant-info-tooltip .tooltip-value.priority-medium {
  color: rgba(251, 191, 36, 0.9);
  font-weight: 600;
}

.participant-info-tooltip .tooltip-value.priority-low {
  color: rgba(34, 197, 94, 0.9);
  font-weight: 600;
}

/* Tooltip arrow/pointer (optional) */
.participant-info-tooltip::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: linear-gradient(135deg,
    rgba(20, 23, 30, 0.95) 0%,
    rgba(13, 15, 20, 0.95) 100%);
  border-left: 1px solid rgba(110, 120, 140, 0.4);
  border-bottom: 1px solid rgba(110, 120, 140, 0.4);
  transform: rotate(45deg);
  left: -5px;
  top: 12px;
}

/* Mobile/touch optimizations */
@media (max-width: 768px) {
  .participant-info-tooltip {
    max-width: 280px;
    font-size: 11px;
  }

  .participant-info-tooltip .tooltip-header {
    font-size: 12px;
  }

  .participant-info-tooltip .tooltip-label,
  .participant-info-tooltip .tooltip-value {
    font-size: 10px;
  }
}