/* rwd-table-block/assets/style.css (v4.3.1 - Fixes & Enhancements) */

/* ======================================================= */
/*  【V5.3 搜尋區域樣式升級 - 整合式專業版】   */
/* ======================================================= */

/* --- 1. 整合式容器 --- */
/* 這是新的視覺主體，它將包裹所有元件 */
.custom-rwd-table-search-wrapper {
display: flex;
align-items: center;
margin-bottom: 1.5rem;

/* 容器本身的視覺樣式 */
background-color: #fff;
border: 1px solid #d1d5db;
border-radius: 6px; /* 柔和的圓角 */
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* 細微的陰影 */
transition: border-color 0.2s ease, box-shadow 0.2s ease;
overflow: hidden; /* 確保子項目的圓角被正確裁切 */
}

/* --- 2. 互動狀態：整個容器一起發光 --- */
/* 當容器內的任何元件被 focus 時，整個容器邊框高亮 */
.custom-rwd-table-search-wrapper:focus-within {
border-color: #007cba;
box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.15);
}

.custom-rwd-table-search-wrapper p{
font-size: 1rem;
padding: 10px;
}

/* --- 3. 內部元件：移除獨立樣式 --- */
/* 讓輸入框和下拉選單無縫融入容器 */
.custom-rwd-table-search-input,
.custom-rwd-table-column-filter {
/* 移除所有獨立邊框和背景 */
border: none;
outline: none;
box-shadow: none;
background-color: transparent;

/* 統一尺寸和字體 */
height: 38px;
font-size: 0.9em; /* 14.4px */
padding-top: 0.2em; /* 微調垂直對齊 */
padding-bottom: 0.2em;
color: #374151;
}

/* --- 4. 搜尋輸入框：加入放大鏡圖示 --- */
.custom-rwd-table-search-input {
flex-grow: 1; /* 佔滿剩餘空間 */
/* 放大鏡圖示 */
background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="%239ca3af"><path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" /></svg>');
background-repeat: no-repeat;
background-position: left 0.75rem center;
background-size: 1rem;

padding-left: 2.5rem; /* 為圖示留出足夠空間 */
}
.custom-rwd-table-search-input::placeholder {
color: #9ca3af;
}

/* --- 5. 分隔線 & 下拉選單 --- */
.custom-rwd-table-column-filter {
/* 移除瀏覽器預設樣式 */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;

/* 左側分隔線 */
border-left: 1px solid #e5e7eb;
border-radius: 0; /* 清除可能繼承的圓角 */

/* 自訂下拉箭頭 */
background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="%236b7280"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" /></svg>');
background-repeat: no-repeat;
background-position: right 0.6rem center;
background-size: 1.25em;

padding-left: 0.75rem;
padding-right: 2.2rem; /* 為箭頭留出空間 */
min-width: 140px;
cursor: pointer;
white-space: nowrap; /* 避免選項文字換行 */
}

/* --- 6. 響應式：手機上恢復獨立樣式 --- */
@media (max-width: 520px) {
/* 容器變回簡單的 flex 佈局 */
.custom-rwd-table-search-wrapper {
flex-direction: column;
align-items: stretch;
gap: 0.5rem;

/* 移除容器的視覺樣式 */
background-color: transparent;
border: none;
box-shadow: none;
}

/* 為內部元件恢復各自的獨立樣式 */
.custom-rwd-table-search-input,
.custom-rwd-table-column-filter {
border: 1px solid #d1d5db;
border-radius: 6px;
background-color: #fff;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* 移除分隔線 */
.custom-rwd-table-column-filter {
border-left: 1px solid #d1d5db; /* 恢復成普通邊框 */
}
}

/* 修正 RWD 寬度計算問題 */
.custom-rwd-table-wrapper {
margin: 1.5rem 0;
max-width: min(100%, var(--table-max-width, 100%));
width: min(100%, var(--table-width, 100%));
overflow-x: auto;
-webkit-overflow-scrolling: touch;
border: 0;
/* 新增: 確保容器不會超出父元素 */
box-sizing: border-box;
}

.custom-rwd-table-wrapper[data-rwd-table-align="center"] {
margin-left: auto;
margin-right: auto;
}

.custom-rwd-table-wrapper[data-rwd-table-align="right"] {
margin-left: auto;
margin-right: 0;
}

.custom-rwd-table-wrapper .custom-rwd-table {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
border-style: solid;
border-width: var(--rwd-border-w, 1px);
border-color: var(--border-color, #e5e7eb);
font-family: inherit;
font-size: var(--font-size, 16px);
margin: 0;
table-layout:auto;
min-width: 100%;
}

.custom-rwd-table-wrapper .custom-rwd-table th p,
.custom-rwd-table-wrapper .custom-rwd-table td p {
font-size: inherit;
line-height: inherit;
text-align: inherit;
margin: 0;
}

.custom-rwd-table-wrapper .custom-rwd-table th span,
.custom-rwd-table-wrapper .custom-rwd-table td span {
font-size: inherit;
line-height: inherit;
text-align: inherit;
}

/* NEW: Rule for the main title, using the correct <caption> tag */
.custom-rwd-table-wrapper .custom-rwd-table caption {
caption-side: top;
background-color: var(--header-bg-color, #f3f4f6);
color: var(--header-text-color, #111827);
font-weight: bold;
text-align: center;
font-size: 1.1em;
padding: var(--cell-padding, 12px);
border: var(--rwd-border-w, 1px) solid var(--border-color, #e5e7eb);
border-bottom: none;
border-radius: 6px 6px 0 0; /* Optional: adds nice rounded corners */
}

.custom-rwd-table-wrapper .custom-rwd-table th,
.custom-rwd-table-wrapper .custom-rwd-table td {
padding: var(--cell-padding, 12px);
border-style: solid;
border-width: 0 var(--rwd-border-w, 1px); /* Vertical borders only */
border-color: var(--border-color, #e5e7eb);
line-height: 1.5;
vertical-align: top; /* Default vertical align */
overflow-wrap: break-word; /* FIXED: Replaced word-wrap with overflow-wrap */
}
.custom-rwd-table-wrapper .custom-rwd-table th:first-child,
.custom-rwd-table-wrapper .custom-rwd-table td:first-child {
border-left-width: 0;
}
.custom-rwd-table-wrapper .custom-rwd-table th:last-child,
.custom-rwd-table-wrapper .custom-rwd-table td:last-child {
border-right-width: 0;
}

.custom-rwd-table-wrapper .custom-rwd-table tr {
border-bottom: var(--rwd-border-w, 1px) solid var(--border-color, #e5e7eb);
}

/* REFACTORED: This rule now correctly styles the column headers inside <thead> */
/* 只讓 thead 中的 th 不換行，確保欄位標題完整 */
.custom-rwd-table-wrapper .custom-rwd-table thead th {
background-color: var(--header-bg-color, #f3f4f6);
color: var(--header-text-color, #111827);
font-weight: 600;
text-align: var(--header-align, left);
border-bottom: var(--rwd-border-w, 1px) solid var(--header-border-color, var(--border-color, #e5e7eb));
white-space: nowrap; /* 【新增】只針對標頭強制不換行 */
}

/* 讓 td 保持可以換行的狀態，但給定一個最小寬度 */
.custom-rwd-table-wrapper .custom-rwd-table td {
min-width: 100px; /* 【新增】給內容儲存格一個最小寬度，避免過度壓縮 */
}

.custom-rwd-table-wrapper .custom-rwd-table .rwd-tbody td { text-align: var(--text-align, left); }
.custom-rwd-table-wrapper .custom-rwd-table .rwd-tbody tr:nth-child(even) { background-color: var(--even-row-bg-color, #ffffff); }
.custom-rwd-table-wrapper .custom-rwd-table .rwd-tbody tr:nth-child(odd) { background-color: var(--odd-row-bg-color, #f9fafb); }
/* NOTE: The .is-header-row rule is no longer needed here as it's now in thead */

.custom-rwd-table-wrapper .custom-rwd-table tfoot td { background-color: var(--header-bg-color, #f3f4f6); color: var(--header-text-color, #111827); font-weight: normal; text-align: center; font-size: 0.9em; }

.custom-rwd-table-wrapper::-webkit-scrollbar { height: 10px; }
.custom-rwd-table-wrapper::-webkit-scrollbar-track { background: #f0f0f0; }
.custom-rwd-table-wrapper::-webkit-scrollbar-thumb { background: #cccccc; border-radius: 5px; border: 2px solid #f0f0f0; }
.custom-rwd-table-wrapper::-webkit-scrollbar-thumb:hover { background: #aaaaaa; }

.is-scroll-desktop, .is-scroll-tablet, .is-scroll-mobile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.custom-rwd-table-wrapper[class*="is-stack-"], .custom-rwd-table-wrapper[class*="is-cards-"], .custom-rwd-table-wrapper[class*="is-list-"] { overflow-x: visible; }
.custom-rwd-table-wrapper[class*="is-stack-"] .custom-rwd-table, .custom-rwd-table-wrapper[class*="is-cards-"] .custom-rwd-table, .custom-rwd-table-wrapper[class*="is-list-"] .custom-rwd-table { border: 0; table-layout: auto; display: block; }
.custom-rwd-table-wrapper[class*="is-stack-"] thead, .custom-rwd-table-wrapper[class*="is-cards-"] thead, .custom-rwd-table-wrapper[class*="is-list-"] thead,
.custom-rwd-table-wrapper[class*="is-stack-"] .is-header-row, .custom-rwd-table-wrapper[class*="is-cards-"] .is-header-row, .custom-rwd-table-wrapper[class*="is-list-"] .is-header-row { display: none; }

.custom-rwd-table-wrapper[class*="is-stack-"] tr { display: block; margin-bottom: 1em; border: var(--rwd-border-w, 1px) solid var(--border-color, #e5e7eb); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); border-radius: 6px; background: #fff; }
.custom-rwd-table-wrapper[class*="is-stack-"] td { display: flex; justify-content: space-between; align-items: flex-start; text-align: right; border: none; border-bottom: 1px solid #eee; padding: 0.8em 1em; }
.custom-rwd-table-wrapper[class*="is-stack-"] td:last-child { border-bottom: 0; }
.custom-rwd-table-wrapper[class*="is-stack-"] td::before { content: attr(data-label); font-weight: 600; text-align: left; padding-right: 1em; color: var(--header-text-color, #111827); flex-shrink: 0; width: 40%; }

.custom-rwd-table-wrapper[class*="is-cards-"] tr { display: block; margin-bottom: 1.5em; border: var(--rwd-border-w, 1px) solid var(--border-color, #e5e7eb); border-radius: 12px; background: #fff; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.08); padding: 1.5em; transition: transform 0.2s ease, box-shadow 0.2s ease; position: relative; }
.custom-rwd-table-wrapper[class*="is-cards-"] tr:hover { transform: translateY(-2px); box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1); }
.custom-rwd-table-wrapper[class*="is-cards-"] td { display: block; text-align: left; border: none; padding: 0.75em 0; border-bottom: 1px solid #f0f0f0; }
.custom-rwd-table-wrapper[class*="is-cards-"] td:last-child { border-bottom: 0; padding-bottom: 0; }
.custom-rwd-table-wrapper[class*="is-cards-"] td::before { content: attr(data-label) ": "; font-weight: 600; color: var(--header-text-color, #111827); display: block; margin-bottom: 0.25em; font-size: 0.9em; text-transform: uppercase; }
.custom-rwd-table-wrapper[class*="is-cards-"] td:first-child { font-size: 1.15em; font-weight: 700; margin-bottom: 0.75em; padding-bottom: 0.75em; border-bottom: 2px solid var(--header-bg-color, #f3f4f6); }
.custom-rwd-table-wrapper[class*="is-cards-"] td:first-child::before { display: none; }

.custom-rwd-table-wrapper[class*="is-list-"] tr { display: block; margin-bottom: 1.25em; border-left: 4px solid var(--header-bg-color, #f3f4f6); padding: 1em 1.5em; background: var(--odd-row-bg-color, #f9fafb); border-radius: 0 6px 6px 0; }
.custom-rwd-table-wrapper[class*="is-list-"] td { display: block; text-align: left; border: none; padding: 0.4em 0; }
.custom-rwd-table-wrapper[class*="is-list-"] td:first-child { font-weight: 700; font-size: 1.2em; color: var(--header-text-color, #111827); margin-bottom: 0.5em; padding-bottom: 0.5em; border-bottom: 1px solid #ddd; }
.custom-rwd-table-wrapper[class*="is-list-"] td::before { content: attr(data-label) ": "; font-weight: 500; color: #555; margin-right: 0.5em; }
.custom-rwd-table-wrapper[class*="is-list-"] td:first-child::before { display: none; }

/* ENHANCED: Dynamic font scaling for mobile */
@media (max-width: 767px) {
.custom-rwd-table-wrapper .custom-rwd-table {
font-size: calc(var(--font-size, 16px) * 0.9);
}
.custom-rwd-table-wrapper[class*="is-list-"] { border-left-width: 2px; } /* Adjusted for narrow screens */
}

/* ENHANCED: Improved dark mode contrast */
@media (prefers-color-scheme: dark) { 
.custom-rwd-table-wrapper[class*="is-cards-"] tr, .custom-rwd-table-wrapper[class*="is-stack-"] tr, .custom-rwd-table-wrapper[class*="is-list-"] tr { 
background: #1a1a1a; 
border-color: #444 !important; /* Improved contrast */
} 
.custom-rwd-table-wrapper[class*="is-stack-"] td, .custom-rwd-table-wrapper[class*="is-cards-"] td { border-color: #444 !important; } 
}

/* Glass Theme Specific */
.custom-rwd-table-wrapper {
    /* Base for glass effect if applied via style attribute */
    transition: backdrop-filter 0.3s ease;
}
.custom-rwd-table-wrapper[style*="rgba"] {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* FIXED: Improved print mode with better page breaks */
@media print { 
.custom-rwd-table-wrapper { overflow: visible !important; box-shadow: none !important; } 
.custom-rwd-table-wrapper .custom-rwd-table { page-break-inside: avoid; font-size: 10pt !important; table-layout: auto !important; } 
.custom-rwd-table-wrapper .custom-rwd-table th, .custom-rwd-table-wrapper .custom-rwd-table td { padding: 4pt !important; border: 1px solid #000 !important; } 
.custom-rwd-table-wrapper .custom-rwd-table thead th, .custom-rwd-table-wrapper .custom-rwd-table .is-header-row th { background-color: #f0f0f0 !important; color: #000 !important; } 
.custom-rwd-table-wrapper .custom-rwd-table tbody tr:nth-child(even), .custom-rwd-table-wrapper .custom-rwd-table tbody tr:nth-child(odd) { background-color: #fff !important; } 
.custom-rwd-table-wrapper[class*="is-stack-"] .is-header-row, .custom-rwd-table-wrapper[class*="is-cards-"] .is-header-row, .custom-rwd-table-wrapper[class*="is-list-"] .is-header-row { display: table-row !important; } 
.custom-rwd-table-wrapper[class*="is-stack-"] tr, .custom-rwd-table-wrapper[class*="is-cards-"] tr, .custom-rwd-table-wrapper[class*="is-list-"] tr { display: table-row !important; margin: 0 !important; border: none !important; background: transparent !important; padding: 0 !important; } 
.custom-rwd-table-wrapper[class*="is-stack-"] td, .custom-rwd-table-wrapper[class*="is-cards-"] td, .custom-rwd-table-wrapper[class*="is-list-"] td { display: table-cell !important; border: 1px solid #000 !important; padding: 4pt !important; } 
.custom-rwd-table-wrapper[class*="is-stack-"] td::before, .custom-rwd-table-wrapper[class*="is-cards-"] td::before, .custom-rwd-table-wrapper[class*="is-list-"] td::before { content: none !important; } 
/* ADDED: Better page break handling */
.custom-rwd-table-wrapper .custom-rwd-table { page-break-before: auto; page-break-after: auto; }
}

@media (prefers-reduced-motion: reduce) { .custom-rwd-table-wrapper, .custom-rwd-table-wrapper * { transition: none !important; animation: none !important; } }

/* NEW: Styles for Sortable Table Headers (FIXED: Arrow positioning to avoid overlap) */
.custom-rwd-table[data-sortable="true"] thead th[role="button"] {
cursor: pointer;
position: relative;
padding-right: 2.5em; /* Increased space for sort icon */
-webkit-user-select: none; /* Safari */
-ms-user-select: none; /* IE 10 and IE 11 */
user-select: none; /* Standard syntax */
}

.custom-rwd-table[data-sortable="true"] thead th[role="button"]::after,
.custom-rwd-table[data-sortable="true"] thead th[role="button"]::before {
content: '';
position: absolute;
right: 0.75em;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
opacity: 0.4;
transition: opacity 0.2s ease;
}

.custom-rwd-table[data-sortable="true"] thead th[role="button"]:hover::after,
.custom-rwd-table[data-sortable="true"] thead th[role="button"]:hover::before {
opacity: 1;
}

/* Default unsorted state icon (up and down arrows) */
.custom-rwd-table[data-sortable="true"] thead th[role="button"]::before {
bottom: 50%;
margin-bottom: 1px;
border-bottom: 5px solid currentColor;
}
.custom-rwd-table[data-sortable="true"] thead th[role="button"]::after {
top: 50%;
margin-top: 1px;
border-top: 5px solid currentColor;
}

/* Ascending state icon (only up arrow is visible) */
.custom-rwd-table[data-sortable="true"] thead th[aria-sort="ascending"]::before {
opacity: 1;
}
.custom-rwd-table[data-sortable="true"] thead th[aria-sort="ascending"]::after {
opacity: 0.4;
}

/* Descending state icon (only down arrow is visible) */
.custom-rwd-table[data-sortable="true"] thead th[aria-sort="descending"]::after {
opacity: 1;
}
.custom-rwd-table[data-sortable="true"] thead th[aria-sort="descending"]::before {
opacity: 0.4;
}

/* ENHANCED: Hover effect for rows */
.custom-rwd-table-wrapper .custom-rwd-table tbody tr:hover {
background-color: rgba(var(--header-bg-color, #f3f4f6), 0.8);
transition: background-color 0.2s ease;
}


/* rwd-table-block/assets/style.css (新增部分) */

/* ENHANCED: Sticky Header Styles */
.custom-rwd-table-wrapper.has-sticky-header {
max-height: var(--rwd-sticky-max-height, 500px);
overflow-y: auto;
position: relative;
}

.has-sticky-header .custom-rwd-table thead th {
position: -webkit-sticky; /* For Safari */
position: sticky;
top: 0;
z-index: 10; /* 確保標頭在捲動內容之上 */
}

/* 確保黏性標頭有實心背景色，避免下方文字透出 */
.has-sticky-header .custom-rwd-table thead th {
background-color: var(--header-bg-color, #f3f4f6);
}

/* 修正邊框，避免黏貼時邊框消失 */
.has-sticky-header .custom-rwd-table thead tr {
border-bottom: var(--rwd-border-w, 1px) solid var(--header-border-color, var(--border-color, #e5e7eb));
}

/* --- 【V5.0】黏性第一欄 (Sticky First Column) --- */
.custom-rwd-table-wrapper.has-sticky-first-column {
/* 確保 overflow-x 在 wrapper 層級 */
overflow-x: auto;
}
.has-sticky-first-column .custom-rwd-table {
/* 確保表格本身不滾動，由 wrapper 滾動 */
overflow: visible;
}
.has-sticky-first-column .custom-rwd-table th:first-child,
.has-sticky-first-column .custom-rwd-table td:first-child {
position: -webkit-sticky;
position: sticky;
left: 0;
z-index: 5; /* 低於 a-index of the header */
/* 確保有背景色，避免文字透出 */
background-color: var(--odd-row-bg-color, #f9fafb);
}
.has-sticky-first-column .custom-rwd-table thead th:first-child {
z-index: 15; /* 必須高於 thead 的 z-index */
background-color: var(--header-bg-color, #f3f4f6);
}
/* 處理 hover 效果下的背景色 */
.has-sticky-first-column.has-hover-highlight .rwd-tbody tr:hover td:first-child {
background-color: var(--row-hover-bg-color, rgba(229, 231, 235, 0.6));
}

/* --- 【V5.0】搜尋高亮 --- */
.search-highlight {
background-color: #fef08a; /* 黃色高亮 */
color: #713f12;
font-weight: bold;
border-radius: 2px;
padding: 0 2px;
}

/* --- 【V5.0】圖表容器 --- */
.custom-rwd-table-chart-container {
margin-bottom: 2rem;
max-width: 800px;
margin-left: auto;
margin-right: auto;
padding: 1rem;
border: 1px solid var(--border-color, #e5e7eb);
border-radius: 8px;
background: #fff;
}

/* 將以下內容添加到 rwd-table-block/assets/style.css 檔案的末尾 */

/* --- 【V5.0 版新功能樣式】 --- */

/* 特殊儲存格類型 */
.rwd-table-button {
display: inline-block;
padding: 0.4em 0.8em;
background-color: var(--header-bg-color, #f3f4f6);
color: var(--header-text-color, #111827);
text-decoration: none;
border-radius: 4px;
font-weight: 500;
transition: opacity 0.2s ease;
border: 1px solid var(--border-color, #e5e7eb);
}
.rwd-table-button:hover {
opacity: 0.8;
}

.rwd-table-rating {
color: #f59e0b; /* 琥珀色 500 */
font-size: 1.2em;
white-space: nowrap;
/* 移除了 cursor: pointer 和 display: inline-block */
/* 移除了所有 hover 效果 */
}

/* --- 【V5.0】進度條 --- */
.rwd-table-progress-bar {
width: 100%;
height: 20px;
background-color: #e9ecef;
border-radius: 4px;
position: relative;
overflow: hidden;
}
.progress-bar-fill {
height: 100%;
width: var(--rwd-progress, 0%);
background-color: #0d6efd; /* Bootstrap 藍 */
transition: width 0.4s ease;
}
.progress-bar-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 12px;
color: #fff;
text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
font-weight: 500;
}

.custom-rwd-table col.rwd-table-col {
width: var(--rwd-col-width, auto);
}

.custom-rwd-table-wrapper .custom-rwd-table th[data-rwd-style-owner="cell"],
.custom-rwd-table-wrapper .custom-rwd-table td[data-rwd-style-owner="cell"] {
text-align: var(--rwd-cell-text-align, var(--text-align, left));
vertical-align: var(--rwd-cell-vertical-align, middle);
}

.custom-rwd-table-wrapper .custom-rwd-table th[data-rwd-style-owner="cell"][style*="--rwd-cell-bg-color"],
.custom-rwd-table-wrapper .custom-rwd-table td[data-rwd-style-owner="cell"][style*="--rwd-cell-bg-color"] {
background-color: var(--rwd-cell-bg-color);
}

.custom-rwd-table-wrapper .custom-rwd-table th[data-rwd-style-owner="cell"][style*="--rwd-cell-text-color"],
.custom-rwd-table-wrapper .custom-rwd-table td[data-rwd-style-owner="cell"][style*="--rwd-cell-text-color"] {
color: var(--rwd-cell-text-color);
}

.rwd-table-print-page {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
margin: 20px;
background: #fff;
color: #111827;
}

.rwd-table-print-page .custom-rwd-table-wrapper {
overflow: visible !important;
max-height: none !important;
box-shadow: none !important;
}

.rwd-table-print-page .custom-rwd-table {
width: 100%;
margin: 20px 0;
}

/* 分頁 */
.custom-rwd-table-pagination {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 1rem 0;
}
.pagination-button {
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.8rem;
    border: 1px solid var(--border-color, #e5e7eb);
    background: #fff;
    cursor: pointer;
    border-radius: 8px;
    color: #4b5563;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.pagination-button:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.pagination-button.is-active {
    background: var(--header-bg-color, #007cba);
    border-color: var(--header-bg-color, #007cba);
    color: var(--header-text-color, #fff);
    box-shadow: 0 4px 10px rgba(0, 124, 186, 0.25);
}
.pagination-button.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f3f4f6;
}
.pagination-button.is-active,
.pagination-button:hover {
background: var(--header-bg-color, #f3f4f6);
border-color: var(--header-border-color, var(--border-color, #e5e7eb));
color: var(--header-text-color, #111827);
}

/* 比較欄位 & 滑鼠懸停高亮 */
.custom-rwd-table th.is-highlighted,
.custom-rwd-table td.is-highlighted {
background-color: var(--highlighted-col-bg-color, #fefce8);
}
/* 此規則現在針對儲存格，以正確覆蓋欄位高亮和斑馬紋 */
.custom-rwd-table.has-hover-highlight .rwd-tbody tr:hover td {
background-color: var(--row-hover-bg-color, rgba(229, 231, 235, 0.6));
transition: background-color 0.2s ease-in-out;
}

/* 進階過濾器 (基礎樣式) */
.custom-rwd-table-advanced-filters {
display: flex;
gap: 1rem;
margin-bottom: 1rem;
flex-wrap: wrap;
align-items: flex-end;
}
.filter-group {
display: flex;
flex-direction: column;
}
.filter-group label {
font-size: 0.8em;
margin-bottom: 0.25rem;
color: #555;
font-weight: 500;
}

.filter-group select,
.filter-group input,
.filter-group .components-checkbox-control__input { /* 新增 */
padding: 0.5em;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 0.9em;
}
/* 數字範圍篩選器 */
.filter-group.number-range-filter {
display: flex;
align-items: center;
gap: 0.5em;
}
.filter-group.number-range-filter input {
width: 80px;
}
/* 複選框篩選器 */
.filter-group.checkbox-filter {
max-height: 150px;
overflow-y: auto;
border: 1px solid #ddd;
padding: 0.5em;
background: #fff;
border-radius: 4px;
}
.filter-group.checkbox-filter .components-checkbox-control {
display: block; /* 讓每個選項佔一行 */
margin-bottom: 0.25em;
}


/* ============================================= */
/*   【V5.4 PDF 匯出按鈕樣式】   */
/* ============================================= */

.custom-rwd-table-controls-bar {
display: flex;
justify-content: space-between; /* 讓篩選器靠左，匯出按鈕靠右 */
align-items: center;
flex-wrap: wrap; /* 在小螢幕上換行 */
gap: 1rem;
margin-bottom: 0.5rem; /* 與搜尋框保持距離 */
}

.custom-rwd-table-export-btn {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.4em 0.8em;
font-size: 0.875em;
font-weight: 500;
color: #374151;
background-color: #fff;
border: 1px solid #d1d5db;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.2s ease, box-shadow 0.2s ease;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.custom-rwd-table-export-btn:hover {
background-color: #f9fafb;
}

.custom-rwd-table-export-btn::before {
content: '';
display: inline-block;
width: 16px;
height: 16px;
background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="%23dc2626"><path fill-rule="evenodd" d="M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z" clip-rule="evenodd" /></svg>');
background-size: contain;
background-repeat: no-repeat;
} 

/* --- 【V5.0】計算列 --- */
.custom-rwd-table tfoot .calculation-row {
background-color: var(--header-bg-color, #f3f4f6);
font-weight: bold;
border-top: 2px solid var(--header-border-color, #e5e7eb);
}
.custom-rwd-table tfoot .calculation-row td {
color: var(--header-text-color, #111827);
text-align: right;
padding-right: 1.5em;
}
.custom-rwd-table tfoot .calc-label-cell {
text-align: right;
}
.custom-rwd-table tfoot .calc-result-cell {
text-align: left;
font-family: monospace; /* 讓數字對齊更好看 */
padding-left: 0.5em;
}

/* 確保 footer-row 在最底下 */
.custom-rwd-table tfoot .footer-row {
background-color: #f8f9fa;
}
.custom-rwd-table tfoot .footer-row td {
text-align: center;
font-style: italic;
font-size: 0.9em;
}

/* --- 【V5.0】多重排序徽章 --- */
.custom-rwd-table thead th[role="button"] .sort-order-badge {
position: absolute;
top: 2px;
right: 2px;
background-color: var(--header-text-color, #111827);
color: var(--header-bg-color, #f3f4f6);
font-size: 10px;
font-weight: bold;
width: 16px;
height: 16px;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
line-height: 1;
}

/* ---【功能】前端圖片樣式 --- */
.rwd-table-image {
max-width: 120px; /* 限制圖片最大寬度 */
height: auto;
display: block;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
margin: 0 auto; /* 預設居中顯示 */
}

/* --- 【V5.1】第一欄作為列標頭 --- */
.rwd-row-header-cell {
    background-color: var(--header-bg-color, #f3f4f6);
    color: var(--header-text-color, #111827);
    font-weight: 600;
    white-space: nowrap;
}

/* --- 【V5.1】隱藏欄位標頭 --- */
.rwd-thead-hidden {
    /* 使用 clip 方式隱藏，保留 accessibility 和 data-label 功能 */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- 【V5.1】行號欄位 --- */
.rwd-row-number-header,
.rwd-row-number {
    width: 40px;
    min-width: 40px !important;
    max-width: 60px;
    text-align: center;
    color: #9ca3af;
    font-size: 0.85em;
    user-select: none;
}
.rwd-row-number-header {
    color: var(--header-text-color, #111827);
}
/* 在堆疊/卡片/清單模式下隱藏行號 */
.custom-rwd-table-wrapper[class*="is-stack-"] .rwd-row-number,
.custom-rwd-table-wrapper[class*="is-cards-"] .rwd-row-number,
.custom-rwd-table-wrapper[class*="is-list-"] .rwd-row-number {
    display: none;
}

/* ========================================
   Class-Based Dark Mode Support
   ======================================== */

body.fc-dark-mode .custom-rwd-table-wrapper .custom-rwd-table,
body.hd-dark-mode .custom-rwd-table-wrapper .custom-rwd-table,
body.dark-mode .custom-rwd-table-wrapper .custom-rwd-table {
--header-bg-color: #2d2d2d;
--header-text-color: #e8e6e3;
--border-color: #404040;
--odd-row-bg-color: #1a1a1a;
--even-row-bg-color: #252525;
--row-hover-bg-color: rgba(255, 255, 255, 0.05);
}

body.fc-dark-mode .custom-rwd-table-search-wrapper,
body.hd-dark-mode .custom-rwd-table-search-wrapper,
body.dark-mode .custom-rwd-table-search-wrapper {
background-color: #2d2d2d;
border-color: #404040;
}

body.fc-dark-mode .custom-rwd-table-search-input,
body.fc-dark-mode .custom-rwd-table-column-filter,
body.hd-dark-mode .custom-rwd-table-search-input,
body.hd-dark-mode .custom-rwd-table-column-filter,
body.dark-mode .custom-rwd-table-search-input,
body.dark-mode .custom-rwd-table-column-filter {
color: #e8e6e3;
}

body.fc-dark-mode .custom-rwd-table-search-input::placeholder,
body.hd-dark-mode .custom-rwd-table-search-input::placeholder,
body.dark-mode .custom-rwd-table-search-input::placeholder {
color: #808080;
}

body.fc-dark-mode .custom-rwd-table-wrapper[class*="is-cards-"] tr,
body.fc-dark-mode .custom-rwd-table-wrapper[class*="is-stack-"] tr,
body.fc-dark-mode .custom-rwd-table-wrapper[class*="is-list-"] tr,
body.hd-dark-mode .custom-rwd-table-wrapper[class*="is-cards-"] tr,
body.hd-dark-mode .custom-rwd-table-wrapper[class*="is-stack-"] tr,
body.hd-dark-mode .custom-rwd-table-wrapper[class*="is-list-"] tr,
body.dark-mode .custom-rwd-table-wrapper[class*="is-cards-"] tr,
body.dark-mode .custom-rwd-table-wrapper[class*="is-stack-"] tr,
body.dark-mode .custom-rwd-table-wrapper[class*="is-list-"] tr {
background: #1a1a1a;
border-color: #404040;
}

body.fc-dark-mode .custom-rwd-table-wrapper[class*="is-stack-"] td,
body.fc-dark-mode .custom-rwd-table-wrapper[class*="is-cards-"] td,
body.hd-dark-mode .custom-rwd-table-wrapper[class*="is-stack-"] td,
body.hd-dark-mode .custom-rwd-table-wrapper[class*="is-cards-"] td,
body.dark-mode .custom-rwd-table-wrapper[class*="is-stack-"] td,
body.dark-mode .custom-rwd-table-wrapper[class*="is-cards-"] td {
border-color: #404040;
color: #e8e6e3;
}

body.fc-dark-mode .pagination-button,
body.hd-dark-mode .pagination-button,
body.dark-mode .pagination-button {
background: #2d2d2d;
border-color: #404040;
color: #e8e6e3;
}

body.fc-dark-mode .pagination-button.is-active,
body.fc-dark-mode .pagination-button:hover,
body.hd-dark-mode .pagination-button.is-active,
body.hd-dark-mode .pagination-button:hover,
body.dark-mode .pagination-button.is-active,
body.dark-mode .pagination-button:hover {
background: #404040;
}

body.fc-dark-mode .custom-rwd-table-chart-container,
body.hd-dark-mode .custom-rwd-table-chart-container,
body.dark-mode .custom-rwd-table-chart-container {
background: #1a1a1a;
border-color: #404040;
}

body.fc-dark-mode .search-highlight,
body.hd-dark-mode .search-highlight,
body.dark-mode .search-highlight {
background-color: #854d0e;
color: #fef08a;
}

body.fc-dark-mode .custom-rwd-table-export-btn,
body.hd-dark-mode .custom-rwd-table-export-btn,
body.dark-mode .custom-rwd-table-export-btn {
background-color: #2d2d2d;
border-color: #404040;
color: #e8e6e3;
}

body.fc-dark-mode .rwd-table-button,
body.hd-dark-mode .rwd-table-button,
body.dark-mode .rwd-table-button {
background-color: #404040;
color: #e8e6e3;
border-color: #555;
}
