/* static/css/style.css */
body { font-family: Arial, sans-serif; margin: 20px; background-color: #0098F0; }
.container { max-width: 80%; margin: 0 auto; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
h2, h3, h4 { color: #333; border-bottom: 2px solid #eee; padding-bottom: 5px; margin-top: 0px;}

/* 輸入與檔案操作 */
input[type="file"] { margin-right: 10px; }
.file-pair { display: flex; align-items: center; margin-bottom: 10px; }
.file-pair label { min-width: 60px; }
.file-pair input { margin-right: 10px; }
.remove-pair-btn { background-color: #ffcccc; border: 1px solid #ff0000; cursor: pointer; }

/* Tab 分頁 */
.tab-nav { border-bottom: 2px solid #ddd; margin-bottom: 15px; }
.tab-btn { border: none; background-color: transparent; cursor: pointer; font-size: 16px;  color: #555; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-btn:hover { background-color: #f4f4f9; }
.tab-btn.active { background-color: #fff; border-color: #007bff;  color: #007bff; border-bottom: 2px solid #007bff; font-weight: bold;}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Viewer 區域 */
pre { white-space: pre-wrap; background-color: #f5f5f5; padding: 15px; margin: 0; font-family: monospace; max-height: 500px; overflow-y: auto; border-radius: 8px; }
.viewer-container { border: 1px solid #ddd; border-radius: 8px; margin-top: 15px; }
.viewer-controls { padding: 15px; background-color: #fcfcfc; border-bottom: 1px solid #ddd; }
.viewer-controls > div { margin-bottom: 12px; }
.viewer-overview { font-size: 1.1em; font-weight: bold;  display: flex; align-items: center; gap: 10px; font-size: 14px; color: #666;}
.viewer-overview span { font-weight: bold; background-color: #e9ecef; padding: 2px 8px; border-radius: 12px; font-family: monospace; font-size: 0.9em; color: #333; display: inline-block; border: 1px solid #dee2e6;}
.viewer-search input { width: 300px; padding: 8px; font-size: 14px; border: 1px solid #ddd; border-radius: 4px; }
.viewer-pagination { display: flex; align-items: center; }
.viewer-pagination .page-input { width: 70px; text-align: center; margin: 0 10px; padding: 8px; font-size: 14px; border: 1px solid #ddd; border-radius: 4px; }
.viewer-entry-info { background-color: #eee; padding: 10px 15px; font-family: monospace; font-size: 0.9em; overflow-x: auto; white-space: nowrap; }
.viewer-entry-info span { margin-right: 15px; }
.viewer-content { border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }
.op-outcome-filters button { background-color: #f0f0f0; color: #333; border: 1px solid #ccc; }
.op-outcome-filters button.active { background-color: #007bff; color: white; border-color: #007bff; }

/* 讓 span (變數內容) 變成像標籤一樣 */
.viewer-overview span {
    display: inline-block;
    border: 1px solid #dee2e6;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px;
    background-color: #fafafa;
    border: 2px dashed #ddd;
    border-radius: 8px;
}

/* 按鈕樣式與顏色 */
button { padding: 8px 12px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; margin: 0 5px 5px 0; }
button:hover { background-color: #0056b3; }
button:disabled { background-color: #ccc; cursor: not-allowed; }
.search-btn{ margin-left: 10px; }

.btn-blue { background-color: #1855BE; }
.btn-blue:hover { background-color: #7499D8; }
.btn-blue2 { background-color: #07B5D3; }
.btn-blue2:hover { background-color: #6Ad2E5; }
.btn-green { background-color: #28a745; } 
.btn-green:hover { background-color: #218838; }
.btn-gray { background-color: #6c757d; }
.btn-gray:hover { background-color: #5a6268; }
.btn-red { background-color: #dc3545; }
.btn-red:hover { background-color: #c82333; }

#downloadButton { background-color: #17a2b8; }
#downloadButton:hover { background-color: #138496; }
#uploadToServerButton { background-color: #28a745; }
#uploadToServerButton:hover { background-color: #218838; }

/* 批次上傳列表樣式 */
#file-list-container { margin-top: 10px; border: 1px solid #ddd; border-radius: 4px; padding: 10px; min-height: 100px; background-color: #fafafa; max-height: 300px; overflow-y: auto; }
.file-item { display: flex; justify-content: space-between; align-items: center; padding: 5px 8px; border-bottom: 1px solid #eee; background-color: #fff; }
.file-item:last-child { border-bottom: none; }
.file-item:hover { background-color: #f0f8ff; }
.file-name { font-family: monospace; font-size: 14px; }
.file-pair {
    background-color: #f9f9f9; /* 極淺的灰色 */
    padding: 10px;             /* 增加內距 */
    border-radius: 6px;        /* 圓角 */
    border: 1px solid #eee;    /* 微弱邊框 */
    margin-bottom: 12px;       /* 增加組與組的距離 */
}

/* 隱藏原生 input */
#batch-file-input, #batch-folder-input { display: none; }

/* Header & Logo 佈局 */
.header-container { display: flex; justify-content: space-between; align-items: center; width: 82%; margin: 0 auto; padding-bottom: 10px; }
/* 修正置中問題：加入 display: flex 和 line-height */
.header-left { display: flex; align-items: center; gap: 20px; height: 100%; }
.header-logo-img { height: 50px; width: auto; object-fit: contain; display: block; margin-left: 20px;}
.fhir-tool-logo { color: white; font-size: 2em; display: flex; align-items: center; line-height: 1; }
.fhir-text { font-family: Arial, sans-serif; padding: 5px 10px; display: inline-flex; font-weight: 900; background-color: #1855BE; border-radius: 5px; letter-spacing: -2px; }
.tool-text { font-weight: 400; margin-left: 10px; }
.version-info { color: white; font-size: 1em; font-family: Arial, sans-serif; font-weight: normal; }
.fhir-r { background-color: white; color: #007bff; padding: 0 4px; border-radius: 4px; margin-left: -5px; display: inline-block; transform: skewX(-5deg); line-height: 1; }
.fhir-r > span { display: inline-block; transform: skewX(5deg); }

/* --- [修改] 檔案上傳按鈕美化 --- */

/* 1. 隱藏真正的原生 input 按鈕 */
.hidden-input {
    display: none !important; /* 強制隱藏，避免跑出原本醜醜的按鈕 */
}

/* 2. 讓 Label 偽裝成按鈕 (繼承 button 的物理屬性) */
.custom-file-label {
    /* 這裡複製了 button 的所有關鍵樣式，讓它看起來跟 button 一模一樣 */
    display: inline-block;
    padding: 8px 12px;       /* 與 button 相同的內距 (決定大小) */
    border-radius: 4px;      /* 與 button 相同的圓角 */
    font-size: 14px;         /* 與 button 相同的字體 */
    color: white;            /* 文字顏色 */
    border: none;            /* 無邊框 */
    cursor: pointer;         /* 滑鼠游標變成手型 */
    margin: 0 10px 5px 0;    /* 你的間距設定 */
    vertical-align: middle;  /* 垂直置中 */
    text-align: center;      /* 文字置中 */
    line-height: normal;     /* 重置行高，避免文字偏上或偏下 */
    box-sizing: border-box;  /* 確保 padding 不會撐爆寬度 */
}

/* 3. 檔名顯示區塊 (保持不變) */
.file-name-display {
    display: inline-block;
    color: #555;
    font-size: 14px;
    margin-right: 15px;
    vertical-align: middle;
    font-family: monospace;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- 新增：Report Viewer 樣式 --- */
.report-summary { padding: 10px; background-color: #e9ecef; border-radius: 4px; margin-bottom: 15px; font-weight: bold; }
.report-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 14px; }
.report-table th, .report-table td { border: 1px solid #ddd; padding: 8px; text-align: left; }
.report-table th { background-color: #f2f2f2; color: #333; }
.report-table tr:hover { background-color: #f9f9f9; }

/* 狀態顏色 */
.status-success { color: #28a745; font-weight: bold; }
.status-failed { color: #dc3545; font-weight: bold; }
.status-partial { color: #ffc107; font-weight: bold; }

/* 錯誤詳情區塊 */
.error-details-box { display: none; background-color: #fff0f0; border-left: 4px solid #dc3545; padding: 10px; margin-top: 5px; font-family: monospace; font-size: 13px; }
.toggle-error-btn { background-color: #6c757d; padding: 2px 6px; font-size: 12px; margin-left: 5px; }

/* --- 錯誤/訊息詳情卡片設計 --- */
.issue-card {
    border: 1px solid #e0e0e0;
    border-left: 5px solid #ccc; /* 預設顏色，JS 會覆蓋 */
    background-color: #fff;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* 左側邊框顏色定義 */
.issue-card.severity-error { border-left-color: #dc3545; }
.issue-card.severity-warning { border-left-color: #ffc107; }
.issue-card.severity-info { border-left-color: #17a2b8; }

/* 標頭：顯示 Row 和 Resource ID */
.issue-header {
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
}

.issue-row-badge {
    background-color: #343a40;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    margin-right: 10px;
}

.issue-resource-id {
    font-family: monospace;
    color: #666;
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
}

/* 內容區：Field, Message, Original Value */
.issue-body {
    padding: 10px 12px;
    font-size: 14px;
}

.issue-field-row {
    margin-bottom: 6px;
}

.issue-field-badge {
    font-family: monospace;
    font-weight: bold;
    color: #0056b3;
    background-color: #e7f1ff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.95em;
}

.issue-message {
    color: #333;
    line-height: 1.5;
    margin-bottom: 8px;
}

.issue-original-value {
    background-color: #f1f1f1;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    font-family: monospace;
    font-size: 12px;
    color: #555;
    white-space: pre-wrap; /* 自動換行 */
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
}

.issue-label {
    font-weight: bold;
    color: #888;
    font-size: 12px;
    margin-bottom: 2px;
    display: block;
}

/* --- 驗證報告迷你控制列 --- */
.issue-toolbar { display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; padding: 10px; border-radius: 6px; margin-bottom: 15px; border: 1px solid #ddd; }
.issue-filters button { margin-right: 8px; border-radius: 20px; padding: 4px 12px; font-size: 13px; font-weight: bold; border: 1px solid transparent; cursor: pointer; transition: 0.2s; }
.issue-filters .filter-err.active { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.issue-filters .filter-warn.active { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.issue-filters .filter-info.active { background: #e0e7ff; color: #4338ca; border-color: #a5b4fc; }
.issue-filters button:not(.active) { background: #fff; color: #6b7280; border-color: #d1d5db; }
.issue-modes button { font-size: 13px; padding: 4px 10px; margin-left: 5px; cursor: pointer; background: #fff; border: 1px solid #ccc; border-radius: 4px; }
.issue-modes button.active { background: #0d6efd; color: white; border-color: #0d6efd; }

/* --- 復刻你截圖的 Issue 卡片設計 --- */
.issue-card-v2 { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; margin-bottom: 12px; position: relative; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.issue-card-v2::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.issue-card-v2.severity-error::before { background-color: #dc3545; }
.issue-card-v2.severity-warning::before { background-color: #ffc107; }
.issue-card-v2.severity-info::before { background-color: #0dcaf0; }

.issue-card-header { display: flex; justify-content: space-between; background: #f9fafb; padding: 8px 12px 8px 16px; border-bottom: 1px solid #e5e7eb; align-items: center; }
.badge-row { background: #374151; color: white; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: bold; margin-right: 8px; }
.badge-resource { background: #f3f4f6; color: #4b5563; padding: 2px 8px; border-radius: 4px; font-size: 12px; border: 1px solid #d1d5db; }
.badge-severity { font-size: 12px; font-weight: bold; letter-spacing: 0.5px; }
.severity-error .badge-severity { color: #dc3545; }
.severity-warning .badge-severity { color: #b45309; }
.severity-info .badge-severity { color: #0dcaf0; }

.issue-card-body { padding: 12px 16px; }
.issue-field-name { background: #e0f2fe; color: #0369a1; display: inline-block; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; font-weight: bold; margin-bottom: 8px; }
.issue-message { font-size: 14px; color: #1f2937; margin-bottom: 10px; }
.issue-original-box { background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 4px; padding: 8px; font-family: monospace; font-size: 12px; color: #4b5563; white-space: pre-wrap; overflow-x: auto; max-height: 150px; }
.issue-original-label { font-size: 12px; color: #6b7280; margin-bottom: 4px; }

/* 欄位聚合視圖的折疊清單 */
.group-header { background: #f1f5f9; padding: 10px; border: 1px solid #cbd5e1; border-radius: 4px; font-weight: bold; cursor: pointer; margin-bottom: 5px; display: flex; justify-content: space-between;}
.group-body { display: none; padding: 10px; border: 1px solid #cbd5e1; border-top: none; border-radius: 0 0 4px 4px; margin-top: -5px; margin-bottom: 15px; }


/* --- 模式按鈕樣式 --- */
.issue-modes button { font-size: 13px; padding: 4px 10px; margin-left: 5px; cursor: pointer; background: #fff; border: 1px solid #ccc; border-radius: 4px; color: #333; font-weight: 500; transition: 0.2s; }
.issue-modes button.active { background: #0d6efd; color: white; border-color: #0d6efd; }

/* --- Code 篩選標籤樣式 --- */
.code-filters-container { background: #fff; padding: 10px; border: 1px solid #ddd; border-top: none; border-radius: 0 0 6px 6px; margin-top: -15px; margin-bottom: 15px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.code-filters-label { font-size: 12px; color: #666; font-weight: bold; margin-right: 5px; }
.code-tag { padding: 3px 10px; border-radius: 12px; font-size: 12px; background: #f3f4f6; color: #4b5563; cursor: pointer; border: 1px solid #d1d5db; transition: 0.2s; }
.code-tag:hover { background: #e5e7eb; }
.code-tag.active { background: #0dcaf0; color: #fff; border-color: #0bacce; font-weight: bold; }

/* --- CSV Row 收合與分頁樣式 --- */
.row-group-header { background: #f8f9fa; padding: 10px 15px; border: 1px solid #dee2e6; border-radius: 4px; font-weight: bold; cursor: pointer; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; color: #374151; transition: background 0.2s; }
.row-group-header:hover { background: #e9ecef; }
.row-group-body { padding: 10px; border: 1px solid #dee2e6; border-top: none; border-radius: 0 0 4px 4px; margin-top: -5px; margin-bottom: 15px; background: #fff; }
.row-pagination { display: flex; align-items: center; justify-content: center; gap: 15px; background: #f1f5f9; padding: 8px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; font-weight: bold; color: #4b5563; }
.row-pagination button { padding: 2px 10px; font-size: 12px; cursor: pointer; background: #fff; border: 1px solid #ccc; border-radius: 4px; color: #333; }
.row-pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- 原始值收合樣式 --- */
.issue-original-details summary { cursor: pointer; font-size: 13px; color: #0d6efd; font-weight: bold; margin-bottom: 5px; outline: none; user-select: none; }
.issue-original-details summary:hover { color: #0a58ca; text-decoration: underline; }

/* --- CSV Row 與 欄位聚合 共用收合樣式 --- */
.foldable-header { background: #f8f9fa; padding: 10px 15px; border: 1px solid #dee2e6; border-radius: 4px; font-weight: bold; cursor: pointer; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; color: #374151; transition: background 0.2s; }
.foldable-header:hover { background: #e9ecef; }
.foldable-body { padding: 15px 10px 5px 10px; border: 1px solid #dee2e6; border-top: none; border-radius: 0 0 4px 4px; margin-top: -5px; margin-bottom: 15px; background: #fff; display: none; } /* 預設隱藏 */

/* --- 原始值專屬收合樣式 --- */
.orig-val-header { cursor: pointer; font-size: 13px; color: #0d6efd; font-weight: bold; margin-bottom: 5px; user-select: none; display: inline-block; }
.orig-val-header:hover { text-decoration: underline; color: #0a58ca; }
.orig-val-body { display: none; margin-top: 5px; } /* 預設隱藏 */


/* 膠囊風格導覽列 */
.main-nav-capsule {
    width: 80%;
    display: flex;
    align-items: center;
    margin: 0 auto;
    gap: 10px;
    padding: 12px 20px;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    margin-bottom: 20px;
}

.main-nav-capsule .nav-item {
    text-decoration: none;
    color: #4b5563; /* 深灰色 */
    font-weight: 500;
    font-size: 15px;
    padding: 8px 16px;
    border-radius: 20px; /* 膠囊圓角 */
    transition: all 0.2s ease-in-out;
}

.main-nav-capsule .nav-item:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

/* 當前所在頁面的標示 */
.main-nav-capsule .nav-item.active {
    background-color: #e0f2fe; /* 淺藍色背景 */
    color: #0369a1;            /* 深藍色文字 */
    font-weight: bold;
}


/* 新增：狀態橫幅的簡單樣式 */
.status-banner { display: none; padding: 15px; margin: 15px 0; border-radius: 4px; font-family: monospace; white-space: pre-wrap; font-size: 15px; border: 1px solid #ccc; }
.status-success { background-color: #e6ffe6; color: #006600; border-color: #b3ffb3; }
.status-error { background-color: #ffe6e6; color: #cc0000; border-color: #ffb3b3; }
/* 新增：OAuth設定區塊展開樣式 */
.config-details { margin: 20px 0; padding: 15px; border: 1px solid #ddd; background-color: #fafafa; border-radius: 4px; }
.config-details summary { font-weight: bold; cursor: pointer; color: #333; outline: none; }
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 15px; }
.config-grid input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 3px; box-sizing: border-box;}


/* 新增：參數設定面板樣式 */
.param-panel { margin: 20px 0; padding: 15px; border: 1px solid #bee5eb; background-color: #e2e3e5; border-radius: 4px; }
.param-panel label { cursor: pointer; margin-right: 15px; display: inline-block; margin-bottom: 8px; }
.param-panel select { padding: 5px; border-radius: 3px; border: 1px solid #ccc; }