/* ECG SMART on FHIR App Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
header {
    background: white;
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    color: #667eea;
    font-size: 24px;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-label {
    color: #666;
    font-size: 14px;
}

.user-name {
    font-weight: bold;
    color: #333;
}

.user-type {
    background: #667eea;
    color: white;

/* 分析次數 Badge 樣式 */
.analysis-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.analysis-count-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.analysis-count-badge .count-icon {
    font-size: 18px;
}

.analysis-count-badge .count-text {
    font-size: 14px;
}

.analysis-count-badge strong {
    font-size: 16px;
    font-weight: 700;
}

/* 根據使用量改變顏色 */
.analysis-count-badge.warning {
    background: linear-gradient(135deg, #ff9800 0%, #ff5722 100%);
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.analysis-count-badge.warning:hover {
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.analysis-count-badge.danger {
    background: linear-gradient(135deg, #f44336 0%, #e91e63 100%);
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

.analysis-count-badge.danger:hover {
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
}

/* Launch Screen */
.launch-screen {
    background: white;
    padding: 60px 40px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 600px;
    margin: 100px auto;
}

.launch-screen h1 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 32px;
}

.subtitle {
    color: #666;
    font-size: 18px;
    margin-bottom: 30px;
}

.status-text {
    color: #764ba2;
    font-size: 16px;
    margin-top: 20px;
}

/* Loader */
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Manual Launch */
.manual-launch {
    margin-top: 30px;
    text-align: left;
}

.manual-launch label {
    display: block;
    margin-bottom: 10px;
    color: #333;
    font-weight: bold;
}

.manual-launch input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 15px;
}

.manual-launch input:focus {
    outline: none;
    border-color: #667eea;
}

.manual-launch button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.manual-launch button:hover {
    background: #5568d3;
}

.info-box {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    text-align: left;
}

.info-box h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.info-box ul {
    list-style: none;
    padding: 0;
}

.info-box li {
    padding: 5px 0;
    font-size: 12px;
    color: #666;
    word-break: break-all;
}

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    padding: 60px 40px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-height: 300px;
}

.loading-screen p {
    color: #666;
    font-size: 16px;
}

/* Main Content */
main {
    margin-bottom: 20px;
}

.app-content {
    display: grid;
    gap: 20px;
}

/* Card */
.card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card h2 {
    color: #667eea;
    margin-bottom: 0;
    font-size: 20px;
}

/* Card 標題容器（包含標題和徽章） */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

.card-header h2 {
    margin-bottom: 0;
}

/* Patient Details */
.patient-details {
    display: grid;
    gap: 15px;
}

.detail-row {
    display: flex;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.detail-row .label {
    font-weight: bold;
    color: #666;
    min-width: 100px;
}

.detail-row .value {
    color: #333;
}

/* Observations */
.observations-list {
    display: grid;
    gap: 15px;
}

.observation-item {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    transition: box-shadow 0.3s;
}

.observation-item:hover {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.obs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.obs-header strong {
    color: #333;
}

.obs-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.status-final {
    background: #d4edda;
    color: #155724;
}

.status-preliminary {
    background: #fff3cd;
    color: #856404;
}

.status-amended {
    background: #d1ecf1;
    color: #0c5460;
}

.obs-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.obs-value {
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
}

.obs-date {
    font-size: 14px;
    color: #666;
}

/* Diagnostic Reports */
/* .reports-list {
    display: grid;
    gap: 15px;
}

.report-item {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    transition: box-shadow 0.3s;
}

.report-item:hover {
    box-shadow: 0 2px 8px rgba(118, 75, 162, 0.2);
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.report-header strong {
    color: #333;
}

.report-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.report-body {
    display: grid;
    gap: 8px;
}

.report-date {
    font-size: 14px;
    color: #666;
}

.report-conclusion {
    font-size: 14px;
    color: #333;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
} */

/* No Data */
.no-data {
    text-align: center;
    color: #999;
    padding: 30px;
    font-style: italic;
}

/* Table Styles */
.table-summary {
    margin-bottom: 20px;
    padding: 15px;
    background: #f0f4ff;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.table-summary p {
    margin: 0;
    color: #333;
}

.table-summary strong {
    color: #667eea;
    font-size: 18px;
}

.table-summary .unanalyzed-count {
    color: #e74c3c;
    font-weight: bold;
}

.table-responsive {
    overflow-x: auto;
}

.patient-ecg-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: white;
}

.patient-ecg-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.patient-ecg-table th {
    padding: 15px 12px;
    text-align: left;
    font-weight: bold;
    font-size: 14px;
    white-space: nowrap;
}

.patient-ecg-table td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

.patient-ecg-table tbody tr:hover {
    background: #f8f9fa;
    cursor: pointer;
}

.patient-ecg-table code {
    background: #f0f0f0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #e83e8c;
}

.obs-id {
    background: #e7f3ff !important;
    color: #0056b3 !important;
    font-weight: bold;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: bold;
}

.badge-ecg {
    background: #d4edda;
    color: #155724;
}

.badge-analyzed {
    background: #d1ecf1;
    color: #155724;
}

.badge-not-analyzed {
    background: #f8d7da;
    color: #721c24;
}

.badge-error {
    background: #f8d7da;
    color: #721c24;
    font-style: italic;
}

.badge-count {
    background: #e3f2fd;
    color: #1976d2;
    font-size: 12px;
}

/* 風險評級標記 (用於表格) */
.risk-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    /* font-size: 12px; */
    font-weight: bold;
    color: white;
    cursor: help;
}

.risk-badge.risk-low {
    background: #4caf50;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.risk-badge.risk-medium {
    background: #ff9800;
    box-shadow: 0 2px 4px rgba(255, 152, 0, 0.3);
}

.risk-badge.risk-high {
    background: #f44336;
    box-shadow: 0 2px 4px rgba(244, 67, 54, 0.3);
}

.risk-badge.risk-unknown {
    background: #9e9e9e;
    box-shadow: 0 2px 4px rgba(158, 158, 158, 0.3);
}

.btn-view {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.3s;
}

.btn-view:hover {
    background: #5568d3;
}

.btn-primary {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #5568d3;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 10px;
    max-width: 1200px; /* 從 800px 增加到 1200px */
    width: 95%; /* 使用 95% 寬度 */
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px 10px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.btn-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 25px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 2px solid #f0f0f0;
    text-align: right;
}

.ecg-details-list {
    display: grid;
    gap: 15px;
    margin-top: 15px;
}

.ecg-detail-item {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    background: #f8f9fa;
}

.ecg-detail-header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.ecg-number {
    background: #667eea;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.ecg-code {
    font-weight: bold;
    color: #333;
    flex: 1;
}

.ecg-detail-body {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 兩欄布局 */
    gap: 12px 20px; /* 垂直間距 12px，水平間距 20px */
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

.ecg-detail-body strong {
    color: #333;
}

/* 讓某些項目佔滿整行（如果需要） */
.ecg-detail-body > div.full-width {
    grid-column: 1 / -1;
}

/* 分析狀態區塊樣式 */
.analysis-status-section {
    /* margin: 15px 0; */
    /* padding: 15px; */
    background: #f8f9ff;
    border-radius: 8px;
    /* border-left: 4px solid #667eea; */
    grid-column: 1 / -1; /* 佔滿整行 */
}

.analysis-status-section h4 {
    margin: 0 0 12px 0;
    color: #667eea;
    font-size: 16px;
}

/* 收合按鈕樣式 */
.toggle-analysis-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.toggle-analysis-btn:hover {
    background: #e8e8e8 !important;
    border-color: #bbb !important;
    transform: translateY(-1px);
}

.toggle-analysis-btn:active {
    transform: translateY(0);
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 0.85em;
}

.analysis-details-wrapper {
    transition: all 0.3s ease;
    overflow: hidden;
}

/* 基本資訊區塊樣式（Observation ID 和日期） */
.ecg-basic-info {
    margin-bottom: 15px;
    padding: 12px;
    background: #f0f4f8;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.ecg-basic-info > div {
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
}

.ecg-basic-info > div:last-child {
    margin-bottom: 0;
}

.ecg-basic-info strong {
    color: #333;
}

.ecg-basic-info code {
    background: #e8eef5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #667eea;
}

/* 執行者資訊樣式 */
.ecg-performer-info {
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 14px;
    color: #666;
}

/* ECG 圖片區塊樣式 */
.ecg-image-section {
    margin-top: 20px;
    padding: 15px;
    background: #ffffff;
    border-radius: 8px;
    border: 2px solid #667eea;
}

.ecg-image-section h4 {
    margin: 0 0 15px 0;
    color: #667eea;
    font-size: 16px;
    font-weight: 600;
}

.ecg-image-container {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    overflow: auto;
    min-height: 100px;
    position: relative;
}

.ecg-image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 15px;
}

.ecg-image-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.ecg-image-loading p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.ecg-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 尚未取得圖片的樣式 */
.ecg-no-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 15px;
    min-height: 150px;
}

.ecg-no-image p {
    color: #999;
    font-size: 14px;
    margin: 0;
    font-style: italic;
}

/* 上傳 ECG 按鈕樣式 */
.btn-upload-ecg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.btn-upload-ecg:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.btn-upload-ecg:active {
    transform: translateY(0);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* 增加最小寬度 */
    gap: 12px;
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-item.risk-description-item {
    grid-column: 1 / -1; /* 佔滿整行 */
}

.status-label {
    font-weight: 600;
    color: #666;
    font-size: 13px;
}

.risk-description {
    padding: 12px 15px;
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
    /* border-left: 4px solid #e74c3c; */
    border-radius: 6px;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    margin-top: 4px;
}

/* 低風險 (Level 0) - 綠色系 */
.risk-description.risk-low {
    background: linear-gradient(135deg, #f0fff4 0%, #dcfce7 100%);
    border-left-color: #22c55e;
}

/* 中風險 (Level 1) - 橘黃色系 */
.risk-description.risk-medium {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-left-color: #f59e0b;
}

/* 高風險 (Level 2) - 紅色系 */
.risk-description.risk-high {
    background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
    border-left-color: #ef4444;
}

.status-analyzed {
    color: #27ae60;
    font-weight: 600;
    padding: 4px 8px;
    background: #d4edda;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.status-not-analyzed {
    color: #999;
    font-weight: 600;
    padding: 4px 8px;
    background: #f0f0f0;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.status-time {
    color: #333;
    font-weight: 500;
}

.confidence-text {
    color: #667eea;
    font-weight: 600;
}

.analysis-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    width: fit-content;
}

.status-badge.success {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

.status-badge.pending {
    background: linear-gradient(135deg, #ff9800 0%, #fb8c00 100%);
    color: white;
}

/* Component Styles */
.components-container {
    display: contents; /* 讓子元素直接參與父元素的 grid 布局 */
}

.components-summary {
    grid-column: 1 / -1; /* 佔滿整行 */
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 15px;
    color: #667eea;
    text-align: center;
}

.component-item {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 0; /* 移除 margin，由 grid gap 控制間距 */
    overflow: hidden;
}

.component-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 10px 15px;
    font-weight: bold;
}

.component-body {
    padding: 15px;
    background: white;
}

/* Sampled Data Styles */
.sampled-data-container {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    margin-top: 10px;
}

.sampled-data-summary {
    margin-bottom: 15px;
    color: #667eea;
    font-size: 16px;
}

.sampled-data-params {
    margin-bottom: 15px;
}

.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.param-item {
    display: flex;
    flex-direction: column;
    padding: 8px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.param-label {
    font-size: 12px;
    color: #666;
    font-weight: bold;
}

.param-value {
    font-size: 14px;
    color: #333;
    font-weight: bold;
}

.sampled-data-preview {
    border-top: 1px solid #dee2e6;
    padding-top: 15px;
}

.data-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.data-preview-header span {
    font-weight: bold;
    color: #333;
}

.btn-show-all {
    padding: 4px 10px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-show-all:hover {
    background: #218838;
}

.btn-ai-analysis {
    padding: 4px 10px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-ai-analysis:hover {
    background: #218838;
}

.data-points {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.data-point {
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

.data-more {
    background: #fff3e0;
    color: #f57c00;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-style: italic;
}

/* Sampled Data Modal */
.sampled-data-modal {
    max-width: 900px;
    width: 95%;
}

.data-table-container {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.sampled-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sampled-data-table th {
    background: #f8f9fa;
    padding: 8px;
    text-align: center;
    font-weight: bold;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sampled-data-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #f0f0f0;
    text-align: center;
}

.data-index {
    background: #f8f9fa;
    font-weight: bold;
    color: #666;
    width: 60px;
}

.data-value {
    font-family: monospace;
    color: #333;
}

.sampled-data-table tbody tr:hover {
    background: #f5f5f5;
}

.data-stats {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.data-stats h4 {
    margin: 0 0 10px 0;
    color: #667eea;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.stat-label {
    font-weight: bold;
    color: #666;
}

.stat-value {
    font-family: monospace;
    color: #333;
    font-weight: bold;
}

/* No Data */
.no-data {
    text-align: center;
    color: #999;
    padding: 30px;
    font-style: italic;
}

/* Error Message */
.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin-top: 20px;
    border: 1px solid #f5c6cb;
}

.error {
    color: #dc3545;
}

.error-detail {
    color: #856404;
    font-size: 14px;
    margin-top: 5px;
}

.error-details {
    margin-top: 20px;
    padding: 20px;
    background: #f8d7da;
    border-radius: 6px;
    text-align: left;
}

.error-details h3 {
    color: #721c24;
    margin-bottom: 10px;
}

.error-details pre {
    background: white;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
    margin: 10px 0;
}

.error-details button {
    padding: 10px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.error-details button:hover {
    background: #c82333;
}

/* 新增錯誤容器樣式 */
.info-text {
    text-align: center;
    color: #007bff;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.error-container {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.error-container .error-detail {
    color: #666;
    font-size: 0.9rem;
    background: #f7fafc;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    word-break: break-word;
    margin: 0.5rem 0;
}

.error-suggestions {
    margin-top: 1rem;
    padding: 1rem;
    background: #f0f8ff;
    border-radius: 4px;
    border-left: 4px solid #007bff;
}

.error-suggestions h4 {
    margin: 0 0 0.5rem 0;
    color: #007bff;
    font-size: 1rem;
}

.error-suggestions ul {
    margin: 0;
    padding-left: 1.5rem;
}

.error-suggestions li {
    margin: 0.25rem 0;
    color: #555;
}

.btn-retry {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 1rem;
    transition: background-color 0.2s;
}

.btn-retry:hover {
    background: #0056b3;
}

/* 沒有 ECG 資料的樣式 */
.no-ecg-data {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    text-align: center;
}

.no-ecg-data h3 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.no-ecg-data .no-data {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: #6c757d;
}

.search-info,
.suggestions {
    background: white;
    padding: 1.5rem;
    margin: 1rem 0;
    border-radius: 8px;
    border-left: 4px solid #007bff;
    text-align: left;
}

.search-info h4,
.suggestions h4 {
    color: #007bff;
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.search-info ul,
.suggestions ul {
    margin: 0;
    padding-left: 1.5rem;
    color: #495057;
}

.search-info li,
.suggestions li {
    margin: 0.5rem 0;
    line-height: 1.5;
}

.suggestions {
    border-left-color: #28a745;
}

.suggestions h4 {
    color: #28a745;
}

/* 安全上下文相關樣式 */
.error-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
}

.error-message {
    text-align: center;
    margin-bottom: 2rem;
}

.error-message h3 {
    color: #856404;
    margin-bottom: 1rem;
}

.solutions {
    text-align: left;
}

.solutions h4 {
    color: #856404;
    margin-bottom: 1rem;
}

.solution-item {
    background: white;
    padding: 1.5rem;
    margin: 1rem 0;
    border-radius: 6px;
    border-left: 4px solid #ffc107;
}

.solution-item h5 {
    color: #856404;
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.solution-item p {
    color: #6c757d;
    margin: 0.5rem 0 1rem 0;
}

.btn-primary {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin: 0.5rem;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background: #545b62;
}

.config-form {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.config-form label {
    display: block;
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
    color: #495057;
}

.config-form input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.config-form input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.config-form input[readonly] {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* 認證錯誤樣式 */
.auth-error-container {
    max-width: 700px;
    margin: 2rem auto;
    padding: 2rem;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 12px;
}

.auth-error-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-error-header h2 {
    color: #e53e3e;
    margin-bottom: 1rem;
}

.auth-error-details {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.error-info {
    margin-bottom: 2rem;
}

.error-info h4 {
    color: #c53030;
    margin-bottom: 1rem;
}

.error-info ul {
    color: #4a5568;
    line-height: 1.6;
}

.solution-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1rem;
}

.server-info-box {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #3182ce;
    margin: 1rem 0;
}

.server-info-box h4 {
    color: #2d3748;
    margin-bottom: 1rem;
}

.server-info-box p {
    margin: 0.5rem 0;
    color: #4a5568;
}

.oauth-instructions {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.oauth-instructions h3 {
    color: #2d3748;
    margin-bottom: 1.5rem;
}

.instructions-content h4 {
    color: #2d3748;
    margin: 1.5rem 0 1rem 0;
}

.config-example {
    background: #edf2f7;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    font-family: monospace;
}

.config-example p {
    margin: 0.5rem 0;
    color: #2d3748;
}

.instructions-content ol {
    color: #4a5568;
    line-height: 1.8;
}

.instructions-content ul {
    margin: 0.5rem 0;
    padding-left: 2rem;
}

.instruction-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.fallback-container {
    max-width: 500px;
    margin: 2rem auto;
    padding: 2rem;
    text-align: center;
}

.warning-box {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
    color: #856404;
}

.server-info {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.server-info p {
    margin: 0 0 1rem 0;
    color: #495057;
}

/* 簡化模式提示樣式 */
.simplified-mode-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    font-size: 0.9rem;
}

.mode-badge {
    background: #ffc107;
    color: #212529;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
}

.server-info {
    color: #495057;
    flex: 1;
    font-family: monospace;
    font-size: 0.85rem;
}

.mode-note {
    color: #6c757d;
    font-style: italic;
    font-size: 0.8rem;
}

/* Footer */
footer {
    background: white;
    padding: 15px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

footer p {
    color: #666;
    font-size: 14px;
}

footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

footer a:hover {
    text-decoration: underline;
}

/* ===== AI 分析結果樣式 ===== */

/* AI 分析 Modal */
.ai-analysis-modal {
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.analysis-section {
    margin-bottom: 30px;
}

.analysis-section h4 {
    color: #667eea;
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

/* 基本資訊網格 */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.info-item {
    padding: 12px;
    background: #f9f9f9;
    border-left: 3px solid #667eea;
    border-radius: 4px;
}

.info-label {
    display: block;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
    font-size: 13px;
}

.info-value {
    display: block;
    color: #666;
    font-size: 14px;
    word-break: break-all;
}

.info-value code {
    background: #e8eaf6;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* 分析結果項目 */
.analysis-results {
    padding: 15px;
    background: #f5f5f5;
    border-radius: 6px;
}

.result-items {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-item {
    display: flex;
    flex-direction: column;
}

.result-label {
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
    font-size: 14px;
}

.result-value {
    color: #555;
    font-size: 15px;
    line-height: 1.6;
}

/* 診斷文本 */
.diagnosis-text {
    background: white;
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid #4caf50;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* 指標網格 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.metric-item {
    padding: 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    text-align: center;
}

.metric-label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.metric-value {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
}

/* ===== STEMI 風險評估樣式 ===== */

.stemi-risk-item {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9ff;
    border-radius: 8px;
    border-left: 5px solid #667eea;
}

.stemi-risk-badge {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 16px;
    text-align: center;
    min-width: 150px;
    color: white;
}

/* 低風險 - 綠色 */
.stemi-risk-badge.risk-low {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* 中等風險 - 橙色 */
.stemi-risk-badge.risk-medium {
    background: linear-gradient(135deg, #ff9800 0%, #fb8c00 100%);
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

/* 高風險 - 紅色 */
.stemi-risk-badge.risk-high {
    background: linear-gradient(135deg, #f44336 0%, #e53935 100%);
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

/* 未知 - 灰色 */
.stemi-risk-badge.risk-unknown {
    background: linear-gradient(135deg, #9e9e9e 0%, #757575 100%);
    box-shadow: 0 2px 8px rgba(158, 158, 158, 0.3);
}

/* 信心程度樣式 */
.confidence-item {
    margin-top: 10px;
    margin-bottom: 15px;
}

.confidence-badge {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    min-width: 140px;
    color: white;
}

/* 高信心 - 深藍綠色 */
.confidence-badge.confidence-high {
    background: linear-gradient(135deg, #00897b 0%, #00796b 100%);
    box-shadow: 0 2px 6px rgba(0, 137, 123, 0.3);
}

/* 中等信心 - 藍色 */
.confidence-badge.confidence-medium {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    box-shadow: 0 2px 6px rgba(25, 118, 210, 0.3);
}

/* 低信心 - 淺藍色 */
.confidence-badge.confidence-low {
    background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%);
    box-shadow: 0 2px 6px rgba(66, 165, 245, 0.3);
}

/* 未知信心 - 灰色 */
.confidence-badge.confidence-unknown {
    background: linear-gradient(135deg, #757575 0%, #616161 100%);
    box-shadow: 0 2px 6px rgba(117, 117, 117, 0.3);
}

/* 狀態指示器 */
.status-SUCCESS {
    color: #4caf50;
    font-weight: bold;
}

.status-PENDING {
    color: #ff9800;
    font-weight: bold;
}

.status-FAILED {
    color: #f44336;
    font-weight: bold;
}

.status-unknown {
    color: #999;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 15px 20px;
    }

    header h1 {
        font-size: 20px;
    }

    .launch-screen {
        padding: 40px 20px;
        margin: 50px auto;
    }

    .card {
        padding: 20px 15px;
    }

    .obs-body,
    .detail-row {
        flex-direction: column;
        gap: 5px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

/* ===== AI 分析進度條樣式 ===== */

.progress-modal {
    max-width: 600px;
    min-width: 500px;
}

.progress-container {
    padding: 10px;
}

.progress-bar-wrapper {
    margin-bottom: 25px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    transition: width 0.3s ease-in-out;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
    font-size: 16px;
    color: #667eea;
}

.progress-status {
    text-align: center;
    margin: 15px 0;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 6px;
    font-size: 14px;
    color: #666;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 進度步驟 */
.progress-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

.step-item.active {
    background: #e8eaf6;
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.step-item.completed {
    background: #e8f5e9;
    border-color: #4caf50;
}

.step-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.step-item.active .step-icon {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.step-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    text-align: center;
}

.step-item.active .step-label {
    color: #667eea;
    font-weight: bold;
}

.step-item.completed .step-label {
    color: #4caf50;
    font-weight: bold;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .progress-modal {
        min-width: 90%;
        max-width: 95%;
    }
    
    .progress-steps {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ===== ECG Analysis Status Styles ===== */

/* Statistics Panel */
.statistics-panel {
    margin-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.stat-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.stat-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.stat-item.analyzed {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.stat-item.unanalyzed {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
}

.stat-value {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* Analysis Status Container */
.analysis-status-container {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 15px;
    margin: 15px 0;
    border-radius: 5px;
}

.analysis-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.analysis-status-header h4 {
    margin: 0;
    color: #333;
    font-size: 16px;
}

/* Analysis Badge */
.analysis-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: help;
    transition: all 0.3s ease;
}

.analysis-badge.analyzed {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.analysis-badge.analyzed:hover {
    background: #c3e6cb;
    transform: scale(1.05);
}

.analysis-badge.not-analyzed {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.analysis-badge.not-analyzed:hover {
    background: #f5c6cb;
    transform: scale(1.05);
}

.badge-icon {
    font-size: 14px;
}

.badge-text {
    font-weight: 600;
}

/* Analysis Details */
.analysis-details {
    margin-top: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: #666;
    font-size: 14px;
}

.detail-value {
    color: #333;
    font-size: 14px;
    text-align: right;
}

.no-analysis {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 10px;
}

/* Loading Status */
.analysis-status-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-size: 14px;
}

.loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== ECG List Page Styles ===== */

/* Breadcrumb */
.breadcrumb {
    margin: 10px 0 0 0;
    font-size: 14px;
}

.breadcrumb a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* Patient Info Header */
.patient-info-header {
    display: flex;
    align-items: center;
}

.patient-info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.patient-info-card h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
}

.patient-details {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 14px;
}

.patient-details span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.patient-details code {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* ECG Table */
.ecg-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.ecg-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ecg-table th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.ecg-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s;
}

.ecg-table tbody tr:hover {
    background-color: #f8f9ff;
}

.ecg-table td {
    padding: 12px;
    /* font-size: 14px; */
}

.ecg-id {
    font-family: 'Courier New', monospace;
    background: #f0f4ff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    display: inline-block;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.analysis-result {
    color: #27ae60;
    font-weight: 600;
    padding: 4px 12px;
    background: #d4edda;
    border-radius: 12px;
    font-size: 12px;
    display: inline-block;
}

.no-analysis {
    color: #999;
    font-weight: 600;
    padding: 4px 12px;
    background: #f0f0f0;
    border-radius: 12px;
    font-size: 12px;
    display: inline-block;
}

.analysis-checkmark {
    color: #27ae60;
    font-size: 20px;
    font-weight: bold;
}

.btn-analyze {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-analyze:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-view-detail {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-view-detail:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ECG Detail Modal */
.modal-large {
    max-width: 900px !important;
    max-height: 90vh;
}

.ecg-detail-full {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-section {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
}

.detail-section h4 {
    margin: 0 0 15px 0;
    color: #667eea;
    font-size: 16px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.detail-grid > div {
    padding: 8px 0;
    font-size: 14px;
}

.detail-grid strong {
    color: #666;
    margin-right: 8px;
}

.detail-value {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    max-height: 400px;
    overflow-y: auto;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-final {
    background: #d4edda;
    color: #155724;
}

.status-preliminary {
    background: #fff3cd;
    color: #856404;
}

.status-registered {
    background: #d1ecf1;
    color: #0c5460;
}

.analysis-info {
    background: #e8f5e9;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #27ae60;
}

.analysis-info p {
    margin: 8px 0;
    font-size: 14px;
}

/* Analysis Result Display */
.analysis-result-display {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    max-height: 500px;
    overflow-y: auto;
}

.analysis-result-display pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* Error Detail Box */
.error-detail-box {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 800px;
    margin: 30px auto;
    border-left: 5px solid #e74c3c;
}

.error-detail-box h3 {
    color: #e74c3c;
    margin: 0 0 15px 0;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.error-detail-box h4 {
    color: #667eea;
    margin: 20px 0 12px 0;
    font-size: 17px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 8px;
}

.error-detail-box > p {
    color: #333;
    margin: 15px 0;
    line-height: 1.7;
    font-size: 15px;
}

.error-detail-box ol {
    margin: 12px 0;
    padding-left: 25px;
}

.error-detail-box li {
    margin: 10px 0;
    color: #333;
    line-height: 1.7;
}

.error-detail-box ul {
    margin: 8px 0;
    padding-left: 25px;
}

.error-detail-box ul li {
    margin: 5px 0;
    color: #666;
    font-size: 14px;
}

.error-detail-box code {
    background: #f8f9fa;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #e74c3c;
    font-size: 13px;
    font-weight: 600;
}

.error-detail-box a {
    color: #667eea;
    text-decoration: none;
    word-break: break-all;
    font-weight: 500;
}

.error-detail-box a:hover {
    text-decoration: underline;
    color: #764ba2;
}

.solution-box {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #e0e7ff;
}

.solution-item {
    background: white;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
    border-left: 3px solid #667eea;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.solution-item strong {
    color: #667eea;
    display: block;
    margin-bottom: 10px;
    font-size: 15px;
}

.solution-item ol,
.solution-item ul {
    margin: 10px 0;
}

.technical-info {
    background: #f0f0f0;
    padding: 15px 20px;
    border-radius: 6px;
    margin: 20px 0;
    font-size: 14px;
}

.technical-info ul {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.technical-info ul li {
    padding: 5px 0;
    color: #555;
}

.technical-info small {
    color: #666;
    line-height: 1.6;
}

.error-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    justify-content: center;
    flex-wrap: wrap;
}

.error-message {
    margin: 20px 0;
}

/* Progress Modal */
.modal-progress {
    max-width: 500px;
}

.progress-container {
    padding: 10px 0;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease-in-out, background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.progress-text {
    text-align: center;
}

.progress-step {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.progress-detail {
    font-size: 14px;
    color: #666;
}

/* 中等螢幕（平板）- 調整 Modal 寬度 */
@media (max-width: 1024px) and (min-width: 769px) {
    .modal-content {
        max-width: 90%;
    }
}

/* Responsive */
@media (max-width: 768px) {
    /* Modal 在手機上調整寬度 */
    .modal-content {
        max-width: 95%;
        width: 95%;
    }
    
    /* ECG 詳情改為單欄 */
    .ecg-detail-body {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    /* 分析狀態區塊也改為單欄 */
    .status-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .analysis-status-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .detail-row {
        flex-direction: column;
        gap: 5px;
    }
    
    .detail-value {
        text-align: left;
    }
    
    .patient-details {
        flex-direction: column;
        gap: 8px;
    }
    
    .ecg-table th,
    .ecg-table td {
        padding: 8px 6px;
        font-size: 12px;
    }
    
    .ecg-id {
        max-width: 100px;
    }
    
    .modal-large {
        max-width: 95%;
    }
}

/* ==================== 分頁控制樣式 ==================== */

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin-top: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-info {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-pagination {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    cursor: pointer;
    border-radius: 5px;
    font-size: 14px;
    transition: all 0.3s ease;
    min-width: 40px;
    font-weight: 500;
}

.btn-pagination:hover:not(:disabled) {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.btn-pagination.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
    font-weight: bold;
}

.btn-pagination:disabled {
    background: #f5f5f5;
    color: #ccc;
    cursor: not-allowed;
    border-color: #e0e0e0;
}

.pagination-ellipsis {
    padding: 0 8px;
    color: #999;
    font-weight: bold;
}

.pagination-jump {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pagination-jump input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    text-align: center;
}

.pagination-jump input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 響應式設計 - 分頁 */
@media (max-width: 768px) {
    .pagination-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .pagination-controls {
        width: 100%;
        justify-content: center;
    }
    
    .pagination-jump {
        width: 100%;
        justify-content: center;
    }
    
    .btn-pagination {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 35px;
    }
}

/* ===========================
   分析詳情區域樣式
   =========================== */
.analysis-details-section {
    margin-top: 20px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.analysis-details-section h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.analysis-details-loading {
    text-align: center;
    padding: 20px;
}

.analysis-details-loading .spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 分析詳情列表 - 簡潔風格（類似 STEMI） */
.analysis-details-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analysis-details-list .detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: white;
    border-radius: 6px;
    border-left: 3px solid #ddd;
    transition: all 0.2s ease;
}

.analysis-details-list .detail-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transform: translateX(3px);
}

.analysis-details-list .item-label {
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.analysis-details-list .item-value {
    font-weight: 600;
    font-size: 14px;
    margin-left: 10px;
}

/* 高風險 */
.analysis-details-list .detail-item.risk-high {
    background-color: #fee;
    border-left-color: #e74c3c;
}

.analysis-details-list .detail-item.risk-high .item-value {
    color: #e74c3c;
}

/* 中風險 */
.analysis-details-list .detail-item.risk-medium {
    background-color: #fff3cd;
    border-left-color: #f39c12;
}

.analysis-details-list .detail-item.risk-medium .item-value {
    color: #f39c12;
}

/* 低風險 */
.analysis-details-list .detail-item.risk-low {
    background-color: #e3f2fd;
    border-left-color: #3498db;
}

.analysis-details-list .detail-item.risk-low .item-value {
    color: #3498db;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .analysis-details-section {
        padding: 15px;
    }
    
    .analysis-details-list .detail-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .analysis-details-list .item-value {
        margin-left: 0;
    }
}

