/**
 * 案例页面样式整合
 * 包含模态框布局、滚动条、分类按钮和导航栏相关样式
 */

/*
 * 第一部分: 导航栏和横幅修复
 * 来源: category-buttons-fix.css
 */

/* 修复导航和横幅部分 */
.header-fixed, header.fixed {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  height: 80px; /* 固定导航栏高度 */
  position: fixed !important; /* 强制固定在顶部 */
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000 !important; /* 确保导航栏在最上层 */
  background-color: white;
}

/* 横幅部分样式 */
.banner-section, section.relative[style*="background-image"] {
  margin-top: 80px !important; /* 与导航栏高度一致，确保内容不被遮挡 */
  padding-top: 1rem;
  display: flex;
  align-items: center;
}

/* 分类按钮容器样式 */
#cases-app .flex.flex-wrap {
  row-gap: 0.75rem; /* 增加按钮之间的垂直间距 */
  margin-bottom: 2.5rem;
}

/* 分类按钮样式 */
#cases-app .flex.flex-wrap button {
  transition: all 0.2s ease;
  border-radius: 9999px;
}

/*
 * 第二部分: 模态框基础布局和动画
 * 来源: case-modal-fix.css + case-modal-scroll.css
 */

/* 确保模态框内容正确显示 */
#case-modal.hidden {
  display: none !important;
}

#case-modal:not(.hidden) {
  display: flex !important;
  animation: modalFadeIn 0.3s ease-out;
}

/* 模态框淡入动画 */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 模态框背景遮罩 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 55;
  background-color: rgba(0, 0, 0, 0.6);
  cursor: pointer;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 调整模态框容器的大小和位置 - 居中布局 */
#case-modal {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 模态框容器样式 */
.case-modal-container, #case-modal > div:nth-child(2) {
  max-height: 85vh;
  width: 90%;
  max-width: 800px;
  border-radius: 0.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  background-color: white;
  position: relative;
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 防止内容溢出 */
  margin: 0 auto; /* 确保水平居中 */
}

/*
 * 第三部分: 模态框滚动区域样式
 * 来源: case-modal-scroll.css
 */

/* 滚动区域样式 */
.case-modal-scroll {
  flex: 1;
  overflow-y: auto !important;
  overflow-x: hidden;
  box-sizing: border-box !important;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* 在iOS设备上提供惯性滚动 */
  position: relative;
  max-height: calc(85vh - 60px - 60px); /* 减去标题和底部按钮高度 */
}

/* Firefox滚动条定制 */
@supports (scrollbar-width: thin) {
  .case-modal-scroll {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(0, 105, 180, 0.5) rgba(240, 240, 240, 0.7); /* Firefox */
  }
}

/* Webkit浏览器滚动条样式（Chrome, Safari, Edge等） */
.case-modal-scroll::-webkit-scrollbar {
  width: 6px; /* 适中的滚动条宽度 */
  height: 6px;
}

.case-modal-scroll::-webkit-scrollbar-track {
  background: rgba(240, 240, 240, 0.7);
  border-radius: 4px;
}

/* 滚动条样式 */
.case-modal-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 105, 180, 0.7);
  border-radius: 4px;
}

.case-modal-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 105, 180, 0.9);
}

/*
 * 第四部分: 模态框内容样式
 * 来源: case-modal-fix.css + case-modal-scroll.css
 */

/* 图片样式 - 图片在文本内容下方 */
#case-modal-image {
  width: 100%;
  max-height: 400px;
  object-fit: contain; /* 不裁剪图片，保持原始比例 */
  border-radius: 4px;
  transition: transform 0.3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: block;
}

#case-modal-image:hover {
  transform: scale(1.01);
}

/* 分类标签样式优化 */
#case-modal-categories span {
  display: inline-block;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0.75rem;
  background-color: rgba(0, 105, 180, 0.1);
  color: #0069B4;
  font-size: 0.875rem;
  border-radius: 9999px;
}

/* 确保模态框内容的间距合理 */
#case-modal-title {
  margin-bottom: 0;
  line-height: 1.2;
  font-size: 1.5rem;
  color: #0069B4; /* 使用主题色 */
}

/* 内容小节的间距和样式 */
.case-modal-scroll h3 {
  color: #1a202c;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  font-weight: 600;
}

.case-modal-scroll h3 i {
  margin-right: 0.5rem;
  color: #0069B4; /* 使用品牌主色 */
}

/* 确保模态框内容部分样式 */
#case-modal-overview, #case-modal-solution, #case-modal-results,
.case-modal-scroll div[id^="case-modal-"] {
  margin-bottom: 1.5rem;
  line-height: 1.6;
  color: #374151; /* 文字颜色 */
}

/* 保持换行格式 */
.case-modal-scroll p {
  white-space: pre-line;
  margin-bottom: 0.75rem;
}

/* 底部按钮区域 */
#case-modal .sticky.bottom-0 {
  background-color: #f9fafb;
  border-top: 1px solid #e5e7eb;
  padding: 1rem;
  text-align: center;
  z-index: 5;
}

#close-case-details {
  min-width: 120px;
  padding: 0.5rem 1.25rem;
  font-weight: 500;
  border-radius: 0.25rem;
  background-color: #0069B4;
  color: white;
  transition: all 0.2s;
}

#close-case-details:hover {
  background-color: rgba(0, 105, 180, 0.9);
}

/*
 * 第五部分: 响应式设计
 * 来源: 整合所有文件的响应式部分
 */

/* 为小屏幕设备优化 */
@media (max-width: 768px) {
  #cases-app .flex.flex-wrap {
    justify-content: flex-start; /* 小屏幕上左对齐更容易阅读 */
    padding: 0 0.5rem; /* 确保边缘有足够空间 */
    margin-bottom: 2rem;
  }
  
  /* 分类按钮在移动设备上可以更小 */
  #cases-app .flex.flex-wrap button {
    padding-left: 1rem;
    padding-right: 1rem;
    font-size: 0.9rem;
  }
  
  /* 横幅高度调整 */
  section.relative[style*="background-image"] {
    height: 240px;
  }
  
  /* 模态框调整 */
  .modal-overlay {
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
}

/* 移动设备优化 */
@media (max-width: 640px) {
  #case-modal > div:nth-child(2),
  .case-modal-container {
    width: 95%;
    max-height: 90vh;
  }
  
  #case-modal-image {
    max-height: 300px;
  }
  
  .case-modal-scroll {
    max-height: calc(90vh - 60px - 60px);
  }
  
  #case-modal-title {
    font-size: 1.25rem;
  }
  
  .case-modal-scroll::-webkit-scrollbar {
    width: 4px; /* 移动设备上更窄的滚动条 */
  }
  
  /* 移动设备上减少边距 */
  #case-modal-overview, #case-modal-solution, #case-modal-results {
    margin-bottom: 1rem;
  }
}

/*
 * 第六部分: RTL支持
 * 来源: 整合所有文件的RTL部分
 */

/* RTL支持 */
html[dir="rtl"] #case-modal-categories span {
  margin-right: 0;
  margin-left: 0.5rem;
}

html[dir="rtl"] .case-modal-scroll h3 i {
  margin-right: 0;
  margin-left: 0.5rem;
}

html[dir="rtl"] #cases-app .flex.flex-wrap {
  justify-content: flex-end; /* RTL语言时右对齐 */
}

html[dir="rtl"] .case-modal-scroll {
  direction: rtl;
  padding-right: 0;
  padding-left: 5px;
}
