/* W3C Web Annotation CSS Styles */

/* Annotation Layer */
#annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
}

/* Base Annotation Styles */
.annotation {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.annotation:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.annotation:focus {
    outline: 2px solid #007ACC;
    outline-offset: 2px;
}

/* Annotation Types */
.annotation-highlighting {
    background-color: rgba(255, 255, 0, 0.5);
    border: 1px solid rgba(255, 255, 0, 0.8);
}

.annotation-commenting {
    background-color: rgba(0, 122, 204, 0.1);
    border: 2px solid #007ACC;
    min-width: 20px;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.annotation-bookmarking {
    background-color: rgba(255, 0, 0, 0.1);
    border: 2px solid #FF0000;
    min-width: 20px;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Highlight Annotations */
.highlight-annotation {
    border: none;
    background-color: rgba(255, 255, 0, 0.5);
}

.highlight-annotation:hover {
    background-color: rgba(255, 255, 0, 0.7);
}

/* Note Annotations */
.note-annotation {
    background-color: rgba(0, 122, 204, 0.9);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.note-annotation:hover {
    background-color: #007ACC;
}

/* Bookmark Annotations */
.bookmark-annotation {
    background-color: rgba(255, 0, 0, 0.9);
    color: white;
    border-radius: 3px;
    width: 20px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transform: perspective(10px) rotateX(5deg);
}

.bookmark-annotation:hover {
    background-color: #FF0000;
}

/* Annotation Tools Panel */
.annotation-tools {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    width: 250px;
    max-height: 80vh;
    overflow-y: auto;
}

.annotation-tools h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

/* Tool Buttons */
.annotation-tool-group {
    margin-bottom: 15px;
}

.annotation-tool-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}

.tool-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tool-btn {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.tool-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Canvas Tool States */
.page-canvas.tool-select {
    cursor: default;
}

.page-canvas.tool-highlight {
    cursor: crosshair;
}

.page-canvas.tool-note {
    cursor: crosshair;
}

.page-canvas.tool-bookmark {
    cursor: pointer;
}

.page-canvas.tool-draw {
    cursor: crosshair;
}

/* Annotation List */
.annotation-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
}

.annotation-list-item {
    display: flex;
    align-items: flex-start;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
    transition: background-color 0.2s ease;
}

.annotation-list-item:hover {
    background: var(--bg-hover);
}

.annotation-list-item:last-child {
    border-bottom: none;
}

.annotation-type {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.annotation-type.highlighting {
    background: rgba(255, 255, 0, 0.3);
    border: 1px solid #FFD700;
}

.annotation-type.commenting {
    background: rgba(0, 122, 204, 0.3);
    border: 1px solid #007ACC;
}

.annotation-type.bookmarking {
    background: rgba(255, 0, 0, 0.3);
    border: 1px solid #FF0000;
}

.annotation-content {
    flex: 1;
    min-width: 0;
}

.annotation-text {
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 2px;
    word-wrap: break-word;
    line-height: 1.3;
}

.annotation-meta {
    font-size: 10px;
    color: var(--text-secondary);
}

.annotation-actions {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
}

.annotation-actions button {
    padding: 2px 6px;
    font-size: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.annotation-actions button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.no-annotations {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    font-style: italic;
}

/* Export/Import Controls */
.annotation-controls {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.control-group {
    margin-bottom: 10px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.checkbox-group input[type="checkbox"] {
    margin: 0;
}

/* Annotation Tooltips */
.annotation-tooltip {
    background: var(--bg-tooltip);
    color: var(--text-tooltip);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    z-index: 1001;
    font-size: 13px;
}

.tooltip-content p {
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.tooltip-meta {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.tooltip-meta small {
    color: var(--text-secondary);
    font-size: 11px;
}

.tooltip-actions {
    display: flex;
    gap: 8px;
}

.tooltip-actions button {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tooltip-actions button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Selection Menu */
.selection-menu {
    background: var(--bg-tooltip);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 4px;
}

.selection-menu button {
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.selection-menu button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Context Menu */
.context-menu {
    background: var(--bg-tooltip);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 120px;
}

.context-menu-item {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.context-menu-item:hover {
    background: var(--bg-hover);
}

/* Note Dialog */
.note-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.note-dialog-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.note-dialog-content h3 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 16px;
}

.note-dialog-content textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.note-dialog-content textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.1);
}

.note-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
}

.note-dialog-actions button {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-cancel:hover {
    background: var(--bg-hover);
}

.btn-save {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-save:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* File Input */
#import-file-input {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .annotation-tools {
        position: fixed;
        bottom: 20px;
        right: 20px;
        top: auto;
        width: 200px;
        max-height: 50vh;
    }
    
    .tool-buttons {
        grid-template-columns: 1fr;
    }
    
    .annotation-tooltip {
        max-width: 250px;
    }
    
    .note-dialog-content {
        width: 300px;
        padding: 15px;
    }
    
    .annotation-list-item {
        padding: 6px;
    }
    
    .annotation-actions {
        flex-direction: column;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .annotation-highlighting {
        background-color: rgba(255, 255, 0, 0.8);
        border: 2px solid #000;
    }
    
    .annotation-commenting {
        background-color: rgba(0, 122, 204, 0.3);
        border: 2px solid #000;
    }
    
    .annotation-bookmarking {
        background-color: rgba(255, 0, 0, 0.3);
        border: 2px solid #000;
    }
    
    .tool-btn.active {
        background: #000;
        color: #fff;
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .annotation,
    .tool-btn,
    .annotation-list-item,
    .tooltip-actions button,
    .selection-menu button {
        transition: none;
    }
    
    .annotation:hover {
        transform: none;
    }
}

/* Dark Mode Adjustments */
@media (prefers-color-scheme: dark) {
    .annotation-highlighting {
        background-color: rgba(255, 255, 0, 0.3);
        border: 1px solid rgba(255, 255, 0, 0.6);
    }
    
    .note-annotation {
        background-color: rgba(100, 200, 255, 0.9);
    }
    
    .bookmark-annotation {
        background-color: rgba(255, 100, 100, 0.9);
    }
}

/* Focus Indicators for Accessibility */
.annotation:focus-visible,
.tool-btn:focus-visible,
.annotation-actions button:focus-visible {
    outline: 2px solid var(--focus-color, #007ACC);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .annotation-tools,
    .annotation-tooltip,
    .selection-menu,
    .context-menu,
    .note-dialog {
        display: none !important;
    }
    
    .annotation {
        border: 1px solid #000 !important;
        background: rgba(255, 255, 0, 0.3) !important;
    }
}
