/* ======================================================
 KPMG TW – Reusable Table Component (v2026.05.08b)
 ====================================================== */

/* ===== Light theme (default) ===== */
.kpmg-tw-table-container {
  --table-header-bg: #00338D;
  --table-header-text: #FFFFFF;
  --table-row-odd-bg: #FFFFFF;
  --table-row-even-bg: rgba(221, 244, 255, 1);
  --table-hover-bg: rgba(30, 73, 226, 1);
  --table-hover-text: #FFFFFF;
  --table-border-color: #FFFFFF;
  --table-hint-text: #777;
}

/* ===== Dark theme (預留，顏色可自行替換) ===== */
.kpmg-tw-table-container.is-dark {
  --table-header-bg: rgba(12, 35, 60, 1);
  --table-header-text: #FFFFFF;
  --table-row-odd-bg: #FFFFFF;
  --table-row-even-bg: #F1F1F1;
  --table-hover-bg: rgba(172, 234, 255, 1);
  --table-hover-text: #00338D;
  --table-border-color: rgba(255, 255, 255, 0.2);
  --table-hint-text: #999999;
}

/* ===== Outer container ===== */
.kpmg-tw-table-container {
  max-width: 1200px;
  margin: 0; /* 靠左貼齊 */
}

/* ===== Scroll layer ===== */
.kpmg-tw-table-scroll {
  overflow-x: auto;
}

/* ===== Table base ===== */
#kpmg-tw-custom-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  border: 1px solid var(--table-border-color);
  font-family: "Microsoft JhengHei", arial;
  table-layout: auto;
  font-size: 0.9rem;
}

/* ===== Header ===== */
#kpmg-tw-custom-table thead th {
  padding: 10px;
  font-size: 16px;
  font-weight: bold;
  text-align: left;
  white-space: nowrap;
  background-color: var(--table-header-bg);
  color: var(--table-header-text);
  border: 1px solid var(--table-border-color);
}

/* ===== Body rows ===== */
#kpmg-tw-custom-table tbody tr:nth-child(odd) {
  background-color: var(--table-row-odd-bg);
}

#kpmg-tw-custom-table tbody tr:nth-child(even) {
  background-color: var(--table-row-even-bg);
}

/* ===== Hover ===== */
#kpmg-tw-custom-table tbody tr:hover {
  background-color: var(--table-hover-bg);
  color: var(--table-hover-text);
  transition: background-color 0.3s ease;
  font-weight: bold;
}

/* ===== Cells ===== */
#kpmg-tw-custom-table td {
  padding: 10px;
  border: 1px solid var(--table-border-color);
  text-align: left;
  vertical-align: top; /* ✅ 預設仍為 top（不改動原本行為） */
  line-height: 1.5;
}

/* ===== First column emphasis ===== */
#kpmg-tw-custom-table tbody td:first-child {
  font-weight: bold;
}

/* ======================================================
 ✅ Vertical Center Extension（重點）
 ====================================================== */

/* ✅ 只有加上 is-vertical-center 才會啟用 */
.kpmg-tw-table-container.is-vertical-center th,
.kpmg-tw-table-container.is-vertical-center td {
  vertical-align: middle;
}

/* ✅ 修正 ul 預設 margin 導致視覺不置中 */
.kpmg-tw-table-container.is-vertical-center td ul {
  margin-top: 0;
  margin-bottom: 0;
  margin-left: -1rem;
}

/* ✅ 微調 li 間距（可選） */
.kpmg-tw-table-container.is-vertical-center td li {
  margin-bottom: 4px;
}

/* ===== Scroll hint ===== */
.kpmg-tw-table-hint {
  display: none;
  margin-top: 6px;
  font-size: 10px;
  color: var(--table-hint-text);
  text-align: right;
  user-select: none;
}

/* ===== RWD ===== */
@media (max-width: 768px) {
  #kpmg-tw-custom-table {
    font-size: 14px;
  }

  #kpmg-tw-custom-table th,
  #kpmg-tw-custom-table td {
    padding: 8px;
  }
}
