/* ========================================
   修复飞书文档图片显示不全问题
   针对 .image-container 容器的图片优化
   ======================================== */

/* 🔥 核心修复 - 移除容器的高度限制 */
.image-container {
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  min-height: auto !important;
  overflow: visible !important;
  position: relative;
  margin: 20px 0;
  padding: 0;
  background: transparent !important; /* 🔥 移除灰色背景 */
  /*box-shadow: none !important; */
}

/* 针对 .content-body 下的图片容器 */
.content-body .image-container {
  background: transparent !important;
  min-height: auto !important;
  overflow: visible !important;
  /*box-shadow: none !important; */
}

/* 🔥 确保图片完整显示 */
.image-container img {
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: none !important;
  min-height: 0 !important; /* 🔥 最小高度设为0 */
  display: block !important;
  object-fit: contain !important;
  margin: 0 auto;
  /*box-shadow: none !important; */
}

/* 针对 .content-body 下的图片 */
.content-body .image-container img {
  min-height: 0 !important; /* 🔥 最小高度设为0 */
}

/* 修复 .image-uploaded 容器 */
.image-uploaded {
  width: 100% !important;
  height: auto !important;
  overflow: visible !important;
  margin: 20px 0;
}

.image-uploaded .image-container {
  height: auto !important;
  max-height: none !important;
}

/* 修复 gallery 相关的容器 */
.gallery .image-container,
.old-record-id-doxcn7Z8CUdRD5ChOILKjeqSx2e {
  height: auto !important;
  max-height: none !important;
}

/* 🔥 针对飞书文档嵌入图片的特殊处理 */
div[data-type="image"] {
  width: 100% !important;
  height: auto !important;
  overflow: visible !important;
}

div[data-ace-gallery-json] {
  height: auto !important;
  max-height: none !important;
}

div[data-ace-gallery-json] .image-container {
  height: auto !important;
}

div[data-ace-gallery-json] img {
  width: 100% !important;
  height: auto !important;
}

/* ========================================
   通用图片优化
   ======================================== */

/* 所有图片的基础样式 */
img {
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

/* 移除所有可能限制图片显示的属性 */
img[style*="height"] {
  height: auto !important;
}

/* ========================================
   移动端适配
   ======================================== */
@media screen and (max-width: 768px) {
  .image-container {
    width: 100% !important;
    padding: 0 10px;
    margin: 15px 0;
  }
  
  .image-container img {
    width: 100% !important;
    height: auto !important;
  }
  
  /* 横长图在移动端可以横向滚动查看 */
  .image-container.wide-image {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }
  
  .image-container.wide-image img {
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: 80vh;
  }
}

/* ========================================
   PC端优化
   ======================================== */
@media screen and (min-width: 769px) {
  .image-container {
    max-width: 1400px;
    margin: 25px auto;
  }
  
  .image-container img {
    cursor: zoom-in;
    transition: transform 0.3s ease;
  }
  
  .image-container img:hover {
    transform: scale(1.01);
    box-shadow: none; /* 悬停时也不显示阴影 */
  }
}

/* ========================================
   图片点击放大功能（可选）
   ======================================== */

/* 为图片添加点击放大效果 */
.image-container img.zoomable {
  cursor: zoom-in;
}

/* 放大遮罩层 */
.image-zoom-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 99999;
  cursor: zoom-out;
  align-items: center;
  justify-content: center;
}

.image-zoom-overlay.active {
  display: flex;
}

.image-zoom-overlay img {
  max-width: 95vw;
  max-height: 95vh;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  box-shadow: 0 0 50px rgba(255, 255, 255, 0.2);
}

/* 关闭按钮 */
.image-zoom-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  transition: all 0.3s ease;
}

.image-zoom-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* ========================================
   其他内容区域的图片
   ======================================== */

/* 文章内容区图片 */
.content img,
article img,
.post-content img,
.article-content img {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin: 20px auto;
  box-shadow: none !important; /* 移除阴影 */
}

/* 表格中的图片 */
table img {
  max-width: 100%;
  height: auto;
}

/* Flex/Grid 布局中的图片 */
.flex-container img,
.grid-container img {
  max-width: 100%;
  height: auto;
}

/* ========================================
   防止常见问题
   ======================================== */

/* 移除内联样式的高度限制 */
*[style*="max-height"] img {
  max-height: none !important;
}

/* 确保父容器不会限制 */
.content-wrapper,
.post-body,
.article-body {
  overflow: visible !important;
}

/* 响应式视频 */
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* ========================================
   调试辅助（开发时可用）
   ======================================== */

/* 取消注释以下代码可以看到容器边界，方便调试 */
/*
.image-container {
  border: 2px dashed red !important;
}
.image-container img {
  border: 2px solid blue !important;
}
*/