/* ===== tool-wrapper (base) ===== */
.tool-wrapper.compare-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #2d3748;
}

/* ===== Dual Upload Row ===== */
.compare-upload-row {
    display: flex;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.compare-upload { flex: 1; position: relative; }
.compare-upload.has-file { border-color: #38a169; background: #f0fff4; }
.compare-vs {
    display: flex; align-items: center; justify-content: center;
    color: #a0aec0; font-size: 1.4rem; flex: 0 0 auto; width: 2rem;
}
.upload-badge {
    position: absolute; top: 0.6rem; left: 0.6rem;
    width: 1.6rem; height: 1.6rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: #fff;
}
.original-badge { background: #e53e3e; }
.modified-badge { background: #38a169; }
.upload-filename { margin-top: 0.5rem; font-size: 0.8rem; color: #2f855a; font-weight: 600; word-break: break-all; }

@media (max-width: 720px) {
    .compare-upload-row { flex-direction: column; }
    .compare-vs { width: 100%; height: 1.6rem; transform: rotate(90deg); }
}

/* ===== Info Note ===== */
.info-note {
    display: flex; align-items: flex-start; gap: 0.75rem;
    background: #ebf8ff; padding: 0.9rem 1.2rem; border-radius: 0.75rem;
    color: #2b6cb0; margin-bottom: 1.5rem;
}
.info-note i { font-size: 1.3rem; margin-top: 0.1rem; }
.note-content strong { display: inline-block; margin-right: 0.3rem; }

/* ===================================================== */
/* Comparison App shell (mimics a desktop PDF viewer)     */
/* ===================================================== */
.compare-app {
    border: 1px solid #d7dde5;
    border-radius: 0.6rem;
    overflow: visible;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 1.5rem;
    position: relative;
}
.compare-app:fullscreen {
    border-radius: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.compare-app:fullscreen .app-body { flex: 1; min-height: 0; }

/* ===== Top Toolbar ===== */
.app-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    background: #f7f8fa;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 0.6rem 0.6rem 0 0;
    padding: 0.55rem 0.9rem;
    position: relative;
    z-index: 5;
}
.toolbar-tabs { display: flex; align-items: center; gap: 0.4rem; }
.tab-chip {
    display: inline-flex; align-items: center; gap: 0.4rem;
    background: #fff; border: 1px solid #e2e8f0;
    padding: 0.3rem 0.8rem 0.3rem 0.5rem; border-radius: 1.4rem;
    font-size: 0.8rem; font-weight: 600; color: #4a5568;
    max-width: 180px; overflow: hidden; cursor: pointer; transition: all 0.15s;
}
.tab-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-chip.active { background: #ebf8ff; border-color: #90cdf4; color: #2b6cb0; }
.tab-chip:hover { border-color: #cbd5e0; }
.chip-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.tab-original .chip-dot { background: #e53e3e; }
.tab-modified .chip-dot { background: #38a169; }
.swap-btn {
    width: 1.9rem; height: 1.9rem; border-radius: 50%;
    border: 1px solid #e2e8f0; background: #fff; color: #718096; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; transition: background 0.15s, transform 0.15s;
}
.swap-btn:hover { background: #edf2f7; transform: rotate(180deg); }

.toolbar-center { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.view-mode-select {
    padding: 0.35rem 0.6rem; border: 1px solid #cbd5e0; border-radius: 0.4rem;
    background: #fff; font-size: 0.85rem;
}
.swipe-slider { width: 120px; accent-color: #3182ce; }
.page-indicator { font-size: 0.85rem; font-weight: 600; color: #4a5568; min-width: 60px; text-align: center; }

.toolbar-right { display: flex; align-items: center; gap: 0.35rem; }
.toolbar-sep { width: 1px; height: 1.4rem; background: #e2e8f0; margin: 0 0.2rem; }
.zoom-value { font-size: 0.8rem; font-weight: 600; color: #4a5568; min-width: 44px; text-align: center; }
.icon-btn {
    width: 2rem; height: 2rem; border-radius: 0.4rem;
    border: 1px solid #e2e8f0; background: #fff; color: #4a5568;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.15s; flex: 0 0 auto;
}
.icon-btn:hover { background: #edf2f7; }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn.btn-danger-icon:hover { background: #fff5f5; color: #c53030; border-color: #feb2b2; }

.btn-flat {
    padding: 0.4rem 0.9rem; border-radius: 0.4rem;
    border: 1px solid #e2e8f0; background: #fff; color: #2d3748;
    font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.btn-flat:hover { background: #edf2f7; }

/* ===== Dropdowns (Options / Export) ===== */
.dropdown-wrap { position: relative; }
.dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.6rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.14);
    padding: 0.6rem;
    min-width: 230px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.dropdown-sep { border: none; border-top: 1px solid #edf2f7; margin: 0.45rem 0; width: 100%; }
.option-check {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.4rem 0.4rem; border-radius: 0.35rem;
    font-size: 0.85rem; color: #2d3748; cursor: pointer; user-select: none;
}
.option-check:hover { background: #f7fafc; }
.option-check input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: #3182ce; flex: 0 0 auto; }
.dropdown-action-btn {
    display: block; width: 100%; text-align: left;
    background: #fff; border: 1px solid #e2e8f0; color: #2d3748;
    font-size: 0.85rem; font-weight: 600; padding: 0.5rem 0.7rem;
    border-radius: 0.4rem; cursor: pointer; transition: background 0.15s;
    margin-top: 0.25rem;
}
.dropdown-action-btn:first-of-type { margin-top: 0; }
.dropdown-action-btn:hover { background: #ebf8ff; border-color: #90cdf4; color: #2b6cb0; }
.dropdown-export .dropdown-action-btn { text-align: center; }

/* ===== Scan Warning / OCR Banner ===== */
.scan-banner {
    display: flex; align-items: center; gap: 0.7rem;
    background: #fffbeb; border-bottom: 1px solid #fbd38d;
    color: #975a16; padding: 0.65rem 1rem; font-size: 0.85rem;
}
.scan-banner i { font-size: 1rem; flex: 0 0 auto; }
.scan-banner span { flex: 1; }
.scan-banner-ocr {
    background: #fff; border: 1px solid #f6ad55; color: #975a16;
    font-size: 0.78rem; font-weight: 700; padding: 0.3rem 0.7rem;
    border-radius: 1rem; cursor: pointer; white-space: nowrap;
}
.scan-banner-ocr:hover { background: #fef3d7; }
.scan-banner-close {
    background: none; border: none; color: #975a16;
    font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 0.3rem;
}
.scan-banner-close:hover { color: #744210; }

.ocr-banner {
    display: flex; align-items: center; gap: 0.6rem;
    background: #ebf8ff; border-bottom: 1px solid #90cdf4;
    color: #2b6cb0; padding: 0.55rem 1rem; font-size: 0.85rem; font-weight: 600;
}

/* ===== App Body: rail | panels | diff ===== */
.app-body {
    display: flex;
    align-items: stretch;
    min-height: 420px;
    max-height: 74vh;
}

/* --- Thumbnail rail --- */
.thumb-rail {
    flex: 0 0 92px;
    background: #f7f8fa;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    padding: 0.7rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}
.thumb-item {
    width: 74px; display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
    cursor: pointer; padding: 0.25rem; border-radius: 0.35rem; border: 2px solid transparent;
}
.thumb-item canvas { width: 100%; height: auto; border: 1px solid #e2e8f0; border-radius: 0.2rem; background: #fff; }
.thumb-num { font-size: 0.7rem; color: #718096; font-weight: 600; }
.thumb-item.active { border-color: #3182ce; background: #ebf8ff; }
.thumb-item.active .thumb-num { color: #2b6cb0; }
.thumb-item:hover { background: #edf2f7; }

/* --- Page panels (side by side) --- */
.compare-panels {
    flex: 1; display: flex; min-width: 0; overflow: auto; background: #e9edf1; position: relative;
}
.compare-panels.single-view { overflow: auto; }
.compare-panel {
    flex: 1; min-width: 0; display: flex; justify-content: center; align-items: flex-start;
    padding: 1.2rem; overflow: auto;
}
.panel-divider { width: 1px; background: #cbd5e0; flex: 0 0 auto; }
.panel-canvas-wrap canvas,
.overlay-canvas-wrap canvas,
.difference-canvas-wrap canvas {
    max-width: 100%; height: auto; box-shadow: 0 1px 6px rgba(0,0,0,0.15); background: #fff;
}
.no-page-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #a0aec0; padding: 3rem 1rem; text-align: center;
}
.no-page-placeholder i { font-size: 2rem; margin-bottom: 0.5rem; }

/* --- Overlay view --- */
.panel-overlay { width: 100%; justify-content: center; }

/* --- Difference view --- */
.panel-difference { width: 100%; justify-content: center; background: #000; }
.difference-canvas-wrap canvas { box-shadow: none; background: #000; }

/* --- Swipe view --- */
.panel-swipe { width: 100%; justify-content: center; padding: 1.2rem; }
.swipe-canvas-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    box-shadow: 0 1px 6px rgba(0,0,0,0.15);
    line-height: 0;
}
.swipe-base canvas { display: block; max-width: 100%; height: auto; }
.swipe-overlay {
    position: absolute; top: 0; left: 50%; height: 100%; overflow: hidden;
}
.swipe-overlay-inner { position: absolute; top: 0; }
.swipe-overlay-inner canvas { display: block; }
.swipe-handle {
    position: absolute; top: 0; height: 100%; width: 3px;
    background: #3182ce; transform: translateX(-50%);
    cursor: ew-resize; display: flex; align-items: center; justify-content: center;
    z-index: 3;
}
.swipe-handle i {
    background: #3182ce; color: #fff; width: 1.8rem; height: 1.8rem;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

/* --- Diff panel --- */
.diff-panel {
    flex: 0 0 260px; background: #fff; border-left: 1px solid #e2e8f0;
    padding: 0.9rem; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.diff-summary { display: flex; gap: 0.4rem; margin-bottom: 0.7rem; flex-wrap: wrap; }
.diff-chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.55rem; border-radius: 1rem; font-size: 0.75rem; font-weight: 700;
}
.diff-added    { background: #f0fff4; color: #2f855a; }
.diff-removed  { background: #fff5f5; color: #c53030; }
.diff-modified { background: #fffaf0; color: #b7791f; }

.diff-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.diff-empty { color: #a0aec0; font-size: 0.88rem; text-align: center; padding: 2.2rem 0.5rem; font-style: italic; }
.diff-empty-success { color: #a0aec0; }

.diff-row {
    display: flex; align-items: flex-start; gap: 0.5rem;
    padding: 0.4rem 0.55rem; border-radius: 0.4rem; font-size: 0.8rem; line-height: 1.4;
}
.diff-tag { font-weight: 800; flex: 0 0 auto; width: 1rem; text-align: center; }
.diff-text { word-break: break-word; }
.diff-text del { color: #c53030; text-decoration: line-through; opacity: 0.85; }
.diff-text ins { color: #2f855a; text-decoration: none; }

.diff-row-added    { background: #f0fff4; color: #22543d; }
.diff-row-added .diff-tag { color: #2f855a; }
.diff-row-removed  { background: #fff5f5; color: #742a2a; }
.diff-row-removed .diff-tag { color: #c53030; }
.diff-row-modified { background: #fffaf0; color: #744210; }
.diff-row-modified .diff-tag { color: #b7791f; }

/* ===== Status text ===== */
.compression-stats {
    background: #f7fafc; padding: 0.5rem 1rem; border-radius: 0.5rem;
    margin-bottom: 1rem; font-size: 0.95rem; color: #4a5568;
}

/* ===== Hidden ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .app-toolbar { justify-content: flex-start; }
    .toolbar-center, .toolbar-right { width: 100%; justify-content: center; }
    .dropdown-panel { right: auto; left: 0; }
    .app-body { flex-direction: column; max-height: none; }
    .thumb-rail {
        flex-direction: row; flex: 0 0 auto; width: 100%;
        border-right: none; border-bottom: 1px solid #e2e8f0;
        overflow-x: auto; overflow-y: hidden;
    }
    .compare-panels { flex-direction: column; }
    .panel-divider { width: 100%; height: 1px; }
    .diff-panel { flex: 0 0 auto; border-left: none; border-top: 1px solid #e2e8f0; max-height: 40vh; }
}