/**
 * 自訂表格樣式 - 靈活調整表格寬度並確保標題與內文對齊
 * 短文字時緊湊顯示，長文字時有足夠空間，超過容器寬度時可水平滾動
 */

/* 表格容器樣式 - 包裝層提供水平滾動 */
.article-content,
.post-content,
.content,
article {
  /* 確保容器有明確的寬度 */
}

/* 為表格創建一個滾動包裝層 */
.article-content table,
.post-content table,
.content table,
article table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* iOS 平滑滾動 */
  margin: 1.5em 0;
}

/* 讓表格內部結構保持原生 table 顯示 */
.article-content table>thead,
.article-content table>tbody,
.article-content table>tfoot,
.post-content table>thead,
.post-content table>tbody,
.post-content table>tfoot,
.content table>thead,
.content table>tbody,
.content table>tfoot,
article table>thead,
article table>tbody,
article table>tfoot {
  display: table-header-group;
  width: 100%;
}

.article-content table>tbody,
.post-content table>tbody,
.content table>tbody,
article table>tbody {
  display: table-row-group;
}

.article-content table>tfoot,
.post-content table>tfoot,
.content table>tfoot,
article table>tfoot {
  display: table-footer-group;
}

/* 表格行 */
.article-content table tr,
.post-content table tr,
.content table tr,
article table tr {
  display: table-row;
}

/* 表格儲存格 - 統一樣式 */
.article-content table td,
.article-content table th,
.post-content table td,
.post-content table th,
.content table td,
.content table th,
article table td,
article table th {
  display: table-cell;
  padding: 0.75em 1em;
  vertical-align: top;
  white-space: normal;
  max-width: 450px;
  min-width: 120px;
  /* 強制最小寬度，防止文字擠壓，觸發水平滾動 */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* 表格標題加粗 */
.article-content table th,
.post-content table th,
.content table th,
article table th {
  font-weight: bold;
}

/* 滾動條樣式美化 */
.article-content table::-webkit-scrollbar,
.post-content table::-webkit-scrollbar,
.content table::-webkit-scrollbar,
article table::-webkit-scrollbar {
  height: 8px;
}

.article-content table::-webkit-scrollbar-track,
.post-content table::-webkit-scrollbar-track,
.content table::-webkit-scrollbar-track,
article table::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.article-content table::-webkit-scrollbar-thumb,
.post-content table::-webkit-scrollbar-thumb,
.content table::-webkit-scrollbar-thumb,
article table::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.article-content table::-webkit-scrollbar-thumb:hover,
.post-content table::-webkit-scrollbar-thumb:hover,
.content table::-webkit-scrollbar-thumb:hover,
article table::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* 移動裝置優化 */
@media screen and (max-width: 768px) {

  .article-content table td,
  .article-content table th,
  .post-content table td,
  .post-content table th,
  .content table td,
  .content table th,
  article table td,
  article table th {
    padding: 0.5em 0.75em;
    font-size: 0.9em;
    max-width: 500px;
    /* 允許更大的最大寬度 */
    min-width: 180px;
    /* 大幅增加最小寬度，確保文字不擠壓，強制水平滾動 */
  }
}