.ocr-page-wrap {
    width: 1600px;
    margin-left: auto;
    margin-right: auto;
}

.ocr-top-card {
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.82));
    box-shadow: 0 20px 46px rgba(0, 0, 0, 0.26);
}

.ocr-grid {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.ocr-panel {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background: rgba(2, 6, 23, 0.5);
    padding: 16px;
}

.ocr-section-title {
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 10px;
}

.ocr-dropzone {
    border: 1px dashed rgba(96, 165, 250, 0.55);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.82), rgba(30, 41, 59, 0.62));
    padding: 18px 16px;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.ocr-dropzone:hover,
.ocr-dropzone:focus {
    border-color: rgba(125, 211, 252, 0.92);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.12);
    transform: translateY(-1px);
}

.ocr-dropzone-title {
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 6px;
}

.ocr-dropzone-help {
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.6;
}

.ocr-dropzone-file {
    margin-top: 12px;
    color: #7dd3fc;
    font-size: 13px;
    min-height: 20px;
    word-break: break-word;
}

.ocr-hidden-file {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ocr-action-row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.ocr-btn {
    min-width: 100px;
    border-radius: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22);
}

.ocr-btn-primary {
    background: linear-gradient(135deg, #0f2a3f, #12304a);
    border-color: #2563eb;
    color: #dbeafe;
}

.ocr-btn-secondary {
    background: linear-gradient(135deg, #1f2937, #111827);
    border-color: #475569;
    color: #f8fafc;
}

.ocr-btn-info {
    background: linear-gradient(135deg, #0e7490, #155e75);
    border-color: #0891b2;
    color: #cffafe;
}

.ocr-status {
    min-height: 24px;
    margin-top: 12px;
    font-size: 13px;
    color: #93c5fd;
    white-space: pre-wrap;
    word-break: break-word;
}

.ocr-status.is-error {
    color: #fecaca;
}

.ocr-health-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.ocr-health-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(30, 41, 59, 0.78);
    color: #e2e8f0;
}

.ocr-health-badge.is-ok {
    border-color: rgba(20, 184, 166, 0.5);
    background: rgba(15, 118, 110, 0.18);
    color: #99f6e4;
}

.ocr-health-text {
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.ocr-thumb-wrap {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(148, 163, 184, 0.32);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.45);
    margin-top: 14px;
    padding: 12px;
}

.ocr-thumb-empty {
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
    line-height: 1.7;
}

.ocr-thumb-img {
    max-width: 100%;
    max-height: 230px;
    border-radius: 12px;
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.28);
    background: #0f172a;
}

.ocr-canvas-wrap {
    min-height: 700px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.09), transparent 28%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.76));
    padding: 18px;
}

.ocr-canvas-stage {
    min-height: 620px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
}

.ocr-preview-shell {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.ocr-preview-img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 14px;
    box-shadow: 0 20px 36px rgba(0, 0, 0, 0.34);
    background: #ffffff;
}

.ocr-overlay-layer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.ocr-box {
    position: absolute;
    border: 2px solid rgba(56, 189, 248, 0.92);
    background: rgba(15, 23, 42, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    overflow: visible;
    transition: opacity 0.2s ease, background 0.2s ease, transform 0.1s ease;
    pointer-events: auto;
}

/* 當滑鼠進入預覽區域時，所有方塊先變半透明 */
.ocr-preview-shell:hover .ocr-box {
    opacity: 0.15; /* 再淡一些 */
}

/* 滑鼠指到的那個方塊恢復不透明並突顯 */
.ocr-box:hover {
    background: rgba(56, 189, 248, 0.3);
    z-index: 100;
    opacity: 1 !important;
    border-color: #60a5fa;
    transform: scale(1.02);
}

.ocr-box-label {
    position: absolute;
    left: 0;
    top: -28px;
    max-width: 320px;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(2, 6, 23, 0.86);
    color: #f8fafc;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ocr-stage-empty {
    min-height: 620px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    text-align: center;
    line-height: 1.8;
    font-size: 14px;
}

.ocr-tabs {
    margin-top: 18px;
}

.ocr-tab-btn {
    color: #cbd5e1;
}

.ocr-tab-btn.active,
.nav-tabs > li.active > a.ocr-tab-btn,
.nav-tabs > li.active > a.ocr-tab-btn:hover,
.nav-tabs > li.active > a.ocr-tab-btn:focus {
    background-color: rgba(30, 41, 59, 0.92) !important;
    color: #f8fafc !important;
    border: 1px solid rgba(96, 165, 250, 0.38) !important;
    border-bottom-color: transparent !important;
}

.ocr-tab-pane {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-top: 0;
    border-radius: 0 0 14px 14px;
    background: rgba(2, 6, 23, 0.55);
    padding: 16px;
    min-height: 230px;
    color: #f8fafc;
}

.ocr-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 12px;
}

.ocr-info-item {
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
}

.ocr-info-title {
    color: #94a3b8;
    font-size: 12px;
    margin-bottom: 6px;
}

.ocr-info-value {
    color: #e2e8f0;
    word-break: break-word;
    white-space: pre-wrap;
}

.ocr-json {
    margin: 0;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    padding: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 520px;
    overflow: auto;
}

.ocr-textarea {
    width: 100%;
    min-height: 260px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.72);
    color: #e2e8f0;
    padding: 14px;
    resize: vertical;
}

.border-secondary {
    border-color: rgba(148, 163, 184, 0.3) !important;
}

/* Bootstrap 3 Utility Polyfills */
.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-center { justify-content: center !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.ms-auto { margin-left: auto !important; }
.gap-3 { gap: 16px !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mt-4 { margin-top: 24px !important; }
.py-4 { padding-top: 24px !important; padding-bottom: 24px !important; }

@media (max-width: 1700px) {
    .ocr-page-wrap {
        width: calc(100% - 48px);
    }
}

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

    .ocr-canvas-wrap {
        min-height: 520px;
    }

    .ocr-canvas-stage,
    .ocr-stage-empty {
        min-height: 440px;
    }
}

@media (max-width: 768px) {
    .ocr-info-grid {
        grid-template-columns: 1fr;
    }
}
