/**
 * Diff Modal Styles for JSONBlob
 * Custom styles for diff engine modals and components
 */

/* Version Selection Modal */
#versionSelectionModal .modal-body {
    padding: 20px;
}

#versionSelectionModal .form-control {
    margin-bottom: 10px;
}

#versionSelectionModal label {
    font-weight: bold;
    margin-bottom: 5px;
    display: block;
}

/* Diff Result Modal */
#diffResultModal .modal-dialog {
    width: 98%;
    max-width: 1800px;
}

#diffResultModal .modal-body {
    padding: 0;
    max-height: 80vh;
    overflow-y: auto;
}

/* Diff Wrapper */
.diff-wrapper {
    width: 100%;
    height: 100%;
}

.diff-header {
    display: flex;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
    height: 40px;
}

.diff-left-header,
.diff-right-header {
    flex: 1;
    padding: 10px 15px;
    font-weight: bold;
    text-align: center;
    border-right: 1px solid #ddd;
}

.diff-right-header {
    border-right: none;
}

.diff-content {
    min-height: 400px;
    background: white;
}

/* Simple Diff Fallback */
.simple-diff {
    display: flex;
    height: 500px;
    min-height: 400px;
}

.diff-side {
    flex: 1;
    padding: 15px;
    border-right: 1px solid #ddd;
    overflow: auto;
}

.diff-side:last-child {
    border-right: none;
}

.diff-side h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e1e1e8;
}

.diff-side pre,
.json-display {
    background: #f8f8f8;
    border: 1px solid #e1e1e8;
    border-radius: 4px;
    padding: 12px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow: auto;
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
}

/* Identical versions display */
.diff-identical {
    text-align: center;
    padding: 40px;
    background: #f0f8ff;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    margin: 20px;
}

.diff-identical h4 {
    color: #4CAF50;
    font-size: 20px;
    margin-bottom: 10px;
}

.diff-identical p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* Diff stats */
.diff-stats {
    background: #f5f5f5;
    padding: 10px;
    border-top: 1px solid #ddd;
    text-align: center;
    font-family: monospace;
}

.diff-stats small {
    color: #666;
    font-size: 11px;
}

/* Error display */
.diff-error {
    background: #ffebee;
    color: #c62828;
    padding: 20px;
    margin: 20px;
    border: 1px solid #ef5350;
    border-radius: 4px;
    text-align: center;
}

/* Compare Button Styles */
#compareBtn {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: white;
}

#compareBtn:hover {
    background-color: #138496;
    border-color: #117a8b;
}

/* Auto-close Popup */
.diff-popup {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Error Modal */
#diffErrorModal .modal-body {
    text-align: center;
    padding: 30px;
}

#diffErrorModal .modal-body p {
    font-size: 16px;
    margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #diffResultModal .modal-dialog {
        width: 95%;
        margin: 10px auto;
    }
    
    .diff-header {
        flex-direction: column;
        height: auto;
    }
    
    .diff-left-header,
    .diff-right-header {
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    
    .diff-right-header {
        border-bottom: none;
    }
    
    .simple-diff {
        flex-direction: column;
        height: auto;
    }
    
    .diff-side {
        border-right: none;
        border-bottom: 1px solid #ddd;
        max-height: 300px;
    }
    
    .diff-side:last-child {
        border-bottom: none;
    }
}

/* Override Bootstrap modal for extra large */
.modal-xl {
    max-width: 98% !important;
    width: 98% !important;
    margin: 1rem auto !important;
}

/* Force modal dialog width override */
#jddDiffModal .modal-dialog {
    max-width: 98% !important;
    width: 98% !important;
    margin: 1rem auto !important;
}

/* Bootstrap modal override for diff result */
#jddDiffModal .modal-dialog.modal-xl {
    max-width: 98% !important;
    width: 98% !important;
    margin: 1rem auto !important;
}

.modal-xl .modal-content {
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-xl .modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid #dee2e6;
}

.modal-xl .modal-body {
    max-height: calc(90vh - 80px);
    overflow-y: auto;
    padding: 5px !important;
    flex: 1;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Force full width for jdd diff modal specifically */
#jddDiffModal .modal-body {
    padding: 5px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.modal-xl .modal-footer {
    flex-shrink: 0;
    border-top: 1px solid #dee2e6;
    background: white;
    padding: 15px 20px;
}

/* JDD specific overrides */
#diffResultModal .d4 {
    background-color: #fff8dc !important;
}

#diffResultModal .r {
    background-color: #ffe6e6 !important;
}

#diffResultModal .a {
    background-color: #e6ffe6 !important;
}

#diffResultModal .c {
    background-color: #e6f3ff !important;
}

/* Loading indicator */
.diff-loading {
    text-align: center;
    padding: 50px;
    color: #666;
}

.diff-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top: 2px solid #666;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* JSONBlob Diff Modal Styles - JDD Native Implementation */

/* JDD Diff Container */
#jdd-diff-container {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Force jdd-diff-container width */
#jddDiffModal #jdd-diff-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Report Section (matches JDD) */
#report {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    position: relative;
    height: auto !important;
    clear: both;
    z-index: 1;
    width: 100%;
    box-sizing: border-box;
}

.reportTitle {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
    width: auto !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
}

.filterBlock {
    display: block;
    margin-top: 10px;
    clear: both;
    width: 100%;
}

.filterBlock label {
    display: inline-block;
    margin-right: 15px;
    margin-bottom: 5px;
    font-size: 13px;
    cursor: pointer;
    background: transparent !important;
    border: none !important;
    padding: 5px !important;
}

.filterBlock input[type="checkbox"] {
    margin-right: 5px;
}

/* Diff Container (side-by-side) */
.diffcontainer {
    display: flex !important;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px !important;
    margin-top: 10px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-height: calc(90vh - 140px);
    min-height: 650px;
    background: white;
    clear: both;
    position: relative;
    z-index: 0;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Force diffcontainer width in jdd modal */
#jddDiffModal .diffcontainer {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.diffcolumn {
    flex: 1 !important;
    overflow: auto;
    max-height: calc(90vh - 140px);
    min-height: 650px;
    background: white;
    width: 50% !important;
    max-width: 50% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Force diffcolumn width in jdd modal */
#jddDiffModal .diffcolumn {
    flex: 1 !important;
    width: 50% !important;
    max-width: 50% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.diffcolumn:first-child {
    border-right: 1px solid #ddd;
}

/* Pre Elements */
pre.left, pre.right {
    margin: 0 !important;
    padding: 8px !important;
    background: white;
    border: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    height: 100% !important;
    min-height: 600px;
    max-height: none;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Force pre element width in jdd modal */
#jddDiffModal pre.left, #jddDiffModal pre.right {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 8px !important;
    box-sizing: border-box !important;
}

pre.left {
    background: #fefefe;
}

pre.right {
    background: #f9f9f9;
}

/* JDD Code Block Structure */
.codeBlock {
    display: flex !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Force codeBlock width in jdd modal */
#jddDiffModal .codeBlock {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Gutter (Line Numbers) */
.codeBlock .gutter {
    background: #f5f5f5;
    border-right: 1px solid #ccc;
    padding: 0;
    min-width: 40px;
    max-width: 40px;
    text-align: right;
    user-select: none;
    flex-shrink: 0;
}

.codeBlock .gutter .line-number {
    display: block;
    padding: 2px 4px 2px 2px;
    color: #666;
    font-size: 11px;
    line-height: 1.4;
    white-space: nowrap;
}

/* Code Content */
.codeBlock > div:last-child {
    flex: 1;
    background: inherit;
    overflow-x: auto;
    width: calc(100% - 40px);
    max-width: calc(100% - 40px);
}

.codeLine {
    line-height: 1.4;
    min-height: 17px;
    white-space: nowrap;
}

.code {
    display: block;
    padding: 2px 6px;
    white-space: pre;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    background: inherit;
    width: 100%;
    box-sizing: border-box;
}

/* JDD Diff Highlighting */
.code.diff {
    background-color: #ffeb3b !important;
    cursor: pointer;
    position: relative;
}

.code.diff:hover {
    background-color: #ffc107 !important;
}

.code.diff.selected {
    background-color: #ff9800 !important;
    color: white;
    font-weight: bold;
}

/* Diff Type Colors */
.code.diff.eq {
    background-color: #ffcdd2 !important;
}

.code.diff.missing {
    background-color: #f8bbd9 !important;
}

.code.diff.type {
    background-color: #c8e6c9 !important;
}

/* Hidden diffs when filters are unchecked */
.code.diff.eq_off,
.code.diff.missing_off,
.code.diff.type_off {
    background-color: transparent !important;
    cursor: default;
}

/* Toolbar */
.toolbar {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
}

.toolbar li {
    margin-bottom: 5px;
    cursor: pointer;
    padding: 3px 0;
    color: #007bff;
    font-size: 13px;
}

.toolbar li:hover {
    color: #0056b3;
    text-decoration: underline;
}

#buttons {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

#buttons a {
    display: inline-block;
    padding: 5px 10px;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 3px;
    margin-right: 5px;
    font-size: 12px;
}

#buttons a:hover {
    background: #0056b3;
}

#buttons a.disabled {
    background: #6c757d;
    cursor: not-allowed;
}

#prevNextLabel {
    margin: 0 10px;
    font-size: 12px;
    color: #666;
}

/* Progress indicators */
.progress .modal-body {
    text-align: center;
    padding: 40px;
}

.progress .modal-body:before {
    content: "⏳";
    display: block;
    font-size: 24px;
    margin-bottom: 10px;
}

/* Error states */
.error {
    background-color: #f8d7da !important;
    border-color: #f5c6cb !important;
    color: #721c24 !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .modal-xl {
        max-width: 98%;
        margin: 0.5rem auto;
    }
    
    .modal-xl .modal-content {
        max-height: 95vh;
    }
    
    .modal-xl .modal-body {
        max-height: calc(95vh - 140px);
        padding: 15px;
    }
    
    .modal-xl .modal-footer {
        padding: 10px 15px;
    }
    
    .diffcontainer {
        flex-direction: column;
        max-height: calc(95vh - 220px);
        min-height: 400px;
    }
    
    .diffcolumn:first-child {
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    
    .diffcolumn {
        max-height: calc((95vh - 220px) / 2);
        min-height: 200px;
    }
    
    .codeBlock .gutter {
        min-width: 35px;
    }
    
    .codeBlock .gutter .line-number {
        padding: 2px 6px 2px 2px;
        font-size: 10px;
    }
    
    .code {
        padding: 2px 6px;
        font-size: 11px;
    }
}

/* Ensure footer is always visible */
@media (max-height: 600px) {
    .modal-xl .modal-content {
        max-height: 95vh;
    }
    
    .modal-xl .modal-body {
        max-height: calc(95vh - 100px);
    }
    
    .diffcontainer {
        max-height: calc(95vh - 180px);
        min-height: 300px;
    }
    
    .diffcolumn {
        max-height: calc(95vh - 180px);
        min-height: 300px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .code.diff.eq {
        background-color: #ff4444 !important;
        color: white !important;
    }
    
    .code.diff.missing {
        background-color: #ff8800 !important;
        color: white !important;
    }
    
    .code.diff.type {
        background-color: #00aa00 !important;
        color: white !important;
    }
}

/* Print styles */
@media print {
    .modal-header,
    .modal-footer,
    .toolbar {
        display: none;
    }
    
    .modal-body {
        max-height: none;
        overflow: visible;
    }
    
    .diffcontainer {
        page-break-inside: avoid;
    }
    
    .code.diff {
        background-color: #ddd !important;
        color: black !important;
    }
}

/* Accessibility improvements */
.code.diff:focus {
    outline: 2px solid #007bff;
    outline-offset: 1px;
}

/* Scrollbar styling for webkit */
.diffcolumn::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.diffcolumn::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.diffcolumn::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.diffcolumn::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animation for smooth transitions */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
}

.modal.show .modal-dialog {
    transform: none;
}

/* Identical files message */
.identical-message {
    text-align: center;
    padding: 40px;
    color: #28a745;
    font-size: 16px;
    font-weight: 600;
}

.identical-message:before {
    content: "✅";
    display: block;
    font-size: 32px;
    margin-bottom: 15px;
}

/* Loading spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

/* JDD Override Fixes */
#jdd-diff-container #report button {
    display: none !important;
}

#jdd-diff-container #report .weak {
    display: none !important;
}

/* Override JDD's absolute positioning */
#jdd-diff-container #report {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    width: 100% !important;
    height: auto !important;
}

/* Ensure proper layout flow */
#jdd-diff-container > * {
    position: relative !important;
    clear: both;
}

/* Fix toolbar positioning */
.toolbar {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    display: block !important;
    margin-top: 10px;
} 