/**
 * PDF Annotation Styles
 *
 * Styles for PDF display and bounding box annotation.
 */

/* PDF Display Container */
.pdf-display {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f5f5f5;
    overflow: hidden;
}

.pdf-viewer-scroll {
    overflow-y: auto;
}

.pdf-viewer-paginated {
    display: flex;
    flex-direction: column;
}

/* PDF Controls */
.pdf-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #333;
    color: white;
    gap: 12px;
    flex-wrap: wrap;
}

.pdf-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pdf-controls button {
    background: #555;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.pdf-controls button:hover {
    background: #666;
}

.pdf-controls button:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
}

.pdf-controls button.active {
    background: #0066cc;
}

.pdf-page-info {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pdf-page-input {
    width: 50px;
    padding: 4px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #444;
    color: white;
    text-align: center;
}

.pdf-zoom-select {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #555;
    background: #444;
    color: white;
    cursor: pointer;
}

/* Bounding Box Tools */
.pdf-bbox-tools {
    display: flex;
    gap: 8px;
}

.pdf-bbox-draw-btn.active {
    background: #28a745;
}

.pdf-bbox-select-btn.active {
    background: #17a2b8;
}

.pdf-bbox-delete-btn:hover {
    background: #dc3545;
}

/* Canvas Container */
.pdf-canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #666;
    padding: 20px;
    min-height: 400px;
}

.pdf-bbox-container {
    cursor: crosshair;
}

.pdf-canvas {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background: white;
}

.pdf-bbox-canvas {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: all;
    z-index: 10;
}

/* Text Layer for Span Annotation */
.pdf-text-layer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 0.2;
    line-height: 1.0;
}

.pdf-text-layer span {
    color: transparent;
    position: absolute;
    white-space: pre;
    pointer-events: all;
    cursor: text;
}

.pdf-text-layer span::selection {
    background: rgba(0, 100, 200, 0.3);
}

/* Loading State */
.pdf-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: #666;
    background: white;
}

.pdf-loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #eee;
    border-top-color: #666;
    border-radius: 50%;
    animation: pdf-spin 1s linear infinite;
}

@keyframes pdf-spin {
    to { transform: rotate(360deg); }
}

/* Error State */
.pdf-error {
    padding: 20px;
    color: #dc3545;
    text-align: center;
    background: #fff5f5;
    border-top: 1px solid #ffcccc;
}

/* Bounding Box Info Panel */
.pdf-bbox-info {
    display: flex;
    gap: 20px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    font-size: 13px;
    color: #555;
}

/* Extracted PDF Content */
.pdf-extracted {
    padding: 0;
}

.pdf-extracted .pdf-content-wrapper {
    padding: 20px;
    background: white;
}

.pdf-metadata {
    padding: 8px 12px;
    background: #e9ecef;
    font-size: 13px;
    color: #666;
    border-bottom: 1px solid #ddd;
}

/* PDF Pages Container */
.pdf-pages-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: #666;
}

.pdf-page-wrapper {
    position: relative;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.pdf-page-number {
    position: absolute;
    top: -24px;
    left: 0;
    font-size: 12px;
    color: #ccc;
}

.pdf-page {
    padding: 20px;
    background: white;
    margin-bottom: 10px;
}

/* Paginated mode - show only current page */
.pdf-bbox-mode .pdf-page {
    display: none;
}

.pdf-bbox-mode .pdf-page.active {
    display: block;
}

.pdf-page-layout {
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
}

/* PDF Word Spans for Highlighting */
.pdf-word {
    background: transparent;
    transition: background 0.2s;
}

.pdf-word:hover {
    background: rgba(0, 100, 200, 0.1);
}

.pdf-word.highlighted {
    background: rgba(255, 200, 0, 0.4);
}

/* Bounding Box Styles (drawn on canvas via JS) */
/* These classes are for any HTML overlays */
.pdf-bbox-overlay {
    position: absolute;
    border: 2px solid #0066cc;
    background: rgba(0, 102, 204, 0.1);
    pointer-events: none;
}

.pdf-bbox-overlay.selected {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.15);
}

.pdf-bbox-label {
    position: absolute;
    top: -20px;
    left: 0;
    font-size: 11px;
    background: #0066cc;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

.pdf-bbox-overlay.selected .pdf-bbox-label {
    background: #28a745;
}

/* Bounding Box Mode Specific */
.pdf-bbox-mode .pdf-canvas-container {
    cursor: crosshair;
}

.pdf-bbox-mode.selecting .pdf-canvas-container {
    cursor: pointer;
}

/* Paginated View Controls */
.pdf-first-btn,
.pdf-last-btn {
    font-size: 12px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .pdf-controls {
        flex-direction: column;
        gap: 8px;
    }

    .pdf-navigation {
        flex-wrap: wrap;
        justify-content: center;
    }

    .pdf-bbox-tools {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Print Styles */
@media print {
    .pdf-controls,
    .pdf-bbox-info {
        display: none;
    }

    .pdf-display {
        border: none;
        box-shadow: none;
    }
}
