/* PDF Viewer Styles */

.pdf-viewer-body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Toolbar */
.pdf-toolbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    height: 48px;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-center {
    flex: 1;
    justify-content: center;
}

.pdf-title {
    font-weight: 600;
    color: var(--text-primary);
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-author {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.toolbar-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s;
    text-decoration: none;
}

.toolbar-btn:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
}

.toolbar-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.25rem;
}

.page-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.page-info input {
    width: 50px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    text-align: center;
    font-size: 0.9rem;
}

.page-info input:focus {
    outline: none;
    border-color: var(--accent);
}

#zoom-level {
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-width: 50px;
    text-align: center;
}

.color-select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

/* Search box */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.search-box input {
    width: 150px;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

#search-results {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
}

/* Search highlights */
.search-highlight {
    position: absolute;
    background: rgba(255, 165, 0, 0.4);
    border: 1px solid orange;
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
}

/* Main container */
.pdf-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* PDF panel */
.pdf-panel {
    flex: 7;
    overflow: auto;
    background: var(--bg-primary);
    display: flex;
    justify-content: center;
    padding: 1rem;
}

#pdf-viewer {
    position: relative;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#pdf-canvas {
    display: block;
}

/* Text layer for text selection */
#text-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 0.2;
    line-height: 1.0;
}

#text-layer > span {
    color: transparent;
    position: absolute;
    white-space: pre;
    transform-origin: 0% 0%;
    cursor: text;
}

#text-layer ::selection {
    background: rgba(59, 130, 246, 0.5);
}

#text-layer.highlight-mode ::selection {
    background: rgba(255, 255, 0, 0.7);
}

#annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

#annotation-layer.active {
    pointer-events: auto;
    cursor: crosshair;
}

/* Annotation markers */
.annotation-highlight {
    position: absolute;
    opacity: 0.4;
    pointer-events: auto;
    cursor: pointer;
}

.annotation-highlight:hover {
    opacity: 0.6;
}

.annotation-comment-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.annotation-comment-marker:hover {
    transform: scale(1.1);
}

/* Sidebar panel */
.sidebar-panel {
    flex: 3;
    min-width: 280px;
    max-width: 400px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent);
}

/* Tab content */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

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

.tab-content h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* Annotations list */
.annotations-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.annotation-item {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 0.75rem;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.annotation-item:hover {
    background: var(--bg-primary);
}

.ann-content {
    flex: 1;
    cursor: pointer;
}

.ann-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    opacity: 0.5;
    transition: all 0.2s;
}

.ann-delete:hover {
    color: #ef4444;
    opacity: 1;
}

.ann-page {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.ann-highlight {
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85rem;
    color: var(--bg-primary);
    font-weight: 500;
}

/* Dark mode friendly highlight colors for sidebar */
.ann-highlight[style*="yellow"] {
    background: #b8860b !important; /* dark goldenrod */
}
.ann-highlight[style*="#90EE90"], .ann-highlight[style*="green"] {
    background: #2e8b57 !important; /* sea green */
}
.ann-highlight[style*="#FFB6C1"], .ann-highlight[style*="pink"] {
    background: #cd5c5c !important; /* indian red */
}
.ann-highlight[style*="#87CEEB"], .ann-highlight[style*="blue"] {
    background: #4682b4 !important; /* steel blue */
}

.ann-comment {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.ann-note {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.25rem;
}

/* Highlight with comment indicator */
.annotation-highlight.has-comment {
    border: 2px solid rgba(0, 0, 0, 0.3);
}

.annotation-highlight.has-comment::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

/* Related list */
.related-list {
    list-style: none;
    padding: 0;
}

.related-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.related-list li:last-child {
    border-bottom: none;
}

.related-list a {
    font-size: 0.9rem;
}

/* Notes section */
.notes-section {
    flex-shrink: 0;
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.notes-section h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

#notes-field {
    width: 100%;
    height: 100px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.5rem;
}

#notes-field:focus {
    outline: none;
    border-color: var(--accent);
}

.save-btn {
    width: 100%;
    padding: 0.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.save-btn:hover {
    background: var(--accent-hover);
}

.save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty state */
.empty-state {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 2rem 1rem;
}

/* Comment popup */
.comment-popup {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    width: 300px;
}

.comment-popup textarea {
    width: 100%;
    height: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    margin-bottom: 0.5rem;
}

.comment-popup-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.comment-popup-buttons button {
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
}

.comment-popup-buttons .cancel-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.comment-popup-buttons .save-btn {
    width: auto;
}

.comment-view {
    margin-bottom: 0.75rem;
}

.comment-view p {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.comment-view small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.delete-btn {
    background: #ef4444 !important;
    color: white;
}

/* Selection popup (appears when text is selected) */
.selection-popup {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    display: flex;
    gap: 4px;
    align-items: center;
}

.selection-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    color: var(--text-primary);
}

.selection-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.color-select-mini {
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    width: 40px;
}

/* Responsive */
@media (max-width: 900px) {
    .pdf-container {
        flex-direction: column;
    }

    .sidebar-panel {
        max-width: none;
        min-width: auto;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .toolbar-center {
        display: none;
    }
}
