:root {
    --diff-changed: #fd7e14;
    --diff-new: #198754;
    --diff-deleted: #dc3545;
    --diff-moved: #0dcaf0;
    --diff-soft-deleted: #6f42c1;
}

.compare-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

.compare-toolbar {
    z-index: 1030;
    flex-shrink: 0;
}

.compare-goto-shortcut-hint {
    flex-shrink: 0;
    white-space: nowrap;
    line-height: 1.2;
    user-select: none;
}

.compare-goto-shortcut-hint kbd {
    font-size: 0.75em;
    padding: 0.15em 0.4em;
}

.compare-goto-modal {
    position: fixed;
    inset: 0;
    z-index: 1055;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.compare-goto-modal.d-none {
    display: none;
}

.compare-goto-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.compare-goto-modal-dialog {
    position: relative;
    width: min(100%, 22rem);
}

.compare-goto-modal-panel {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.5rem;
    box-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.18);
}

.compare-goto-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem 0.5rem;
}

.compare-goto-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

.compare-goto-modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.35rem 1rem 0.85rem;
}

.compare-goto-modal-fields {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.compare-goto-side-toggle {
    align-self: flex-start;
}

.compare-goto-input {
    width: 100%;
}

.compare-goto-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.65rem 1rem 0.85rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.compare-goto-message {
    line-height: 1.35;
}

body.compare-goto-modal-open {
    overflow: hidden;
}

.compare-table-view tr.compare-row-goto-highlight > td {
    animation: compare-row-goto-flash 2.5s ease-out;
}

@keyframes compare-row-goto-flash {
    0%,
    15% {
        background-color: #fff3cd;
    }
    100% {
        background-color: transparent;
    }
}

.compare-summary-groups {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.compare-summary-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
}

.compare-summary-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #868e96;
    min-width: 7.5rem;
    flex-shrink: 0;
}

.compare-summary-label-text.has-summary-tip {
    cursor: help;
    text-decoration: underline dotted #adb5bd;
    text-underline-offset: 0.15em;
}

.compare-summary-badges .badge[data-bs-toggle="tooltip"] {
    cursor: help;
}

.compare-summary-issues {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    margin-top: 0.15rem;
    padding-left: 7.5rem;
    font-size: 0.78rem;
    color: #6c757d;
}

.compare-summary-issues.active {
    color: #212529;
    font-weight: 500;
}

.compare-summary-issues .compare-issues-show {
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0;
}

.compare-summary-issues.active .compare-issues-show {
    color: #0d6efd;
}

.compare-summary-badges .badge {
    margin-right: 0.15rem;
}

.compare-summary .badge,
.compare-summary-badges .badge {
    margin-right: 0.35rem;
}

.summary-changed { background-color: var(--diff-changed) !important; color: #fff !important; }
.summary-new { background-color: var(--diff-new) !important; color: #fff !important; }
.summary-deleted { background-color: var(--diff-deleted) !important; color: #fff !important; }
.summary-moved { background-color: var(--diff-moved) !important; color: #000 !important; }
.summary-soft-deleted { background-color: var(--diff-soft-deleted) !important; color: #fff !important; }
.summary-obsolete { background-color: var(--diff-soft-deleted) !important; color: #fff !important; }
.summary-unchanged { background-color: #6c757d !important; color: #fff !important; }
.summary-empty { background-color: #dc3545 !important; color: #fff !important; }

.compare-summary-empty-note {
    font-size: 0.72rem;
    color: #b02a37;
    font-weight: 500;
}

.compare-summary .badge,
.compare-table-view td[class*="col-status-"] .badge {
    border: none;
}

.compare-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    background: #fff;
}

table.compare-table-view {
    width: 100%;
    table-layout: fixed;
    font-size: 0.875rem;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.compare-table-view .col-w-status {
    width: 5%;
}

.compare-table-view .col-w-change-info {
    width: 5%;
}

.compare-table-view.has-change-info .col-w-content {
    width: 37.5%;
}

.compare-table-view:not(.has-change-info) .col-w-content {
    width: 45%;
}

.compare-table-view > thead th:first-child,
.compare-table-view > thead th:last-child {
    font-size: 0.7rem;
    font-weight: 500;
    color: #868e96;
    white-space: nowrap;
}

.compare-table-view td.col-status {
    font-size: 0.7rem;
    font-weight: 500;
    vertical-align: top;
    white-space: normal;
}

.compare-table-view td.col-status.has-content-change-tooltip {
    cursor: help;
}

.compare-table-view td.col-status .col-status-main {
    white-space: nowrap;
}

.compare-table-view td.col-status .col-status-number {
    margin-top: 0.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.2;
    color: color-mix(in srgb, currentColor 72%, transparent);
    text-transform: none;
    letter-spacing: normal;
}

.compare-table-view td.col-status .col-status-number-moved {
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.compare-table-view td.col-status-changed {
    background-color: color-mix(in srgb, var(--diff-changed) 18%, #fff);
    color: color-mix(in srgb, var(--diff-changed) 72%, #000);
}
.compare-table-view td.col-status-new {
    background-color: color-mix(in srgb, var(--diff-new) 18%, #fff);
    color: color-mix(in srgb, var(--diff-new) 72%, #000);
}
.compare-table-view td.col-status-deleted {
    background-color: color-mix(in srgb, var(--diff-deleted) 18%, #fff);
    color: color-mix(in srgb, var(--diff-deleted) 72%, #000);
}
.compare-table-view td.col-status-moved {
    background-color: color-mix(in srgb, var(--diff-moved) 22%, #fff);
    color: color-mix(in srgb, var(--diff-moved) 65%, #000);
}
.compare-table-view td.col-status-soft-deleted {
    background-color: color-mix(in srgb, var(--diff-soft-deleted) 18%, #fff);
    color: color-mix(in srgb, var(--diff-soft-deleted) 72%, #000);
}
.compare-table-view td.col-status-unchanged {
    background-color: color-mix(in srgb, #6c757d 14%, #fff);
    color: color-mix(in srgb, #6c757d 70%, #000);
}

.compare-table-view td.col-status-changed .badge,
.compare-table-view td.col-status-new .badge,
.compare-table-view td.col-status-deleted .badge,
.compare-table-view td.col-status-moved .badge,
.compare-table-view td.col-status-soft-deleted .badge,
.compare-table-view td.col-status-unchanged .badge {
    background-color: transparent !important;
    color: inherit !important;
    padding-left: 0;
    padding-right: 0;
    font-size: inherit;
    font-weight: inherit;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.compare-table-view td.col-status-changed .badge.summary-moved,
.compare-table-view td.col-status-new .badge.summary-moved,
.compare-table-view td.col-status-deleted .badge.summary-moved,
.compare-table-view td.col-status-soft-deleted .badge.summary-moved,
.compare-table-view td.col-status-unchanged .badge.summary-moved {
    background-color: color-mix(in srgb, var(--diff-moved) 28%, transparent) !important;
    color: color-mix(in srgb, var(--diff-moved) 70%, #000) !important;
    padding: 0.1em 0.35em;
    border-radius: 0.2rem;
}

.compare-table-view td.col-status-moved .badge.summary-changed {
    background-color: color-mix(in srgb, var(--diff-changed) 28%, transparent) !important;
    color: color-mix(in srgb, var(--diff-changed) 72%, #000) !important;
    padding: 0.1em 0.35em;
    border-radius: 0.2rem;
}

.compare-cell-empty {
    background-color: #f8f9fa;
}

.row-chapter {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.35;
    margin-bottom: 0.35rem;
}

.row-chapter-empty,
.row-text-empty {
    min-height: 1.35em;
}

.row-chapter-empty {
    margin-bottom: 0.35rem;
}

.row-chapter p,
.row-text p {
    margin-bottom: 0.35rem;
}

.row-chapter p:last-child,
.row-text p:last-child {
    margin-bottom: 0;
}

.row-text {
    font-size: 0.9rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.col-content-body {
    --depth-step: 18px;
    --depth: 1;
    padding-left: calc((max(var(--depth, 1), 1) - 1) * var(--depth-step));
    max-width: 100%;
}

.row-chapter .text-muted,
.row-text .text-muted {
    font-weight: 400;
}

.diff-changed,
.diff-cell-changed {
    background-color: color-mix(in srgb, var(--diff-changed) 35%, transparent);
}

.diff-new,
.diff-cell-new {
    background-color: color-mix(in srgb, var(--diff-new) 35%, transparent);
    white-space: pre-wrap;
}

.diff-deleted,
.diff-cell-deleted {
    background-color: color-mix(in srgb, var(--diff-deleted) 25%, transparent);
    white-space: pre-wrap;
}

.compare-table td .diff-new,
.compare-table div.diff-new,
.compare-table td p.diff-new,
.compare-table td div.diff-new {
    background-color: color-mix(in srgb, var(--diff-new) 35%, transparent);
}

.compare-table td .diff-deleted,
.compare-table div.diff-deleted,
.compare-table td p.diff-deleted,
.compare-table td div.diff-deleted {
    background-color: color-mix(in srgb, var(--diff-deleted) 25%, transparent);
}

.compare-table td .diff-changed {
    background-color: color-mix(in srgb, var(--diff-changed) 35%, transparent);
}

.diff-cell-unchanged {
    background-color: transparent;
}

.diff-cell-empty {
    background-color: #fff;
    color: #212529;
}

.diff-table-structure-note,
.diff-image-note {
    font-size: 0.75rem;
    color: #856404;
    background: #fff3cd;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    margin-bottom: 0.35rem;
}

.compare-table {
    width: auto;
    max-width: 100%;
    table-layout: auto;
    font-size: inherit;
    margin-top: 0.35rem;
}

td.col-content {
    max-width: 0;
    vertical-align: top;
}

.row-text:has(table),
.row-chapter:has(table) {
    overflow-x: auto;
    max-width: 100%;
}

.col-content table {
    width: auto;
    max-width: none;
    table-layout: auto;
    margin-bottom: 0;
}

.col-content .compare-table th,
.col-content .compare-table td,
.col-content table th,
.col-content table td {
    color: #212529;
    font-size: inherit;
    overflow-wrap: normal;
    word-break: normal;
    white-space: normal;
    vertical-align: top;
}

.col-content .compare-table thead th,
.col-content table thead th {
    color: #212529;
    font-weight: 600;
    font-size: inherit;
    white-space: normal;
}

.col-content table th p,
.col-content table td p,
.col-content .compare-table th p,
.col-content .compare-table td p {
    margin-bottom: 0.35rem;
}

.col-content table th p:last-child,
.col-content table td p:last-child,
.col-content .compare-table th p:last-child,
.col-content .compare-table td p:last-child {
    margin-bottom: 0;
}

.compare-table td,
.compare-table th {
    vertical-align: top;
}

.text-diff-ws {
    opacity: 0.5;
}

.diff-deleted .text-diff-ws,
.diff-new .text-diff-ws,
.diff-deleted.text-diff-ws,
.diff-new.text-diff-ws {
    opacity: 1;
    font-weight: 700;
}

.diff-change-info {
    font-weight: 600;
    display: inline-block;
    padding: 0.12em 0.4em;
    border-radius: 0.2em;
    white-space: normal;
}

.reqif-image-block {
    display: block;
    margin: 0.5rem 0;
    max-width: 100%;
}

.reqif-image-block .reqif-image {
    display: block;
    max-width: 100%;
    height: auto;
    box-sizing: border-box;
    border: 2px solid transparent;
    border-radius: 0.25rem;
}

.reqif-image-block.diff-image-deleted .reqif-image {
    border-color: var(--diff-deleted);
}

.reqif-image-block.diff-image-new .reqif-image {
    border-color: var(--diff-new);
}

.reqif-image-block.diff-image-changed .reqif-image {
    border-color: var(--diff-changed);
}

.compare-table-view .col-change-info .col-change-info-value {
    margin-bottom: 0.15rem;
}

.compare-table-view .col-change-info .col-change-info-error {
    margin-top: 0.2rem;
    font-size: 0.62rem;
    font-weight: 500;
    line-height: 1.25;
    color: #b02a37;
}

.compare-table-view .col-change-info {
    vertical-align: top;
    font-size: 0.85rem;
    max-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 992px) {
    .compare-page {
        height: auto;
        overflow: visible;
    }

    .compare-table-wrap {
        flex: none;
        min-height: 400px;
    }
}
