:root {
    /* Font definitions - easily changeable */
    --font-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
    --font-serif: Lyon-Text, Georgia, YuMincho, "Yu Mincho", "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Songti TC", "Songti SC", SimSun, "Nanum Myeongjo", NanumMyeongjo, Batang, serif;
    --font-monospace: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    --font-dyslexia: 'OpenDyslexic', 'Comic Sans MS', cursive;
    
    /* Active font variable */
    --font-family: var(--font-sans-serif);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

/* Ensure all buttons and interactive elements use the selected font */
button, input, select, textarea {
    font-family: var(--font-family);
}

.app-layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 320px;
    background-color: #f5f5f5;
    padding: 20px;
    overflow-y: auto;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    border-right: 1px solid #dee2e6;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    transform: translateX(-280px);
}

.sidebar-toggle {
    position: fixed;
    left: 320px;
    top: 50%;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #34495e;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateX(-16px) translateY(-16px);
}

.sidebar-toggle:hover {
    background-color: #34495e;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.sidebar.collapsed + .sidebar-toggle {
    left: 40px;
    transform: translateX(-16px) translateY(-16px);
}

.toggle-icon {
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin-top: -5px;
    font-family: var(--font-sans-serif) !important;
}

.main-content {
    margin-left: 320px;
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    background-color: white;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 40px;
}

header {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h1 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 24px;
}

.header-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.upload-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}


.file-input-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
    border: 2px dashed #34495e;
    border-radius: 5px;
    background-color: #f8f9fa;
    gap: 8px;
}

.file-input-label {
    display: inline-block;
    padding: 8px 16px;
    background-color: white;
    border: 2px solid #34495e;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    color: #34495e;
    transition: all 0.3s;
}

.file-input-label:hover {
    background-color: #34495e;
    color: white;
}

.file-input-name {
    color: #7f8c8d;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

#loadSample {
    padding: 10px 20px;
    background-color: #34495e;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

#loadSample:hover {
    background-color: #2980b9;
}

.hidden {
    display: none;
}

.session-info {
    background-color: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.session-info h2 {
    font-size: 18px;
    margin: 0;
    flex-grow: 1;
}

.unload-json-btn {
    background-color: transparent;
    color: #7f8c8d;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.unload-json-btn:hover {
    background-color: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

.session-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.session-stats span {
    color: #7f8c8d;
    font-size: 13px;
    display: block;
}

.visualization {
    background-color: white;
    padding: 20px;
    height: 100%;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ecf0f1;
}

.tab-button {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-family: var(--font-family);
    color: #7f8c8d;
    transition: all 0.3s;
}

.tab-button:hover {
    color: #2c3e50;
}

.tab-button.active {
    color: #34495e;
    border-bottom: 2px solid #34495e;
    margin-bottom: -2px;
}

.tab-content {
    display: none;
    min-height: 400px;
}

.tab-content.active {
    display: block;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.timeline-controls {
    display: flex;
    gap: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    flex-wrap: wrap;
}

.timeline-actions {
    display: flex;
    gap: 8px;
}

.export-btn, .undo-btn, .restore-btn, .expand-btn, .collapse-btn {
    padding: 10px 20px;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.export-btn {
    background-color: #34495e;
}

.export-btn:hover {
    background-color: #2980b9;
}

.undo-btn {
    background-color: #34495e;
}

.undo-btn:hover:not(:disabled) {
    background-color: #2980b9;
}

.undo-btn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

.restore-btn {
    background-color: #27ae60;
}

.restore-btn:hover {
    background-color: #229954;
}

.restore-btn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

.restore-btn:disabled:hover {
    background-color: #95a5a6;
}

.rematch-btn {
    background-color: #34495e;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.rematch-btn:hover {
    background-color: #2980b9;
}

/* Rematch progress indicator */
.rematch-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
    padding: 6px 10px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    font-size: 0.85em;
    color: #856404;
}

.rematch-progress.hidden {
    display: none !important;
}

.rematch-progress.success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.rematch-progress.success .progress-spinner {
    animation: none;
    color: #28a745;
}

.rematch-progress.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.rematch-progress.error .progress-spinner {
    animation: none;
    color: #dc3545;
}

.expand-btn, .collapse-btn {
    background-color: #34495e;
    padding: 10px 14px !important;
    font-size: 14px !important;
}

.expand-btn:hover, .collapse-btn:hover {
    background-color: #2c3e50;
}

.search-actions {
    margin-top: 10px;
}

.remove-search-btn {
    padding: 6px 12px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.3s;
}

.remove-search-btn:hover {
    background-color: #c0392b;
}

/* Unload DOCX button */
.unload-docx-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.unload-docx-btn:hover {
    background-color: #5a6268;
}

.unload-docx-btn.hidden {
    display: none;
}

.view-unmatched-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.view-unmatched-btn:hover {
    background-color: #5a6268;
}

.view-unmatched-btn.hidden {
    display: none;
}

.docx-buttons {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

/* Actions box styles */
.actions-box {
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 15px;
}

.actions-box h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
    border-bottom: 2px solid #34495e;
    padding-bottom: 8px;
}

.actions-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.actions-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.actions-group button {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s;
    text-align: center;
}

/* Research summary styles removed */

.timeline-controls label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

#timelineContent {
    padding: 20px;
}

.search-group {
    margin-bottom: 30px;
    background-color: white;
    border-radius: 8px;
    border: 1px solid #bdc3c7;
    overflow: hidden;
}

.search-header {
    display: flex;
    align-items: center;
    background-color: #f8f9fa;
    transition: background-color 0.3s;
}

.search-header:hover {
    background-color: #f0f3f4;
}

.toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 20px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.toggle-btn::after {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent #7f8c8d;
    transition: transform 0.2s, border-color 0.2s;
    display: block;
}

.toggle-btn.expanded::after {
    transform: rotate(90deg);
}

.toggle-btn:hover::after {
    border-color: transparent transparent transparent #2c3e50;
}

.search-content {
    display: flex;
    align-items: flex-start;
    flex: 1;
    padding: 20px 20px 20px 0;
}

.search-time {
    color: #7f8c8d;
    font-size: 14px;
    min-width: 80px;
}

.search-icon {
    font-size: 24px;
    margin: 0 15px;
}

.search-info {
    flex: 1;
}

.search-query {
    font-weight: 500;
    color: #2c3e50;
    font-size: 16px;
    margin-bottom: 5px;
}

.search-details {
    color: #7f8c8d;
    font-size: 14px;
    margin-bottom: 10px;
}

.pages-container {
    border-top: 1px solid #95a5a6;
    background-color: #fafbfc;
}

.page-item {
    display: flex;
    align-items: flex-start;
    padding: 15px 20px 15px 60px;
    border-bottom: 1px solid #bdc3c7;
    transition: background-color 0.3s;
}

.page-item:hover {
    background-color: #f5f6f7;
}

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

.page-time {
    color: #95a5a6;
    font-size: 13px;
    min-width: 80px;
}

.page-icon {
    font-size: 18px;
    margin: 0 15px;
}

.page-content {
    flex: 1;
    min-width: 0;
    position: relative;
}

.page-title-container {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.page-title {
    font-weight: 500;
    color: #2c3e50;
    cursor: help;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.page-details {
    color: #7f8c8d;
    font-size: 13px;
    margin-top: 3px;
}

.orphan-header {
    padding: 20px;
    background-color: #f8f9fa;
    color: #7f8c8d;
}

.page-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 260px;
    margin-left: 20px;
    flex-shrink: 0;
}

.page-actions.vertical {
    grid-template-columns: 1fr;
    width: 120px;
}

.visit-page-btn, .view-cards-btn, .edit-meta-btn, .remove-page-btn {
    padding: 10px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-actions.vertical .visit-page-btn,
.page-actions.vertical .view-cards-btn,
.page-actions.vertical .edit-meta-btn,
.page-actions.vertical .remove-page-btn {
    padding: 8px 12px;
    font-size: 13px;
}

.visit-page-btn {
    background-color: #34495e;
    color: white;
}

.visit-page-btn:hover {
    background-color: #2980b9;
}

.view-cards-btn {
    background-color: #34495e;
    color: white;
}

.view-cards-btn:hover {
    background-color: #2980b9;
}

.view-cards-btn.disabled {
    background-color: #95a5a6;
    color: white;
    cursor: not-allowed;
    opacity: 0.6;
}

.view-cards-btn.disabled:hover {
    background-color: #95a5a6;
}

.edit-meta-btn {
    background-color: #34495e;
    color: white;
}

.edit-meta-btn:hover {
    background-color: #2980b9;
}

.remove-page-btn {
    background-color: #e74c3c;
    color: white;
}

.remove-page-btn:hover {
    background-color: #c0392b;
}

/* Smaller font size for page action buttons when monospace font is selected */
:root[style*="--font-family: var(--font-monospace)"] .page-actions .visit-page-btn,
:root[style*="--font-family: var(--font-monospace)"] .page-actions .view-cards-btn,
:root[style*="--font-family: var(--font-monospace)"] .page-actions .edit-meta-btn,
:root[style*="--font-family: var(--font-monospace)"] .page-actions .remove-page-btn {
    font-size: 12px;
}

:root[style*="--font-family: var(--font-monospace)"] .page-actions.vertical .visit-page-btn,
:root[style*="--font-family: var(--font-monospace)"] .page-actions.vertical .view-cards-btn,
:root[style*="--font-family: var(--font-monospace)"] .page-actions.vertical .edit-meta-btn,
:root[style*="--font-family: var(--font-monospace)"] .page-actions.vertical .remove-page-btn {
    font-size: 11px;
}

.metadata-form {
    padding: 15px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-top: 10px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 14px;
}

.metadata-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.metadata-input:focus {
    outline: none;
    border-color: #34495e;
}

.metadata-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.save-metadata-btn, .cancel-metadata-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.save-metadata-btn {
    background-color: #27ae60;
    color: white;
}

.save-metadata-btn:hover {
    background-color: #229954;
}

.cancel-metadata-btn {
    background-color: #95a5a6;
    color: white;
}

.cancel-metadata-btn:hover {
    background-color: #7f8c8d;
}

.timeline-time {
    flex-shrink: 0;
    width: 120px;
    color: #7f8c8d;
    font-size: 14px;
}

.timeline-content {
    flex-grow: 1;
    padding-left: 20px;
}

.timeline-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.search-event .timeline-icon {
    background-color: #34495e;
}

.page-event .timeline-icon {
    background-color: #2ecc71;
}

.note-event .timeline-icon {
    background-color: #f39c12;
}

.event-title {
    font-weight: 600;
    margin-bottom: 5px;
    cursor: help;
}

.event-details {
    color: #7f8c8d;
    font-size: 14px;
}

.event-note {
    background-color: white;
    padding: 10px;
    margin-top: 10px;
    
    border-radius: 5px;
    font-style: italic;
    border-left: 3px solid #34495e;
}

.metadata-section {
    margin-top: 10px;
    padding: 10px;
    background-color: white;
    border-radius: 5px;
    font-size: 14px;
    
}

.metadata-item {
    display: flex;
    margin-bottom: 5px;
}

.metadata-label {
    font-weight: 600;
    color: #7f8c8d;
    min-width: 100px;
}

.metadata-value {
    color: #2c3e50;
}

/* Citation IDs styling */
.citation-ids .metadata-value {
    font-family: var(--font-monospace);
    font-size: 12px;
    background-color: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Extractor info styling */
.extractor-info {
    font-size: 12px;
    opacity: 0.7;
    font-style: italic;
}

/* Metadata form columns */
.metadata-form-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

/* Metadata info at bottom of form */
.metadata-info {
    font-size: 0.85em;
    color: #666;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.teacher-comment {
    margin-top: 10px;
    
    padding: 15px;
    background-color: #fff3cd;
    border-radius: 5px;
    border-left: 4px solid #f39c12;
}

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

.comment-label {
    font-weight: 600;
    color: #856404;
}

.comment-content {
    color: #856404;
    line-height: 1.6;
}

.add-comment-btn {
    padding: 6px 12px;
    background-color: #f39c12;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    margin-top: 10px;
    
    display: inline-block;
}

.add-comment-btn:hover {
    background-color: #e67e22;
}

.edit-comment-btn, .delete-comment-btn {
    padding: 8px 15px;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.edit-comment-btn {
    background-color: #34495e;
}

.edit-comment-btn:hover {
    background-color: #2980b9;
}

.delete-comment-btn {
    background-color: #e74c3c;
}

.delete-comment-btn:hover {
    background-color: #c0392b;
}

.comment-form {
    margin-top: 10px;
    
    padding: 15px;
    background-color: white;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.comment-textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: inherit;
    resize: vertical;
}

.comment-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.save-comment-btn, .cancel-comment-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.save-comment-btn {
    background-color: #27ae60;
    color: white;
}

.cancel-comment-btn {
    background-color: #95a5a6;
    color: white;
}

.source-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 10px;
    text-transform: uppercase;
}

/* Academic sources */
.type-journal-article {
    background-color: #d4edda;
    color: #155724;
}

.type-preprint {
    background-color: #e7f3ff;
    color: #004085;
}

.type-conference-paper {
    background-color: #e1f5fe;
    color: #0277bd;
}

.type-proceedings-article {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.type-thesis {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.type-dissertation {
    background-color: #ede7f6;
    color: #512da8;
}

.type-dataset {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Books and Reference */
.type-book {
    background-color: #fff8e1;
    color: #f57f17;
}

.type-book-chapter {
    background-color: #fff3e0;
    color: #ef6c00;
}

.type-monograph {
    background-color: #fce4ec;
    color: #c2185b;
}

.type-reference-entry {
    background-color: #f5f5f5;
    color: #616161;
}

/* Reports and Documents */
.type-report {
    background-color: #e3f2fd;
    color: #1565c0;
}

/* News and Media */
.type-article-newspaper {
    background-color: #ffeaa7;
    color: #856404;
}

.type-article-magazine {
    background-color: #e6f4ea;
    color: #2e7d32;
}

/* Legal and Government */
.type-legislation {
    background-color: #e2e3e5;
    color: #383d41;
}

.type-legal-case {
    background-color: #eceff1;
    color: #455a64;
}

.type-treaty {
    background-color: #e8eaf6;
    color: #3f51b5;
}

.type-law-review {
    background-color: #e0f2f1;
    color: #00695c;
}

/* Communication and Speeches */
.type-interview {
    background-color: #ffebee;
    color: #c62828;
}

.type-speech {
    background-color: #f3e5f5;
    color: #8e24aa;
}

.type-personal-communication {
    background-color: #fce4ec;
    color: #e91e63;
}

/* Web Content */
.type-webpage {
    background-color: #fafafa;
    color: #616161;
}


#statsContent {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.stat-card {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #34495e;
}

.stat-card h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #34495e;
}

.stat-label {
    color: #7f8c8d;
    font-size: 14px;
}

.search-engine-list {
    list-style: none;
    margin-top: 10px;
}

.search-engine-list li {
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
}

.domain-list {
    list-style: none;
    margin-top: 10px;
}

.domain-list li {
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

/* Parsed sections link */
.parsed-sections-link {
    color: #34495e;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
}

.parsed-sections-link:hover {
    text-decoration: underline;
}

/* Modal for showing parsed sections */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #34495e;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #7f8c8d;
}

.close-modal:hover {
    color: #2c3e50;
}

.sections-list {
    list-style: none;
    padding: 0;
}

.section-item {
    padding: 10px;
    margin-bottom: 8px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #34495e;
}

.section-header {
    font-weight: 600;
    color: #2c3e50;
}

.section-level-1 {
    border-left-color: #34495e;
    margin-left: 0;
}

.section-level-2 {
    border-left-color: #3498db;
    margin-left: 20px;
}

.section-level-3 {
    border-left-color: #2ecc71;
    margin-left: 40px;
}

.section-level-4 {
    border-left-color: #f39c12;
    margin-left: 60px;
}

/* Metadata modal styles */
.metadata-modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
}

.metadata-form-container {
    padding: 0;
}

/* Override metadata-form styles when in modal */
.metadata-modal-content .metadata-form {
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: 0;
    margin-top: 0;
}

/* Cards modal styles */
.cards-modal-content {
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.cards-modal-body {
    display: flex;
    gap: 20px;
    height: calc(100% - 60px);
    overflow: hidden;
}

.cards-nav {
    width: 250px;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    flex-shrink: 0;
}

.cards-nav h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
}

#cardsNavList, #unmatchedCardsNav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cards-nav-item {
    margin-bottom: 8px;
}

.cards-nav-item a {
    display: block;
    padding: 8px 12px;
    color: #34495e;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: background-color 0.2s, color 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cards-nav-item a:hover {
    background-color: #e8f4f8;
    color: #2980b9;
}

.cards-content-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.card-item {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #34495e;
    scroll-margin-top: 20px;
}

.card-header h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.match-info {
    display: flex;
    margin-bottom: 15px;
    font-size: 14px;
    align-items: center;
    justify-content: space-between;
}

.match-details {
    display: flex;
    gap: 20px;
    align-items: center;
}

.card-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.match-score {
    color: #27ae60;
    font-weight: 600;
}

.match-types {
    color: #7f8c8d;
}

.weighting-method {
    color: #5a6c7d;
    font-style: italic;
}

.card-content {
    color: #2c3e50;
    line-height: 1.6;
}

.card-content p {
    margin-bottom: 10px;
}

.card-content h1, .card-content h2, .card-content h3, .card-content h4 {
    margin-top: 15px;
    margin-bottom: 10px;
}

.unlink-card-btn {
    margin-left: auto;
    padding: 4px 12px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.unlink-card-btn:hover {
    background-color: #c0392b;
}

.unlink-all-card-btn {
    margin-left: 8px;
    padding: 4px 12px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.unlink-all-card-btn:hover {
    background-color: #c82333;
}

/* Font selector styles */
.font-selector {
    margin-top: auto;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
}

.font-selector h4 {
    font-family: var(--font-family);
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
    border-bottom: 2px solid #34495e;
    padding-bottom: 8px;
}

.font-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.font-btn {
    padding: 10px 8px;
    border: 2px solid #d0d0d0;
    border-radius: 6px;
    background-color: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s ease;
    color: #34495e;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.font-btn:hover {
    border-color: #34495e;
    background-color: #f8f9fa;
}

.font-btn.active {
    border-color: #34495e;
    background-color: #34495e;
    color: white;
}

/* Apply specific fonts to each button */
.font-btn[data-font="sans-serif"] {
    font-family: var(--font-sans-serif);
}

.font-btn[data-font="serif"] {
    font-family: var(--font-serif);
}

.font-btn[data-font="monospace"] {
    font-family: var(--font-monospace);
}

.font-btn[data-font="dyslexia"] {
    font-family: var(--font-dyslexia);
}

/* Pie chart styles */
.source-types-card {
    grid-column: span 2;
}

.pie-chart-container {
    display: flex;
    gap: 30px;
    align-items: center;
    margin-top: 20px;
}

.pie-chart {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 2px solid #dee2e6;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
}

.chart-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #dee2e6;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    font-size: 14px;
    color: #2c3e50;
}

.legend-value {
    font-size: 13px;
    color: #7f8c8d;
    font-weight: 500;
}

.no-data {
    color: #7f8c8d;
    font-style: italic;
    margin-top: 10px;
}

.pie-tooltip {
    position: fixed;
    background-color: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    max-width: 200px;
    text-align: center;
}

/* DOI Autofill Styles */
.fill-from-doi-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin: 0 5px;
    transition: background-color 0.3s;
}

.fill-from-doi-btn:hover {
    background-color: #2980b9;
}

.doi-input-container {
    padding: 10px;
}

.doi-input-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #2c3e50;
}

.doi-input-container input {
    padding: 10px;
    border: 2px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
}

.doi-input-container input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.doi-help-text {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 15px;
    line-height: 1.4;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.fetch-doi-btn {
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.fetch-doi-btn:hover:not(:disabled) {
    background-color: #229954;
}

.fetch-doi-btn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.cancel-doi-btn {
    background-color: #95a5a6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.cancel-doi-btn:hover {
    background-color: #7f8c8d;
}

.close-doi-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #7f8c8d;
}

.close-doi-modal:hover {
    color: #2c3e50;
}

.doi-status {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
}

.doi-status.loading {
    background-color: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
}

.doi-status.success {
    background-color: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.doi-status.error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* Text truncation and expansion */
.expandable-text {
    display: inline;
}

.expand-text-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.9em;
    text-decoration: underline;
    padding: 0;
    margin: 0 0 0 4px;
    font-family: inherit;
}

.expand-text-btn:hover {
    color: #333;
    text-decoration: none;
}

.expand-text-btn:focus {
    outline: 1px dotted #007bff;
    outline-offset: 2px;
}

.non-text-content {
    color: #666;
    font-style: italic;
    font-size: 0.9em;
}

/* Card move functionality */
.move-card-btn {
    background-color: #17a2b8;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8em;
    margin-right: 8px;
}

.move-card-btn:hover {
    background-color: #138496;
}

/* Move card modal - positioned as inset box */
.move-card-modal {
    z-index: 1001; /* Higher than cards modal */
}

.move-card-modal-content {
    background-color: white;
    margin: 90px auto 50px; /* 90px top to align with cards modal, 50px bottom */
    padding: 20px;
    border-radius: 8px;
    width: calc(90% - 80px); /* 40px less on each side than cards modal */
    max-width: calc(1200px - 80px);
    height: calc(80vh - 80px); /* 40px less than cards modal */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 2px solid #17a2b8;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.move-card-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Page selection table */
.page-selection-table-container {
    flex: 1;
    overflow-y: auto;
    margin: 20px 0;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.page-selection-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.page-selection-table thead {
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 1;
}

.page-selection-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.page-selection-table th:first-child {
    width: 60px;
    text-align: center;
}

.page-selection-table th:nth-child(2) {
    width: 50%;
}

.page-selection-table th:nth-child(3) {
    width: 100px;
    text-align: center;
}

.page-selection-row {
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background-color 0.2s;
}

.page-selection-row:hover {
    background-color: #f8f9fa;
}

.page-selection-row.selected {
    background-color: #e3f2fd;
}

.page-selection-row td {
    padding: 10px 12px;
}

.page-selection-row td:first-child {
    text-align: center;
}

.page-selection-row input[type="radio"] {
    cursor: pointer;
}

.page-title-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;
}

.page-score-cell {
    text-align: center;
    font-weight: 600;
    color: #27ae60;
}

.page-fields-cell {
    color: #666;
    font-size: 13px;
}

/* Enhanced tooltips for page selection rows */
.page-metadata-tooltip {
    position: fixed;
    background: #2c3e50;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-line;
    z-index: 1002;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 300px;
    word-wrap: break-word;
    pointer-events: none;
    display: none;
}

.selected-page-info {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.selected-page-info h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
}

.confirm-move-btn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    margin-right: 10px;
}

.confirm-move-btn:hover {
    background-color: #218838;
}

.cancel-move-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.cancel-move-btn:hover {
    background-color: #5a6268;
}

/* Move success message styling */
.move-success-body {
    padding: 40px 20px;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    padding: 30px;
    max-width: 400px;
}

.success-message p {
    margin: 10px 0;
    color: #155724;
    font-size: 16px;
    line-height: 1.5;
}

.success-message p:first-child {
    font-size: 18px;
    margin-bottom: 20px;
}

/* Cards modal left panel */
.cards-left-panel {
    width: 300px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Page metadata display in cards modal */
.page-metadata-display {
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

/* Override the old cards-nav style */
.cards-modal-body .cards-nav {
    width: 100%;
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    flex-shrink: 1;
    flex-grow: 1;
    overflow-y: auto;
}

.page-metadata-display h4,
.cards-nav h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 0.9em;
    font-weight: 600;
}

.page-metadata-content {
    font-size: 0.8em;
}

.metadata-item-compact {
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
}

.metadata-label-compact {
    font-weight: 600;
    color: #6c757d;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.metadata-value-compact {
    color: #212529;
    line-height: 1.3;
    word-break: break-word;
}

.metadata-value-compact .expand-text-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.85em;
    padding: 0;
    margin-left: 5px;
    text-decoration: underline;
}

.metadata-value-compact .expand-text-btn:hover {
    color: #333;
    text-decoration: underline;
}

.no-metadata {
    color: #6c757d;
    font-style: italic;
    font-size: 0.85em;
}

/* Card cite display */
.card-cite-display {
    margin: 20px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.card-cite-display h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 1em;
}

.card-cite-content {
    font-size: 0.9em;
    line-height: 1.4;
    color: #212529;
}

.card-cite-content p {
    margin: 0;
    padding: 0;
}


/* Inline confirmation buttons */
.confirm-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}

.confirm-btn {
    padding: 4px 8px;
    border: 1px solid;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-btn.confirm-yes {
    background-color: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

.confirm-btn.confirm-yes:hover {
    background-color: #c0392b;
    border-color: #c0392b;
}

.confirm-btn.confirm-yes.restore {
    background-color: #28a745;
    border-color: #28a745;
}

.confirm-btn.confirm-yes.restore:hover {
    background-color: #218838;
    border-color: #1e7e34;
}

.confirm-btn.confirm-yes.rematch {
    background-color: #34495e;
    border-color: #34495e;
}

.confirm-btn.confirm-yes.rematch:hover {
    background-color: #2980b9;
    border-color: #2980b9;
}

.confirm-btn.confirm-no {
    background-color: #6c757d;
    color: white;
    border-color: #6c757d;
}

.confirm-btn.confirm-no:hover {
    background-color: #5a6268;
    border-color: #545b62;
}

/* DOCX progress indicator */
.docx-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
    padding: 6px 10px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    font-size: 0.85em;
    color: #856404;
}

.progress-spinner {
    animation: spin 1s linear infinite;
    font-size: 1em;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.progress-text {
    font-style: italic;
}

.docx-progress.hidden {
    display: none !important;
}

.docx-progress.success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.docx-progress.success .progress-spinner {
    animation: none;
    color: #28a745;
}

/* Edit and Move buttons container */
.edit-move-container {
    display: flex;
    gap: 4px;
}

.half-btn {
    flex: 1;
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.edit-meta-btn.half-btn {
    background-color: #34495e;
    color: white;
}

.edit-meta-btn.half-btn:hover {
    background-color: #2980b9;
}

.move-page-btn.half-btn {
    background-color: #34495e;
    color: white;
}

.move-page-btn.half-btn:hover {
    background-color: #2980b9;
}

/* Move Page Modal */
.move-page-modal-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.search-selection-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 10px 0;
}

.search-option {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-option:last-child {
    border-bottom: none;
}

.search-option:hover {
    background-color: #f8f9fa;
}

.search-option.selected {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.search-info {
    flex: 1;
}

.search-engine {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    margin-bottom: 2px;
}

.move-page-modal-content .search-query {
    color: #7f8c8d;
    font-size: 13px;
    font-style: italic;
}

.search-timestamp {
    color: #95a5a6;
    font-size: 11px;
    margin-left: 10px;
}

.search-pages-count {
    background-color: #6c757d;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 11px;
    margin-left: 10px;
}

.move-page-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.move-page-confirm-btn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.move-page-confirm-btn:hover {
    background-color: #218838;
}

.move-page-confirm-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.move-page-cancel-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.move-page-cancel-btn:hover {
    background-color: #5a6268;
}


