/**
 * 自定义修复样式
 * 用于解决特定问题和兼容性问题
 */

/* 修复PDF查看器滚动条问题 */
@media screen and (min-width: 768px) {
  #viewerContainer {
    max-height: 100vh;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
  }
  
  #viewerContainer::-webkit-scrollbar {
    width: 12px;
    height: 12px;
  }
  
  #viewerContainer::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: content-box;
  }
  
  #viewerContainer::-webkit-scrollbar-track {
    background-color: transparent;
  }
  
  .pdfViewer {
    min-height: 101vh;
  }
}

/* 修复移动端样式问题 */
@media screen and (max-width: 767px) {
  .mobile-folder-view .folder-item {
    padding: 8px;
  }
  
  .search-results-container {
    padding: 10px;
  }
}

/* 修复搜索结果样式 */
.search-result-item {
  transition: background-color 0.2s;
}

.search-result-item:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

/* 搜索关键词高亮优化 - 红色加粗无背景 */
.highlight {
    color: #dc2626 !important; /* 红色 */
    font-weight: bold !important;
    background: none !important; /* 无背景色 */
    padding: 0 !important; /* 移除内边距 */
}

/* 夜间模式下的搜索关键词高亮 */
body.dark-theme .highlight,
body.theme-dark .highlight,
.zib-theme-dark .highlight,
.dark-mode .highlight,
body[data-theme="dark"] .highlight,
html[data-theme="dark"] .highlight,
html.dark .highlight,
body.dark .highlight {
    color: #f87171 !important; /* 浅红色 */
    font-weight: bold !important;
    background: none !important; /* 无背景色 */
    padding: 0 !important; /* 移除内边距 */
}

/* 去除电脑端搜索结果的所有动画效果 */
.zib-search-button,
.zib-search-button::before,
.search-mode-option,
.search-results-container,
.search-results-placeholder::before,
.search-result-item,
.download-btn,
.download-btn::before,
.pagination-btn,
.search-form-container {
    transition: none !important;
    animation: none !important;
    transform: none !important;
}

/* 去除hover时的transform效果 */
.zib-search-button:hover,
.zib-search-button:active,
.search-mode-option:hover,
.search-result-item:hover,
.download-btn:hover,
.download-btn:active,
.pagination-btn:hover {
    transform: none !important;
}

/* 去除float动画 */
@keyframes float {
    0%, 100% { transform: none !important; }
    50% { transform: none !important; }
}

/* 去除fadeInUp动画 */
@keyframes fadeInUp {
    from { opacity: 1 !important; transform: none !important; }
    to { opacity: 1 !important; transform: none !important; }
}

/* 修复模态框样式 */
.modal-dialog {
  max-width: 95%;
  margin: 1.75rem auto;
}

@media (min-width: 768px) {
  .modal-dialog {
    max-width: 700px;
  }
}

/* 修复字体显示问题 */
body, .folder-item, .search-result-item {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 修改文章页面内边距和添加内边框 */
.article.page-article {
  padding-top: 10px !important;
  padding-left: 2px !important;
  padding-right: 2px !important;
  padding-bottom: 10px !important;
  border: 0px solid #337ab7 !important;
  border-radius: 8px !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1) !important;
  background-color: #fff !important;
  margin-bottom: 20px !important;
}

.article {
  padding: 0 !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  padding-bottom: 15px !important;
  overflow: hidden;
  border: 3px solid #3ca5f6 !important;
  border-radius: 8px !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1) !important;
  background-color: #fff !important;
  margin-bottom: 20px !important;
}

/* 夜间主题覆盖 */
body.dark-theme .article,
body.theme-dark .article,
.zib-theme-dark .article,
.dark-mode .article,
body[data-theme="dark"] .article,
html[data-theme="dark"] .article,
html.dark .article,
body.dark .article {
  background-color: #1a1a1a !important;
  color: #f0f0f0 !important;
  border-color: #404040 !important;
}

/* 移动端文章页面底部修复 */
@media (max-width: 768px) {
  .article.page-article.main-bg.theme-box.box-body.radius8.main-shadow,
  .article.page-article {
    margin-bottom: 15px !important;
    padding-bottom: 15px !important;
    max-width: calc(100vw - 20px) !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    position: relative !important;
    /* 确保article从最顶部开始 */
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  
  /* 防止内容溢出 */
  .article.page-article * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* 确保页面有足够的底部间距 */
  .main-bg.theme-box.box-body.radius8.main-shadow {
    margin-bottom: 30px !important;
  }
  
  /* 移动端隐藏子比主题顶部菜单栏 */
  .header,
  .navbar,
  .top-nav,
  .site-header,
  .main-header,
  .zib-header,
  .header-wrapper,
  .navigation,
  .menu-wrapper,
  .top-menu,
  .header-nav,
  .main-nav,
  .primary-nav,
  .site-nav,
  .top-bar,
  .header-bar,
  .nav-bar,
  .menu-bar {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* 确保主体内容从顶部开始 */
  .main,
  .content,
  .site-content,
  .main-content,
  .zib-main,
  .container,
  .wrapper,
  .site-wrapper,
  .page-wrapper {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  
  /* 确保html和body从顶部开始 */
  html, body {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
}

/* 强制修改搜索结果文件名样式 - 小字体无加粗 */
.file-name-cell .name,
.search-result-item .file-name,
.search-result-item .name,
.zib-file .name,
.search-results .name,
.search-results-table .name,
.search-results-list .file-name {
  font-size: 14px !important;
  font-weight: normal !important;
  line-height: 1.4 !important;
}

/* 额外确保移动端文件名样式正确 */
@media (max-width: 768px) {
  .search-result-item .file-name,
  .zib-file .name {
    font-size: 14px !important;
    font-weight: normal !important;
  }
}

/* 修复搜索结果表格布局 - 强制覆盖所有样式 */
.search-results-table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    margin: 0 !important;
}

/* 强制重置所有列宽度 */
.search-results-table th,
.search-results-table td {
    box-sizing: border-box !important;
    padding: 16px 16px !important;
    vertical-align: top !important;
    border-bottom: 1px solid #e5e7eb !important;
    line-height: 1.4 !important;
}

/* 文件名列 - 75% */
.search-results-table .file-name-header,
.search-results-table .file-name-cell,
.file-name-header,
.file-name-cell,
.search-results-table th:nth-child(1),
.search-results-table td:nth-child(1) {
    width: 75% !important;
    max-width: 75% !important;
    min-width: 75% !important;
    text-align: left !important;
}

/* 文件大小列 - 10% */
.search-results-table .file-size-header,
.search-results-table .file-size-cell,
.file-size-header,
.file-size-cell,
.search-results-table th:nth-child(2),
.search-results-table td:nth-child(2) {
    width: 10% !important;
    max-width: 10% !important;
    min-width: 10% !important;
    text-align: center !important;
}

/* 操作列 - 15% */
.search-results-table .file-actions-header,
.search-results-table .file-actions-cell,
.file-actions-header,
.file-actions-cell,
.search-results-table th:nth-child(3),
.search-results-table td:nth-child(3) {
    width: 15% !important;
    max-width: 15% !important;
    min-width: 15% !important;
    text-align: center !important;
}

/* 文件名样式 */
.search-results-table .file-name-cell .name,
.file-name-cell .name {
    max-width: 100% !important;
    overflow: hidden !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    word-wrap: break-word !important;
    word-break: break-all !important;
    width: 100% !important;
    font-size: 14px !important;
    font-weight: normal !important;
}

/* 表格容器 */
.search-results-table-container {
    width: 100% !important;
    overflow-x: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 确保下载按钮不会影响列宽 */
.download-btn {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* 强制重置表格行的grid布局，确保使用表格布局 */
.search-results-table tr.search-result-item {
    display: table-row !important;
    grid-template-columns: unset !important;
    grid-template-rows: unset !important;
    grid-gap: unset !important;
    gap: unset !important;
    width: 100% !important;
}

/* 强制重置表格单元格布局 */
.search-results-table tr.search-result-item td {
    display: table-cell !important;
    grid-column: unset !important;
    grid-row: unset !important;
    flex: unset !important;
    width: auto !important;
}

/* 确保表格本身使用正确的布局 */
.search-results-table {
    display: table !important;
    table-layout: fixed !important;
    width: 100% !important;
}

/* 确保表格头部使用正确的布局 */
.search-results-table thead {
    display: table-header-group !important;
}

.search-results-table tbody {
    display: table-row-group !important;
}

.search-results-table thead tr,
.search-results-table tbody tr {
    display: table-row !important;
}

.search-results-table th,
.search-results-table td {
    display: table-cell !important;
}
