/* ===================================================================
   Auto-BP-Log AI - 核心樣式表 (Core Stylesheet)
   支援 4 大主題：健康清新 (Health)、大地紙感 (Terracotta)、經典明亮 (Classic - 預設)、深邃夜幕 (Dark)
   =================================================================== */

:root {
    /* 預設：經典明亮 (Classic Theme - 專業醫療高雅藍白) */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-border: #bfdbfe;
    --accent: #0891b2;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.92);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
}

[data-theme="health"] {
    --primary: #059669;
    --primary-hover: #047857;
    --primary-light: #ecfdf5;
    --primary-border: #a7f3d0;
    --accent: #0284c7;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
}

[data-theme="terracotta"] {
    --primary: #ea580c;
    --primary-hover: #c2410c;
    --primary-light: #fff7ed;
    --primary-border: #fed7aa;
    --accent: #d97706;
    --bg-main: #fafaf9;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.88);
    --text-main: #1c1917;
    --text-muted: #78716c;
    --border-color: #e7e5e4;
}

[data-theme="dark"] {
    --primary: #38bdf8;
    --primary-hover: #0ea5e9;
    --primary-light: #082f49;
    --primary-border: #0369a1;
    --accent: #34d399;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.88);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* 基礎重設 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'PingFang TC', 'Microsoft JhengHei', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* 頂部導航列 (全平台自適應) */
.navbar {
    background-color: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.65rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    transition: border-color 0.25s ease;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text-main);
    text-decoration: none;
    flex-shrink: 0;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.brand-tag {
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary-border);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 按鈕風格 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(5, 150, 105, 0.3);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary);
}

.btn-icon-only {
    padding: 0.5rem;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
}

/* 主容器排版 */
.main-container {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* 頁籤切換條 */
.tab-nav {
    display: flex;
    gap: 0.5rem;
    background-color: var(--bg-card);
    padding: 0.35rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    min-width: 130px;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

/* 工作區卡片容器 */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    box-shadow: none;
}

/* 掃描工作區 (永遠水平置中) */
.scanner-zone {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 檔案拖曳上傳區 (永遠水平置中) */
.dropzone {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 2.5rem 1.5rem;
    text-align: center;
    background-color: var(--bg-card);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dropzone-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(5, 150, 105, 0.2));
}

/* ==========================================
   📸 橫式 4:3 醫學相機觀景窗與所見即所得對焦取景器
   ========================================== */
.camera-container {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: #000000;
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
}

#cameraVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.camera-viewfinder-wrapper {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 4;
}

.camera-guide-box {
    width: 86%;
    aspect-ratio: 4 / 3;
    max-width: 480px;
    max-height: 86%;
    position: relative;
    border: 2px dashed rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.62);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 4 個綠色精準對焦角標 */
.viewfinder-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: #22c55e;
    border-style: solid;
    pointer-events: none;
}
.corner-tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; }
.corner-tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; }
.corner-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; }
.corner-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; }

.camera-guide-text {
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    text-align: center;
    white-space: nowrap;
}

.camera-controls {
    position: absolute;
    bottom: 12px;
    display: flex;
    gap: 0.6rem;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* ==========================================
   LicenseOCR 標準級互動式 Canvas 裁切與縮放視圖
   ========================================== */
.queue-thumb-wrapper {
    width: 100%;
    height: 280px;
    background-color: #0f172a;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    overflow: hidden;
    user-select: none;
    touch-action: none;
}

.queue-thumb-wrapper.is-panning {
    cursor: grabbing !important;
}

.queue-thumb-wrapper.is-locked {
    cursor: default !important;
    touch-action: pan-y !important;
}

.queue-thumb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    will-change: transform;
    pointer-events: none;
    user-select: none;
}

/* 4:3 橘色虛線裁切框導引 */
.crop-overlay-guide {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2.5px dashed #ea580c;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.65);
    pointer-events: none;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-guide-hint {
    background: rgba(15, 23, 42, 0.92);
    color: #f97316;
    font-size: 12px;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid #ea580c;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* 浮動頂部操作列 */
.queue-floating-top {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

.queue-filename-tag {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
}

.queue-top-actions-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.btn-crop-inline-confirm-intense {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #ffffff;
    border: 1.5px solid #86efac;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
    animation: cropBtnGlow 1.5s infinite alternate;
}

@keyframes cropBtnGlow {
    from { box-shadow: 0 0 4px rgba(34, 197, 94, 0.4); }
    to { box-shadow: 0 0 10px rgba(34, 197, 94, 0.8); }
}

.btn-crop-inline-confirm-intense:hover {
    background: #15803d;
    transform: scale(1.03);
}

.btn-crop-inline-reedit {
    background: rgba(15, 23, 42, 0.85);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-crop-inline-reedit:hover {
    background: var(--primary);
    color: #ffffff;
}

/* 浮動縮放平移旋轉快捷工具列 (左下角) */
.queue-floating-controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    gap: 4px;
    align-items: center;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    padding: 3px 6px;
    z-index: 5;
}

.btn-zoom-ctrl {
    background: transparent;
    border: none;
    color: #f8fafc;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-zoom-ctrl:hover {
    background: var(--primary);
    color: #ffffff;
}

/* 浮動底部列 (右下角移除按鈕) */
.queue-floating-bottom {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

.btn-floating-action {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    color: #fca5a5;
    border: 1px solid rgba(248, 113, 113, 0.4);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-floating-action:hover {
    background: #dc2626;
    color: #ffffff;
}

/* 卡片排版 */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.5rem;
    margin-top: 1.25rem;
}

.ocr-card {
    background-color: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

/* 血壓大字數值排版 */
.bp-numbers {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    background-color: var(--bg-main);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    text-align: center;
}

.bp-num-box .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.bp-num-box .val {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
}

.bp-num-box .unit {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* 醫學分級彩色標籤 */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-green { background-color: #d1fae5; color: #065f46; }
.badge-yellow { background-color: #fef3c7; color: #92400e; }
.badge-orange { background-color: #ffedd5; color: #9a3412; }
.badge-red { background-color: #fee2e2; color: #991b1b; }
.badge-purple { background-color: #f3e8ff; color: #6b21a8; }
.badge-blue { background-color: #e0f2fe; color: #075985; }
.badge-gray { background-color: #f1f5f9; color: #475569; }

/* 統計指標卡片網格 */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-box .title {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-box .number {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-box .subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 圖表容器 */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 960px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
}

/* 歷史記錄資料表格 */
.table-responsive {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    white-space: nowrap;
}

.data-table tr:hover {
    background-color: rgba(5, 150, 105, 0.04);
}

/* 跨裝置同步取件碼展示框 */
.pickup-code-display {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 6px;
    color: var(--primary);
    background-color: var(--primary-light);
    border: 2px dashed var(--primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    margin: 1rem 0;
}

/* 全域 Toast 元件 */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    max-width: 400px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* 彈窗 Dialog Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 560px;
    width: 92%;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* ==========================================
   LicenseOCR 標準級推論服務商選擇卡片 (Provider Radio)
   ========================================== */
.provider-radio-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 10px 0 16px;
}

@media (max-width: 600px) {
    .provider-radio-group {
        grid-template-columns: 1fr;
    }
}

.provider-radio-card {
    background: var(--bg-main);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    user-select: none;
}

.provider-radio-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
}

.provider-radio-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px var(--primary-border);
}

.provider-radio-icon {
    font-size: 1.5rem;
    margin-bottom: 2px;
}

.provider-radio-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-main);
}

.provider-radio-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.provider-section-box {
    margin-top: 10px;
}

.btn-preset-chip {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-main);
}

.btn-preset-chip:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

/* 抽屜 Popover */
.popover-drawer {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background-color: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.popover-drawer.active {
    right: 0;
}

.drawer-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-body {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 診斷日誌列表 */
.debug-log-body {
    background-color: #0f172a;
    color: #e2e8f0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    height: 250px;
    overflow-y: auto;
}

.debug-log-item {
    margin-bottom: 4px;
    line-height: 1.4;
}
.debug-log-item.info { color: #38bdf8; }
.debug-log-item.success { color: #4ade80; }
.debug-log-item.warn { color: #fbbf24; }
.debug-log-item.error { color: #f87171; }

/* 頁尾 */
footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding: 1.25rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    background-color: var(--bg-card);
}

/* ==========================================
   📱 手機與窄螢幕載具全方位自適應優化 (Mobile Responsive Excellence)
   ========================================== */
.actions-bar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 8px;
    flex-wrap: nowrap;
}

.actions-bar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.actions-bar-btns {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap;
}

.btn-compact-mobile {
    padding: 0.45rem 0.85rem !important;
    font-size: 0.82rem !important;
    white-space: nowrap !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 36px;
}

@media (max-width: 768px) {
    .hide-on-mobile,
    .hide-mobile-text {
        display: none !important;
    }

    .navbar {
        padding: 0.45rem 0.65rem;
        gap: 0.35rem;
        flex-wrap: nowrap;
    }
    
    .nav-brand {
        font-size: 1rem;
        gap: 0.4rem;
    }

    .brand-icon {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .brand-tag {
        display: none;
    }
    
    .nav-actions {
        gap: 0.3rem;
        flex-wrap: nowrap;
    }
    
    .nav-actions .btn {
        padding: 0.35rem 0.55rem;
        font-size: 0.78rem;
        white-space: nowrap !important;
        height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-actions .btn-icon-only {
        width: 32px;
        height: 32px;
        padding: 0;
    }
    
    .tab-nav {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.25rem;
        padding: 0.25rem;
        margin-bottom: 0.75rem;
    }
    
    .tab-btn {
        padding: 0.45rem 0.2rem;
        font-size: 0.75rem;
        flex-direction: column;
        gap: 0.2rem;
        text-align: center;
        white-space: normal;
        line-height: 1.2;
    }
    
    .tab-btn i {
        font-size: 0.95rem;
    }
    
    .main-container {
        padding: 0.5rem 0.5rem 1.5rem;
    }
    
    .card {
        padding: 0.75rem;
        border-radius: var(--radius-md);
        margin-bottom: 0.75rem;
    }

    .actions-bar-title {
        font-size: 0.85rem;
    }

    .actions-bar-title span {
        display: none;
    }

    .btn-compact-mobile {
        padding: 0.35rem 0.65rem !important;
        font-size: 0.78rem !important;
        height: 32px;
    }
    
    .scanner-zone, .dropzone {
        max-width: 100%;
        padding: 1.25rem 0.75rem;
        border-radius: var(--radius-md);
    }
    
    .dropzone-icon {
        font-size: 2rem;
    }

    /* 照片卡片頂部標籤與按鈕在手機上精緻自適應 */
    .queue-floating-top {
        top: 6px;
        left: 6px;
        right: 6px;
        gap: 4px;
    }

    .queue-filename-tag {
        max-width: 35%;
        font-size: 10px;
        padding: 2px 6px;
        border-radius: 4px;
    }

    .crop-top-inline-group {
        gap: 4px;
        white-space: nowrap;
    }

    .crop-top-inline-group .badge {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }

    .btn-crop-inline-reedit {
        font-size: 10.5px !important;
        padding: 2px 6px !important;
        height: 24px;
        line-height: 1;
        white-space: nowrap !important;
    }

    .btn-crop-inline-confirm-intense {
        font-size: 11px !important;
        padding: 3px 8px !important;
        height: 26px;
        white-space: nowrap !important;
    }

    .bp-num-box .val {
        font-size: 1.8rem !important;
    }

    .bp-num-box .label {
        font-size: 0.75rem !important;
    }
}

/* ==========================================
   🖼️ LicenseOCR 旗艦級 4:3 影像畫布與精確裁切樣式
   ========================================== */
.ocr-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
}

.queue-thumb-wrapper {
    width: 100%;
    aspect-ratio: 4 / 3 !important;
    height: auto !important;
    max-height: none !important;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    overflow: hidden;
    user-select: none;
    touch-action: none;
}

.queue-thumb-wrapper.is-panning {
    cursor: grabbing !important;
}

.queue-thumb-wrapper.is-locked {
    cursor: default !important;
    touch-action: pan-y !important;
}

.queue-thumb-img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    will-change: transform;
    pointer-events: none;
    user-select: none;
}

.crop-overlay-guide {
    position: absolute;
    inset: 0;
    border: 2px dashed #f97316;
    border-radius: var(--radius-sm);
    pointer-events: none;
    box-shadow: inset 0 0 0 1000px rgba(15, 23, 42, 0.25);
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-guide-hint {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    color: #fdba74;
    border: 1px solid rgba(249, 115, 22, 0.4);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    pointer-events: none;
}

.queue-floating-top {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

.queue-filename-tag {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 40%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
}

.queue-top-actions-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
    white-space: nowrap;
}

.crop-top-inline-group {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-crop-inline-confirm-intense {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #ffffff;
    border: 1.5px solid #86efac;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
    animation: cropBtnGlow 1.5s infinite alternate;
}

@keyframes cropBtnGlow {
    from { box-shadow: 0 0 4px rgba(34, 197, 94, 0.4); }
    to { box-shadow: 0 0 10px rgba(34, 197, 94, 0.8); }
}

.btn-crop-inline-confirm-intense:hover {
    background: #15803d;
    transform: scale(1.03);
}

.btn-crop-inline-reedit {
    background: rgba(15, 23, 42, 0.85);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.btn-crop-inline-reedit:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.queue-floating-controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    gap: 6px;
    z-index: 5;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    padding: 4px 6px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-zoom-ctrl {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 13px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.btn-zoom-ctrl:hover {
    background: rgba(255, 255, 255, 0.2);
}

.queue-floating-bottom {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 5;
}

.btn-floating-action {
    background: rgba(15, 23, 42, 0.85);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}

.btn-floating-action:hover {
    background: #dc2626;
    color: #ffffff;
}

/* ==========================================
   🔍 滑鼠懸停 (Mouseover) 照片即時浮動預覽卡片
   ========================================== */
.photo-hover-card {
    position: fixed;
    z-index: 9999;
    width: 330px;
    background: #0f172a;
    border: 2px solid var(--primary);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
    padding: 6px;
    pointer-events: auto;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    display: none;
}

.photo-hover-card.active {
    display: block !important;
    opacity: 1;
    transform: scale(1);
}

.photo-hover-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #000;
    border-radius: var(--radius-sm);
    display: block;
}

.photo-hover-meta {
    font-size: 11.5px;
    color: #cbd5e1;
    padding: 6px 4px 2px;
    line-height: 1.4;
    text-align: center;
}

/* 常態螢幕下隱藏列印專屬容器 */
.print-only-container {
    display: none;
}

/* ==========================================
   🏥 專業醫院級 A4 就醫追蹤報告列印樣式 (@media print)
   ========================================== */
@media print {
    /* 隱藏網頁上所有無關元素 */
    .navbar, .tab-nav, .nav-actions, .bottom-action-bar, 
    .popover-drawer, .modal-overlay, .toast-container,
    .main-container, footer, .btn {
        display: none !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-family: '微軟正黑體', 'Noto Sans TC', sans-serif !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 顯示列印專屬容器 */
    .print-only-container {
        display: block !important;
        width: 100% !important;
        padding: 0 10pt !important;
        box-sizing: border-box !important;
    }

    /* 醫院級標題 Header */
    .print-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-end !important;
        border-bottom: 2pt solid #0f172a !important;
        padding-bottom: 8pt !important;
        margin-bottom: 12pt !important;
    }

    .print-header-main {
        display: flex !important;
        align-items: center !important;
        gap: 8pt !important;
    }

    .print-hospital-icon {
        font-size: 26pt !important;
    }

    .print-title {
        font-size: 16pt !important;
        font-weight: 900 !important;
        color: #0f172a !important;
        margin: 0 !important;
        line-height: 1.2 !important;
    }

    .print-subtitle {
        font-size: 9pt !important;
        color: #475569 !important;
        margin-top: 2pt !important;
    }

    .print-date-box {
        text-align: right !important;
        font-size: 8.5pt !important;
        color: #64748b !important;
        line-height: 1.4 !important;
    }

    /* 受檢者基本資料卡 */
    .print-patient-card {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6pt 12pt !important;
        background: #f8fafc !important;
        border: 1pt solid #cbd5e1 !important;
        border-radius: 4pt !important;
        padding: 8pt 12pt !important;
        margin-bottom: 12pt !important;
        font-size: 9.5pt !important;
        line-height: 1.4 !important;
    }

    .print-section-title {
        font-size: 11pt !important;
        font-weight: 800 !important;
        color: #1e293b !important;
        margin-bottom: 5pt !important;
        border-left: 3pt solid #2563eb !important;
        padding-left: 5pt !important;
    }

    /* 統計摘要表 */
    .print-summary-table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-bottom: 12pt !important;
        text-align: center !important;
    }

    .print-summary-table th, .print-summary-table td {
        border: 1pt solid #94a3b8 !important;
        padding: 6pt 4pt !important;
    }

    .print-summary-table th {
        background: #f1f5f9 !important;
        font-size: 9pt !important;
        font-weight: bold !important;
    }

    .print-summary-table td {
        font-size: 10.5pt !important;
    }

    /* 明細紀錄表 */
    .print-detail-table {
        width: 100% !important;
        border-collapse: collapse !important;
        text-align: center !important;
        margin-bottom: 12pt !important;
    }

    .print-detail-table th, .print-detail-table td {
        border: 0.75pt solid #cbd5e1 !important;
        padding: 5pt 3pt !important;
        font-size: 8.5pt !important;
    }

    .print-detail-table th {
        background: #f1f5f9 !important;
        font-weight: bold !important;
        color: #0f172a !important;
    }

    /* 頁尾醫師簽名欄 */
    .print-footer-box {
        display: grid !important;
        grid-template-columns: 2fr 1fr !important;
        gap: 12pt !important;
        margin-top: 15pt !important;
        page-break-inside: avoid !important;
    }

    .print-doctor-note {
        border: 1pt dashed #cbd5e1 !important;
        border-radius: 4pt !important;
        padding: 8pt !important;
        font-size: 8.5pt !important;
        min-height: 55pt !important;
    }

    .print-note-lines {
        border-bottom: 1pt dashed #e2e8f0 !important;
        margin-top: 15pt !important;
    }

    .print-doctor-sign {
        border: 1pt solid #cbd5e1 !important;
        border-radius: 4pt !important;
        padding: 8pt !important;
        font-size: 9pt !important;
        text-align: right !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }
}
