/* Simple PDF Search Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.search-section {
    flex: 0 0 auto;
    margin-bottom: 2rem;
    padding-top: 1rem;
}

#searchQuery {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    background: white;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    outline: none;
}

#searchQuery:focus {
    border-color: #6c757d;
    box-shadow: 0 0 0 3px rgba(108, 117, 125, 0.1);
}

#searchQuery::placeholder {
    color: #adb5bd;
}

.results-section {
    flex: 1;
}

.loading {
    text-align: center;
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #6c757d;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #dc3545;
    margin-bottom: 1rem;
}

.results-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-type {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.result-type h3 {
    margin-bottom: 1.5rem;
    color: #495057;
    border-bottom: 2px solid #f8f9fa;
    padding-bottom: 0.5rem;
    font-size: 1.1rem;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-item {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.result-item:hover {
    border-color: #6c757d;
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.1);
}

/* Clickable elements */
.clickable {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.clickable:hover {
    opacity: 0.8;
}

.document-title.clickable:hover {
    color: #495057;
    text-decoration: underline;
}

/* New clean document result layout */
.document-result {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.document-preview-large {
    flex-shrink: 0;
    width: 120px;
}

.large-preview-thumbnail {
    width: 120px;
    height: auto;
    max-height: 160px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 2px solid #e9ecef;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.large-preview-thumbnail:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-color: #6c757d;
}

.no-preview {
    width: 120px;
    height: 160px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 0.85rem;
    text-align: center;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-title {
    margin: 0 0 1rem 0;
    color: #495057;
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
}

.page-thumbnails {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.page-thumbnail-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

.page-thumbnail {
    width: 50px;
    height: auto;
    max-height: 70px;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.page-thumbnail:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: #6c757d;
}

.page-thumbnail.active {
    border-color: #6c757d;
    border-width: 2px;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
    transform: scale(1.05);
}

.no-preview-small {
    width: 50px;
    height: 70px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.no-preview-small:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: #6c757d;
}

.no-preview-small.active {
    border-color: #6c757d;
    border-width: 2px;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
    transform: scale(1.05);
    background: #e9ecef;
}

.page-number {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
    font-weight: 500;
}

.page-content-preview {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 1rem;
    border-left: 3px solid #6c757d;
    margin-top: 0.5rem;
    min-height: 80px;
    display: block; /* Always visible */
}

.content-text {
    color: #495057;
    line-height: 1.5;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}

.page-info-simple {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

/* Remove old styles that are no longer needed */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.result-title-section {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-weight: 600;
    color: #495057;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.result-score {
    background: #6c757d;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
}

.document-preview, .page-preview {
    flex-shrink: 0;
}

.preview-thumbnail {
    width: 80px;
    height: auto;
    max-height: 100px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #e9ecef;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.preview-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #6c757d;
}

.page-preview-thumbnail {
    width: 60px;
    height: auto;
    max-height: 80px;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    transition: transform 0.2s ease;
}

.page-preview-thumbnail:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.page-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f1f3f4;
}

.page-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Clean up old styles - remove metadata and technical information */
.result-metadata {
    display: none; /* Hide technical metadata */
}

.result-content {
    display: none; /* Hide old content display */
}

.document-pages {
    display: none; /* Hide old page structure */
}

.page-result {
    display: none; /* Hide old page results */
}

.page-title {
    display: none; /* Hide old page titles */
}

.page-score {
    display: none; /* Hide scoring information */
}

.page-content {
    display: none; /* Hide old page content */
}

/* EmbedPDF Modal */
.pdf-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-modal-content {
    width: 95%;
    height: 95%;
    background: white;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.pdf-modal-header {
    background: #f8f9fa;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.pdf-modal-header h3 {
    margin: 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.pdf-controls {
    display: flex;
    gap: 0.5rem;
}

.pdf-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.pdf-btn:hover {
    background: #495057;
}

.pdf-close-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    min-width: 40px;
    transition: background 0.2s ease;
}

.pdf-close-btn:hover {
    background: #c82333;
}

.pdf-viewer-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: #f8f9fa;
}

#pdfViewer {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* Mobile responsive for PDF viewer */
@media (max-width: 768px) {
    .pdf-modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .pdf-modal-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .pdf-modal-header h3 {
        text-align: center;
        font-size: 1rem;
    }
    
    .pdf-controls {
        justify-content: center;
    }
    
    .pdf-btn, .pdf-close-btn {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
}

/* PDF Viewer Modal */
.pdf-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-viewer-container {
    width: 95%;
    height: 95%;
    background: white;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdf-viewer-header {
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.pdf-viewer-header h3 {
    margin: 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
    min-width: 200px;
}

.pdf-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pdf-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 40px;
    transition: background 0.2s ease;
}

.pdf-btn:hover:not(:disabled) {
    background: #495057;
}

.pdf-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

.pdf-close-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    min-width: 40px;
    transition: background 0.2s ease;
}

.pdf-close-btn:hover {
    background: #c82333;
}

#zoomLevel {
    color: #495057;
    font-weight: 500;
    min-width: 50px;
    text-align: center;
}

.pdf-viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background: #e9ecef;
    padding: 1rem;
}

#pdfCanvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: white;
}

/* Mobile responsive for PDF viewer */
@media (max-width: 768px) {
    .pdf-viewer-container {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .pdf-viewer-header {
        padding: 0.75rem;
        flex-direction: column;
        align-items: stretch;
    }
    
    .pdf-viewer-header h3 {
        text-align: center;
        margin-bottom: 0.5rem;
    }
    
    .pdf-controls {
        justify-content: center;
    }
    
    .pdf-btn, .pdf-close-btn {
        padding: 0.75rem;
        font-size: 1rem;
    }
}

/* Document Browser Popup */
.document-browser-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.document-browser-popup {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    height: 90%;
    max-height: 600px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.browser-header {
    background: #f8f9fa;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.browser-header h3 {
    margin: 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.close-button:hover {
    background: #e9ecef;
    color: #495057;
}

.browser-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow: hidden;
}

.page-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.nav-button {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.nav-button:hover:not(:disabled) {
    background: #495057;
}

.nav-button:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

#pageInfo {
    color: #495057;
    font-weight: 500;
    font-size: 0.9rem;
}

.page-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 1rem;
}

#currentPageImage {
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    object-fit: contain;
}

/* Mobile responsive for popup */
@media (max-width: 768px) {
    .document-browser-popup {
        width: 95%;
        height: 95%;
    }
    
    .browser-header {
        padding: 0.75rem 1rem;
    }
    
    .browser-header h3 {
        font-size: 1rem;
    }
    
    .page-navigation {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .nav-button {
        width: 100%;
    }
}

.hidden {
    display: none !important;
}

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .search-section {
        padding-top: 0.5rem;
        margin-bottom: 1.5rem;
    }
    
    .document-result {
        flex-direction: column;
        gap: 1rem;
    }
    
    .document-preview-large {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .large-preview-thumbnail {
        width: 100px;
        max-height: 130px;
    }
    
    .no-preview {
        width: 100px;
        height: 130px;
    }
    
    .page-thumbnails {
        justify-content: center;
    }
}