/* ========================
   图片弹窗样式
   ======================== */

/* 弹窗遮罩层 */
.image-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 弹窗容器 */
.image-modal {
  position: relative;
  width: 90vw;
  height: 90vh;
  max-width: 1400px;
  background: rgba(30, 30, 40, 0.95);
  border-radius: 16px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.image-modal-overlay.active .image-modal {
  transform: scale(1);
}

/* 弹窗头部 */
.image-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(40, 40, 55, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.image-modal-title {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  margin: 0;
}

/* 图片计数器 */
.image-modal-counter {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-left: auto;
  margin-right: 16px;
}

/* 关闭按钮 */
.image-modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: #fff;
  font-size: 20px;
  flex-shrink: 0;
}

.image-modal-close:hover {
  background: rgba(255, 80, 80, 0.8);
  transform: rotate(90deg);
}

.image-modal-close:active {
  transform: rotate(90deg) scale(0.95);
}

/* 缩放控制按钮 */
.image-modal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-modal-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: #fff;
  font-size: 18px;
}

.image-modal-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.image-modal-btn:active {
  transform: scale(0.95);
}

/* 缩放倍数显示 */
.image-modal-zoom-level {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  min-width: 50px;
  text-align: center;
}

/* 图片查看区域 */
.image-modal-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: grab;
}

.image-modal-body:active {
  cursor: grabbing;
}

/* 图片包装器 */
.image-modal-img-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  transition: transform 0.1s ease-out;
}

/* 图片 */
.image-modal-img {
  max-width: 100%;
  max-height: calc(90vh - 120px);
  object-fit: contain;
  transition: transform 0.1s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}

/* 缩放后的图片样式 */
.image-modal-img.zoomed {
  cursor: move;
}

/* 加载状态 */
.image-modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: modal-spin 0.8s linear infinite;
}

@keyframes modal-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* 缩略图列表 */
.image-modal-thumbs {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: rgba(30, 30, 40, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.image-modal-thumbs::-webkit-scrollbar {
  height: 4px;
}

.image-modal-thumbs::-webkit-scrollbar-track {
  background: transparent;
}

.image-modal-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.image-modal-thumb {
  width: 80px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.image-modal-thumb:hover {
  opacity: 0.9;
}

.image-modal-thumb.active {
  border-color: #4a9eff;
  opacity: 1;
  box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.image-modal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 导航箭头 */
.image-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: #fff;
  font-size: 24px;
  z-index: 10;
  opacity: 0.7;
}

.image-modal-nav:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
}

.image-modal-nav:active {
  transform: translateY(-50%) scale(0.95);
}

.image-modal-nav.prev {
  left: 20px;
}

.image-modal-nav.next {
  right: 20px;
}

.image-modal-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* 空状态 */
.image-modal-empty {
  color: rgba(255, 255, 255, 0.5);
  font-size: 16px;
  text-align: center;
}

/* 响应式 */
@media (max-width: 768px) {
  .image-modal {
    width: 95vw;
    height: 95vh;
    border-radius: 12px;
  }

  .image-modal-header {
    padding: 12px 16px;
  }

  .image-modal-title {
    font-size: 14px;
  }

  .image-modal-nav {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .image-modal-nav.prev {
    left: 10px;
  }

  .image-modal-nav.next {
    right: 10px;
  }

  .image-modal-thumbs {
    padding: 12px 16px;
  }

  .image-modal-thumb {
    width: 60px;
    height: 45px;
  }
}

/* ============================================
   手机设备增强 (≤480px)
   ============================================ */
@media screen and (max-width: 480px) {
  .image-modal-overlay {
    z-index: 100000;
  }

  .image-modal {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    max-width: none;
    max-height: none;
  }

  .image-modal-header {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
    min-height: 56px;
  }

  .image-modal-title {
    font-size: 15px;
    font-weight: 600;
  }

  .image-modal-controls {
    gap: 4px;
  }

  .image-modal-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 20px;
    -webkit-tap-highlight-color: transparent;
  }

  .image-modal-zoom-level {
    font-size: 12px;
    min-width: 42px;
  }

  .image-modal-counter {
    font-size: 13px;
    margin-right: 12px;
  }

  .image-modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 22px;
    -webkit-tap-highlight-color: transparent;
  }

  .image-modal-nav {
    width: 48px;
    height: 48px;
    font-size: 28px;
    opacity: 0.8;
    border-radius: 50%;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .image-modal-nav.prev {
    left: 8px;
  }

  .image-modal-nav.next {
    right: 8px;
  }

  .image-modal-body {
    cursor: default;
    touch-action: none;
  }

  .image-modal-img {
    max-height: calc(100vh - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .image-modal-thumbs {
    padding: 10px 14px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
  }

  .image-modal-thumb {
    width: 56px;
    height: 42px;
    border-radius: 6px;
  }

  .image-modal-loading {
    width: 36px;
    height: 36px;
  }
}

/* 小屏手机 (≤374px) */
@media screen and (max-width: 374px) {
  .image-modal-header {
    padding: 10px 12px;
  }

  .image-modal-btn {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .image-modal-nav {
    width: 42px;
    height: 42px;
    font-size: 24px;
  }

  .image-modal-thumb {
    width: 48px;
    height: 36px;
  }
}

/* 横屏模式 */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .image-modal {
    height: 100vh;
    border-radius: 12px;
  }

  .image-modal-img {
    max-height: calc(100vh - 100px);
  }

  .image-modal-header {
    padding: 8px 16px;
    min-height: 48px;
  }

  .image-modal-thumbs {
    display: none;
  }
}

/* 触摸优化 */
@media screen and (max-width: 768px) {
  .image-modal-btn,
  .image-modal-close,
  .image-modal-nav,
  .image-modal-thumb {
    -webkit-tap-highlight-color: transparent;
  }

  .image-modal-btn:active,
  .image-modal-close:active,
  .image-modal-nav:active {
    opacity: 0.7;
  }
}
