/* ── OCR overlay ──────────────────────────────────────────────── */
#ocrOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
}

#ocrOverlay.active { display: flex; }

.ocr-spinner { width: 3rem; height: 3rem; }

.ocr-overlay-label {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── Status dots ──────────────────────────────────────────────── */
.file-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-validated {
    background-color: #28a745;
}

.dot-suspect {
    background-color: #ffc107;
}

.dot-unprocessed {
    background-color: #6c757d;
}

/* ── 3-pane shell ─────────────────────────────────────────────── */
.kocr-shell {
    display: grid;
    grid-template-columns: 220px 4px 1fr 4px 420px;
    height: calc(100vh - 56px); /* 56px = fixed navbar */
    overflow: hidden;
}

.kocr-pane {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    min-width: 100px;
}

.kocr-pane-left  { min-width: 140px; border-right: 1px solid #dee2e6; }
.kocr-pane-center { min-width: 200px; background: #e9ecef; }
.kocr-pane-right  { min-width: 200px; border-left: 1px solid #dee2e6; }

/* ── Splitters ────────────────────────────────────────────────── */
.splitter {
    width: 4px;
    background: #ced4da;
    cursor: col-resize;
    transition: background 0.15s;
    flex-shrink: 0;
    z-index: 10;
}
.splitter:hover, .splitter.dragging { background: #0d6efd; }

/* ── File list ────────────────────────────────────────────────── */
/* ── Shared panel header styles ───────────────────────────────── */
.kocr-panel-header {
    flex-shrink: 0;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 8px;
    user-select: none;
}

.kocr-file-list-header {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.kocr-file-items {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.kocr-file-list-footer {
    flex-shrink: 0;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.pg-size-row { display: flex; align-items: center; gap: 4px; }
.pg-size-label { font-size: 11px; color: #6c757d; }
.pg-size-select { width: auto; font-size: 11px; }
.pg-nav-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.pg-label { flex: 1; text-align: center; color: #6c757d; font-size: 11px; }

.file-list-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    gap: 6px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #212529;
}
.file-list-item:hover   { background: #e9ecef; }
.file-list-item.active  { background: #cfe2ff; }

/* ── Document viewer ──────────────────────────────────────────── */
.viewer-toolbar {
    gap: 6px;
}

.viewer-btn {
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid #0d6efd;
    border-radius: 4px;
    background: #fff;
    color: #0d6efd;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.viewer-btn:hover { background: #0d6efd; color: #fff; }
.viewer-btn-fit   { font-size: 12px; font-weight: 500; padding: 4px 8px; }

.viewer-zoom-label {
    font-size: 12px;
    color: #6c757d;
    min-width: 42px;
    text-align: center;
    font-weight: 500;
}

.viewer-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    background: #2b2b2b;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.viewer-page-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

.viewer-page-label {
    font-size: 11px;
    color: #bbb;
    padding: 2px 4px 4px;
    align-self: flex-start;
    user-select: none;
}

.viewer-img-wrap {
    position: relative;
    display: block;
    /* width is set inline as zoom % of the scroll container */
}

.viewer-page-img {
    display: block;
    width: 100%;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    background: #fff;
}

.viewer-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #6c757d;
    font-size: 13px;
    font-style: italic;
    user-select: none;
    min-height: 120px;
}

/* ── Invoice panel ────────────────────────────────────────────── */
.kocr-invoice-header {
    padding: 0 8px;
}

.kocr-invoice-header .nav-tabs {
    flex: 1;
    border-bottom: none;
    margin: 0;
}
.kocr-invoice-header .nav-tabs .nav-link {
    padding: 8px 12px;
    color: #6c757d;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-bottom: 2px solid transparent;
    transition: color 0.12s, border-color 0.12s;
}
.kocr-invoice-header .nav-tabs .nav-link:hover {
    color: #212529;
    border-bottom-color: #dee2e6;
}
.kocr-invoice-header .nav-tabs .nav-link.active {
    color: #0d6efd;
    border-bottom-color: #0d6efd;
    background-color: transparent;
}

.validation-status-label {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 500;
    padding: 0 10px;
    white-space: nowrap;
    margin-left: auto;
}

.validation-status-label.is-validated    { color: #28a745; }
.validation-status-label.is-not-validated { color: #dc3545; }

.kocr-invoice-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* ── Invoice field table ──────────────────────────────────────── */
.invoice-field-table td:first-child {
    font-weight: 600;
    white-space: nowrap;
    width: 140px;
}

/* UNUSED: .confidence-low      { background-color: #fff3cd; } */
/* UNUSED: .confidence-very-low { background-color: #f8d7da; } */

/* ── Bbox SVG overlay ─────────────────────────────────────────── */
.viewer-bbox-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: visible;
}

.viewer-bbox {
    fill: transparent;
    vector-effect: non-scaling-stroke;
    stroke-width: 2;
    opacity: 0.35;
    transition: opacity 0.15s;
}

.bbox-ok       { stroke: #50c878; }
.bbox-suspect  { stroke: #e05050; opacity: 0.55; }
.bbox-selected { stroke: #ffaa00; fill: rgba(255,170,0,0.18); opacity: 1; stroke-width: 4; filter: drop-shadow(0 0 2px rgba(255,170,0,0.3)); }

/* ── Invoice field rows (clickable) ───────────────────────────── */
.inv-field-row { cursor: pointer; }
.inv-field-row:hover > td,
.inv-field-row:hover > th { background-color: #e9ecef !important; transition: background-color 0.12s; }
.inv-field-row.inv-field-selected > td,
.inv-field-row.inv-field-selected > th { background-color: #fff3cd !important; }

/* ── Validation error highlighting ───────────────────────────── */
.inv-suspect-row > td,
.inv-suspect-row > th { background-color: #fff0f0 !important; }
.inv-suspect-row.inv-field-selected > td,
.inv-suspect-row.inv-field-selected > th { background-color: #ffe4c8 !important; }
.inv-suspect-input.form-control { border-color: #e08080 !important; background-color: #fff8f8 !important; }
.inv-suspect-input.form-control:focus { border-color: #c04040 !important; box-shadow: 0 0 0 0.2rem rgba(192,64,64,0.2) !important; }

/* ── Validation custom tooltip ────────────────────────────────── */
.kocr-vtip {
    position: fixed;
    z-index: 10000;
    background: #fff;
    border: 1px solid #bbb;
    border-radius: 4px;
    padding: 6px 9px;
    font-size: 12px;
    line-height: 1.5;
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
    max-width: 320px;
    pointer-events: none;
    white-space: pre-wrap;
    word-break: break-word;
}
.kocr-vtip-value  { color: #222; }
.kocr-vtip-error  { color: #c0392b; font-weight: 500; }

/* ── Line-item table: fixed + resizable columns ───────────────── */
.li-table-wrap { overflow-x: auto; }
.li-table { table-layout: fixed; width: 100%; }
.li-table td, .li-table th { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.li-table td input.inv-field { width: 100%; }

/* Line-item input highlighting when row is selected */
.inv-field-row.inv-field-selected input.inv-field { background-color: #fff3cd !important; }
.inv-suspect-row.inv-field-selected input.inv-field { background-color: #ffe4c8 !important; }

.li-th { position: relative; white-space: nowrap; overflow: hidden; user-select: none; }

/* Drag handle — sits at the right edge of each resizable header cell */
.li-col-drag {
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 1;
}
.li-col-drag:hover, .li-col-drag.dragging { background: rgba(13,110,253,0.5); }

/* ── Sidebar nav ──────────────────────────────────────────────── */
/* UNUSED: Sidebar styling - may be for future use */
/* 
.sidebar .nav-link {
    color: #495057;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
}
.sidebar .nav-link:hover {
    background-color: #e9ecef;
    color: #212529;
}
*/

/* ── Navbar nested dropdown ───────────────────────────────────── */
.dropdown-submenu { position: relative; }
.dropdown-submenu > .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -2px;
    display: none;
}
.dropdown-submenu:hover > .dropdown-menu,
.dropdown-submenu:focus-within > .dropdown-menu { display: block; }
.dropdown-submenu > .dropdown-item::after {
    content: ' ▶';
    float: right;
    font-size: 0.75em;
    opacity: 0.7;
}

html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 16px; } }

.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.form-floating > .form-control::placeholder          { color: var(--bs-secondary-color); text-align: end; }
.form-floating > .form-control:focus::placeholder    { text-align: start; }
