/* v156：表單回應表格隨瀏覽器可視區域自動伸縮。 */

/*
 * response-auto-fit.css 仍負責依內容保留欄寬；這一版只接管外框尺寸
 * 與捲動。表格區高度以目前瀏覽器高度計算，視窗變高／變矮時會
 * 自動增加／減少可見資料列，不需要重新載入頁面。
 */
.response-table-module[data-response-table-scope="responses"] {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: clamp(180px, calc(100dvh - 225px), 100dvh) !important;
  min-height: 0 !important;
  max-height: none !important;
  box-sizing: border-box;
}

.response-table-module[data-response-table-scope="responses"] .response-table-tools {
  flex: 0 0 auto;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

.response-table-module[data-response-table-scope="responses"] .response-table-scroll {
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.response-table-module[data-response-table-scope="responses"] .response-table-scroll > table {
  width: max-content !important;
  min-width: 100% !important;
}

.response-table-module[data-response-table-scope="responses"] .response-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 8;
}

@media (max-width: 900px) {
  .response-table-module[data-response-table-scope="responses"] {
    height: clamp(180px, calc(100dvh - 250px), 100dvh) !important;
  }
}
