:root {
    --color-xi-deep-blue: #122d43;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    color: #222;
    background: #f6f7fb;
}

/* 헤더 */
.header {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--color-xi-deep-blue);
    color: #fff;
}

.header .logo {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.header .logo img {
    width: 80px;
}

.header h1 {
    font-size: 16px;
    margin: 0;
}

.header .file-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.manager-info span {
    font-size: 12px;
}

/* 메인 2열 레이아웃 */
.main {
    height: calc(100vh - 56px);
    display: grid;
    /* grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); */
    /* grid-template-columns: 1fr 4fr 3fr; */
    grid-template-columns: 2fr 8fr 5fr;
    /* 3:1 비율 + 수축 허용 */
    gap: 8px;
    padding: 12px;
    min-width: 0;
    /* ✅ 그리드 컨테이너도 수축 허용 */
}

/* 좌측 */
.left {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    overflow: hidden;
}

.pageSpec-container {
    display: flex;
    flex-direction: row;
    gap: 5px;
    justify-content: space-between;
}

#btnSelectPage {
    width: 80px;
}

#pageSpec {
    width: 100%;
}

/* 중앙 */
.center {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    overflow: hidden;
}

/* 툴바 */
.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 8px;
    justify-content: space-between;
}

#totalPages {
    margin: 0 6px;
    font-weight: 500;
    color: #555;
}

/* 캔버스 */
.canvas-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 360px;
    border: 1px solid #e5e7eb;
    background: #fafafa;
    overflow: hidden;
    border-radius: 6px;
    cursor: default;
}

.canvas-wrap.panning {
    cursor: grabbing;
}

#pdfCanvas {
    display: block;
}

.roi {
    position: absolute;
    border: 5px solid;
    pointer-events: none;
}

.roi-num {
    border-color: #1f77ff;
    background-color: rgba(31, 119, 255, 0.1);
}

.roi-name {
    border-color: #ff3b3b;
    background-color: rgba(255, 59, 59, 0.1);
}

/* ROI 메뉴 설정(마우스 우클릭 시) */
.roi-menu {
    position: absolute;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    z-index: 1000;
}

.roi-menu button {
    display: block;
    width: 100%;
    border: none;
    background: none;
    padding: 6px 12px;
    text-align: left;
    cursor: pointer;
}

.roi-menu button:hover {
    background: #f3f4f6;
}

/* ===== Pager (캔버스와 썸네일 사이) ===== */
.pager {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    justify-content: center;
}

/* .pager-label input[type="number"] {
    width: 60px;
} */

.pager button {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f7f7f7;
    cursor: pointer;
}

.pager button:hover {
    background: #efefef;
}

.pager button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pager-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#pageNo {
    width: 88px;
    /* 입력 칸 너비 */
    padding: 4px 6px;
}

#totalPages {
    font-weight: 500;
    color: #555;
}


/* 썸네일 래퍼: 자체 크기는 고정, 내부 스크롤만 허용 */
.thumbs-wrap {
    height: 160px;
    margin-top: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 6px;
    /* overflow: hidden; */
    /* 바깥으로 새지 않음 */
    display: block;
    min-width: 0;
    /* ✅ 부모 폭을 늘리지 않음 */
}

/* 썸네일 리스트: 한 줄로 쭉 + 가로 스크롤바 */
.thumbs {
    display: block;
    width: 100%;
    max-width: 100%;
    /* ✅ 부모 폭 한계 내에서만 배치 */
    min-width: 0;
    /* ✅ 수축 허용 */
    overflow-x: auto;
    /* ✅ 가로 스크롤 담당 */
    overflow-y: hidden;
    white-space: nowrap;
    /* 한 줄 유지(길이는 스크롤로 처리) */
    padding: 8px;
    /* 선택: 레이아웃 격리 → 내부 폭 계산이 바깥에 전파되지 않도록 */
    contain: layout;
    /* ✅ (지원 브라우저에서) 내부 레이아웃 영향 차단 */
}

.thumbs .thumb-card {
    cursor: pointer;
}

.thumbs::-webkit-scrollbar {
    height: 10px;
}

.thumbs::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 6px;
}

.thumbs::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.thumbs img {
    display: inline-block;
    height: 100px;
    margin: 2px 4px 0px 4px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
}

.thumbs img.active {
    border-color: #2d7cff !important;
    box-shadow: 0 0 0 2px rgba(45, 124, 255, 0.15);
}

.thumbs-actions {
    display: flex;
    gap: 10px;
}

.thumbs-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thumbs-actions-button-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.thumbs-actions label {
    font-size: 12px;
    text-align: left;
    align-items: center;
}

.ocr-actions {
    margin-top: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 6px;
    padding: 10px;
    display: grid;
    grid-template-columns: 3fr 1fr;
}

.partition {
    border-top: 1px solid #ccc;
    margin-top: 5px;
    padding-top: 5px;
}

/* ===== 선택 개수 배지 ===== */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    color: #0f172a;
    background: #e2e8f0;
    /* slate-200 계열 */
    border: 1px solid #cbd5e1;
    /* slate-300 */
    margin-left: 8px;
    user-select: none;
}

/* 우측 */
.right {
    min-width: 0;
    overflow: hidden;
}

.panel {
    height: 100%;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    overflow-y: hidden;
}

.panel-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

h3 {
    margin: 12px 0 8px;
    font-size: 15px;
}

.box {
    border: 1px solid #e5e7eb;
    padding: 8px;
    background: #fff;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tablebox {
    min-height: 40vh;
    max-height: 60vh;
    overflow: auto;
    background: #fff;

}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* ✅ 고정 레이아웃 */
th,
td {
    border-bottom: 1px solid #eee;
    padding: 6px;
    font-size: 12px;
    word-break: break-word;
    text-align: center;
}

th:nth-child(1) {
    width: 10%;
}

th:nth-child(2) {
    width: 10%;
}

th:nth-child(3) {
    width: 15%;
}

th:nth-child(4) {
    width: 65%;
}

/* ✅ 긴 텍스트 줄바꿈 */
td input[type="text"] {
    width: 100%;
    min-width: 0;
}

#resultTable tbody td.cursor-pointer {
    cursor: pointer;
}

#resultTable tbody td.cursor-pointer:hover {
    text-decoration: underline;
}

#rowSelectTools {
    display: grid;
    align-items: center;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

/* 찾기/바꾸기 유틸리티 스타일 */
#frBox {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fr-container {
    display: flex;
    flex-direction: row;
    gap: 2px;
    flex-wrap: nowrap;
    align-items: center;
    font-size: .8em;
    justify-content: space-between;
}

.fr-container label {
    flex-grow: 1;
}

.fr-container label select {
    width: 100%;
    height: 24px;
    margin-top: 3px;
}

.fr-container label input {
    width: 100%;
    height: 24px;
    margin-top: 3px;
}

.fr-options-container label {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fr-options-container {
    font-size: .8em;
}

#splitInfo {
    font-size: .8em;
}

/* ✅ 입력창도 수축 허용 */
button {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f7f7f7;
    cursor: pointer;
}

button:hover {
    background: #efefef;
}

/* 버튼 스타일 개별 설정 */
#btnUpload,
#btnRunOCR,
#btnSplit {
    background-color: #2d7cff;
    color: #f7f7f7;
    font-weight: 700;
}

/* 작은 화면 대응 */
@media (max-width: 1024px) {
    .main {
        grid-template-columns: 1fr;
        /* 한 열 */
        height: auto;
        min-height: calc(100vh - 56px);
    }

    .right {
        margin-top: 12px;
    }
}

/* ===== Loading Overlay ===== */
.loading-overlay[hidden] {
    display: none !important;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    /* 맨 위에 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.3);
    /* 어두운 반투명 배경 */
    backdrop-filter: blur(1px);
}

.loading-panel {
    position: relative;
    z-index: 1;
    min-width: 220px;
    max-width: min(80vw, 360px);
    padding: 16px 20px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
}

.spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #e5e7eb;
    border-top-color: #2d7cff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    font-size: 14px;
    color: #111827;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 버튼 비활성화시 시각 피드백 */
button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== Canvas Loading Overlay ===== */
.canvas-loading[hidden] {
    display: none !important;
}

.canvas-loading {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-loading-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(1px);
}

.canvas-loading-panel {
    position: relative;
    z-index: 1;
    min-width: 160px;
    max-width: min(70%, 280px);
    padding: 10px 14px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* OCR Progress */
#ocrProgress {
    margin-top: 10px;
}

#ocrBarWrap {
    position: relative;
    height: 10px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

#ocrBar {
    height: 100%;
    width: 0%;
    background: #2d7cff;
    transition: width 180ms ease;
}

#ocrText {
    margin-top: 6px;
    font-size: 12px;
    color: #334155;
}

/* spinner / loading-text 는 기존 전역 스타일을 그대로 사용 */
#canvasBlocker[hidden] {
    display: none !important;
}

#canvasBlocker {
    background: rgba(0, 0, 0, 0.15);
}

/* .canvas-blocker {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    color: #000;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 5px;
    backdrop-filter: blur(1px);
    z-index: 15;
} */

.thumbs.locked,
.pager.locked,
.toolbar.locked {
    pointer-events: none;
    opacity: 55;
}