/**
 * Full-Text Viewer Styles
 * CSS for scrollable viewer with line highlighting and range selection
 */

/* Main container for the full-text viewer modal */
.full-text-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.full-text-modal-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Modal header */
.full-text-header {
    padding: 20px 25px;
    border-bottom: 2px solid #e9ecef;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.full-text-header h3 {
    margin: 0 0 10px 0;
    font-size: 1.4em;
    font-weight: 500;
}

.work-subtitle {
    font-size: 0.9em;
    opacity: 0.9;
    margin-top: 5px;
}

.viewer-instructions {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.instruction-item {
    font-size: 0.85em;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Text viewer container with scrolling */
.text-viewer-container {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 0;
    background: #fafafa;
    position: relative !important;
    /*max-height: 60vh;*/
}

#text-viewer {
    padding: 0;
    margin: 0;
}

/* Individual text lines */
.text-line {
    display: flex;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
    user-select: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
}

.text-line:nth-child(even) {
    background: #f8f9fa;
}

.text-line:nth-child(odd) {
    background: #ffffff;
}

.text-line:hover {
    background: #e3f2fd !important;
    border-left-color: #2196f3;
}

/* Line number styling */
.line-num {
    min-width: 60px;
    color: #6c757d;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    user-select: none;
    text-align: right;
    padding-right: 15px;
    flex-shrink: 0;
    font-size: 12px;
}

.line-text {
    flex: 1;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Selection states */
.text-line.suggested {
    background: #fff3e0 !important;
    border-left-color: #ff9800;
}

.text-line.selected {
    background: #bbdefb !important;
    border-left-color: #1976d2;
}

.text-line.range-start {
    border-top: 3px solid #1976d2;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.text-line.range-end {
    border-bottom: 3px solid #1976d2;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.text-line.preview-range {
    background: #e1f5fe !important;
    border-left-color: #0288d1;
}

.text-line.scroll-target {
    animation: highlight-pulse 2s ease-in-out;
}

@keyframes highlight-pulse {
    0%, 100% { background: inherit; }
    50% { background: #ffeb3b !important; }
}

/* Search functionality */
.text-line.search-match {
    background: #fff9c4 !important;
}

.text-line.search-match mark {
    background: #ffeb3b;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

/* Selection info panel */
.selection-info-container {
    padding: 15px 25px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    min-height: 60px;
}

.no-selection {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #6c757d;
    font-style: italic;
}

.selection-icon {
    font-size: 1.2em;
}

.selection-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.selection-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-item {
    font-size: 0.9em;
    color: #495057;
}

.selection-preview {
    font-size: 0.85em;
    color: #6c757d;
    background: white;
    padding: 6px 12px;
    border-radius: 6px;
    border-left: 3px solid #1976d2;
    max-height: 60px;
    overflow-y: auto;
}

/* Modal actions */
.full-text-actions {
    padding: 20px 25px;
    background: white;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.full-text-actions .btn {
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

.cancel-btn {
    background: #6c757d;
    color: white;
}

.cancel-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.confirm-btn {
    background: #28a745;
    color: white;
}

.confirm-btn:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

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

/* Search box (if added) */
.text-search-container {
    padding: 10px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    gap: 10px;
    align-items: center;
}

.text-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.text-search-input:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.search-results-info {
    font-size: 0.85em;
    color: #6c757d;
    min-width: 120px;
}

/* Responsive design */
@media (max-width: 768px) {
    .full-text-modal {
        padding: 10px;
    }

    .full-text-modal-container {
        width: 95%;
        height: 90vh;
    }

    .full-text-header {
        padding: 15px 20px;
    }

    .viewer-instructions {
        flex-direction: column;
        gap: 8px;
    }

    .text-line {
        padding: 4px 8px;
        font-size: 13px;
    }

    .line-num {
        min-width: 45px;
        padding-right: 10px;
    }

    .selection-stats {
        flex-direction: column;
        gap: 8px;
    }

    .full-text-actions {
        padding: 15px 20px;
        flex-direction: column;
    }

    .full-text-actions .btn {
        width: 100%;
    }
}

/* Scrollbar styling */
.text-viewer-container::-webkit-scrollbar {
    width: 12px;
}

.text-viewer-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.text-viewer-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 6px;
}

.text-viewer-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Loading state */
.text-viewer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6c757d;
}

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

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

/* Accessibility improvements */
.text-line:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .text-line {
        transition: none;
    }

    .scroll-target {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .text-line.selected {
        background: #000080 !important;
        color: white;
    }

    .text-line.range-start,
    .text-line.range-end {
        border-color: #000080;
    }
}