/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container { 
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 300;
}

.header p {
    opacity: 0.9;
    font-size: 1.1rem;
}

.content {
    padding: 30px;
}

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

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

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

/* Flash Messages */
.flash-messages {
    margin-bottom: 20px;
}

.flash-message {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease-out;
}

.flash-message.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.flash-message.warning {
    background: #fffbeb;
    border: 1px solid #fed7aa;
    color: #92400e;
}

.flash-message.info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.flash-message.success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

/* Upload Section */
.upload-section {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    margin-bottom: 30px;
    transition: all 0.3s ease;
    position: relative;
}

.upload-section.dragover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3rem;
    color: #94a3b8;
    margin-bottom: 20px;
}

.upload-section.dragover .upload-icon {
    color: #667eea;
}

.file-input-wrapper {
    position: relative;
    display: inline-block;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.file-input-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.file-info {
    margin-top: 15px;
    color: #64748b;
    font-size: 0.9rem;
}

.file-input-info {
    margin-left: 15px;
    font-size: 0.9em;
    color: #64748b;
}

.selected-file {
    background: #e0f2fe;
    border: 1px solid #81d4fa;
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
    display: none;
}

.selected-file.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

/* Selected Files (Multi-file) */
.selected-files {
    margin-top: 15px;
    display: none;
}

.selected-files.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

.selected-files-header {
    background: #e0f2fe;
    border: 1px solid #81d4fa;
    border-radius: 10px 10px 0 0;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #0369a1;
}

.selected-files-list {
    background: #f0f9ff;
    border: 1px solid #81d4fa;
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 200px;
    overflow-y: auto;
}

.selected-file-item {
    padding: 10px 15px;
    border-bottom: 1px solid #e0f2fe;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
}

.selected-file-item:hover {
    background: #e0f2fe;
}

.selected-file-item:last-child {
    border-bottom: none;
}

.file-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-item-details {
    display: flex;
    flex-direction: column;
}

.file-item-name {
    font-weight: 500;
    color: #0f172a;
}

.file-item-size {
    font-size: 0.85rem;
    color: #64748b;
}

.file-item-remove {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-item-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Radio Group Styles */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.radio-wrapper {
    position: relative;
}

.radio-wrapper input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-wrapper label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.radio-wrapper label:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.radio-wrapper input[type="radio"]:checked + label {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.radio-wrapper label::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    background: white;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.3s ease;
}

.radio-wrapper input[type="radio"]:checked + label::before {
    border-color: #667eea;
    background: #667eea;
    box-shadow: inset 0 0 0 3px white;
}

.radio-wrapper label i {
    color: #667eea;
    font-size: 1.2rem;
    margin-top: 2px;
}

.radio-label {
    font-weight: 600;
    color: #334155;
    margin-bottom: 4px;
}

.radio-wrapper label small {
    color: #64748b;
    font-size: 0.85rem;
    line-height: 1.4;
}

.radio-wrapper label .radio-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

input[type='radio'][disabled] + label,
input[type='radio'][disabled] + label .radio-label {
  color: #a0aec0;
  cursor: not-allowed;
}

.mode-helper {
  font-style: italic;
  color: #666;
  margin-top: 4px;
  display: block;
}

.radio-wrapper.disabled {
  border-color: #cbd5e0 !important;
  background-color: #f7fafc !important;
  opacity: 0.6;
  cursor: not-allowed;
}
.radio-wrapper.disabled .radio-label,
.radio-wrapper.disabled i {
  color: #a0aec0 !important;
}

/* Progress Bar Styles */
.progress-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.progress-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-header h3 {
    color: #334155;
    font-size: 1.1rem;
    margin: 0;
}

.progress-text {
    color: #64748b;
    font-size: 0.9rem;
}

.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-percentage {
    font-weight: 600;
    color: #334155;
    min-width: 40px;
    text-align: right;
}

.progress-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #64748b;
}

/* Separate Results Panel */
.separate-files-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.separate-file-result {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
}

.separate-file-result.active {
    border-color: #6366f1;
    background: #eef2ff;
}

.separate-file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.separate-file-name {
    font-weight: 600;
    color: #334155;
}

.separate-file-actions {
    display: flex;
    gap: 10px;
}

.separate-file-preview {
    max-height: none;
    overflow-y: auto;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #475569;
}

.separate-file-preview.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

/* Options Section */
.options-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.option-group {
    background: #f8fafc;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.option-group h3 {
    margin-bottom: 15px;
    color: #334155;
    font-size: 1.1rem;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.select-wrapper select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

/* Process Button */
.process-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 15px 40px;
    border: none;
    border-radius: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    width: 100%;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.process-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

.process-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.loading-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Results Section */
.results-section {
    display: flex;
    gap: 25px;
    margin-top: 30px;
}

.result-panel {
    background: #f8fafc;
    border-radius: 15px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: auto; /* Allow dynamic height growth */
    min-height: 400px; /* Ensure minimum height */
}

.result-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: nowrap;
    gap: 15px;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: nowrap;
    min-width: 0;
}

.result-panel h3 {
    margin-bottom: 0;
    flex-shrink: 0;
}

.result-textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    resize: none; /* Disable manual resizing */
    background: white;
    overflow-y: hidden; /* Hide scrollbar, let it expand instead */
    flex: 1;
    min-height: 350px;
    height: auto; /* Allow dynamic height growth */
    max-height: none; /* Remove any max-height constraints */
    box-sizing: border-box; /* Include padding in the element's total width and height */
}

.preview-area {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 18px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: #334155;
    font-size: 13px;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    flex: 1;
    min-height: 350px;
    height: auto; /* Allow dynamic height growth */
    max-height: none; /* Remove any max-height constraints */
}

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

.preview-area::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.preview-area::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.preview-area::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.preview-area h1, .preview-area h2, .preview-area h3, 
.preview-area h4, .preview-area h5, .preview-area h6 {
    color: #1e293b;
    margin-top: 1.2em;
    margin-bottom: 0.4em;
    font-weight: 600;
    line-height: 1.3;
}

.preview-area h1 { 
    font-size: 1.4em; 
    border-bottom: 1px solid #e2e8f0; 
    padding-bottom: 0.2em; 
    margin-top: 0.8em;
}
.preview-area h2 { font-size: 1.2em; }
.preview-area h3 { font-size: 1.1em; }
.preview-area h4 { font-size: 1.05em; }

.preview-area p {
    margin-bottom: 0.8em;
    text-align: justify;
    text-justify: inter-word;
}

.preview-area ul, .preview-area ol {
    margin-bottom: 0.8em;
    padding-left: 1.2em;
}

.preview-area li {
    margin-bottom: 0.2em;
    word-break: normal;
}

.preview-area code {
    background: #f1f5f9;
    padding: 0.15em 0.3em;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85em;
    word-break: break-all;
}

.preview-area pre {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.75em;
    overflow-x: auto;
    margin-bottom: 0.8em;
    font-size: 0.9em;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
}

.preview-area pre code {
    background: none;
    padding: 0;
}

.preview-area blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1em;
    margin: 1em 0;
    color: #64748b;
    font-style: italic;
    background-color: #f8faff; /* Light background for blockquotes */
    border-radius: 4px;
    padding: 0.8em 1em;
}

.preview-area blockquote p {
    margin-bottom: 0;
}

.preview-area table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}

.preview-area th, .preview-area td {
    border: 1px solid #e2e8f0;
    padding: 0.5em;
    text-align: left;
}

.preview-area th {
    background: #f8fafc;
    font-weight: 600;
}

.preview-area img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1em 0;
}

.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.action-button {
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0;
    text-decoration: none;
    color: white;
    white-space: nowrap;
}

.action-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.action-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.copy-button {
    background-color: #3b82f6;
}

.copy-button:hover {
    background-color: #2563eb;
}

.download-button {
    background-color: #8b5cf6;
}

.download-button:hover:not(:disabled) {
    background-color: #7c3aed;
}

.download-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.copy-button-wrapper {
    position: relative;
    display: inline-flex;
}

.copy-status {
    font-size: 0.8rem;
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #22c55e;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.copy-status.show {
    opacity: 1;
    transform: translateY(-50%) translateX(4px);
}

/* Stats Panel */
.stats-panel {
    display: flex;
    gap: 12px;
    align-items: center;
    background: none;
    padding: 0;
    border: none;
    flex-shrink: 0;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #64748b;
    cursor: help;
}

.stat-item i {
    font-size: 0.9em;
}

.stat-label {
    display: none;
}

.stat-value {
    font-weight: 600;
    font-size: 0.8rem;
    color: #334155;
    background: #e2e8f0;
    padding: 2px 5px;
    border-radius: 3px;
    border: none;
}

/* Preview Placeholder */
.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #94a3b8;
    text-align: center;
}

.preview-placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.preview-placeholder p {
    font-size: 1.1rem;
    opacity: 0.8;
}

/* Info Section */
.info-section {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.info-section h4 {
    color: #0c4a6e;
    margin-bottom: 10px;
}

.info-section ul {
    color: #0369a1;
    margin-left: 20px;
}

.info-section li {
    margin-bottom: 5px;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    background: #f1f5f9;
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}

.tab-button {
    flex: 1;
    padding: 15px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: #64748b;
    transition: all 0.3s ease;
    text-align: center;
}

.tab-button:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.tab-button.active {
    background: #667eea;
    color: white;
    box-shadow: inset 0 -2px 0 #764ba2;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: slideIn 0.3s ease-out;
}

/* Source Image Placeholder */
.source-image-placeholder {
    text-align: center;
    padding: 40px;
    background: #f8fafc;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
}

.source-image-placeholder h3 {
    margin-bottom: 10px;
    color: #334155;
}

.source-image-placeholder p {
    color: #64748b;
}

/* Annotation Styling */
.preview-area pre code.language-json {
    display: block;
    background-color: #f0f9ff; /* Light blue background */
    border: 1px solid #bae6fd; /* Light blue border */
    border-left: 5px solid #3b82f6; /* Blue left border for emphasis */
    padding: 1em;
    margin: 1em 0;
    border-radius: 8px;
    color: #1e40af; /* Darker blue text */
    font-size: 0.9em;
    line-height: 1.4;
    white-space: pre-wrap; /* Ensure long lines wrap */
    word-break: break-all; /* Break long words */
}

/* Utility Classes */
.is-hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .results-section {
        flex-direction: column;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .options-section {
        grid-template-columns: 1fr;
    }
    
    .results-section {
        flex-direction: column;
        gap: 20px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .content {
        padding: 20px;
    }
    
    .upload-section {
        padding: 20px;
    }
    
    .file-input-button {
        padding: 12px 24px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .content {
        padding: 15px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .upload-section {
        padding: 15px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-button {
        justify-content: center;
    }
    
    .stats-panel {
        flex-direction: column;
        gap: 10px;
    }
    
    .stat-item {
        justify-content: space-between;
        padding: 8px;
        background: white;
        border-radius: 6px;
    }
} 

/* Main Sections Layout */
#pre-processing-section {
    background: #f8fafc;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
}

/* Post-Processing Split-Pane Layout */
.post-processing-section {
    background: #f8fafc;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
}

.post-processing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.post-processing-header h3 {
    margin: 0;
    color: #334155;
    font-size: 1.2rem;
}

.new-session-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.new-session-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.split-pane-container {
    display: flex;
    gap: 20px;
    min-height: 400px;
    height: auto; /* Allow dynamic height growth */
}

/* Left Pane: Thumbnail List */
.thumbnail-pane {
    flex: 0 0 250px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.thumbnail-header {
    padding: 15px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thumbnail-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #334155;
}

.thumbnail-counter {
    font-size: 0.8rem;
    color: #64748b;
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 12px;
}

.thumbnail-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.thumbnail-item {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0; /* Prevent shrinking */
    display: flex;
    flex-direction: row; /* Horizontal layout */
    align-items: center;
    padding: 10px;
    gap: 12px;
    min-height: 60px; /* Minimum height to ensure consistent spacing */
}

.thumbnail-item:hover {
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

.thumbnail-item.active {
    border-color: #7c3aed;
    border-width: 3px;
    background: #ede9fe;
    box-shadow: 0 0 0 3px #c4b5fd, 0 4px 12px rgba(124, 58, 237, 0.15);
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.thumbnail-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.thumbnail-filename {
    font-size: 0.85rem;
    color: #334155;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0; /* Allow text to shrink */
}

.thumbnail-index {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 2px;
}

/* Right Pane: Image Viewer */
.image-viewer-pane {
    flex: 1;
    background: white;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.image-viewer-header {
    padding: 15px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.image-viewer-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #334155;
}

.image-viewer-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.viewer-nav-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.viewer-nav-btn:hover:not(:disabled) {
    background: #5a67d8;
    transform: translateY(-1px);
}

.viewer-nav-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.viewer-counter {
    font-size: 0.8rem;
    color: #64748b;
    background: #e2e8f0;
    padding: 4px 8px;
    border-radius: 12px;
    min-width: 60px;
    text-align: center;
}

.image-viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
    background: #f8fafc;
    position: relative; /* For loading overlay positioning */
    height: 500px; /* Fixed height to eliminate layout jumps */
    min-height: 500px; /* Ensure consistent height */
    max-height: 500px; /* Prevent height expansion */
}

.image-viewer-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease;
    /* Perfect centering within fixed container */
    display: block;
    margin: auto;
}

.image-viewer-content img.fit-to-view {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    /* Ensure minimum size for very small images */
    min-width: 50px;
    min-height: 50px;
    /* Perfect centering within fixed container */
    display: block;
    margin: auto;
}

.image-viewer-content img.actual-size {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    object-fit: unset;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
}

/* Loading state for images */
.image-viewer-content img.loading {
    opacity: 0.6;
}

/* Error state for images */
.image-viewer-content img.error {
    opacity: 0.3;
    filter: grayscale(1);
}

/* Loading overlay */
.image-loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

.image-loading-overlay.show {
    display: flex;
}

.image-loading-overlay i {
    animation: spin 1s linear infinite;
    color: #667eea;
}

/* Error state for images */
.image-error-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    display: none;
    z-index: 10;
}

.image-error-overlay.show {
    display: block;
}

.image-error-overlay i {
    color: #ef4444;
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.image-error-overlay p {
    color: #dc2626;
    font-size: 0.9rem;
    margin: 0;
}

.image-placeholder {
    text-align: center;
    color: #94a3b8;
}

.image-placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.image-placeholder p {
    font-size: 1rem;
    opacity: 0.8;
}

.no-images-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
}

.no-images-message i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.no-images-message p {
    font-size: 1rem;
    opacity: 0.8;
    margin: 0;
}

.document-icon {
    width: 40px;
    height: 40px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.document-icon i {
    font-size: 1.2rem;
    color: #64748b;
}

.document-note {
    font-size: 0.8rem;
    opacity: 0.6;
    margin-top: 10px;
}

/* Responsive Design for Split-Pane */
@media (max-width: 1024px) {
    .split-pane-container {
        flex-direction: column;
        height: auto;
        min-height: 600px;
    }
    
    .thumbnail-pane {
        flex: none;
        height: 200px;
    }
    
    .thumbnail-list {
        flex-direction: column !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
    
    .thumbnail-item {
        flex: none !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

@media (max-width: 768px) {
    .post-processing-section {
        padding: 20px;
    }
    
    .split-pane-container {
        gap: 15px;
    }
    
    .thumbnail-pane {
        height: 180px;
    }
    
    .thumbnail-item {
        flex: none !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

#bottom-section {
    background: white;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
    overflow: visible; /* Allow content to overflow and grow the container */
    display: flex;
    flex-direction: column;
}

/* Source Images Preview */
.source-images-preview {
    margin-top: 20px;
    display: none;
}

.source-images-preview.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

.source-image-item {
    display: inline-block;
    margin: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    max-width: 200px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.source-image-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.source-image-name {
    padding: 8px;
    font-size: 0.8rem;
    color: #64748b;
    text-align: center;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Output Tab Navigation */
#output-tab-nav {
    display: flex;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

#output-tab-nav .tab-button {
    flex: 1;
    padding: 15px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: #64748b;
    transition: all 0.3s ease;
    text-align: center;
    border-bottom: 3px solid transparent;
}

#output-tab-nav .tab-button:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

#output-tab-nav .tab-button.active {
    background: white;
    color: #667eea;
    border-bottom-color: #667eea;
}

#output-tab-content {
    min-height: 400px;
    height: auto; /* Allow dynamic height growth */
}

#output-tab-content .tab-content {
    display: none;
    padding: 20px;
    height: auto; /* Allow dynamic height growth */
    min-height: 400px; /* Ensure minimum height for content */
}

#output-tab-content .tab-content.active {
    display: block;
    animation: slideIn 0.3s ease-out;
}

/* Image Modal Styles */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px); /* Safari support */
    animation: fadeIn 0.3s ease-out;
}

.image-modal.show {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 50%, transparent 100%);
    color: white;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.modal-body {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: 90vw;
    max-height: 80vh;
}

.modal-image-container {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: opacity 0.3s ease;
}

.modal-image-container img.loading {
    opacity: 0.5;
}

.modal-loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 5;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-loading-overlay.show {
    display: flex;
}

.modal-loading-overlay i {
    font-size: 1.2rem;
    animation: spin 1s linear infinite;
}

.modal-loading-overlay span {
    font-size: 0.9rem;
    font-weight: 500;
}

.modal-error-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(220, 38, 38, 0.9);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 5;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
}

.modal-error-overlay i {
    font-size: 2rem;
    margin-bottom: 8px;
}

.modal-error-overlay p {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.modal-error-overlay .error-filename {
    font-size: 0.8rem;
    opacity: 0.8;
    word-break: break-word;
    max-width: 200px;
}

.pdf-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: white;
    text-align: center;
    padding: 40px;
}

.pdf-placeholder i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.8;
}

.pdf-placeholder p {
    font-size: 1.2rem;
    margin: 10px 0;
    opacity: 0.9;
}

.pdf-placeholder .pdf-note {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-top: 15px;
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 15px 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.modal-nav:hover {
    background: rgba(102, 126, 234, 0.9);
    border-color: rgba(102, 126, 234, 0.6);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.modal-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: translateY(-50%) scale(1);
    background: rgba(0, 0, 0, 0.5);
}

.modal-prev {
    left: 20px;
}

.modal-next {
    right: 20px;
}

.modal-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 50%, transparent 100%);
    color: white;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.modal-footer span {
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Enhanced Thumbnail Styles */
.selected-file-item .file-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 12px;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.selected-file-item .file-thumbnail:hover {
    border-color: #667eea;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.selected-file-item .file-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 8px;
    margin-right: 12px;
    color: #64748b;
    font-size: 1.5rem;
    border: 2px solid #e2e8f0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        padding: 10px;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-header h3 {
        font-size: 1rem;
    }
    
    .modal-nav {
        width: 40px;
        height: 40px;
        padding: 10px 8px;
        font-size: 1.2rem;
    }
    
    .modal-prev {
        left: 10px;
    }
    
    .modal-next {
        right: 10px;
    }
    
    .modal-footer {
        padding: 15px;
    }
}

/* Responsive improvements for image viewer */
@media (max-width: 1024px) {
    .image-viewer-content {
        padding: 15px;
    }
    
    .image-viewer-content img.fit-to-view {
        /* Ensure images remain visible on smaller screens */
        min-width: 80px;
        min-height: 80px;
    }
}

@media (max-width: 768px) {
    .image-viewer-content {
        padding: 10px;
    }
    
    .image-viewer-content img.fit-to-view {
        /* Slightly larger minimum size for mobile */
        min-width: 120px;
        min-height: 120px;
    }
    
    .image-loading-overlay {
        padding: 15px;
        font-size: 0.9rem;
    }
    
    .image-error-overlay {
        padding: 12px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .image-viewer-content {
        padding: 8px;
    }
    
    .image-viewer-content img.fit-to-view {
        /* Ensure images are always visible on very small screens */
        min-width: 100px;
        min-height: 100px;
    }
    
    .image-loading-overlay {
        padding: 12px;
        font-size: 0.8rem;
    }
}