/**
 * 现代化图片展示系统样式 - Modern Lightbox CSS
 * 支持响应式设计、动画效果、移动端友好
 */

/* 基础lightbox样式 */
.modern-lightbox-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.modern-lightbox-overlay.visible,
.modern-lightbox-overlay.active {
  opacity: 1 !important;
  visibility: visible !important;
}

.modern-lightbox-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: lightboxFadeIn 0.3s ease-out;
}

/* 图片容器样式 */
.image-container {
   width: calc(100vw - 2rem);
   height: calc(100vh - 2rem);
   border-radius: 12px;
   overflow: hidden;
   box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
   display: flex;
   align-items: center;
   justify-content: center;
 }

/* 现代灯箱图片自适应：大图缩小到可视区域，保持比例 */
.modern-lightbox-image {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  /* 允许 JS 控制缩放/平移 */
  will-change: transform;
  /* 去掉禁止变换的规则，避免缩放失效 */
}

.lightbox-image {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center center;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
}

.lightbox-image.zoomed {
  cursor: grab !important;
}

.lightbox-image.dragging {
  cursor: grabbing !important;
}

/* 加载指示器 */
.loading-indicator {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 12px;
}

.loading-indicator .animate-spin {
  animation: spin 1s linear infinite;
}

/* 工具栏样式 */
.toolbar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  animation: slideInFromTop 0.4s ease-out 0.1s both;
  z-index: 30;
}

.tool-btn {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 9999px;
  padding: 0.75rem;
  min-width: 44px;
  min-height: 44px;
}

.tool-btn:hover {
  transform: scale(1.05);
  background-color: rgba(0, 0, 0, 0.9) !important;
  border-color: rgba(255, 255, 255, 0.2);
}

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

/* 导航按钮样式 */
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideInFromSide 0.4s ease-out 0.2s both;
  z-index: 20; /* 提升层级，避免被图片遮挡 */
  color: #fff;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 9999px;
  padding: 0.75rem;
  min-width: 44px;
  min-height: 44px;
}
.prev-btn { left: 1rem; }
.next-btn { right: 1rem; }
.prev-btn {
  animation-name: slideInFromLeft;
}

.next-btn {
  animation-name: slideInFromRight;
}

.nav-btn:hover {
  background-color: rgba(0, 0, 0, 0.9) !important;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

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

/* 信息栏样式 */
.info-bar {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideInFromBottom 0.4s ease-out 0.3s both;
  max-width: calc(100vw - 2rem);
}

.counter {
  font-variant-numeric: tabular-nums;
}

.caption {
  opacity: 0.9;
  line-height: 1.4;
}

/* 手势提示 */
.gesture-hint {
  position: absolute;
  bottom: 4rem;
  left: 50%;
  transform: translateX(-50%);
  animation: fadeInUp 0.5s ease-out 0.5s both;
  opacity: 0.6;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .modern-lightbox-content {
    padding: 1rem;
  }
  
  .image-container {
    max-width: 100vw;
    max-height: calc(100vh - 1.5rem);
    border-radius: 8px;
  }
  
  .toolbar {
    top: 1rem;
    right: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .tool-btn {
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
  }
  
  .tool-btn svg {
    width: 1.125rem;
    height: 1.125rem;
  }
  
  .prev-btn { left: 0.75rem; }
  .next-btn { right: 0.75rem; }
  .nav-btn {
    padding: 1rem;
    min-width: 48px;
    min-height: 48px;
  }
  
  .nav-btn svg {
    width: 1.5rem;
    height: 1.5rem;
  }
  
  .info-bar {
    bottom: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
  
  .gesture-hint {
    bottom: 4rem;
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
  }
}

@media (max-width: 480px) {
  .modern-lightbox-content {
    padding: 0.5rem;
  }
  
  .image-container {
    max-height: calc(100vh - 1rem);
    border-radius: 6px;
  }
  
  .toolbar {
    top: 0.5rem;
    right: 0.5rem;
    gap: 0.25rem;
  }
  
  .tool-btn {
    padding: 0.625rem;
    min-width: 40px;
    min-height: 40px;
  }
  
  .tool-btn svg {
    width: 1rem;
    height: 1rem;
  }
  
  .nav-btn {
    padding: 0.875rem;
    min-width: 44px;
    min-height: 44px;
  }
  
  .nav-btn svg {
    width: 1.25rem;
    height: 1.25rem;
  }
  
  .info-bar {
    bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
  
  .gesture-hint {
    bottom: 3rem;
    font-size: 0.6875rem;
    padding: 0.375rem 0.75rem;
  }
}
  
  /* removed erroneous global .nav-btn left/right (caused full-width overlap) */
  
  .info-bar {
    bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }


/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 600px) {
  .modern-lightbox-content {
    padding: 0.5rem;
  }
  
  .image-container {
    max-height: calc(100vh - 1rem);
    max-width: calc(100vw - 8rem);
  }
  
  .toolbar {
    top: 0.5rem;
    right: 0.5rem;
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .nav-btn {
    top: 50%;
    transform: translateY(-50%);
    padding: 0.75rem;
  }
  
  .info-bar {
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: 80%;
    text-align: center;
  }
  
  .gesture-hint {
    display: none; /* 横屏时隐藏手势提示 */
  }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
  .modern-lightbox-content {
    padding: 0.25rem;
  }
  
  .image-container {
    max-height: calc(100vh - 3rem);
    border-radius: 4px;
  }
  
  .toolbar {
    top: 0.25rem;
    right: 0.25rem;
    gap: 0.125rem;
  }
  
  .tool-btn {
    padding: 0.5rem;
    min-width: 36px;
    min-height: 36px;
  }
  
  .tool-btn svg {
    width: 0.875rem;
    height: 0.875rem;
  }
  
  .nav-btn {
    padding: 0.75rem;
    min-width: 40px;
    min-height: 40px;
  }
  
  .nav-btn svg {
    width: 1.125rem;
    height: 1.125rem;
  }
  
  .info-bar {
    bottom: 0.25rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .modern-lightbox-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* 触摸设备特定样式 */
@media (hover: none) and (pointer: coarse) {
  .tool-btn:hover,
  .nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: none;
  }
  
  .tool-btn:active,
  .nav-btn:active {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
  }
  
  .gesture-hint {
    display: block;
    animation-delay: 1s;
  }
}

/* 键盘导航设备 */
@media (hover: hover) and (pointer: fine) {
  .gesture-hint {
    display: none;
  }
  
  .tool-btn:focus,
  .nav-btn:focus {
    outline: 2px solid #06b6d4;
    outline-offset: 2px;
  }
}

/* 动画定义 */
@keyframes lightboxFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInFromTop {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translate(-20px, -50%);
  }
  to {
    opacity: 1;
    transform: translate(0, -50%);
  }
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translate(20px, -50%);
  }
  to {
    opacity: 1;
    transform: translate(0, -50%);
  }
}

@keyframes slideInFromBottom {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 0.6;
    transform: translate(-50%, 0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 全屏模式样式 */
.modern-lightbox-overlay:fullscreen {
  background: black;
}

.modern-lightbox-overlay:fullscreen .image-container {
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  .tool-btn,
  .nav-btn,
  .info-bar {
    background-color: rgba(0, 0, 0, 0.9) !important;
    border-color: rgba(255, 255, 255, 0.5);
  }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
  .modern-lightbox-overlay,
  .lightbox-image,
  .tool-btn,
  .nav-btn {
    transition: none !important;
    animation: none !important;
  }
  
  .modern-lightbox-content,
  .toolbar,
  .nav-btn,
  .info-bar,
  .gesture-hint {
    animation: none !important;
  }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  .tool-btn,
  .nav-btn {
    padding: 0.75rem;
  }
  
  .tool-btn svg,
  .nav-btn svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  .modern-lightbox-overlay {
    background-color: rgba(0, 0, 0, 0.95);
  }
}

/* 浅色模式支持 */
@media (prefers-color-scheme: light) {
  .modern-lightbox-overlay {
    background-color: rgba(0, 0, 0, 0.9);
  }
}