/* ==========================================================================
    第一頁：結果總表分頁樣式 (#resultTablePage)
   ========================================================================== */
#resultTablePage {
    position: relative;
    width: 100%;
    height: 100vh;
    padding: 0;
    box-sizing: border-box;
    background-color: #f8f9fa;
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- 頂部操作工具列 --- */
.result-header {
    flex-shrink: 0;
    width: calc(100% - 80px);
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px 8px 0 0;
    box-sizing: border-box;
    position: relative;
    z-index: 1200;
}

.result-header h2 {
    margin: 0;
    font-size: 20px;
    color: #3c4043;
    font-weight: 500;
}

.result-actions {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

/* --- 表格內容區塊 --- */
#resultTableContent {
    flex-grow: 1;
    width: calc(100% - 80px);
    margin: 0 auto 20px auto;
    padding: 0;
    box-sizing: border-box;
    overflow: auto;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
}

#resultTableContent .data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: #ffffff;
    box-sizing: border-box;
}

/* --- 表頭樣式與排序符號 --- */
#resultTableContent .data-table th {
    background-color: #ffffff;
    color: #5f6368;
    font-size: 13px;
    font-weight: 600;
    padding: 16px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    border-right: 1px solid #f1f3f4;
    position: sticky;
    top: 0;
    z-index: 1100;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

#resultTableContent .data-table th::after {
    content: '⏷';
    margin-left: 8px;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

#resultTableContent .data-table th:hover::after {
    opacity: 0.5;
}

#resultTableContent .data-table th.sort-asc,
#resultTableContent .data-table th.sort-desc {
    color: #1a73e8;
}

#resultTableContent .data-table th.sort-asc::after {
    content: '▲';
    opacity: 1;
}

#resultTableContent .data-table th.sort-desc::after {
    content: '▼';
    opacity: 1;
}

/* 第一欄固定樣式 */
#resultTableContent .data-table th:first-child {
    position: sticky;
    left: 0;
    top: 0;
    z-index: 1150;
    background-color: #ffffff;
    border-right: 2px solid #e0e0e0;
}

#resultTableContent .data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 900;
    background-color: #ffffff;
    border-right: 2px solid #e0e0e0;
    text-align: center;
}

/* --- 資料列效果 --- */
#resultTableContent .data-table td {
    padding: 12px;
    font-size: 14px;
    color: #3c4043;
    border-bottom: 1px solid #f1f3f4;
    border-right: 1px solid #f8f9fa;
    white-space: nowrap;
}

#resultTableContent .data-table tr:nth-child(even) td {
    background-color: #fcfcfc;
}

#resultTableContent .data-table tr:hover td {
    background-color: #f1f3f4;
}

#resultTableContent .data-table td.cell-highlight {
    background-color: #fff9c4 !important;
    transition: background-color 0.3s;
}

/* 最後一欄寬度處理 */
#resultTableContent .data-table td:last-child,
#resultTableContent .data-table th:last-child {
    white-space: normal;
    min-width: 250px;
    border-right: none;
}

/* --- 搜尋與分頁控制項 --- */
.search-box {
    margin-left: auto;
    margin-right: 20px;
}

.search-box input {
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    width: 200px;
    outline: none;
}

.highlight {
    background-color: #fff2ac;
    color: #000000;
    padding: 2px 1px;
    border-radius: 2px;
    font-weight: bold;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    color: #5f6368;
    white-space: nowrap;
}

.pagination-controls select {
    padding: 4px 8px;
    border: 1px solid #dadce0;
    border-radius: 4px;
}

.pagination-controls input[type="number"] {
    padding: 2px 0;
    border: none;
    border-bottom: 1.5px solid #000000;
    width: 35px;
    text-align: center;
    outline: none;
    background: transparent;
}

.page-nav-btn {
    background: none;
    border: none;
    color: #5f6368;
    font-size: 18px;
    cursor: pointer;
    padding: 5px 10px;
    display: flex;
    align-items: center;
}

.page-nav-btn:hover:not(:disabled) {
    color: #1a73e8;
}

.page-nav-btn:disabled {
    color: #bdc1c6 !important;
    cursor: not-allowed;
}


/* ==========================================================================
    第二頁：信度分析報告樣式 (#reliabilityResultPage) - 響應式對齊修正版
   ========================================================================== */

#reliabilityResultPage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    padding: 40px;
    box-sizing: border-box;
    background-color: #f4f7f6;
    z-index: 3000;
    display: none;
    flex-direction: column;
    overflow-y: auto;
}

#reliabilityResultContent {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding-bottom: 50px;
}

/* --- 🎯 頂部雙排框架：預設雙排佈局 --- */
.reliability-top-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 25px;
    width: 100%;
    align-items: stretch !important;
    margin-bottom: 25px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

/* 左側群組 */
.left-column-group {
    display: flex;
    flex-direction: column;
    gap: 25px;
    grid-column: 1;
    height: 100%;
}

/* 🎯 項目統計量：右側 */
.card-item-stats {
    grid-column: 2 !important;
    width: 100% !important;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* 🎯 尺度統計量位移 */
.card-scale-summary.move-to-right {
    grid-column: 2 !important;
    grid-row: 1 !important;
    height: 100%;
}

/* --- 📱 手機與窄螢幕修正 (RWD) --- */
@media (max-width: 992px) {
    #reliabilityResultPage {
        padding: 20px;
        /* 縮小邊距 */
    }

    .reliability-top-grid {
        grid-template-columns: 1fr !important;
        /* 強制改為單排 */
        gap: 20px;
    }

    .left-column-group,
    .card-item-stats,
    .card-scale-summary.move-to-right {
        grid-column: 1 !important;
        /* 全部回到第一欄 */
        grid-row: auto !important;
        /* 照順序堆疊 */
        height: auto;
    }

    .reliability-header h2 {
        font-size: 20px;
        /* 縮小標題 */
    }

    .analysis-card {
        padding: 20px;
        /* 縮小卡片內距 */
    }
}

/* --- 🎯 卡片基礎樣式 --- */
.analysis-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 30px;
    box-sizing: border-box;
    opacity: 0;
    animation: slideUpFade 0.8s ease-out forwards;
    flex: none !important;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: visible;
    position: relative;
    margin-bottom: 10px;
}

/* 🎯 橫向滾輪容器 */
.table-responsive {
    flex: none !important;
    width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    margin-top: 15px;
    border: 1px solid #f1f3f4;
    border-radius: 4px;
}

/* --- 🎯 側邊欄凍結 (has-sidebar) --- */
.analysis-card .data-table.has-sidebar {
    border-collapse: separate !important;
    border-spacing: 0;
}

.analysis-card .data-table.has-sidebar th:first-child,
.analysis-card .data-table.has-sidebar td:first-child {
    position: sticky !important;
    left: 0;
    z-index: 20;
    text-align: left !important;
    font-weight: 600;
    background-color: #f8f9fa !important;
    border-right: 2px solid #e8eaed !important;
}

.analysis-card .data-table.has-sidebar td:first-child {
    background-color: #ffffff !important;
}

/* --- 🎯 平均欄寬表格 (equal-layout) --- */
.analysis-card .data-table.equal-layout {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
}

.analysis-card .data-table.equal-layout th,
.analysis-card .data-table.equal-layout td {
    position: static !important;
    width: auto !important;
    border: 1px solid #e0e0e0 !important;
    text-align: center !important;
    padding: 12px;
    background-color: #f8f9fa !important;
    white-space: normal;
    word-break: break-all;
}

.analysis-card .data-table.equal-layout td {
    background-color: #ffffff !important;
}

/* --- 🎯 通用表格基礎樣式 --- */
.analysis-card .data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    table-layout: auto;
}

.analysis-card .data-table th {
    background-color: #f8f9fa !important;
    color: #5f6368;
    padding: 12px;
    text-align: center;
    border: 1px solid #f1f3f4;
    border-bottom: 2px solid #e8eaed;
    font-size: 13px;
    white-space: nowrap;
}

.analysis-card .data-table td {
    padding: 12px;
    border: 1px solid #f1f3f4;
    color: #3c4043;
    font-size: 14px;
    text-align: center;
    background-color: #ffffff;
}

/* --- 🎯 其他組件 --- */
.reliability-header {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto 20px auto;
    flex-shrink: 0;
}

.card-header-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.card-title-bar {
    width: 8px;
    height: 24px;
    background: #1a73e8;
    border-radius: 4px;
}

.card-title-text {
    margin: 0;
    color: #333;
    font-size: 20px;
    font-weight: bold;
}

@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(40px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
    視窗：分析彈窗樣式 (基礎共用)
   ========================================================================== */
.analysis-btn {
    background-color: #ffffff;
    color: #1a73e8;
    border: 1px solid #dadce0;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.analysis-btn:hover {
    background-color: #f1f6fe;
    border-color: #1a73e8;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3);
}

.analysis-btn.cancel-btn {
    color: #5f6368;
    border-color: #dadce0;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fff;
    margin: 3% auto 50px auto;
    padding: 0;
    border-radius: 8px;
    width: 520px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.25);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 85vh;
    max-height: 85vh;
    overflow: hidden;
    transition: width 0.3s ease, height 0.3s ease;
}

/* 信度與效度視窗通用的步驟寬度控制 */
.modal-content.is-step-1 {
    width: 450px;
    margin-top: 10vh;
    height: 80vh;
}

.modal-content.is-step-2 {
    width: 500px;
    margin-top: 8vh;
    height: 77vh;
}

.modal-header {
    flex-shrink: 0;
    padding: 25px 20px 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================================================
    信度分析專屬樣式 (#analysisModal)
   ========================================================================== */
#modalTitle {
    margin: 0;
    font-size: 18px;
    color: #202124;
}

/* ==========================================================================
    效度分析專屬樣式 (#validityModal)
   ========================================================================== */
#validityModalTitle {
    margin: 0;
    font-size: 18px;
    color: #202124;
    /* 你可以根據需要更改顏色，例如改為綠色系區分 */
}

/* 效度分析專用的變數格線樣式 (若需要與信度不同可在此修改) */
#validityVariableList.variable-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 5px 0;
}

/* ==========================================================================
    內部組件樣式 (通用於所有 Modal Body)
   ========================================================================== */
.close-btn {
    color: #5f6368;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}

.close-btn:hover {
    color: #d93025;
}

.modal-body {
    flex-grow: 1;
    padding: 0 20px 20px 20px;
    overflow-y: auto;
}

.modal-body p {
    margin-bottom: 10px;
    font-size: 13px;
    color: #70757a;
}

.variable-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 5px 0;
}

.variable-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.variable-item label {
    cursor: pointer;
}

.variable-item.hidden {
    display: none !important;
}

.select-all-wrapper {
    padding: 8px 0;
    margin-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.select-all-wrapper label {
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.modal-footer {
    flex-shrink: 0;
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background-color: #ffffff;
}

.modal-search-wrapper input:focus {
    border-color: #1a73e8 !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}