/* ==========================================================================
   SecureChat Pro - Enhanced Fullscreen Media Lightbox Gallery & Sticky Audio Player
   (增强型全屏多媒体画廊与置顶音频浮动播放条)
   Benchmark: Telegram Web / Discord Web media viewer & voice playback bar
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Enhanced Fullscreen Lightbox Gallery (增强型全屏画廊)
   -------------------------------------------------------------------------- */

.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  background: rgba(6, 9, 16, 0.96);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  user-select: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-backdrop.active,
.lightbox-backdrop[style*="display: flex"] {
  opacity: 1;
  pointer-events: auto;
}

body.lightbox-active {
  overflow: hidden !important;
}

/* Lightbox Header Toolbar */
.lightbox-header {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(15, 20, 32, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 20;
  flex-shrink: 0;
}

.lightbox-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.lightbox-badge-icon {
  font-size: 18px;
  opacity: 0.9;
}

.lightbox-counter {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.lightbox-meta-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lightbox-filename {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.lightbox-sender-info {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lightbox-tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-tool-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.lightbox-tool-btn:active {
  transform: translateY(1px);
}

.lightbox-zoom-badge {
  width: auto;
  min-width: 58px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.lightbox-btn-close {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  margin-left: 6px;
}

.lightbox-btn-close:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
  border-color: rgba(239, 68, 68, 0.5);
}

/* Lightbox Main Stage */
.lightbox-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 12px;
}

/* Prev / Next Nav Buttons */
.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(17, 24, 39, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.lightbox-nav-prev {
  left: 24px;
}

.lightbox-nav-next {
  right: 24px;
}

.lightbox-nav-btn:hover {
  background: var(--primary, #3b82f6);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 0 20px var(--primary-glow, rgba(59, 130, 246, 0.5));
}

.lightbox-nav-btn:active {
  transform: translateY(-50%) scale(0.96);
}

/* Viewport & Transform Layer */
.lightbox-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: default;
}

.lightbox-img-transform-layer {
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
  transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 100%;
  max-height: 100%;
}

.lightbox-img-transform-layer.is-dragging {
  transition: none !important;
}

#lightbox-img {
  max-width: 86vw;
  max-height: calc(100vh - 170px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75);
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: auto;
}

/* Bottom Filmstrip Bar */
.lightbox-filmstrip-bar {
  height: 84px;
  background: rgba(13, 17, 28, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  flex-shrink: 0;
  z-index: 20;
}

.lightbox-thumbnails {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  max-width: 90vw;
  padding: 6px 4px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.lightbox-thumbnails::-webkit-scrollbar {
  height: 4px;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.lightbox-thumb-item {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.55;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background: #111827;
}

.lightbox-thumb-item:hover {
  opacity: 0.9;
  transform: translateY(-2px) scale(1.06);
}

.lightbox-thumb-item.active {
  opacity: 1;
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 16px var(--primary-glow, rgba(59, 130, 246, 0.65));
  transform: translateY(-3px) scale(1.12);
}

.lightbox-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Lightbox Toast / Notification */
.lightbox-toast {
  position: absolute;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-color, #334155);
  color: #f1f5f9;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
}

.lightbox-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   2. Sticky Audio Mini-Player (置顶音频浮动播放条)
   -------------------------------------------------------------------------- */

.sticky-audio-player {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  z-index: 45;
  background: rgba(17, 23, 37, 0.94);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--border-color, #232a3d);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.sticky-audio-player.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.sticky-audio-content {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  max-width: 100%;
}

/* Sticky Play / Pause Button */
.sticky-audio-btn-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary, #3b82f6);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 10px var(--primary-glow, rgba(59, 130, 246, 0.4));
}

.sticky-audio-btn-play:hover {
  transform: scale(1.08);
  background: var(--primary-hover, #2563eb);
  box-shadow: 0 4px 14px var(--primary-glow, rgba(59, 130, 246, 0.55));
}

.sticky-audio-btn-play:active {
  transform: scale(0.96);
}

/* Sender & Track Metadata */
.sticky-audio-info {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 100px;
  max-width: 160px;
  transition: opacity 0.15s;
}

.sticky-audio-info:hover {
  opacity: 0.85;
}

.sticky-audio-sender-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main, #f3f5f9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sticky-audio-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}

.sticky-audio-player.playing .sticky-audio-pulse-dot {
  animation: stickyPulseDot 1.4s infinite ease-in-out;
}

@keyframes stickyPulseDot {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.2); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.sticky-audio-sender {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sticky-audio-locate-hint {
  font-size: 10px;
  color: var(--primary, #3b82f6);
  background: rgba(59, 130, 246, 0.12);
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 500;
  margin-left: 2px;
  flex-shrink: 0;
}

.sticky-audio-time-row {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-muted, #9ba3b5);
  margin-top: 1px;
}

.sticky-audio-time-sep {
  margin: 0 2px;
  opacity: 0.6;
}

/* Animated Waveform Bars */
.sticky-audio-waveform {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 20px;
  flex-shrink: 0;
  padding: 0 4px;
}

.sticky-audio-waveform span {
  width: 2.5px;
  height: 6px;
  background: var(--text-muted, #94a3b8);
  border-radius: 2px;
  transition: height 0.15s ease, background 0.15s;
}

.sticky-audio-waveform.animating span {
  background: var(--primary, #3b82f6);
}

.sticky-audio-waveform.animating span:nth-child(2n) {
  animation: stickyWaveAnim 0.6s infinite alternate ease-in-out;
}

.sticky-audio-waveform.animating span:nth-child(2n+1) {
  animation: stickyWaveAnim 0.85s infinite alternate ease-in-out;
}

.sticky-audio-waveform.animating span:nth-child(3n) {
  animation: stickyWaveAnim 0.5s infinite alternate ease-in-out;
}

@keyframes stickyWaveAnim {
  0% { height: 4px; }
  100% { height: 18px; }
}

/* Interactive Progress Scrubber / Slider */
.sticky-audio-slider-wrap {
  flex: 1;
  min-width: 120px;
  padding: 12px 0;
  cursor: pointer;
  position: relative;
}

.sticky-audio-slider-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  position: relative;
  transition: height 0.15s ease;
  overflow: visible;
}

.sticky-audio-slider-wrap:hover .sticky-audio-slider-track {
  height: 7px;
}

.sticky-audio-slider-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary, #3b82f6), #60a5fa);
  border-radius: 3px;
  width: 0%;
  pointer-events: none;
  transition: width 0.08s linear;
}

.sticky-audio-slider-handle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.15s, transform 0.1s;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.sticky-audio-slider-wrap:hover .sticky-audio-slider-handle {
  opacity: 1;
}

/* Speed Toggle Button */
.sticky-audio-btn-speed {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main, #f3f5f9);
  border-radius: 12px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  transition: all 0.15s ease;
}

.sticky-audio-btn-speed:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

.sticky-audio-btn-speed:active {
  transform: scale(0.95);
}

/* Close Button */
.sticky-audio-btn-close {
  border: none;
  background: transparent;
  color: var(--text-muted, #9ba3b5);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  transition: all 0.15s ease;
}

.sticky-audio-btn-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main, #f3f5f9);
}

.sticky-audio-btn-close:active {
  transform: scale(0.92);
}

/* Message Bubble Flash Highlight when jumping */
.msg-row.highlight-pulse {
  animation: msgPulseGlow 1.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes msgPulseGlow {
  0% {
    background: rgba(59, 130, 246, 0.35);
    box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
  }
  100% {
    background: transparent;
    box-shadow: none;
  }
}

/* --------------------------------------------------------------------------
   3. Mobile Responsive Ergonomics (< 768px)
   -------------------------------------------------------------------------- */

@media (max-width: 767px) {
  .lightbox-header {
    height: 52px;
    padding: 0 12px;
  }

  .lightbox-filename {
    max-width: 140px;
  }

  .lightbox-sender-info {
    display: none;
  }

  .lightbox-tool-btn {
    width: 32px;
    height: 32px;
  }

  .lightbox-nav-btn {
    width: 40px;
    height: 40px;
  }

  .lightbox-nav-prev {
    left: 10px;
  }

  .lightbox-nav-next {
    right: 10px;
  }

  .lightbox-filmstrip-bar {
    height: 68px;
    padding: 6px 12px;
  }

  .lightbox-thumb-item {
    width: 44px;
    height: 44px;
  }

  .sticky-audio-player {
    top: 56px;
  }

  .sticky-audio-content {
    gap: 10px;
    padding: 6px 12px;
  }

  .sticky-audio-info {
    max-width: 110px;
    min-width: 70px;
  }

  .sticky-audio-waveform {
    display: none; /* Hide on compact mobile screens to preserve scrubber space */
  }

  .sticky-audio-locate-hint {
    display: none;
  }
}
