/* Cell color opacity constant - 30% transparency = 70% opacity */
:root {
    --cell-opacity: 0.7;
    --table-font-size: 14px; /* Base font size for table */
    --table-zoom: 1; /* Zoom multiplier (1 = 100%) */
}

/* Section separator for removed/added rows grouping */
.tabulator-row.section-separator {
    border-top: 2px solid #dee2e6;
    margin-top: 2px;
}

.tabulator-row.section-separator:first-child {
    border-top: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    padding: 20px;
    padding-bottom: 60px; /* Space for floating status bar */
    color: #333;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h1 {
    margin-bottom: 30px;
    color: #d10d13;
    font-size: 28px;
}

.controls {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
}

.main-content-wrapper {
    display: block;
}

/* Header slider styles */
.header-threshold-slider {
    width: 100%;
    height: 4px;
    margin: 4px 0 0 0;
    border-radius: 2px;
    background: #dee2e6;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    display: block;
}

.header-threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #d10d13;
    cursor: pointer;
    transition: background 0.2s;
}

.header-threshold-slider::-webkit-slider-thumb:hover {
    background: #a00a0f;
}

.header-threshold-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #d10d13;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.header-threshold-slider::-moz-range-thumb:hover {
    background: #a00a0f;
}

/* Header container for slider (generic) */
.tabulator-col-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Adjust header height to accommodate slider */
.table-container .tabulator-header {
    min-height: 0; /* Increased to fit rotated text + slider */
}


.control-group {
    margin-bottom: 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
    align-items: center;
}

.control-group:last-child {
    margin-bottom: 0;
}

.controls label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #495057;
}

.toggle-label {
    display: flex !important;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0 !important;
}

.toggle-label.hidden {
    display: none !important;
}

.toggle-label input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.toggle-label span {
    user-select: none;
}

/* Toolbar divider in control group */
.control-group .toolbar-divider {
    width: 1px;
    height: 24px;
    background-color: #dee2e6;
    margin: 0 4px;
    flex-shrink: 0;
}

/* Toolbar buttons (icon-only, smaller) */
.toolbar-btn {
    padding: 4px 8px;
    font-size: 16px;
    line-height: 1;
    color: #495057;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
    user-select: none;
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover:not(:disabled) {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.toolbar-btn:active:not(:disabled) {
    transform: translateY(0);
    background-color: #dee2e6;
}

.toolbar-btn:disabled {
    background-color: #f8f9fa;
    color: #adb5bd;
    border-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Action buttons (Undo/Redo) - kept for backward compatibility */
.action-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background-color: #007bff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    user-select: none;
}

.action-btn:hover:not(:disabled) {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.action-btn:active:not(:disabled) {
    transform: translateY(0);
}

.action-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Zoom level indicator */
.zoom-level {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    min-width: 50px;
    justify-content: center;
    height: 32px;
}

/* Apply proportional zoom to table */
.table-container {
    font-size: calc(14px * var(--table-zoom));
    transform: scale(var(--table-zoom));
    transform-origin: top left;
}

/* Adjust container width to compensate for scale transform */
.table-container-wrapper {
    width: calc(100% / var(--table-zoom));
    overflow: visible;
}

/* Apply zoom to all table elements proportionally */
.table-container .tabulator,
.table-container .tabulator-table,
.table-container .tabulator-cell,
.table-container .tabulator-header,
.table-container .tabulator-col,
.table-container .tabulator-col-content,
.table-container .tabulator-row {
    font-size: calc(14px * var(--table-zoom)) !important;
}

/* Scale cell padding proportionally */
.table-container .tabulator-cell {
    padding: calc(4px * var(--table-zoom)) calc(8px * var(--table-zoom)) !important;
}

/* Scale header cell padding proportionally */
.table-container .tabulator-col-content {
    padding: calc(4px * var(--table-zoom)) calc(8px * var(--table-zoom)) !important;
    white-space: normal; /* Allow word wrapping */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto; /* Enable automatic hyphenation for better wrapping */
    overflow: visible;
    text-overflow: clip;
    position: relative;
    text-align: center;
    line-height: 1.2; /* Tighter line height for better wrapping */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end; /* Align content to bottom */
    gap: 4px;
    height: 100%; /* Fill full height */
    min-height: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* === RESULT_* HEADER LAYOUT (text left, slider right, BOTH bottom-aligned) === */

/* Col-content for result_*: horizontal row, items on bottom */
.table-container .tabulator-col[tabulator-field^="result_"] .tabulator-col-content {
    display: flex !important;
    flex-direction: row !important;       /* text left, slider right */
    align-items: flex-end !important;     /* ⬅ align both to bottom of header cell */
    justify-content: center !important;
    gap: 8px !important;
    padding: 0 !important;
    height: 100% !important;
}

/* Wrapper inside col-content */
.table-container .tabulator-col[tabulator-field^="result_"] .tabulator-col-content .header-content {
    display: flex;
	padding: 10px;
    flex-direction: row;
    align-items: anchor-center;   
    justify-content: center;
    width: 100%;
    height: 100%;
    gap: 8px;
}

/* Text column - bottom-aligned */
.table-container .tabulator-col[tabulator-field^="result_"] .tabulator-col-content .header-text-col {
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* ⬅ bottom */
    align-items: center;
    flex: 0;
}

/* Slider column - bottom-aligned too */
.table-container .tabulator-col[tabulator-field^="result_"] .tabulator-col-content .header-slider-col {
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* ⬅ bottom */
    align-items: center;
    flex-shrink: 0;
}

/* Rotate title text for result columns (but not sliders) */
.table-container .tabulator-col[tabulator-field^="result_"] .tabulator-col-content .title-text {
    writing-mode: vertical-rl !important; /* Natural vertical layout */
    transform: rotate(180deg) !important; /* Flip direction */
    max-height: 120px !important; /* Constrain height for wrapping */
    width: auto;
    height: auto;
    white-space: normal !important; /* Allow wrapping */
    overflow-wrap: break-word;
    word-break: break-word;
    display: inline-block;
    line-height: 1.2;
    text-align: center;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

/* Rotate text for old/new columns (existing behavior) */
.table-container .tabulator-col[data-field^="old_"] .tabulator-col-content,
.table-container .tabulator-col[data-field^="new_"] .tabulator-col-content {
    transform: rotate(-90deg);
    transform-origin: center;
    max-width: 150px;
    width: auto;
    height: auto;
}

/* Vertical slider styling - native vertical slider */
.table-container .header-threshold-slider {
    -webkit-appearance: slider-vertical !important; /* Chrome/Safari */
    writing-mode: bt-lr !important;                 /* Firefox */
    width: 10px !important;
    height: 80px !important;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

/* Adjust header height to accommodate vertical text + vertical slider */
.table-container .tabulator-header {
    height: auto !important;
	padding-bottom: 10px
    min-height: 10px; /* Increased to fit wrapped vertical text + vertical slider */
}


.table-container .tabulator-col {
    height: auto;
    /* min-height: 160px; */ /* Match header height */
    /* When text is rotated -90deg, width becomes height, so ensure column width is sufficient */
    min-width: 30px; /* Minimum width for column (becomes height when rotated) */
    padding: 0 !important; /* Remove any padding that might cause bottom space */
    display: flex;
    align-items: flex-end; /* Push col-content to bottom of header cell */
}



/* Scale row height proportionally */
.table-container .tabulator-row {
    min-height: calc(30px * var(--table-zoom)) !important;
}

#thresholdValue {
    font-weight: 600;
    color: #007bff;
}

#threshold {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #dee2e6;
    outline: none;
    -webkit-appearance: none;
}

#threshold::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    transition: background 0.2s;
}

#threshold::-webkit-slider-thumb:hover {
    background: #0056b3;
}

#threshold::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

#threshold::-moz-range-thumb:hover {
    background: #0056b3;
}

.table-container-wrapper {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden; /* Tabulator handles vertical scrolling internally */
    min-width: 0;
    /* Fixed pixel height for optimal virtual DOM performance */
    height: min(600px, calc(100vh - 300px));
    min-height: 400px;
    max-height: 800px;
}

.table-container {
    border-radius: 6px;
    border: 1px solid #dee2e6;
    height: 100%; /* Fill parent container */
    display: flex;
    flex-direction: column;
}

/* Ensure dataTable container has fixed height for virtual DOM */
#dataTable {
    height: 100%;
    flex: 1;
    min-height: 0; /* Important for flex children */
}

/* Tabulator row styling */
.tabulator-row {
    transition: background-color 0.2s;
    cursor: context-menu;
}

.tabulator-row:hover {
    background-color: #f8f9fa !important;
}

.tabulator-row.auto-accepted {
    background-color: rgba(212, 237, 218, var(--cell-opacity)) !important;
}

.tabulator-row.manual-accepted {
    background-color: rgba(207, 226, 255, var(--cell-opacity)) !important;
}

.tabulator-row.pending {
    background-color: rgba(255, 255, 255, var(--cell-opacity)) !important;
}

.tabulator-row.approved {
    background-color: rgba(209, 236, 241, var(--cell-opacity)) !important;
}

.tabulator-row.approved:hover {
    background-color: rgba(190, 229, 235, var(--cell-opacity)) !important;
}

.tabulator-row.skipped {
    background-color: rgba(226, 227, 229, var(--cell-opacity)) !important;
}

.tabulator-row.skipped:hover {
    background-color: rgba(214, 216, 219, var(--cell-opacity)) !important;
}

/* Red background for removed rows */
.tabulator-row.removed {
    background-color: rgba(220, 53, 69, var(--cell-opacity)) !important;
}

.tabulator-row.removed:hover {
    background-color: rgba(200, 35, 51, var(--cell-opacity)) !important;
}

.tabulator-row.removed .tabulator-cell {
    color: #ffffff !important;
}

/* Green background for added rows */
.tabulator-row.added {
    background-color: rgba(40, 167, 69, var(--cell-opacity)) !important;
}

.tabulator-row.added:hover {
    background-color: rgba(33, 136, 56, var(--cell-opacity)) !important;
}

.tabulator-row.added .tabulator-cell {
    color: #ffffff !important;
}

/* Auto-accepted removed rows (red with slightly lighter shade) */
.tabulator-row.removed.auto-accepted {
    background-color: rgba(228, 96, 109, var(--cell-opacity)) !important;
}

.tabulator-row.removed.auto-accepted:hover {
    background-color: rgba(216, 69, 85, var(--cell-opacity)) !important;
}

.tabulator-row.removed.auto-accepted .tabulator-cell {
    color: #ffffff !important;
}

/* Auto-accepted added rows (green with slightly darker shade) */
.tabulator-row.added.auto-accepted {
    background-color: rgba(52, 206, 87, var(--cell-opacity)) !important;
}

.tabulator-row.added.auto-accepted:hover {
    background-color: rgba(40, 167, 69, var(--cell-opacity)) !important;
}

.tabulator-row.added.auto-accepted .tabulator-cell {
    color: #ffffff !important;
}

/* Vivid blue highlighted selected rows */
.tabulator-row.tabulator-selected {
    background-color: #4da6ff !important;
}

.tabulator-row.tabulator-selected:hover {
    background-color: #3399ff !important;
}

.tabulator-row.tabulator-selected .tabulator-cell {
    border-color: #1a8cff !important;
    color: #ffffff !important;
    font-weight: 500;
}

.tabulator-row.auto-accepted:hover {
    background-color: rgba(195, 230, 203, var(--cell-opacity)) !important;
}

.tabulator-row.manual-accepted:hover {
    background-color: rgba(184, 212, 255, var(--cell-opacity)) !important;
}

/* Orange background for cells that don't match threshold */
.tabulator-cell.threshold-not-met {
    background-color: rgba(255, 193, 7, var(--cell-opacity)) !important;
}

.tabulator-cell.threshold-not-met:hover {
    background-color: rgba(255, 179, 0, var(--cell-opacity)) !important;
}

/* Green background for manually copied cells */
.tabulator-cell.manually-copied {
    background-color: rgba(40, 167, 69, var(--cell-opacity)) !important;
}

.tabulator-cell.manually-copied:hover {
    background-color: rgba(33, 136, 56, var(--cell-opacity)) !important;
}



.status {
    font-weight: 500;
}

.status.auto {
    color: #155724;
}

.status.manual {
    color: #004085;
}

.status.pending {
    color: #856404;
}

.context-menu {
    display: none;
    position: fixed;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1200;
    min-width: 180px;
    overflow: hidden;
}

.context-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

.context-menu-item:hover {
    background-color: #f8f9fa;
}

.context-menu-divider {
    height: 1px;
    background-color: #dee2e6;
    margin: 4px 0;
}

.context-menu-item:not(:last-child) {
    border-bottom: 1px solid #e9ecef;
}

/* Number formatting */
.number {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* Delta Tooltip */
.delta-tooltip {
    display: none;
    position: absolute;
    background: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 10000;
    white-space: pre-line;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Status Bar */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #ffffff;
    border-top: 2px solid #dee2e6;
    padding: 12px 20px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    font-size: 14px;
    color: #495057;
}

.status-bar #statusBarContent {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.status-bar .stat-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 4px;
    background-color: #f8f9fa;
}

.status-bar .stat-label {
    font-weight: 500;
    color: #6c757d;
}

.status-bar .stat-value {
    font-weight: 600;
    color: #212529;
}

/* Color coding for status items */
.status-bar .stat-total {
    background-color: #e9ecef;
}

.status-bar .stat-total .stat-value {
    color: #495057;
}

.status-bar .stat-pending {
    background-color: rgba(255, 193, 7, 0.2);
}

.status-bar .stat-pending .stat-value {
    color: #856404;
}

.status-bar .stat-removed {
    background-color: rgba(220, 53, 69, 0.2);
}

.status-bar .stat-removed .stat-value {
    color: #721c24;
}

.status-bar .stat-added {
    background-color: rgba(40, 167, 69, 0.2);
}

.status-bar .stat-added .stat-value {
    color: #155724;
}

.status-bar .stat-resolved {
    background-color: rgba(0, 123, 255, 0.2);
}

.status-bar .stat-resolved .stat-value {
    color: #004085;
}

.status-bar .stat-progress {
    background-color: rgba(23, 162, 184, 0.2);
}

.status-bar .stat-progress .stat-value {
    color: #0c5460;
}

.status-bar .stat-commit-section {
    display: flex;
    align-items: center;
    margin-left: auto;
    padding-left: 20px;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
}

.status-bar .commit-button:hover {
    background: #229954 !important;
}

.status-bar .commit-button:disabled {
    background: #95a5a6 !important;
    cursor: not-allowed;
    opacity: 0.6;
}

.delta-tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px 5px 0;
    border-style: solid;
    border-color: #333 transparent transparent;
}

/* Breadcrumbs styling */
.breadcrumbs {
    font-size: 14px;
}

.breadcrumbs a {
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs span:last-child {
    color: #6c757d;
}

/* Top info panel toggle functionality */
.top-info-panel {
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-bottom 0.3s ease, padding-bottom 0.3s ease;
    overflow: hidden;
    max-height: 2000px; /* Large enough to accommodate all content */
    opacity: 1;
}

/* Hidden state - collapses the top info panel */
body.info-hidden .top-info-panel,
.compare-page.info-hidden .top-info-panel {
    max-height: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

/* Ensure smooth transition when toggling */
body.info-hidden .controls,
.compare-page.info-hidden .controls {
    margin-top: 0;
    margin-bottom: 10px;
}

/* Hide breadcrumbs in fullscreen/info-hidden mode */
body.info-hidden .breadcrumbs {
    display: none !important;
}

/* Tighten spacing above the toolbar when info is hidden */
body.info-hidden #comparePage {
    padding-top: 8px;
}