/**
 * Browse page styles
 */

.browse-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 2rem;
}

.results-info {
    padding: 0.75rem 1rem;
    background: #f7fafc;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #4a5568;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

#resultsCount {
    flex-shrink: 0;
}

.btn-danger-icon {
    background: none;
    border: none;
    color: #e53e3e;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.7;
}

.btn-danger-icon:hover {
    opacity: 1;
    background: #fff5f5;
    transform: scale(1.1);
}

.btn-danger-icon:active {
    transform: scale(0.95);
}

.no-results {
    text-align: center;
    padding: 3rem 2rem;
    color: #718096;
}

.no-results p {
    font-size: 1.1rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

#pageInfo {
    font-weight: 600;
    color: #4a5568;
}

/* Document Details */
.btn-expand {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    transition: transform 0.2s;
}

.btn-expand:hover {
    color: #764ba2;
}

.btn-expand.expanded {
    transform: rotate(0deg);
}

.document-detail-row {
    background: #f8f9fa;
}

.document-details {
    padding: 1.5rem;
    animation: fadeIn 0.3s ease-in;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.detail-section {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.detail-section.full-width {
    grid-column: 1 / -1;
}

.detail-section h4 {
    margin: 0 0 0.75rem 0;
    color: #667eea;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

.detail-item {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.detail-item strong {
    color: #555;
    margin-right: 0.5rem;
}

.bullet-list {
    margin: 0;
    padding-left: 1.5rem;
}

.bullet-list li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.people-list {
    display: grid;
    gap: 0.75rem;
}

.person-card {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.person-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.person-detail {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

.reference-list {
    margin: 0;
    padding-left: 1.5rem;
    list-style-type: square;
}

.reference-list li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.notes-content {
    line-height: 1.8;
    color: #444;
    white-space: pre-wrap;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
}

code.hash {
    background: #f1f3f5;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #495057;
}

/* Sortable Table Headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    position: relative;
}

th.sortable:hover {
    opacity: 0.85;
}

th.sortable .sort-indicator {
    display: inline-block;
    margin-left: 0.35rem;
    font-size: 0.9em;
    min-width: 1em;
    font-weight: bold;
}

th.sortable.sort-asc,
th.sortable.sort-desc {
    background-color: rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

th.sortable.sort-asc .sort-indicator,
th.sortable.sort-desc .sort-indicator {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Source File Cell with Delete Button */
.source-file-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
}

.btn-delete-source {
    background: none;
    border: none;
    color: #e53e3e;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.6;
    flex-shrink: 0;
}

.btn-delete-source:hover {
    opacity: 1;
    background: #fff5f5;
    transform: scale(1.1);
}

.btn-delete-source:active {
    transform: scale(0.95);
}

/* Page Gallery Styles */
.page-gallery {
    margin-top: 1rem;
}

.gallery-header {
    margin-bottom: 1rem;
}

.gallery-header h4 {
    margin: 0;
    color: #667eea;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

.gallery-loading,
.gallery-empty,
.gallery-error {
    text-align: center;
    padding: 2rem;
    color: #718096;
    font-style: italic;
}

.gallery-error {
    color: #e53e3e;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.gallery-item {
    position: relative;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    aspect-ratio: 1 / 1.414;
}

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

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-item-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
}

/* Lightbox Styles */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

.lightbox-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    max-height: 90vh;
}

.lightbox-image-container img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
    color: #667eea;
    font-size: 1rem;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(102, 126, 234, 0.15);
    border-radius: 4px;
    font-weight: 500;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #667eea;
    border: none;
    color: #f0f4ff;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: bold;
    line-height: 1;
    z-index: 1001;
}

.lightbox-close:hover {
    background: #7b93f5;
    transform: scale(1.1);
}

/* Navigation arrows - positioned outside the document */
.lightbox-prev,
.lightbox-next {
    position: fixed;
    background: #667eea;
    border: none;
    color: #f0f4ff;
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: bold;
    line-height: 1;
    z-index: 1001;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: #7b93f5;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.lightbox-prev {
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-prev:hover {
    transform: translateY(-50%) scale(1.1);
}

.lightbox-next {
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Full Text Collapsible Section */
.full-text-section {
    margin-top: 1rem;
}

.full-text-header {
    cursor: pointer;
    user-select: none;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.full-text-header:hover {
    background: #e9ecef;
}

.full-text-header .expand-icon {
    transition: transform 0.2s ease;
    font-size: 0.9rem;
    color: #667eea;
    font-weight: bold;
}

.full-text-section.expanded .expand-icon {
    transform: rotate(90deg);
}

.full-text-length {
    color: #718096;
    font-size: 0.875rem;
    margin-left: 0.25rem;
}

.full-text-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.full-text-section.expanded .full-text-content {
    max-height: 600px;
    overflow-y: auto;
    margin-top: 0.75rem;
}

.full-text-content pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
    color: #333;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    margin: 0;
}

/* Siblings Section - Collapsible */
.siblings-section {
    margin-top: 1rem;
}

.siblings-header {
    cursor: pointer;
    user-select: none;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.siblings-header:hover {
    background: #e9ecef;
}

.siblings-header .expand-icon {
    transition: transform 0.2s ease;
    font-size: 0.9rem;
    color: #667eea;
    font-weight: bold;
}

.siblings-section.expanded .siblings-header .expand-icon {
    transform: rotate(90deg) !important;
}

.siblings-count {
    color: #718096;
    font-size: 0.875rem;
    margin-left: 0.25rem;
}

.siblings-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.siblings-section.expanded .siblings-content {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 0.75rem;
}

.siblings-loading,
.siblings-empty,
.siblings-error {
    padding: 1rem;
    color: #718096;
    font-style: italic;
    text-align: center;
}

.siblings-error {
    color: #e53e3e;
}

.siblings-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.sibling-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.15s ease;
}

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

.sibling-item:hover {
    background: #f7fafc;
}

.sibling-date {
    color: #718096;
    font-size: 0.85rem;
    min-width: 80px;
}

.sibling-type {
    font-size: 0.75rem;
    min-width: 90px;
    text-align: center;
}

.sibling-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sibling-link:hover {
    text-decoration: underline;
    color: #5a67d8;
}

/* Highlight flash animation for navigated documents */
.highlight-flash {
    animation: highlightFlash 2s ease;
}

@keyframes highlightFlash {
    0% { background-color: #fef3c7; }
    100% { background-color: transparent; }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .lightbox-close {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
        top: 10px;
        right: 10px;
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 50px;
        height: 50px;
        font-size: 2rem;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
}

/* Intelligent Search Answer Box */
.intelligent-search-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 2rem;
}

.answer-box {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.answer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.answer-header h3 {
    margin: 0;
    color: #2d3748;
    font-size: 1.25rem;
}

.btn-toggle-reasoning {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-toggle-reasoning:hover {
    background: #764ba2;
    transform: translateY(-1px);
}

.answer-content {
    color: #4a5568;
    line-height: 1.6;
}

.answer-content p {
    margin: 0.75rem 0;
}

.answer-content p:first-child {
    margin-top: 0;
}

.answer-content p:last-child {
    margin-bottom: 0;
}

.answer-reasoning {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.answer-reasoning h4 {
    margin: 0 0 0.75rem 0;
    color: #4a5568;
    font-size: 1rem;
    font-weight: 600;
}

.answer-reasoning p {
    color: #718096;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0.5rem 0;
}

.error-message {
    color: #e53e3e;
    padding: 1rem;
    background: #fff5f5;
    border-radius: 6px;
    border: 1px solid #fc8181;
}

