/* Side-by-Side Comparison Modal Styles */

#sideBySideModal .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: none;
    padding: 1rem 1.5rem;
}

#sideBySideModal .modal-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#sideBySideModal .btn-close {
    filter: brightness(0) invert(1);
}

#sideBySideModal .header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
    margin-right: 1rem;
}

#sideBySideModal .page-controls {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
}

#sideBySideModal .page-info {
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
}

#sideBySideModal .zoom-controls {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
}

#sideBySideModal .zoom-info {
    color: white;
    font-weight: 500;
    min-width: 50px;
    text-align: center;
    font-size: 0.9rem;
}

#sideBySideModal .btn-outline-secondary {
    background: white;
    border-color: white;
    color: #667eea;
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
}

#sideBySideModal .btn-outline-secondary:hover {
    background: #f8f9fa;
    border-color: #f8f9fa;
    color: #667eea;
}

#sideBySideModal .btn-outline-secondary:disabled {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(102, 126, 234, 0.5);
    cursor: not-allowed;
}

.comparison-container {
    display: flex;
    height: calc(100vh - 65px);
    background: #f5f7fa;
}

.comparison-container.resizing {
    cursor: col-resize;
    user-select: none;
}

.comparison-container.resizing .panel-content {
    pointer-events: none;
}

.comparison-panel {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
    min-width: 0;
    overflow: hidden;
    transition: flex 0.1s ease-out;
}

.panel-header {
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    padding: 0.75rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.panel-header h6 {
    margin: 0;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.panel-header h6::after {
    content: "↕ vertical sync";
    font-size: 0.75rem;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    margin-left: auto;
    font-weight: 500;
}

.panel-content {
    flex: 1;
    overflow: auto; /* Enable both horizontal and vertical scrolling */
    position: relative;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.panel-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.panel-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.divider {
    width: 8px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    cursor: col-resize;
    position: relative;
    transition: width 0.2s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.divider::before {
    content: "⋮";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: #667eea;
    font-size: 1.5rem;
    font-weight: bold;
    width: 24px;
    height: 48px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.3s ease;
    line-height: 0.5;
}

.divider:hover::before {
    opacity: 1;
}

.divider:hover {
    width: 12px;
    background: linear-gradient(180deg, #764ba2 0%, #667eea 100%);
}

.divider:active {
    width: 12px;
    background: #667eea;
}

/* Loading indicators */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
}

.loading-indicator p {
    margin: 0;
    font-size: 0.9rem;
}

/* Error state */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

.error-state h5 {
    color: #dc3545;
    margin-bottom: 0.5rem;
}

.error-state p {
    color: #6c757d;
    margin: 0;
}

/* PDF Canvas */
#pdf-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

#pdf-canvas {
    display: block;
    margin: 0 auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    max-width: 100%;
    height: auto;
}

/* Image container */
.image-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    box-sizing: border-box;
}

.image-container img {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    max-width: 100%;
    height: auto;
}

/* OCR render area */
.ocr-render-area {
    background: white;
    font-size: 1rem;
    line-height: 1.6;
    color: #212529;
    width: 100%;
    box-sizing: border-box;
}

/* Custom scrollbar for OCR area */
.ocr-render-area::-webkit-scrollbar {
    width: 8px;
}

.ocr-render-area::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.ocr-render-area::-webkit-scrollbar-thumb {
    background: #28a745;
    border-radius: 10px;
}

.ocr-render-area::-webkit-scrollbar-thumb:hover {
    background: #218838;
}

.ocr-content-wrapper {
    /* Content now scales with aspect-ratio, no need for max-content */
    width: 100%;
    padding: 1.5rem;
    background: white;
    box-sizing: border-box;
}

.ocr-content-wrapper * {
    box-sizing: border-box;
}

/* Only constrain images and media */
.ocr-content-wrapper img,
.ocr-content-wrapper video,
.ocr-content-wrapper iframe {
    max-width: 100%;
}

.ocr-content-wrapper h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: #1a237e;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.ocr-content-wrapper h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    color: #1976d2;
}

.ocr-content-wrapper h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #424242;
}

.ocr-content-wrapper p {
    margin-bottom: 1rem;
    text-align: justify;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.ocr-content-wrapper ul,
.ocr-content-wrapper ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.ocr-content-wrapper li {
    margin-bottom: 0.5rem;
}

.ocr-content-wrapper table {
    width: 100%;
    max-width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    table-layout: auto;
    font-size: 0.9rem;
}

.ocr-content-wrapper table th,
.ocr-content-wrapper table td {
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    text-align: left;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 0;
    overflow: hidden;
}

.ocr-content-wrapper table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.ocr-content-wrapper table tr:hover {
    background: #f8f9fa;
}

.ocr-content-wrapper .formula {
    background: #f5f5f5;
    border-radius: 4px;
    padding: 1rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: 'Latin Modern Math', 'Cambria Math', serif;
}

.ocr-content-wrapper pre {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    max-width: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ocr-content-wrapper code {
    background: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    word-wrap: break-word;
}

.ocr-content-wrapper img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
}

.ocr-content-wrapper iframe,
.ocr-content-wrapper embed,
.ocr-content-wrapper object,
.ocr-content-wrapper video {
    max-width: 100%;
}

.no-data {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .comparison-container {
        flex-direction: column;
    }

    .divider {
        width: 100%;
        height: 3px;
        cursor: row-resize;
    }

    .comparison-panel {
        height: 50vh;
    }

    #sideBySideModal .header-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #sideBySideModal .page-controls,
    #sideBySideModal .zoom-controls {
        font-size: 0.8rem;
    }
}

/* Original panel specific styling */
.original-panel .panel-header {
    border-left: 4px solid #667eea;
}

/* OCR panel specific styling */
.ocr-panel .panel-header {
    border-left: 4px solid #28a745;
}

/* Sync scroll indicator (optional visual feedback) */
.panel-content.syncing {
    box-shadow: inset 0 0 10px rgba(102, 126, 234, 0.2);
    transition: box-shadow 0.3s ease;
}

/* Keyboard shortcuts panel */
.shortcuts-panel {
    position: absolute;
    top: 65px;
    right: 20px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.shortcuts-content {
    padding: 1rem;
    min-width: 250px;
}

.shortcuts-content h6 {
    margin: 0 0 0.75rem 0;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.shortcuts-grid {
    display: grid;
    gap: 0.5rem;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.shortcut-item kbd {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    min-width: 28px;
    text-align: center;
}

.shortcut-item span {
    color: #6c757d;
}
