/* ========================================
   CHAT LIGHTBOX - Image/Video Viewer
   ======================================== */

.chat-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.chat-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.chat-lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-lightbox-image {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.25s ease;
}

.chat-lightbox.active .chat-lightbox-image {
  transform: scale(1);
}

.chat-lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  z-index: 10001;
}

.chat-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-lightbox-close svg {
  width: 24px;
  height: 24px;
  stroke: white;
}

.chat-lightbox-info {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 14px;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 16px;
  border-radius: 20px;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  z-index: 10001;
}

.chat-lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-lightbox-nav svg {
  width: 24px;
  height: 24px;
  stroke: white;
}

.chat-lightbox-prev {
  left: 20px;
}

.chat-lightbox-next {
  right: 20px;
}

.chat-lightbox-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Download button */
.chat-lightbox-download {
  position: fixed;
  top: 20px;
  right: 80px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  z-index: 10001;
}

.chat-lightbox-download:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-lightbox-download svg {
  width: 20px;
  height: 20px;
  stroke: white;
}

/* Loading state */
.chat-lightbox-loading {
  color: white;
  font-size: 16px;
}

.chat-lightbox-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: lightbox-spin 0.8s linear infinite;
}

@keyframes lightbox-spin {
  to { transform: rotate(360deg); }
}

/* Video in lightbox */
.chat-lightbox-video {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 4px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.25s ease;
  background: #000;
}

.chat-lightbox.active .chat-lightbox-video {
  transform: scale(1);
}

/* Video preview in chat bubble */
.video-preview {
  position: relative;
  display: inline-block;
  max-width: 100%; /* Follow bubble width */
  min-width: 250px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #1a1a2e;
  margin-top: 5px;
}

.video-preview-thumbnail {
  width: 100%;
  height: auto;
  min-height: 150px;
  max-height: 250px;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.video-preview-placeholder {
  width: 100%;
  height: 180px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  transition: background 0.2s ease;
}

.video-preview:hover .video-preview-overlay {
  background: rgba(0, 0, 0, 0.4);
}

.video-play-button {
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.video-preview:hover .video-play-button {
  transform: scale(1.1);
  background: white;
}

.video-play-button svg {
  width: 28px;
  height: 28px;
  fill: #1a1a2e;
  margin-left: 4px; /* Optical centering for play icon */
}

.video-preview-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
}

.video-preview-name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.video-preview-size {
  font-size: 11px;
  opacity: 0.8;
}

.video-preview-duration {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

/* Loading state for video */
.video-preview.loading .video-preview-overlay {
  background: rgba(0, 0, 0, 0.6);
}

.video-preview.loading .video-play-button {
  display: none;
}

.video-preview-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: lightbox-spin 0.8s linear infinite;
}

/* Encrypted video indicator */
.video-preview.encrypted .video-preview-placeholder {
  background: linear-gradient(135deg, #2d1b4e 0%, #1a1a2e 100%);
}

/* Loading state - show spinner */
.video-preview.loading .video-play-button {
  display: none;
}

.video-preview.loading .video-preview-overlay::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: lightbox-spin 0.8s linear infinite;
}

/* Video lock icon for encrypted videos */
.video-lock-icon {
  color: rgba(255, 255, 255, 0.6);
  opacity: 0.8;
}

/* Encrypted badge icon */
.encrypted-badge {
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0.8;
}
