/* Article Annotations Styles */

/* Container layout - article + sidebar */
.article-container {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.wiki-article {
    flex: 1;
    min-width: 0;
}

/* Annotations sidebar */
.annotations-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

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

/* Reuse annotation item styles from pdf-viewer */
.annotations-sidebar .annotations-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

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

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

.annotations-sidebar .ann-highlight {
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 500;
    display: block;
}

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

.annotations-sidebar .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;
}

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

.annotations-sidebar .empty-state {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem 0;
}

/* Highlight marks in article content */
mark.highlight-mark {
    padding: 0.1em 0.2em;
    border-radius: 2px;
    cursor: pointer;
    transition: outline 0.3s;
}

mark.highlight-mark.has-comment {
    border-bottom: 2px dashed rgba(255, 255, 255, 0.5);
}

/* ===========================================
   Dark mode friendly highlight colors
   Applies to: sidebar, article content, preview
   =========================================== */
.ann-highlight,
mark.highlight-mark,
.highlight-preview {
    color: white !important;
}

/* Yellow (default) */
.ann-highlight[style*="yellow"],
mark.highlight-mark[style*="yellow"],
.highlight-preview[style*="yellow"],
.ann-highlight:not([style*="#"]),
mark.highlight-mark:not([style*="#"]),
.highlight-preview:not([style*="#"]) {
    background: #b8860b !important;
}

/* Green */
.ann-highlight[style*="#90EE90"],
mark.highlight-mark[style*="#90EE90"],
.highlight-preview[style*="#90EE90"] {
    background: #2e8b57 !important;
}

/* Pink */
.ann-highlight[style*="#FFB6C1"],
mark.highlight-mark[style*="#FFB6C1"],
.highlight-preview[style*="#FFB6C1"] {
    background: #cd5c5c !important;
}

/* Blue */
.ann-highlight[style*="#87CEEB"],
mark.highlight-mark[style*="#87CEEB"],
.highlight-preview[style*="#87CEEB"] {
    background: #4682b4 !important;
}

/* Selection popup - reuse from pdf-viewer */
.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;
}

/* Comment popup - reuse from pdf-viewer */
.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 {
    background: var(--accent);
    color: white;
}

.comment-popup-buttons .delete-btn {
    background: #ef4444;
    color: white;
}

.highlight-preview {
    word-break: break-word;
}

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

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

    .annotations-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }
}
